]> git.ipfire.org Git - thirdparty/qemu.git/commitdiff
monitor: cleanup detection of qmp_dispatcher_co shutting down
authorPaolo Bonzini <pbonzini@redhat.com>
Fri, 3 Mar 2023 11:45:29 +0000 (12:45 +0100)
committerPaolo Bonzini <pbonzini@redhat.com>
Thu, 25 May 2023 08:18:33 +0000 (10:18 +0200)
Instead of overloading qmp_dispatcher_co_busy, make the coroutine
pointer NULL.  This will make things break spectacularly if somebody
tries to start a request after monitor_cleanup().

AIO_WAIT_WHILE_UNLOCKED() does not need qatomic_mb_read(), because
the macro contains all the necessary memory barriers.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
monitor/monitor.c
monitor/qmp.c

index 15f97538ef2b4f3522e7a4140f09a815202a2ec4..c4ed2547c25f35f4e161034af1fb2a3234207ff0 100644 (file)
@@ -686,7 +686,7 @@ void monitor_cleanup(void)
 
     AIO_WAIT_WHILE_UNLOCKED(NULL,
                    (aio_poll(iohandler_get_aio_context(), false),
-                    qatomic_mb_read(&qmp_dispatcher_co_busy)));
+                    qatomic_read(&qmp_dispatcher_co)));
 
     /*
      * We need to explicitly stop the I/O thread (but not destroy it),
index 092c527b6fc9c6363f4bf81d85736144b656d038..f0cc6dc886f8e35239990d7924a158b367b33ab7 100644 (file)
@@ -226,6 +226,7 @@ void coroutine_fn monitor_qmp_dispatcher_co(void *data)
 
         /* On shutdown, don't take any more requests from the queue */
         if (qmp_dispatcher_co_shutdown) {
+            qatomic_set(&qmp_dispatcher_co, NULL);
             return;
         }
 
@@ -250,6 +251,7 @@ void coroutine_fn monitor_qmp_dispatcher_co(void *data)
              * yielded and were reentered from monitor_cleanup()
              */
             if (qmp_dispatcher_co_shutdown) {
+                qatomic_set(&qmp_dispatcher_co, NULL);
                 return;
             }
         }