qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] Make qemu_shutdown_requested signal-safe
@ 2014-10-26  9:32 Jan Kiszka
  2014-10-26  9:43 ` Gonglei
  2014-10-27  9:09 ` Paolo Bonzini
  0 siblings, 2 replies; 4+ messages in thread
From: Jan Kiszka @ 2014-10-26  9:32 UTC (permalink / raw)
  To: Peter Maydell, qemu-devel
  Cc: Paolo Bonzini, Alex Bennée, Stefan Hajnoczi, Gonglei

[-- 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 --]

^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2014-10-27  9:12 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-10-26  9:32 [Qemu-devel] [PATCH] Make qemu_shutdown_requested signal-safe Jan Kiszka
2014-10-26  9:43 ` Gonglei
2014-10-27  9:09 ` Paolo Bonzini
2014-10-27  9:11   ` Jan Kiszka

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).