Make qemu_shutdown_requested signal-safe
PATCH 1/1 Make qemu_shutdown_requested signal-safe
From: Jan Kiszka <[email protected]>
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.
--- vl.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
vl.c +1 -3
@@ -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 )
Signature · 1 line
1.8.4.5
Quoted 17 lines · Jan Kiszka
From: Jan Kiszka <[email protected]>
qemu_shutdown_requestedmay be interrupted byqemu_system_killed. If the latter setsshutdown_requestedafterqemu_shutdown_requestedhas read it but before it was cleared, the shutdown event is lost. Fix this by usingatomic_xchg.Signed-off-by Jan Kiszka <[email protected]>--- vl.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)vl.c +0
-0
vl.c int qemu_reset_requested_get(void) · line 1615
Quoted 10 lines
vl.c +1
-3@@ -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 )
Looks good to me, so
Best regards,
-Gonglei
Quoted 14 lines · Jan Kiszka
From: Jan Kiszka <[email protected]>
qemu_shutdown_requestedmay be interrupted byqemu_system_killed. If the latter setsshutdown_requestedafterqemu_shutdown_requestedhas read it but before it was cleared, the shutdown event is lost. Fix this by usingatomic_xchg.Signed-off-by Jan Kiszka <[email protected]> --- vl.c | 4+--- 1 file changed, 1 insertion(+), 3 deletions(-)
vl.c index 2f81384..f6b3546 100644 --- a/vl.c renamed from vl.c +1
-0+++ b/vl.c @@ -1609,9 +1609,7 @@ int
qemu_reset_requested_get(void)
Quoted 6 lines
static int
qemu_shutdown_requested(void){ - int r =shutdown_requested; -shutdown_requested= 0; - return r; +
returnatomic_xchg(&shutdown_requested, 0); }static void
qemu_kill_report(void)
Are you going to send a pull request yourself?
Quoted 19 lines · Paolo Bonzini
Quoted 18 lines · Jan Kiszka
From: Jan Kiszka <[email protected]>
qemu_shutdown_requestedmay be interrupted byqemu_system_killed. If the latter setsshutdown_requestedafterqemu_shutdown_requestedhas read it but before it was cleared, the shutdown event is lost. Fix this by usingatomic_xchg.Signed-off-by Jan Kiszka <[email protected]> --- vl.c | 4+--- 1 file changed, 1 insertion(+), 3 deletions(-)
vl.c index 2f81384..f6b3546 100644 --- a/vl.c renamed from vl.c +1
-0+++ 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; +
returnatomic_xchg(&shutdown_requested, 0); }
Quoted 8 lines
Quoted 2 lines
static void
qemu_kill_report(void)Reviewed-by Paolo Bonzini <[email protected]>Are you going to send a pull request yourself?
I was assuming Peter would merge (and decide about the ordering).
Jan