All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] libxl: Use xenbus to communicate with xenstore if the socket fails
@ 2010-12-08 20:47 Mihir Nanavati
  2010-12-09  9:17 ` Ian Campbell
  0 siblings, 1 reply; 23+ messages in thread
From: Mihir Nanavati @ 2010-12-08 20:47 UTC (permalink / raw)
  To: xen-devel


[-- Attachment #1.1: Type: text/plain, Size: 198 bytes --]

Adds an open xenstore connection function which tries to use the xenbus
interface (xs_domain_open) when the socket interface (xs_daemon_opn) fails.

Signed-off-by: Mihir Nanavati <mihirn@cs.ubc.ca>

[-- Attachment #1.2: Type: text/html, Size: 773 bytes --]

[-- Attachment #2: libxl_domain.patch --]
[-- Type: text/x-patch, Size: 2948 bytes --]

diff -r f5d6afa46dd7 tools/libxl/libxl.c
--- a/tools/libxl/libxl.c	Tue Dec 07 18:10:46 2010 +0000
+++ b/tools/libxl/libxl.c	Wed Dec 08 12:32:04 2010 -0800
@@ -1418,11 +1418,11 @@
         goto out;
 
     /* we mustn't use the parent's handle in the child */
-    xsh = xs_daemon_open();
+    xsh = libxl__xs_open();
 
     xs_write(xsh, XBT_NULL, path, pid, len);
 
-    xs_daemon_close(xsh);
+    libxl__xs_close(xsh);
 out:
     free(path);
     free(pid);
diff -r f5d6afa46dd7 tools/libxl/libxl_device.c
--- a/tools/libxl/libxl_device.c	Tue Dec 07 18:10:46 2010 +0000
+++ b/tools/libxl/libxl_device.c	Wed Dec 08 12:32:04 2010 -0800
@@ -428,7 +428,7 @@
     unsigned int num;
     char **l = NULL;
 
-    xsh = xs_daemon_open();
+    xsh = libxl__xs_open(); 
     path = libxl__sprintf(&gc, "/local/domain/0/device-model/%d/state", domid);
     xs_watch(xsh, path, path);
     tv.tv_sec = LIBXL_DEVICE_MODEL_START_TIMEOUT;
@@ -450,7 +450,7 @@
 
         free(p);
         xs_unwatch(xsh, path, path);
-        xs_daemon_close(xsh);
+        libxl__xs_close(xsh);
         libxl__free_all(&gc);
         return rc;
 again:
@@ -467,7 +467,7 @@
         }
     }
     xs_unwatch(xsh, path, path);
-    xs_daemon_close(xsh);
+    libxl__xs_close(xsh);
     LIBXL__LOG(ctx, LIBXL__LOG_ERROR, "Device Model not ready");
     libxl__free_all(&gc);
     return -1;
diff -r f5d6afa46dd7 tools/libxl/libxl_internal.h
--- a/tools/libxl/libxl_internal.h	Tue Dec 07 18:10:46 2010 +0000
+++ b/tools/libxl/libxl_internal.h	Wed Dec 08 12:32:04 2010 -0800
@@ -140,6 +140,8 @@
 _hidden char *libxl__xs_get_dompath(libxl__gc *gc, uint32_t domid); // logs errs
 _hidden char *libxl__xs_read(libxl__gc *gc, xs_transaction_t t, char *path);
 _hidden char **libxl__xs_directory(libxl__gc *gc, xs_transaction_t t, char *path, unsigned int *nb);
+_hidden struct xs_handle *libxl__xs_open(void);
+_hidden void libxl__xs_close(struct xs_handle *xsh);
 
 /* from xl_dom */
 _hidden int libxl__domain_is_hvm(libxl_ctx *ctx, uint32_t domid);
diff -r f5d6afa46dd7 tools/libxl/libxl_utils.c
--- a/tools/libxl/libxl_utils.c	Tue Dec 07 18:10:46 2010 +0000
+++ b/tools/libxl/libxl_utils.c	Wed Dec 08 12:32:04 2010 -0800
@@ -399,7 +399,7 @@
 
 int libxl_ctx_postfork(libxl_ctx *ctx) {
     if (ctx->xsh) xs_daemon_destroy_postfork(ctx->xsh);
-    ctx->xsh = xs_daemon_open();
+    ctx->xsh = libxl__xs_open();
     if (!ctx->xsh) return ERROR_FAIL;
     return 0;
 }
diff -r f5d6afa46dd7 tools/libxl/libxl_xshelp.c
--- a/tools/libxl/libxl_xshelp.c	Tue Dec 07 18:10:46 2010 +0000
+++ b/tools/libxl/libxl_xshelp.c	Wed Dec 08 12:32:04 2010 -0800
@@ -121,3 +121,19 @@
     libxl__ptr_add(gc, ret);
     return ret;
 }
+
+struct xs_handle *libxl__xs_open(void)
+{
+    struct xs_handle* xsh = NULL;
+    
+    xsh = xs_daemon_open();
+    if ( !xsh )
+        xsh = xs_domain_open();
+
+    return xsh;
+}
+
+void libxl__xs_close(struct xs_handle *xsh)
+{
+    xs_daemon_close(xsh);
+}

[-- Attachment #3: Type: text/plain, Size: 138 bytes --]

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

^ permalink raw reply	[flat|nested] 23+ messages in thread

end of thread, other threads:[~2010-12-13 17:19 UTC | newest]

Thread overview: 23+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-12-08 20:47 [PATCH] libxl: Use xenbus to communicate with xenstore if the socket fails Mihir Nanavati
2010-12-09  9:17 ` Ian Campbell
2010-12-09  9:59   ` Mihir Nanavati
2010-12-09 10:37     ` Ian Campbell
2010-12-09 10:06   ` Vincent Hanquez
2010-12-09 10:21     ` Ian Campbell
2010-12-09 10:53       ` Vincent Hanquez
2010-12-09 11:39         ` Ian Campbell
2010-12-10  6:52           ` Mihir Nanavati
2010-12-10  9:07             ` Ian Campbell
2010-12-10  9:38               ` Mihir Nanavati
2010-12-10  9:48                 ` Ian Campbell
2010-12-10  9:55                   ` Mihir Nanavati
2010-12-10 10:03                     ` Ian Campbell
2010-12-10 10:34                       ` Mihir Nanavati
2010-12-10 10:45                         ` Ian Campbell
2010-12-10 11:10                           ` Mihir Nanavati
2010-12-10 11:24                             ` Ian Campbell
2010-12-10 11:39                               ` Mihir Nanavati
2010-12-10 11:52                                 ` Ian Campbell
2010-12-10 17:49                                   ` Ian Jackson
2010-12-13 17:19                                     ` [PATCH] libxl: Use xenbus to communicate with xenstore if the socket failsx Stefano Stabellini
2010-12-10 17:28           ` [PATCH] libxl: Use xenbus to communicate with xenstore if the socket fails Ian Jackson

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.