Skip to content

Commit

Permalink
Make qemu_shutdown_requested signal-safe
Browse files Browse the repository at this point in the history
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 15124e1
attempts to deal with. That commit breaks use of ^C to drop into gdb,
and so this approach is better (and 15124e1 can be reverted).

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Reviewed-by: Gonglei <arei.gonglei@huawei.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
[PMM: commit message tweak]
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>

(cherry picked from commit 817ef04)
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
  • Loading branch information
jan-kiszka authored and mdroth committed Jan 7, 2015
1 parent 90de7a0 commit 5a6af97
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions vl.c
Expand Up @@ -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)
Expand Down

0 comments on commit 5a6af97

Please sign in to comment.