qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v4] osdep: add a qemu_close_all_open_fd() helper


From: Marc-André Lureau
Subject: Re: [PATCH v4] osdep: add a qemu_close_all_open_fd() helper
Date: Tue, 23 Jul 2024 11:42:52 +0400

Hi

On Wed, Jul 17, 2024 at 4:48 PM Clément Léger <cleger@rivosinc.com> wrote:
Since commit 03e471c41d8b ("qemu_init: increase NOFILE soft limit on
POSIX"), the maximum number of file descriptors that can be opened are
raised to nofile.rlim_max. On recent debian distro, this yield a maximum
of 1073741816 file descriptors. Now, when forking to start
qemu-bridge-helper, this actually calls close() on the full possible file
descriptor range (more precisely [3 - sysconf(_SC_OPEN_MAX)]) which
takes a considerable amount of time. In order to reduce that time,
factorize existing code to close all open files descriptors in a new
qemu_close_all_open_fd() function. This function uses various methods
to close all the open file descriptors ranging from the most efficient
one to the least one. It also accepts an ordered array of file
descriptors that should not be closed since this is required by the
callers that calls it after forking.

Signed-off-by: Clément Léger <cleger@rivosinc.com>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>


GLib already implemented those kinds of portable facilities.

I wonder why launch_script() is not using glib gspawn API.

async-teardown should use g_clownfrom() when glib >= 2.80.

my 2c

--
Marc-André Lureau

reply via email to

[Prev in Thread] Current Thread [Next in Thread]