Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1LrccW-00081G-Hj for qemu-devel@nongnu.org; Wed, 08 Apr 2009 14:35:32 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1LrccR-000809-PU for qemu-devel@nongnu.org; Wed, 08 Apr 2009 14:35:32 -0400 Received: from [199.232.76.173] (port=56003 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LrccR-000806-MQ for qemu-devel@nongnu.org; Wed, 08 Apr 2009 14:35:27 -0400 Received: from e34.co.us.ibm.com ([32.97.110.152]:57320) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1LrccR-0004DJ-6v for qemu-devel@nongnu.org; Wed, 08 Apr 2009 14:35:27 -0400 Received: from d03relay02.boulder.ibm.com (d03relay02.boulder.ibm.com [9.17.195.227]) by e34.co.us.ibm.com (8.13.1/8.13.1) with ESMTP id n38IX8SB020030 for ; Wed, 8 Apr 2009 12:33:08 -0600 Received: from d03av04.boulder.ibm.com (d03av04.boulder.ibm.com [9.17.195.170]) by d03relay02.boulder.ibm.com (8.13.8/8.13.8/NCO v9.2) with ESMTP id n38IZA3i060690 for ; Wed, 8 Apr 2009 12:35:12 -0600 Received: from d03av04.boulder.ibm.com (loopback [127.0.0.1]) by d03av04.boulder.ibm.com (8.12.11.20060308/8.13.3) with ESMTP id n38IZ9rY013544 for ; Wed, 8 Apr 2009 12:35:09 -0600 From: Anthony Liguori Date: Wed, 8 Apr 2009 13:35:01 -0500 Message-Id: <1239215702-23818-5-git-send-email-aliguori@us.ibm.com> In-Reply-To: <1239215702-23818-4-git-send-email-aliguori@us.ibm.com> References: <1239215702-23818-1-git-send-email-aliguori@us.ibm.com> <1239215702-23818-2-git-send-email-aliguori@us.ibm.com> <1239215702-23818-3-git-send-email-aliguori@us.ibm.com> <1239215702-23818-4-git-send-email-aliguori@us.ibm.com> Subject: [Qemu-devel] [PATCH 5/6] Implement vm-state notifications (v2) Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: libvir-list@redhat.com, Anthony Liguori , Jan Kiszka , Hollis Blanchard This patch adds notification whenever a vm starts or stops. Signed-off-by: Anthony Liguori 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 }, };