diff mbox

[07/15] xen: handle xenstore events

Message ID 1281622202-3453-7-git-send-email-stefano.stabellini@eu.citrix.com
State New
Headers show

Commit Message

Stefano Stabellini Aug. 12, 2010, 2:09 p.m. UTC
From: Anthony PERARD <anthony.perard@citrix.com>

Add an handler to process xenstore events.

Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>
Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
---
 target-xen/xenstore.c |   16 ++++++++++++++++
 1 files changed, 16 insertions(+), 0 deletions(-)
diff mbox

Patch

diff --git a/target-xen/xenstore.c b/target-xen/xenstore.c
index c202f66..9f2e1ea 100644
--- a/target-xen/xenstore.c
+++ b/target-xen/xenstore.c
@@ -1,6 +1,18 @@ 
 #include "hw/xen_backend.h"
 #include "xenstore.h"
 
+static void xenstore_process_event(void *opaque)
+{
+    char **vec;
+    unsigned int num;
+
+    vec = xs_read_watch(xenstore, &num);
+    if (!vec)
+        return;
+
+    free(vec);
+}
+
 int xen_dm_init(void)
 {
     xenstore = xs_daemon_open();
@@ -9,6 +21,9 @@  int xen_dm_init(void)
         return -1;
     }
 
+    if (qemu_set_fd_handler(xs_fileno(xenstore), xenstore_process_event, NULL, NULL) < 0)
+        goto err;
+
     xen_xc = xc_interface_open(NULL, NULL, 0);
     if (xen_xc == NULL) {
         xen_be_printf(NULL, 0, "can't open xen interface\n");
@@ -17,6 +32,7 @@  int xen_dm_init(void)
     return 0;
 
 err:
+    qemu_set_fd_handler(xs_fileno(xenstore), NULL, NULL, NULL);
     xs_daemon_close(xenstore);
     xenstore = NULL;