Skip to contentSkip to conversation

watchdog: fix deadlock with -watchdog-action pause

PATCH In review Paolo Bonzini 2 participants 2 messages Jul 4, 2014

lore
Share & tools
lore
#0 lore raw

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
index 9f607d4..aa25b6f 100644
@@ -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
Tested-by on v1 1/1
#1 lore raw
Quoted 8 lines · On Fri, 4 Jul 2014 15:48:50 +0200 Paolo Bonzini <[email protected]> wrote:

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.
*/

Quoted 7 lines

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.

Quoted 18 lines
---
 hw/watchdog/watchdog.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
hw/watchdog/watchdog.c +2 -1
index 9f607d4..aa25b6f 100644
@@ -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: