]> git.ipfire.org Git - thirdparty/qemu.git/commitdiff
monitor: don't wake up qmp_dispatcher_co coroutine upon cleanup
authorAndrey Drobyshev <andrey.drobyshev@virtuozzo.com>
Fri, 2 May 2025 21:47:29 +0000 (00:47 +0300)
committerPaolo Bonzini <pbonzini@redhat.com>
Fri, 2 May 2025 21:51:30 +0000 (23:51 +0200)
Since the commit 3e6bed61 ("monitor: cleanup detection of qmp_dispatcher_co
shutting down"), coroutine pointer qmp_dispatcher_co is set to NULL upon
cleanup.  If a QMP command is sent after monitor_cleanup() (e.g. after
shutdown), this may lead to SEGFAULT on aio_co_wake(NULL).

As mentioned in the comment inside monitor_cleanup(), the intention is to
allow incoming requests while shutting down, but simply leave them
without any response.  Let's do exactly that, and if qmp_dispatcher_co
coroutine pointer has already been set to NULL, let's simply skip the
aio_co_wake() part.

Signed-off-by: Andrey Drobyshev <andrey.drobyshev@virtuozzo.com>
Link: https://lore.kernel.org/r/20250502214729.928380-2-andrey.drobyshev@virtuozzo.com
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
monitor/qmp.c

index 2f46cf9e494193f1770c785a99f109e95f3b1936..cb99a12d94175b395033569e8ead908d9453e759 100644 (file)
@@ -356,7 +356,8 @@ void qmp_dispatcher_co_wake(void)
     /* Write request before reading qmp_dispatcher_co_busy.  */
     smp_mb__before_rmw();
 
-    if (!qatomic_xchg(&qmp_dispatcher_co_busy, true)) {
+    if (!qatomic_xchg(&qmp_dispatcher_co_busy, true) &&
+            qatomic_read(&qmp_dispatcher_co)) {
         aio_co_wake(qmp_dispatcher_co);
     }
 }