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] libxl: make libxl communicate with xenstored by sock

To: "xen-devel@xxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxx>
Subject: [Xen-devel] [PATCH] libxl: make libxl communicate with xenstored by socket or xenbus driver
From: "Jun Zhu (Intern)" <Jun.Zhu@xxxxxxxxxx>
Date: Thu, 2 Sep 2010 14:56:41 +0100
Accept-language: zh-CN, en-US
Acceptlanguage: zh-CN, en-US
Delivery-date: Thu, 02 Sep 2010 06:57:33 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
Thread-index: AQHLSqarF2CIPnhhX0e7DS5vpJiNlQ==
Thread-topic: [PATCH] libxl: make libxl communicate with xenstored by socket or xenbus driver
Hi,

George sent a patch on this problem before, but it was not completed. 
This patch makes libxl use xenbus to communicate with xenstored if libxl cannot 
open a socket. There's a place that does not close fd in the case of failure, 
which is also fixed in this patch.

-----------------------------------------Patch------------------------------------------------------
diff -r eff592364826 tools/libxl/libxl.c
--- a/tools/libxl/libxl.c       Wed Sep 01 11:23:49 2010 +0100
+++ b/tools/libxl/libxl.c       Thu Sep 02 14:51:46 2010 +0100
@@ -1387,10 +1387,8 @@
 {
     libxl_device_model_starting *starting = for_spawn;
     char *kvs[3];
-    int rc;
     struct xs_handle *xsh;
 
-    xsh = xs_daemon_open();
     /* we mustn't use the parent's handle in the child */
 
     kvs[0] = "image/device-model-pid";
@@ -1398,9 +1396,10 @@
         return;
     kvs[2] = NULL;
 
-    rc = xs_writev(xsh, XBT_NULL, starting->dom_path, kvs);
-    if (rc)
-        return;
+    xsh = xs_daemon_open();
+    if (!xsh)
+        xsh = xs_domain_open();
+    xs_writev(xsh, XBT_NULL, starting->dom_path, kvs);
     xs_daemon_close(xsh);
 }
 
diff -r eff592364826 tools/libxl/libxl_device.c
--- a/tools/libxl/libxl_device.c        Wed Sep 01 11:23:49 2010 +0100
+++ b/tools/libxl/libxl_device.c        Thu Sep 02 14:51:46 2010 +0100
@@ -406,6 +406,8 @@
     char **l = NULL;
 
     xsh = xs_daemon_open();
+    if (!xsh)
+        xsh = xs_domain_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;
diff -r eff592364826 tools/libxl/libxl_dom.c
--- a/tools/libxl/libxl_dom.c   Wed Sep 01 11:23:49 2010 +0100
+++ b/tools/libxl/libxl_dom.c   Thu Sep 02 14:51:46 2010 +0100
@@ -284,6 +284,8 @@
     snprintf(path, sizeof(path), 
"/local/domain/0/device-model/%u/logdirty/cmd", domid);
 
     xsh = xs_daemon_open();
+    if (!xsh)
+        xsh = xs_domain_open();
 
     if (enable)
         xs_write(xsh, XBT_NULL, path, "enable", strlen("enable"));
diff -r eff592364826 tools/libxl/libxl_utils.c
--- a/tools/libxl/libxl_utils.c Wed Sep 01 11:23:49 2010 +0100
+++ b/tools/libxl/libxl_utils.c Thu Sep 02 14:51:46 2010 +0100
@@ -368,6 +368,8 @@
 int libxl_ctx_postfork(libxl_ctx *ctx) {
     if (ctx->xsh) xs_daemon_destroy_postfork(ctx->xsh);
     ctx->xsh = xs_daemon_open();
+    if (!ctx->xsh)
+        ctx->xsh = xs_domain_open();
     if (!ctx->xsh) return ERROR_FAIL;
     return 0;
 }
--------------------------------------END----------------------------------------------


Jun Zhu
Citrix Systems UK
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel