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] Re: [PATCH] libxenlight: fix multiple xenstore watches probl

To: Stefano Stabellini <Stefano.Stabellini@xxxxxxxxxxxxx>, xen-devel@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-devel] Re: [PATCH] libxenlight: fix multiple xenstore watches problem
From: Andres Lagar-Cavilla <andres@xxxxxxxxxxxxxxxx>
Date: Wed, 02 Dec 2009 13:08:24 -0500
Cc:
Delivery-date: Wed, 02 Dec 2009 09:55:16 -0800
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
In-reply-to: <20091202173927.DBE2959805E@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx>
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>
References: <20091202173927.DBE2959805E@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.4pre) Gecko/20091014 Fedora/3.0-2.8.b4.fc11 Thunderbird/3.0b4
mmm,
most likely the first two patches in my latest resend clash against this. Yikes
Andres
Message: 3
Date: Wed, 2 Dec 2009 15:01:32 +0000
From: Stefano Stabellini<stefano.stabellini@xxxxxxxxxxxxx>
Subject: [Xen-devel] [PATCH] libxenlight: fix multiple xenstore
        watches problem
To: xen-devel@xxxxxxxxxxxxxxxxxxx
Message-ID:<alpine.DEB.2.00.0912021455450.26846@kaball-desktop>
Content-Type: text/plain; charset="US-ASCII"

Hi all,
this patch fixes the multiple xenstore watches problem in libxenlight
opening a new xenstore connection to set and read temporary watches on
the device state nodes.
This way they don't interfere with other long running watches.

Signed-off-by: Stefano Stabellini<stefano.stabellini@xxxxxxxxxxxxx>

---

diff -r 96a9740f4f33 tools/libxl/libxl_device.c
--- a/tools/libxl/libxl_device.c        Wed Dec 02 14:29:24 2009 +0000
+++ b/tools/libxl/libxl_device.c        Wed Dec 02 14:43:06 2009 +0000
@@ -212,47 +212,50 @@
      fd_set rfds;
      struct timeval tv;
      flexarray_t *toremove;
+    struct libxl_ctx clone = *ctx;

+    clone.xsh = xs_daemon_open();
      toremove = flexarray_make(16, 1);
-    path = libxl_sprintf(ctx, "/local/domain/%d/device", domid);
-    l1 = libxl_xs_directory(ctx, XBT_NULL, path,&num1);
+    path = libxl_sprintf(&clone, "/local/domain/%d/device", domid);
+    l1 = libxl_xs_directory(&clone, XBT_NULL, path,&num1);
      if (!l1) {
-        XL_LOG(ctx, XL_LOG_ERROR, "%s is empty", path);
+        XL_LOG(&clone, XL_LOG_ERROR, "%s is empty", path);
+        xs_daemon_close(clone.xsh);
          return -1;
      }
      for (i = 0; i<  num1; i++) {
-        path = libxl_sprintf(ctx, "/local/domain/%d/device/%s", domid, l1[i]);
-        l2 = libxl_xs_directory(ctx, XBT_NULL, path,&num2);
+        path = libxl_sprintf(&clone, "/local/domain/%d/device/%s", domid, 
l1[i]);
+        l2 = libxl_xs_directory(&clone, XBT_NULL, path,&num2);
          if (!l2)
              continue;
          for (j = 0; j<  num2; j++) {
-            fe_path = libxl_sprintf(ctx, "/local/domain/%d/device/%s/%s", 
domid, l1[i], l2[j]);
-            be_path = libxl_xs_read(ctx, XBT_NULL, libxl_sprintf(ctx, 
"%s/backend", fe_path));
+            fe_path = libxl_sprintf(&clone, "/local/domain/%d/device/%s/%s", 
domid, l1[i], l2[j]);
+            be_path = libxl_xs_read(&clone, XBT_NULL, libxl_sprintf(&clone, 
"%s/backend", fe_path));
              if (be_path != NULL) {
-                if (libxl_device_destroy(ctx, be_path, force)>  0)
+                if (libxl_device_destroy(&clone, be_path, force)>  0)
                      n_watches++;
-                flexarray_set(toremove, n++, libxl_dirname(ctx, be_path));
+                flexarray_set(toremove, n++, libxl_dirname(&clone, be_path));
              } else {
-                xs_rm(ctx->xsh, XBT_NULL, path);
+                xs_rm(clone.xsh, XBT_NULL, path);
              }
          }
      }
      if (!force) {
-        nfds = xs_fileno(ctx->xsh) + 1;
+        nfds = xs_fileno(clone.xsh) + 1;
          /* Linux-ism */
          tv.tv_sec = LIBXL_DESTROY_TIMEOUT;
          tv.tv_usec = 0;
          while (n_watches>  0&&  tv.tv_sec>  0) {
              FD_ZERO(&rfds);
-            FD_SET(xs_fileno(ctx->xsh),&rfds);
+            FD_SET(xs_fileno(clone.xsh),&rfds);
              if (select(nfds,&rfds, NULL, NULL,&tv)>  0) {
-                l1 = xs_read_watch(ctx->xsh,&num1);
+                l1 = xs_read_watch(clone.xsh,&num1);
                  if (l1 != NULL) {
-                    char *state = libxl_xs_read(ctx, XBT_NULL, l1[0]);
+                    char *state = libxl_xs_read(&clone, XBT_NULL, l1[0]);
                      if (!state || atoi(state) == 6) {
-                        xs_unwatch(ctx->xsh, l1[0], l1[1]);
-                        xs_rm(ctx->xsh, XBT_NULL, l1[1]);
-                        XL_LOG(ctx, XL_LOG_DEBUG, "Destroyed device backend at 
%s", l1[1]);
+                        xs_unwatch(clone.xsh, l1[0], l1[1]);
+                        xs_rm(clone.xsh, XBT_NULL, l1[1]);
+                        XL_LOG(&clone, XL_LOG_DEBUG, "Destroyed device backend at 
%s", l1[1]);
                          n_watches--;
                      }
                      free(l1);
@@ -263,9 +266,10 @@
      }
      for (i = 0; i<  n; i++) {
          flexarray_get(toremove, i, (void**)&path);
-        xs_rm(ctx->xsh, XBT_NULL, path);
+        xs_rm(clone.xsh, XBT_NULL, path);
      }
      flexarray_free(toremove);
+    xs_daemon_close(clone.xsh);
      return 0;
  }



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

<Prev in Thread] Current Thread [Next in Thread>