From: Paolo Bonzini <pbonzini@redhat.com>
To: qemu-devel@nongnu.org
Cc: armbru@redhat.com, kwolf@redhat.com
Subject: [PATCH 1/5] monitor: cleanup detection of qmp_dispatcher_co shutting down
Date: Thu, 18 May 2023 12:18:19 +0200 [thread overview]
Message-ID: <20230518101823.992158-2-pbonzini@redhat.com> (raw)
In-Reply-To: <20230518101823.992158-1-pbonzini@redhat.com>
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 | 2 +-
monitor/qmp.c | 2 ++
2 files changed, 3 insertions(+), 1 deletion(-)
diff --git a/monitor/monitor.c b/monitor/monitor.c
index 15f97538ef2b..c4ed2547c25f 100644
--- a/monitor/monitor.c
+++ b/monitor/monitor.c
@@ -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),
diff --git a/monitor/qmp.c b/monitor/qmp.c
index 092c527b6fc9..f0cc6dc886f8 100644
--- a/monitor/qmp.c
+++ b/monitor/qmp.c
@@ -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;
}
}
--
2.40.1
next prev parent reply other threads:[~2023-05-18 10:18 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-18 10:18 [PATCH 0/5] qmp: cleanup QMP dispatcher coroutine Paolo Bonzini
2023-05-18 10:18 ` Paolo Bonzini [this message]
2023-05-18 10:18 ` [PATCH 2/5] monitor: cleanup fetching of QMP requests Paolo Bonzini
2023-05-18 10:18 ` [PATCH 3/5] monitor: introduce qmp_dispatcher_co_wake Paolo Bonzini
2023-05-18 10:18 ` [PATCH 4/5] monitor: extract request dequeuing to a new function Paolo Bonzini
2023-05-18 10:18 ` [PATCH 5/5] monitor: do not use mb_read/mb_set Paolo Bonzini
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230518101823.992158-2-pbonzini@redhat.com \
--to=pbonzini@redhat.com \
--cc=armbru@redhat.com \
--cc=kwolf@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).