qemu-devel
[Top][All Lists]
Advanced

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

[Qemu-devel] [PATCH 5/6] Implement vm-state notifications (v2)


From: Anthony Liguori
Subject: [Qemu-devel] [PATCH 5/6] Implement vm-state notifications (v2)
Date: Wed, 8 Apr 2009 13:35:01 -0500

This patch adds notification whenever a vm starts or stops.

Signed-off-by: Anthony Liguori <address@hidden>

diff --git a/vl.c b/vl.c
index f78cabb..ca0bcf9 100644
--- a/vl.c
+++ b/vl.c
@@ -164,6 +164,8 @@ int main(int argc, char **argv)
 #include "libslirp.h"
 #endif
 
+#include "wait.h"
+
 //#define DEBUG_UNUSED_IOPORT
 //#define DEBUG_IOPORT
 //#define DEBUG_NET
@@ -3545,6 +3547,11 @@ static void vm_state_notify(int running, int reason)
 {
     VMChangeStateEntry *e;
 
+    if (running)
+        qemu_notify_event("vm-state", "start", "");
+    else
+        qemu_notify_event("vm-state", "stop", "");
+
     for (e = vm_change_state_head.lh_first; e; e = e->entries.le_next) {
         e->cb(e->opaque, running, reason);
     }
diff --git a/wait-events.c b/wait-events.c
index 3617ca6..ecd26d2 100644
--- a/wait-events.c
+++ b/wait-events.c
@@ -31,10 +31,24 @@ typedef struct EventClassDesc
 } EventClassDesc;
 
 static const EventDesc vm_state_events[] = {
+    { "start", "the VM was started",
+      "This event occurs whenever a VM's state changes from stopped to\n"
+      "started.  A vm initially is in a stopped state so a start event will\n"
+      "always occur when the vm is first launched unless the -S option is\n"
+      "provided.",
+      NULL, },
+    { "stop", "the VM was stopped",
+      "This event occurs whenever a VM's state changes from started to 
stopped\n"
+      "A vm initially is in the stopped state but no notification is 
generated\n"
+      "by this.",
+      NULL, },
     { 0 },
 };
 
 static const EventClassDesc vm_event_classes[] = {
+    { "vm-state", "the VM start/stop state has changed",
+      "These events occur whenever a VM's state changes.",
+      vm_state_events, },
     { 0 },
 };
 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]