WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

[Xen-devel] [PATCH 07/15] xen: handle xenstore events

From: Anthony PERARD <anthony.perard@xxxxxxxxxx>

Add an handler to process xenstore events.

Signed-off-by: Anthony PERARD <anthony.perard@xxxxxxxxxx>
Signed-off-by: Stefano Stabellini <stefano.stabellini@xxxxxxxxxxxxx>
---
 target-xen/xenstore.c |   30 +++++++++++++++++++++++++++++-
 1 files changed, 29 insertions(+), 1 deletions(-)

diff --git a/target-xen/xenstore.c b/target-xen/xenstore.c
index bd74787..331b25f 100644
--- a/target-xen/xenstore.c
+++ b/target-xen/xenstore.c
@@ -1,13 +1,41 @@
 #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();
+    if (!xenstore) {
+        xen_be_printf(NULL, 0, "can't connect to xenstored\n");
+        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");
-        return -1;
+        goto err;
     }
 
     return 0;
+
+err:
+    qemu_set_fd_handler(xs_fileno(xenstore), NULL, NULL, NULL);
+    xs_daemon_close(xenstore);
+    xenstore = NULL;
+
+    return -1;
 }
-- 
1.7.0.4


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel