From patchwork Mon Jun 20 13:42:44 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Gollub X-Patchwork-Id: 897472 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.4) with ESMTP id p5KDp04m022078 for ; Mon, 20 Jun 2011 13:51:10 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754798Ab1FTNvA (ORCPT ); Mon, 20 Jun 2011 09:51:00 -0400 Received: from schattenjagd.systems.b1-systems.de ([217.11.58.34]:54634 "EHLO mx1.b1-systems.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1754755Ab1FTNu4 (ORCPT ); Mon, 20 Jun 2011 09:50:56 -0400 Received: from marvin.site (ppp-88-217-124-96.dynamic.mnet-online.de [88.217.124.96]) by mx1.b1-systems.de (Postfix) with ESMTPSA id 561514085; Mon, 20 Jun 2011 15:45:02 +0200 (CEST) From: Daniel Gollub To: kvm@vger.kernel.org Cc: Daniel Gollub Subject: [PATCH 2/2] QMP: Introduce QEVENT_PANIC Date: Mon, 20 Jun 2011 15:42:44 +0200 Message-Id: <1308577364-17650-3-git-send-email-gollub@b1-systems.de> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1308577364-17650-1-git-send-email-gollub@b1-systems.de> References: <1308577364-17650-1-git-send-email-gollub@b1-systems.de> Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Mon, 20 Jun 2011 13:51:12 +0000 (UTC) Emitted when the guest panics. For now only if KVM_EXIT_PANIC got triggered. Signed-off-by: Daniel Gollub --- QMP/qmp-events.txt | 13 +++++++++++++ kvm-all.c | 3 ++- monitor.c | 3 +++ monitor.h | 1 + sysemu.h | 2 ++ vl.c | 18 ++++++++++++++++++ 6 files changed, 39 insertions(+), 1 deletions(-) diff --git a/QMP/qmp-events.txt b/QMP/qmp-events.txt index 0ce5d4e..96e4307 100644 --- a/QMP/qmp-events.txt +++ b/QMP/qmp-events.txt @@ -264,3 +264,16 @@ Example: Note: If action is "reset", "shutdown", or "pause" the WATCHDOG event is followed respectively by the RESET, SHUTDOWN, or STOP events. + + +PANIC +----- + +Emitted when the guest panics. + +Data: None. + +Example: + +{ "timestamp": {"seconds": 1308569038, "microseconds": 918147}, + "event": "PANIC"} diff --git a/kvm-all.c b/kvm-all.c index 9771f91..9fdda69 100644 --- a/kvm-all.c +++ b/kvm-all.c @@ -1030,7 +1030,8 @@ int kvm_cpu_exec(CPUState *env) ret = EXCP_INTERRUPT; break; case KVM_EXIT_PANIC: - panic = 1; + DPRINTF("panic\n"); + qemu_system_panic_request(); ret = 1; break; case KVM_EXIT_UNKNOWN: diff --git a/monitor.c b/monitor.c index fd6a881..5b337f2 100644 --- a/monitor.c +++ b/monitor.c @@ -468,6 +468,9 @@ void monitor_protocol_event(MonitorEvent event, QObject *data) case QEVENT_SPICE_DISCONNECTED: event_name = "SPICE_DISCONNECTED"; break; + case QEVENT_PANIC: + event_name = "PANIC"; + break; default: abort(); break; diff --git a/monitor.h b/monitor.h index 4f2d328..8b045df 100644 --- a/monitor.h +++ b/monitor.h @@ -35,6 +35,7 @@ typedef enum MonitorEvent { QEVENT_SPICE_CONNECTED, QEVENT_SPICE_INITIALIZED, QEVENT_SPICE_DISCONNECTED, + QEVENT_PANIC, QEVENT_MAX, } MonitorEvent; diff --git a/sysemu.h b/sysemu.h index 8ab0168..30744b0 100644 --- a/sysemu.h +++ b/sysemu.h @@ -43,11 +43,13 @@ void qemu_system_shutdown_request(void); void qemu_system_powerdown_request(void); void qemu_system_debug_request(void); void qemu_system_vmstop_request(int reason); +void qemu_system_panic_request(void); int qemu_shutdown_requested_get(void); int qemu_reset_requested_get(void); int qemu_shutdown_requested(void); int qemu_reset_requested(void); int qemu_powerdown_requested(void); +int qemu_panic_requested(void); void qemu_system_killed(int signal, pid_t pid); void qemu_kill_report(void); extern qemu_irq qemu_system_powerdown; diff --git a/vl.c b/vl.c index 1d9a068..d997c36 100644 --- a/vl.c +++ b/vl.c @@ -1173,6 +1173,7 @@ static pid_t shutdown_pid; static int powerdown_requested; static int debug_requested; static int vmstop_requested; +static int panic_requested; int qemu_shutdown_requested_get(void) { @@ -1235,6 +1236,13 @@ static int qemu_vmstop_requested(void) return r; } +int qemu_panic_requested(void) +{ + int r = panic_requested; + panic_requested = 0; + return r; +} + void qemu_register_reset(QEMUResetHandler *func, void *opaque) { QEMUResetEntry *re = qemu_mallocz(sizeof(QEMUResetEntry)); @@ -1311,6 +1319,13 @@ void qemu_system_vmstop_request(int reason) qemu_notify_event(); } +void qemu_system_panic_request(void) +{ + panic = 1; + panic_requested = 1; + qemu_notify_event(); +} + void main_loop_wait(int nonblocking) { fd_set rfds, wfds, xfds; @@ -1418,6 +1433,9 @@ static void main_loop(void) if ((r = qemu_vmstop_requested())) { vm_stop(r); } + if (qemu_panic_requested()) { + monitor_protocol_event(QEVENT_PANIC, NULL); + } } bdrv_close_all(); pause_all_vcpus();