From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55455) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X5Gpz-0000df-6A for qemu-devel@nongnu.org; Thu, 10 Jul 2014 12:04:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1X5Gpp-0004JH-Oa for qemu-devel@nongnu.org; Thu, 10 Jul 2014 12:04:47 -0400 Received: from mail-we0-x232.google.com ([2a00:1450:400c:c03::232]:34002) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X5Gpp-0004IZ-Dj for qemu-devel@nongnu.org; Thu, 10 Jul 2014 12:04:37 -0400 Received: by mail-we0-f178.google.com with SMTP id x48so9234230wes.37 for ; Thu, 10 Jul 2014 09:04:36 -0700 (PDT) Received: from playground.station ([37.116.194.21]) by mx.google.com with ESMTPSA id by3sm91931143wjc.10.2014.07.10.09.04.33 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 10 Jul 2014 09:04:33 -0700 (PDT) Sender: Paolo Bonzini From: Paolo Bonzini Date: Thu, 10 Jul 2014 18:04:08 +0200 Message-Id: <1405008253-9816-6-git-send-email-pbonzini@redhat.com> In-Reply-To: <1405008253-9816-1-git-send-email-pbonzini@redhat.com> References: <1405008253-9816-1-git-send-email-pbonzini@redhat.com> Subject: [Qemu-devel] [PULL 05/10] watchdog: fix deadlock with -watchdog-action pause List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org 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; yet another alternative could be a BH. I checked other occurrences of vm_stop and they should not have this problem. RUN_STATE_IO_ERROR could in principle (it depends on the code in the drivers) but it has been fixed by commit 2bd3bce, "block: asynchronously stop the VM on I/O errors", 2014-06-05. Tested-by: Luiz Capitulino Signed-off-by: Paolo Bonzini --- hw/watchdog/watchdog.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/hw/watchdog/watchdog.c b/hw/watchdog/watchdog.c index 9f607d4..c307f9b 100644 --- a/hw/watchdog/watchdog.c +++ b/hw/watchdog/watchdog.c @@ -122,8 +122,12 @@ void watchdog_perform_action(void) exit(0); case WDT_PAUSE: /* same as 'stop' command in monitor */ + /* In a timer callback, when vm_stop calls qemu_clock_enable + * you would get a deadlock. Bypass the problem. + */ + qemu_system_vmstop_request_prepare(); qapi_event_send_watchdog(WATCHDOG_EXPIRATION_ACTION_PAUSE, &error_abort); - vm_stop(RUN_STATE_WATCHDOG); + qemu_system_vmstop_request(RUN_STATE_WATCHDOG); break; case WDT_DEBUG: -- 1.8.3.1