* [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
* Re: [Qemu-devel] [PATCH] Make qemu_shutdown_requested signal-safe
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
1 sibling, 0 replies; 4+ messages in thread
From: Gonglei @ 2014-10-26 9:43 UTC (permalink / raw)
To: Jan Kiszka
Cc: Peter Maydell, qemu-devel, Stefan Hajnoczi, Paolo Bonzini,
Alex Bennée, Gonglei
On 2014/10/26 17:32, Jan Kiszka wrote:
> 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)
Looks good to me, so
Reviewed-by: Gonglei <arei.gonglei@huawei.com>
Best regards,
-Gonglei
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Qemu-devel] [PATCH] Make qemu_shutdown_requested signal-safe
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
1 sibling, 1 reply; 4+ messages in thread
From: Paolo Bonzini @ 2014-10-27 9:09 UTC (permalink / raw)
To: Jan Kiszka, Peter Maydell, qemu-devel
Cc: Alex Bennée, qemu-stable, Stefan Hajnoczi, Gonglei
On 10/26/2014 10:32 AM, Jan Kiszka wrote:
> 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)
>
Cc: qemu-stable@nongnu.org
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Are you going to send a pull request yourself?
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Qemu-devel] [PATCH] Make qemu_shutdown_requested signal-safe
2014-10-27 9:09 ` Paolo Bonzini
@ 2014-10-27 9:11 ` Jan Kiszka
0 siblings, 0 replies; 4+ messages in thread
From: Jan Kiszka @ 2014-10-27 9:11 UTC (permalink / raw)
To: Paolo Bonzini, Peter Maydell, qemu-devel
Cc: Alex Bennée, qemu-stable, Stefan Hajnoczi, Gonglei
[-- Attachment #1: Type: text/plain, Size: 1123 bytes --]
On 2014-10-27 10:09, Paolo Bonzini wrote:
> On 10/26/2014 10:32 AM, Jan Kiszka wrote:
>> 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)
>>
>
> Cc: qemu-stable@nongnu.org
> Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
>
> Are you going to send a pull request yourself?
>
I was assuming Peter would merge (and decide about the ordering).
Jan
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 198 bytes --]
^ permalink raw reply [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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.