watchdog: fix deadlock with -watchdog-action pause
PATCH 1/1 watchdog: fix deadlock with -watchdog-action pause
qemu_clock_enable says:
/* Disabling the clock will wait for related timerlists to stop
* executing qemu_run_timers. Thus, this functions should not
* be used from the callback of a timer that is based on @clock.
* Doing so would cause a deadlock.
*/
and it indeed does: vm_stop uses qemu_clock_enable on QEMU_CLOCK_VIRTUAL and watchdogs are based on QEMU_CLOCK_VIRTUAL, and we get a deadlock.
Use qemu_system_vmstop_request_prepare()/qemu_system_vmstop_request() instead; the alternative could be a BH.
--- hw/watchdog/watchdog.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
hw/watchdog/watchdog.c +2 -1
@@ -123,7 +123,8 @@ void watchdog_perform_action(void)case WDT_PAUSE :/* same as 'stop' command in monitor */ qapi_event_send_watchdog (WATCHDOG_EXPIRATION_ACTION_PAUSE , &error_abort); -vm_stop (RUN_STATE_WATCHDOG ); +qemu_system_vmstop_request_prepare (); +qemu_system_vmstop_request (RUN_STATE_WATCHDOG );break ;case WDT_DEBUG :
Signature · 1 line
1.9.3
Quoted 8 lines · On Fri, 4 Jul 2014 15:48:50 +0200 Paolo Bonzini <[email protected]> wrote:
qemu_clock_enablesays:/* Disabling the clock will wait for related timerlists to stop
* executingqemu_run_timers. Thus, this functions should not
* be used from the callback of a timer that is based on @clock.
* Doing so would cause a deadlock.
*/
Quoted 7 lines
and it indeed does:
vm_stopusesqemu_clock_enableonQEMU_CLOCK_VIRTUALand watchdogs are based onQEMU_CLOCK_VIRTUAL, and we get a deadlock.Use qemu_system_vmstop_request_prepare()/qemu_system_vmstop_request() instead; the alternative could be a BH.
Signed-off-by Paolo Bonzini <[email protected]>
Quoted 18 lines
--- hw/watchdog/watchdog.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)hw/watchdog/watchdog.c +2
-1@@ -123,7 +123,8 @@ void watchdog_perform_action(void)case WDT_PAUSE :/* same as 'stop' command in monitor */ qapi_event_send_watchdog (WATCHDOG_EXPIRATION_ACTION_PAUSE , &error_abort); -vm_stop (RUN_STATE_WATCHDOG ); +qemu_system_vmstop_request_prepare (); +qemu_system_vmstop_request (RUN_STATE_WATCHDOG );break ;case WDT_DEBUG :