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-changelog

[Xen-changelog] [xen-unstable] libxl: split forced and non-forced uses o

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] [xen-unstable] libxl: split forced and non-forced uses of libxl__device_del
From: Xen patchbot-unstable <patchbot@xxxxxxx>
Date: Tue, 01 Nov 2011 23:55:15 +0000
Delivery-date: Tue, 01 Nov 2011 16:56:55 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-changelog-request@lists.xensource.com?subject=help>
List-id: BK change log <xen-changelog.lists.xensource.com>
List-post: <mailto:xen-changelog@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
Reply-to: xen-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User Ian Campbell <ian.campbell@xxxxxxxxxx>
# Date 1318941402 -3600
# Node ID 781c6672a25394a57b4c1eeaae40de9d05e5b9b6
# Parent  18505ddad997630e6696089c6fc6fe2b0e35014a
libxl: split forced and non-forced uses of libxl__device_del

Most forced users can now simply call libxl__device_destroy directly.

libxl__devices_destroy is something of a special case, it is really
just iterating over an opaque set of xenstore directories and removing
them. Until this can be refactored just do the force-remove case
manually, doing otherwise led to too much entanglement with the other
callers of libxl__device_destroy which do know about specific device
types.

For the time being do the same in libxl__device_pci_remove_xenstore.

Signed-off-by: Ian Campbell <ian.campbell@xxxxxxxxxx>
Acked-by: Ian Jackson <ian.jackson.citrix.com>
Committed-by: Ian Jackson <ian.jackson.citrix.com>
---


diff -r 18505ddad997 -r 781c6672a253 tools/libxl/libxl.c
--- a/tools/libxl/libxl.c       Tue Oct 18 13:36:42 2011 +0100
+++ b/tools/libxl/libxl.c       Tue Oct 18 13:36:42 2011 +0100
@@ -1074,7 +1074,10 @@
     device.domid            = domid;
     device.devid            = devid;
     device.kind             = DEVICE_VBD;
-    rc = libxl__device_del(&gc, &device, wait);
+    if (wait)
+        rc = libxl__device_del(&gc, &device);
+    else
+        rc = libxl__device_destroy(&gc, &device);
 out_free:
     libxl__free_all(&gc);
     return rc;
@@ -1286,7 +1289,11 @@
     device.domid            = domid;
     device.kind             = DEVICE_VIF;
 
-    rc = libxl__device_del(&gc, &device, wait);
+    if (wait)
+        rc = libxl__device_del(&gc, &device);
+    else
+        rc = libxl__device_destroy(&gc, &device);
+
     libxl__free_all(&gc);
     return rc;
 }
diff -r 18505ddad997 -r 781c6672a253 tools/libxl/libxl_device.c
--- a/tools/libxl/libxl_device.c        Tue Oct 18 13:36:42 2011 +0100
+++ b/tools/libxl/libxl_device.c        Tue Oct 18 13:36:42 2011 +0100
@@ -401,11 +401,17 @@
     return rc;
 }
 
-int libxl__device_destroy(libxl__gc *gc, char *be_path)
+int libxl__device_destroy(libxl__gc *gc, libxl__device *dev)
 {
     libxl_ctx *ctx = libxl__gc_owner(gc);
+    char *be_path = libxl__device_backend_path(gc, dev);
+    char *fe_path = libxl__device_frontend_path(gc, dev);
+
     xs_rm(ctx->xsh, XBT_NULL, be_path);
+    xs_rm(ctx->xsh, XBT_NULL, fe_path);
+
     libxl__device_destroy_tapdisk(gc, be_path);
+
     return 0;
 }
 
@@ -466,10 +472,14 @@
             fe_path = libxl__sprintf(gc, "/local/domain/%d/device/%s/%s", 
domid, l1[i], l2[j]);
             be_path = libxl__xs_read(gc, XBT_NULL, libxl__sprintf(gc, 
"%s/backend", fe_path));
             if (be_path != NULL) {
-                int rc = force ? libxl__device_destroy(gc, be_path)
-                               : libxl__device_remove(gc, be_path);
-                if (rc > 0)
-                    n_watches++;
+                if (force) {
+                    xs_rm(ctx->xsh, XBT_NULL, be_path);
+                    xs_rm(ctx->xsh, XBT_NULL, fe_path);
+                    libxl__device_destroy_tapdisk(gc, be_path);
+                } else {
+                    if (libxl__device_remove(gc, be_path) > 0)
+                        n_watches++;
+                }
             } else {
                 xs_rm(ctx->xsh, XBT_NULL, path);
             }
