From: Jan Kiszka <jan.kiszka@web.de>
To: Peter Maydell <peter.maydell@linaro.org>,
qemu-devel <qemu-devel@nongnu.org>
Cc: "Paolo Bonzini" <pbonzini@redhat.com>,
"Alex Bennée" <alex.bennee@linaro.org>,
"Stefan Hajnoczi" <stefanha@redhat.com>,
Gonglei <arei.gonglei@hotmail.com>
Subject: [Qemu-devel] [PATCH] Make qemu_shutdown_requested signal-safe
Date: Sun, 26 Oct 2014 10:32:17 +0100 [thread overview]
Message-ID: <544CBFA1.1090108@web.de> (raw)
[-- Attachment #1: Type: text/plain, Size: 786 bytes --]
From: Jan Kiszka <jan.kiszka@siemens.com>
qemu_shutdown_requested may be interrupted by qemu_system_killed. If the
latter sets shutdown_requested after qemu_shutdown_requested has read it
but before it was cleared, the shutdown event is lost. Fix this by using
atomic_xchg.
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
---
vl.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/vl.c b/vl.c
index 2f81384..f6b3546 100644
--- a/vl.c
+++ b/vl.c
@@ -1609,9 +1609,7 @@ int qemu_reset_requested_get(void)
static int qemu_shutdown_requested(void)
{
- int r = shutdown_requested;
- shutdown_requested = 0;
- return r;
+ return atomic_xchg(&shutdown_requested, 0);
}
static void qemu_kill_report(void)
--
1.8.4.5
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 198 bytes --]
next reply other threads:[~2014-10-26 9:32 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-10-26 9:32 Jan Kiszka [this message]
2014-10-26 9:43 ` [Qemu-devel] [PATCH] Make qemu_shutdown_requested signal-safe Gonglei
2014-10-27 9:09 ` Paolo Bonzini
2014-10-27 9:11 ` Jan Kiszka
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=544CBFA1.1090108@web.de \
--to=jan.kiszka@web.de \
--cc=alex.bennee@linaro.org \
--cc=arei.gonglei@hotmail.com \
--cc=pbonzini@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@redhat.com \
/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).