From patchwork Fri Jul 6 09:41:29 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wen Congyang X-Patchwork-Id: 169400 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id D69E82C0089 for ; Fri, 6 Jul 2012 19:56:35 +1000 (EST) Received: from localhost ([::1]:51775 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Sn5H7-0000Np-Pr for incoming@patchwork.ozlabs.org; Fri, 06 Jul 2012 05:56:33 -0400 Received: from eggs.gnu.org ([208.118.235.92]:48532) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Sn5Gt-000080-MI for qemu-devel@nongnu.org; Fri, 06 Jul 2012 05:56:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Sn5Gl-0006bp-MD for qemu-devel@nongnu.org; Fri, 06 Jul 2012 05:56:19 -0400 Received: from [222.73.24.84] (port=19944 helo=song.cn.fujitsu.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Sn5Gl-0006bY-A0 for qemu-devel@nongnu.org; Fri, 06 Jul 2012 05:56:11 -0400 X-IronPort-AV: E=Sophos;i="4.77,537,1336320000"; d="scan'208";a="5344265" Received: from unknown (HELO tang.cn.fujitsu.com) ([10.167.250.3]) by song.cn.fujitsu.com with ESMTP; 06 Jul 2012 17:55:15 +0800 Received: from fnstmail02.fnst.cn.fujitsu.com (tang.cn.fujitsu.com [127.0.0.1]) by tang.cn.fujitsu.com (8.14.3/8.13.1) with ESMTP id q669aMHO011969; Fri, 6 Jul 2012 17:37:01 +0800 Received: from [10.167.225.226] ([10.167.225.226]) by fnstmail02.fnst.cn.fujitsu.com (Lotus Domino Release 8.5.3) with ESMTP id 2012070617370004-560452 ; Fri, 6 Jul 2012 17:37:00 +0800 Message-ID: <4FF6B2C9.10302@cn.fujitsu.com> Date: Fri, 06 Jul 2012 17:41:29 +0800 From: Wen Congyang User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.9) Gecko/20100413 Fedora/3.0.4-2.fc13 Thunderbird/3.0.4 MIME-Version: 1.0 To: kvm list , qemu-devel , "linux-kernel@vger.kernel.org" , Avi Kivity , "Daniel P. Berrange" , KAMEZAWA Hiroyuki , Jan Kiszka , Gleb Natapov References: <4FF6B188.2060607@cn.fujitsu.com> In-Reply-To: <4FF6B188.2060607@cn.fujitsu.com> X-MIMETrack: Itemize by SMTP Server on mailserver/fnst(Release 8.5.3|September 15, 2011) at 2012/07/06 17:37:00, Serialize by Router on mailserver/fnst(Release 8.5.3|September 15, 2011) at 2012/07/06 17:37:04, Serialize complete at 2012/07/06 17:37:04 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 222.73.24.84 Subject: [Qemu-devel] [PATCH 6/7 v6] deal with guest panicked event accoring to -onpanic parameter X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org The onpanic parameter can have the following value: 1. none 2. pause 3. poweroff 4. reset The action for each value when the guest is panicked: 1. none: emit QEVENT_GUEST_PANICKED only 2. pause: emit QEVENT_GUEST_PANICKED and pause the guest 3. poweroff: emit QEVENT_GUEST_PANICKED and poweroff the guest 4. reset: emit QEVENT_GUEST_PANICKED and reset the guest Signed-off-by: Wen Congyang --- hw/kvm/pv_event.c | 17 +++++++++++++++++ qemu-options.hx | 15 +++++++++++++++ vl.c | 6 ++++++ 3 files changed, 38 insertions(+), 0 deletions(-) diff --git a/hw/kvm/pv_event.c b/hw/kvm/pv_event.c index d7ded37..890abcd 100644 --- a/hw/kvm/pv_event.c +++ b/hw/kvm/pv_event.c @@ -59,6 +59,23 @@ static void panicked_perform_action(uint32_t panicked_action) } } +int select_panicked_action(const char *p) +{ + if (strcasecmp(p, "none") == 0) { + panicked_action = PANICKED_REPORT; + } else if (strcasecmp(p, "pause") == 0) { + panicked_action = PANICKED_PAUSE; + } else if (strcasecmp(p, "poweroff") == 0) { + panicked_action = PANICKED_POWEROFF; + } else if (strcasecmp(p, "reset") == 0) { + panicked_action = PANICKED_RESET; + } else { + return -1; + } + + return 0; +} + #if defined(KVM_PV_PORT) #include "pv_ioport.c" diff --git a/qemu-options.hx b/qemu-options.hx index 8b66264..4a061bf 100644 --- a/qemu-options.hx +++ b/qemu-options.hx @@ -2743,6 +2743,21 @@ DEF("qtest-log", HAS_ARG, QEMU_OPTION_qtest_log, "-qtest-log LOG specify tracing options\n", QEMU_ARCH_ALL) +DEF("onpanic", HAS_ARG, QEMU_OPTION_onpanic, \ + "-onpanic none|pause|poweroff|reset\n" \ + " action when the guest is panicked [default=none]", + QEMU_ARCH_ALL) +STEXI +@item -onpanic @var{action} + +The @var{action} controls what QEmu will do when the guest is panicked. +The default is @code{none} (emit QEVENT_GUEST_PANICKED only). +Other possible actions are: +@code{pause} (emit QEVENT_GUEST_PANICKED and pause the guest), +@code{poweroff} (emit QEVENT_GUEST_PANICKED and forcefully poweroff the guest), +@code{reset} (emit QEVENT_GUEST_PANICKED and forcefully reset the guest). +ETEXI + HXCOMM This is the last statement. Insert new options before this line! STEXI @end table diff --git a/vl.c b/vl.c index f5cd28d..1a68257 100644 --- a/vl.c +++ b/vl.c @@ -3205,6 +3205,12 @@ int main(int argc, char **argv, char **envp) case QEMU_OPTION_qtest_log: qtest_log = optarg; break; + case QEMU_OPTION_onpanic: + if (select_panicked_action(optarg) == -1) { + fprintf(stderr, "Unknown -onpanic parameter\n"); + exit(1); + } + break; default: os_parse_cmd_args(popt->index, optarg); }