Received: from eggs.gnu.org ([2001:4830:134:3::10]:60027) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X4uHt-0005tq-HM for qemu-devel@nongnu.org; Wed, 09 Jul 2014 12:00:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1X4uHj-0006nh-Ah for qemu-devel@nongnu.org; Wed, 09 Jul 2014 12:00:05 -0400 Received: from mail-wi0-x230.google.com ([2a00:1450:400c:c05::230]:38168) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X4uHj-0006nb-48 for qemu-devel@nongnu.org; Wed, 09 Jul 2014 11:59:55 -0400 Received: by mail-wi0-f176.google.com with SMTP id n3so3019374wiv.9 for ; Wed, 09 Jul 2014 08:59:54 -0700 (PDT) Received: from playground.station (net-2-35-201-190.cust.vodafonedsl.it. [2.35.201.190]) by mx.google.com with ESMTPSA id ub11sm9013105wib.1.2014.07.09.08.59.52 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 09 Jul 2014 08:59:53 -0700 (PDT) Sender: Paolo Bonzini From: Paolo Bonzini Date: Wed, 9 Jul 2014 17:59:32 +0200 Message-Id: <1404921577-1461-6-git-send-email-pbonzini@redhat.com> In-Reply-To: <1404921577-1461-1-git-send-email-pbonzini@redhat.com> References: <1404921577-1461-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