From patchwork Wed Mar 7 01:58:57 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wen Congyang X-Patchwork-Id: 145140 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 6419FB6ED0 for ; Wed, 7 Mar 2012 12:57:35 +1100 (EST) Received: from localhost ([::1]:32863 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S568D-0004hb-Cq for incoming@patchwork.ozlabs.org; Tue, 06 Mar 2012 20:57:33 -0500 Received: from eggs.gnu.org ([208.118.235.92]:51525) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S5684-0004hT-Mw for qemu-devel@nongnu.org; Tue, 06 Mar 2012 20:57:26 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1S5682-0006E8-NV for qemu-devel@nongnu.org; Tue, 06 Mar 2012 20:57:24 -0500 Received: from [222.73.24.84] (port=58847 helo=song.cn.fujitsu.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S5682-0006Do-Ba for qemu-devel@nongnu.org; Tue, 06 Mar 2012 20:57:22 -0500 X-IronPort-AV: E=Sophos;i="4.73,542,1325433600"; d="scan'208";a="4474640" Received: from unknown (HELO tang.cn.fujitsu.com) ([10.167.250.3]) by song.cn.fujitsu.com with ESMTP; 07 Mar 2012 09:57:14 +0800 Received: from mailserver.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 q271vEKJ008658; Wed, 7 Mar 2012 09:57:14 +0800 Received: from [10.167.225.226] ([10.167.225.226]) by mailserver.fnst.cn.fujitsu.com (Lotus Domino Release 8.5.1FP4) with ESMTP id 2012030709551904-902497 ; Wed, 7 Mar 2012 09:55:19 +0800 Message-ID: <4F56C0E1.1090703@cn.fujitsu.com> Date: Wed, 07 Mar 2012 09:58:57 +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: <4F56BEF2.4020405@cn.fujitsu.com> In-Reply-To: <4F56BEF2.4020405@cn.fujitsu.com> X-MIMETrack: Itemize by SMTP Server on mailserver/fnst(Release 8.5.1FP4|July 25, 2010) at 2012-03-07 09:55:19, Serialize by Router on mailserver/fnst(Release 8.5.1FP4|July 25, 2010) at 2012-03-07 09:55:24, Serialize complete at 2012-03-07 09:55:24 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 v2] deal with guest paniced event 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 When the host knows the guest is paniced, it will set exit_reason to KVM_EXIT_GUEST_PANICED. So if qemu receive this exit_reason, we can send a event to tell management application that the guest is paniced and set the guest status to RUN_STATE_PANICED. Signed-off-by: Wen Congyang --- kvm-all.c | 4 ++++ linux-headers/linux/kvm.h | 1 + monitor.c | 3 +++ monitor.h | 1 + qapi-schema.json | 2 +- qmp.c | 3 ++- vl.c | 1 + 7 files changed, 13 insertions(+), 2 deletions(-) diff --git a/kvm-all.c b/kvm-all.c index c4babda..d356948 100644 --- a/kvm-all.c +++ b/kvm-all.c @@ -1190,6 +1190,10 @@ int kvm_cpu_exec(CPUState *env) (uint64_t)run->hw.hardware_exit_reason); ret = -1; break; + case KVM_EXIT_GUEST_PANICED: + monitor_protocol_event(QEVENT_GUEST_PANICED, NULL); + vm_stop(RUN_STATE_PANICED); + break; case KVM_EXIT_INTERNAL_ERROR: ret = kvm_handle_internal_error(env, run); break; diff --git a/linux-headers/linux/kvm.h b/linux-headers/linux/kvm.h index f6b5343..ddc9716 100644 --- a/linux-headers/linux/kvm.h +++ b/linux-headers/linux/kvm.h @@ -163,6 +163,7 @@ struct kvm_pit_config { #define KVM_EXIT_OSI 18 #define KVM_EXIT_PAPR_HCALL 19 #define KVM_EXIT_S390_UCONTROL 20 +#define KVM_EXIT_GUEST_PANICED 21 /* For KVM_EXIT_INTERNAL_ERROR */ #define KVM_INTERNAL_ERROR_EMULATION 1 diff --git a/monitor.c b/monitor.c index 953e748..9802792 100644 --- a/monitor.c +++ b/monitor.c @@ -494,6 +494,9 @@ void monitor_protocol_event(MonitorEvent event, QObject *data) case QEVENT_WAKEUP: event_name = "WAKEUP"; break; + case QEVENT_GUEST_PANICED: + event_name = "GUEST_PANICED"; + break; default: abort(); break; diff --git a/monitor.h b/monitor.h index 0d49800..a62da93 100644 --- a/monitor.h +++ b/monitor.h @@ -41,6 +41,7 @@ typedef enum MonitorEvent { QEVENT_DEVICE_TRAY_MOVED, QEVENT_SUSPEND, QEVENT_WAKEUP, + QEVENT_GUEST_PANICED, QEVENT_MAX, } MonitorEvent; diff --git a/qapi-schema.json b/qapi-schema.json index d0b6792..dd4b7a0 100644 --- a/qapi-schema.json +++ b/qapi-schema.json @@ -121,7 +121,7 @@ { 'enum': 'RunState', 'data': [ 'debug', 'inmigrate', 'internal-error', 'io-error', 'paused', 'postmigrate', 'prelaunch', 'finish-migrate', 'restore-vm', - 'running', 'save-vm', 'shutdown', 'watchdog' ] } + 'running', 'save-vm', 'shutdown', 'watchdog', 'paniced' ] } ## # @StatusInfo: diff --git a/qmp.c b/qmp.c index a182b51..eeb6d3b 100644 --- a/qmp.c +++ b/qmp.c @@ -148,7 +148,8 @@ void qmp_cont(Error **errp) error_set(errp, QERR_MIGRATION_EXPECTED); return; } else if (runstate_check(RUN_STATE_INTERNAL_ERROR) || - runstate_check(RUN_STATE_SHUTDOWN)) { + runstate_check(RUN_STATE_SHUTDOWN) || + runstate_check(RUN_STATE_PANICED)) { error_set(errp, QERR_RESET_REQUIRED); return; } diff --git a/vl.c b/vl.c index 1d4c350..d9c13cf 100644 --- a/vl.c +++ b/vl.c @@ -359,6 +359,7 @@ static const RunStateTransition runstate_transitions_def[] = { { RUN_STATE_RUNNING, RUN_STATE_SAVE_VM }, { RUN_STATE_RUNNING, RUN_STATE_SHUTDOWN }, { RUN_STATE_RUNNING, RUN_STATE_WATCHDOG }, + { RUN_STATE_RUNNING, RUN_STATE_PANICED }, { RUN_STATE_SAVE_VM, RUN_STATE_RUNNING },