You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
qemu/include/chardev
Jie Song e714f1a3d4 monitor/qmp: cleanup SocketChardev listener sources early to avoid fd handling race
When starting a dummy QEMU process with virsh version, monitor_init_qmp()
enables IOThread monitoring of the QMP fd by default. However, a race
condition exists during the initialization phase: the IOThread only removes
the main thread's fd watch when it reaches qio_net_listener_set_client_func_full(),
which may be delayed under high system load.

This creates a window between monitor_qmp_setup_handlers_bh() and
qio_net_listener_set_client_func_full() where both the main thread and
IOThread are simultaneously monitoring the same fd and processing events.
This race can cause either the main thread or the IOThread to hang and
become unresponsive.

Fix this by proactively cleaning up the listener's IO sources in
monitor_init_qmp() before the IOThread initializes QMP monitoring,
ensuring exclusive fd ownership and eliminating the race condition.

Signed-off-by: Jie Song <songjie_yewu@cmss.chinamobile.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-ID: <20251125140706.114197-1-mail@jiesong.me>
1 week ago
..
char-fd.h chardev: qemu_chr_open_fd(): add errp 4 months ago
char-fe.h char: rename CharBackend->CharFrontend 3 months ago
char-io.h monitor/qmp: cleanup SocketChardev listener sources early to avoid fd handling race 1 week ago
char-parallel.h char: fix alias devices regression 9 years ago
char-serial.h char: fix alias devices regression 9 years ago
char-socket.h chardev: introduce 'reconnect-ms' and deprecate 'reconnect' 1 year ago
char-win-stdio.h chardev: move headers to include/chardev 9 years ago
char-win.h Use DECLARE_*CHECKER* macros 5 years ago
char.h monitor/qmp: cleanup SocketChardev listener sources early to avoid fd handling race 1 week ago
spice.h chardev/spice: simplify chardev setup 5 years ago