qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH 49/88] Make qemu_shutdown_requested signal-safe


From: Michael Roth
Subject: [Qemu-devel] [PATCH 49/88] Make qemu_shutdown_requested signal-safe
Date: Thu, 8 Jan 2015 11:33:53 -0600

From: Jan Kiszka <address@hidden>

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.

This provides a different fix for the problem which commit 15124e142
attempts to deal with. That commit breaks use of ^C to drop into gdb,
and so this approach is better (and 15124e142 can be reverted).

Signed-off-by: Jan Kiszka <address@hidden>
Reviewed-by: Gonglei <address@hidden>
Reviewed-by: Paolo Bonzini <address@hidden>
[PMM: commit message tweak]
Signed-off-by: Peter Maydell <address@hidden>

(cherry picked from commit 817ef04db2cfa2df04daffd6917f4ea7605f6403)
Signed-off-by: Michael Roth <address@hidden>
---
 vl.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/vl.c b/vl.c
index 7f8bd39..3650f4f 100644
--- a/vl.c
+++ b/vl.c
@@ -1745,9 +1745,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.9.1




reply via email to

[Prev in Thread] Current Thread [Next in Thread]