@@ -480,10 +490,13 @@
     fe_path = libxl__sprintf(gc, "/local/domain/%d/console", domid);
     be_path = libxl__xs_read(gc, XBT_NULL, libxl__sprintf(gc, "%s/backend", 
fe_path));
     if (be_path && strcmp(be_path, "")) {
-        int rc = force ? libxl__device_destroy(gc, be_path)
-                       : libxl__device_remove(gc, be_path);
-        if (rc > 0)
-            n_watches++;
+        if (force) {
+            xs_rm(ctx->xsh, XBT_NULL, be_path);
+            xs_rm(ctx->xsh, XBT_NULL, fe_path);
+        } else {
+            if (libxl__device_remove(gc, be_path) > 0)
+                n_watches++;
+        }
     }
 
     if (!force) {
@@ -507,29 +520,24 @@
     return 0;
 }
 
-int libxl__device_del(libxl__gc *gc, libxl__device *dev, int wait)
+int libxl__device_del(libxl__gc *gc, libxl__device *dev)
 {
     libxl_ctx *ctx = libxl__gc_owner(gc);
+    struct timeval tv;
     char *backend_path;
     int rc;
 
     backend_path = libxl__device_backend_path(gc, dev);
 
-    if (wait)
-        rc = libxl__device_remove(gc, backend_path);
-    else
-        rc = libxl__device_destroy(gc, backend_path);
+    rc = libxl__device_remove(gc, backend_path);
     if (rc == -1) {
         rc = ERROR_FAIL;
         goto out;
     }
 
-    if (wait) {
-        struct timeval tv;
-        tv.tv_sec = LIBXL_DESTROY_TIMEOUT;
-        tv.tv_usec = 0;
-        (void)wait_for_dev_destroy(gc, &tv);
-    }
+    tv.tv_sec = LIBXL_DESTROY_TIMEOUT;
+    tv.tv_usec = 0;
+    (void)wait_for_dev_destroy(gc, &tv);
 
     xs_rm(ctx->xsh, XBT_NULL, libxl__device_frontend_path(gc, dev));
     rc = 0;
diff -r 18505ddad997 -r 781c6672a253 tools/libxl/libxl_internal.h
--- a/tools/libxl/libxl_internal.h      Tue Oct 18 13:36:42 2011 +0100
+++ b/tools/libxl/libxl_internal.h      Tue Oct 18 13:36:42 2011 +0100
@@ -252,9 +252,9 @@
                              char **bents, char **fents);
 _hidden char *libxl__device_backend_path(libxl__gc *gc, libxl__device *device);
 _hidden char *libxl__device_frontend_path(libxl__gc *gc, libxl__device 
*device);
-_hidden int libxl__device_del(libxl__gc *gc, libxl__device *dev, int wait);
+_hidden int libxl__device_del(libxl__gc *gc, libxl__device *dev);
 _hidden int libxl__device_remove(libxl__gc *gc, char *be_path);
-_hidden int libxl__device_destroy(libxl__gc *gc, char *be_path);
+_hidden int libxl__device_destroy(libxl__gc *gc, libxl__device *dev);
 _hidden int libxl__devices_destroy(libxl__gc *gc, uint32_t domid, int force);
 _hidden int libxl__wait_for_backend(libxl__gc *gc, char *be_path, char *state);
 
diff -r 18505ddad997 -r 781c6672a253 tools/libxl/libxl_pci.c
--- a/tools/libxl/libxl_pci.c   Tue Oct 18 13:36:42 2011 +0100
+++ b/tools/libxl/libxl_pci.c   Tue Oct 18 13:36:42 2011 +0100
@@ -411,7 +411,7 @@
 
     if (num == 1) {
         char *fe_path = libxl__xs_read(gc, XBT_NULL, libxl__sprintf(gc, 
"%s/frontend", be_path));
-        libxl__device_destroy(gc, be_path);
+        xs_rm(ctx->xsh, XBT_NULL, be_path);
         xs_rm(ctx->xsh, XBT_NULL, fe_path);
         return 0;
     }

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

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] [xen-unstable] libxl: split forced and non-forced uses of libxl__device_del, Xen patchbot-unstable <=