From: "Philippe Mathieu-Daudé" <philmd@linaro.org>
To: andrey.drobyshev@virtuozzo.com, qemu-devel@nongnu.org
Cc: armbru@redhat.com, pbonzini@redhat.com, den@virtuozzo.com,
qemu-block <qemu-block@nongnu.org>
Subject: Re: [PATCH 1/1] monitor: don't wake up qmp_dispatcher_co coroutine upon cleanup
Date: Sat, 3 May 2025 00:06:32 +0200 [thread overview]
Message-ID: <e2ca43dd-a1ba-4eba-ac17-1e0ac0d42fbc@linaro.org> (raw)
In-Reply-To: <20250502214729.928380-2-andrey.drobyshev@virtuozzo.com>
On 2/5/25 23:47, andrey.drobyshev@virtuozzo.com wrote:
> From: Andrey Drobyshev <andrey.drobyshev@virtuozzo.com>
>
> 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.
>
Cc: qemu-stable@nongnu.org
> Signed-off-by: Andrey Drobyshev <andrey.drobyshev@virtuozzo.com>
> ---
> monitor/qmp.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/monitor/qmp.c b/monitor/qmp.c
> index 2f46cf9e49..cb99a12d94 100644
> --- a/monitor/qmp.c
> +++ b/monitor/qmp.c
> @@ -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);
> }
> }
prev parent reply other threads:[~2025-05-02 22:07 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-05-02 21:47 [PATCH 0/1] Fix racy SEGFAULT upon monitor_cleanup() andrey.drobyshev
2025-05-02 21:47 ` [PATCH 1/1] monitor: don't wake up qmp_dispatcher_co coroutine upon cleanup andrey.drobyshev
2025-05-02 22:06 ` Philippe Mathieu-Daudé [this message]
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=e2ca43dd-a1ba-4eba-ac17-1e0ac0d42fbc@linaro.org \
--to=philmd@linaro.org \
--cc=andrey.drobyshev@virtuozzo.com \
--cc=armbru@redhat.com \
--cc=den@virtuozzo.com \
--cc=pbonzini@redhat.com \
--cc=qemu-block@nongnu.org \
--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).