[PATCH 2/2] QMP: Introduce QEVENT_PANIC

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Emitted when the guest panics.
For now only if KVM_EXIT_PANIC got triggered.

Signed-off-by: Daniel Gollub <gollub@xxxxxxxxxxxxx>
---
 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();
-- 
1.7.1

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux