Make qemu_shutdown_requested signal-safe
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 commit15124e142
attempts to deal with. That commit breaks use of ^C to drop into gdb, and so this approach is better (and15124e142
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>
This commit is contained in:
parent
ff0d48768b
commit
817ef04db2
4
vl.c
4
vl.c
|
@ -1609,9 +1609,7 @@ int qemu_reset_requested_get(void)
|
||||||
|
|
||||||
static int qemu_shutdown_requested(void)
|
static int qemu_shutdown_requested(void)
|
||||||
{
|
{
|
||||||
int r = shutdown_requested;
|
return atomic_xchg(&shutdown_requested, 0);
|
||||||
shutdown_requested = 0;
|
|
||||||
return r;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void qemu_kill_report(void)
|
static void qemu_kill_report(void)
|
||||||
|
|
Loading…
Reference in New Issue