[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] [PATCH 07 of 13 RFC] libxl: remove force parameter from libxl__device_remove



# HG changeset patch
# User Roger Pau Monne <roger.pau@xxxxxxxxxxxxx>
# Date 1326728426 -3600
# Node ID 2a28a1126ab2fd6ab6b5c959daabdc6b3afd1fc6
# Parent  f7b6d7cd98202be1ca642949c4722c5e6da75540
libxl: remove force parameter from libxl__device_remove

All callers where using the wait parameter from
libxl__device_remove, so it's safe to simplify the logic of the
function and assume that the callers always want libxl__device_remove
to wait for the unplug of the device.

Signed-off-by: Roger Pau Monne <roger.pau@xxxxxxxxxxxxx>

diff -r f7b6d7cd9820 -r 2a28a1126ab2 tools/libxl/libxl.c
--- a/tools/libxl/libxl.c       Mon Jan 16 16:39:49 2012 +0100
+++ b/tools/libxl/libxl.c       Mon Jan 16 16:40:26 2012 +0100
@@ -1160,7 +1160,7 @@ int libxl_device_disk_remove(libxl_ctx *
     rc = libxl__device_from_disk(gc, domid, disk, &device);
     if (rc != 0) goto out;
 
-    rc = libxl__device_remove(gc, &device, 1);
+    rc = libxl__device_remove(gc, &device);
 out:
     GC_FREE;
     return rc;
@@ -1628,7 +1628,7 @@ int libxl_device_nic_remove(libxl_ctx *c
     rc = libxl__device_from_nic(gc, domid, nic, &device);
     if (rc != 0) goto out;
 
-    rc = libxl__device_remove(gc, &device, 1);
+    rc = libxl__device_remove(gc, &device);
 out:
     GC_FREE;
     return rc;
@@ -1968,7 +1968,7 @@ int libxl_device_vkb_remove(libxl_ctx *c
     rc = libxl__device_from_vkb(gc, domid, vkb, &device);
     if (rc != 0) goto out;
 
-    rc = libxl__device_remove(gc, &device, 1);
+    rc = libxl__device_remove(gc, &device);
 out:
     GC_FREE;
     return rc;
@@ -2085,7 +2085,7 @@ int libxl_device_vfb_remove(libxl_ctx *c
     rc = libxl__device_from_vfb(gc, domid, vfb, &device);
     if (rc != 0) goto out;
 
-    rc = libxl__device_remove(gc, &device, 1);
+    rc = libxl__device_remove(gc, &device);
 out:
     GC_FREE;
     return rc;
diff -r f7b6d7cd9820 -r 2a28a1126ab2 tools/libxl/libxl_device.c
--- a/tools/libxl/libxl_device.c        Mon Jan 16 16:39:49 2012 +0100
+++ b/tools/libxl/libxl_device.c        Mon Jan 16 16:40:26 2012 +0100
@@ -469,13 +469,14 @@ out:
  * Returns 0 (device already destroyed) or 1 (caller must
  * wait_for_dev_destroy) on success, ERROR_* on fail.
  */
-int libxl__device_remove(libxl__gc *gc, libxl__device *dev, int wait)
+int libxl__device_remove(libxl__gc *gc, libxl__device *dev)
 {
     libxl_ctx *ctx = libxl__gc_owner(gc);
     xs_transaction_t t;
     char *be_path = libxl__device_backend_path(gc, dev);
     char *state_path = libxl__sprintf(gc, "%s/state", be_path);
     char *state;
+    struct timeval tv;
     int rc = 0;
 
 retry_transaction:
@@ -506,18 +507,13 @@ retry_transaction:
     xs_watch(ctx->xsh, state_path, be_path);
     libxl__device_destroy_tapdisk(gc, be_path);
 
-    if (wait) {
-        struct timeval tv;
-        tv.tv_sec = LIBXL_DESTROY_TIMEOUT;
-        tv.tv_usec = 0;
-        rc = libxl__wait_for_device_state(gc, &tv, XenbusStateClosed,
-                                          destroy_device);
-        if (rc < 0) /* an error or timeout occurred, clear watches */
-            xs_unwatch(ctx->xsh, state_path, be_path);
-        xs_rm(ctx->xsh, XBT_NULL, libxl__device_frontend_path(gc, dev));
-    } else {
-        rc = 1; /* Caller must wait_for_dev_destroy */
-    }
+    tv.tv_sec = LIBXL_DESTROY_TIMEOUT;
+    tv.tv_usec = 0;
+    rc = libxl__wait_for_device_state(gc, &tv, XenbusStateClosed,
+                                      destroy_device);
+    if (rc < 0) /* an error or timeout occurred, clear watches */
+        xs_unwatch(ctx->xsh, state_path, be_path);
+    xs_rm(ctx->xsh, XBT_NULL, libxl__device_frontend_path(gc, dev));
 
 out:
     return rc;
diff -r f7b6d7cd9820 -r 2a28a1126ab2 tools/libxl/libxl_internal.h
--- a/tools/libxl/libxl_internal.h      Mon Jan 16 16:39:49 2012 +0100
+++ b/tools/libxl/libxl_internal.h      Mon Jan 16 16:40:26 2012 +0100
@@ -275,7 +275,7 @@ _hidden char *libxl__device_backend_path
 _hidden char *libxl__device_frontend_path(libxl__gc *gc, libxl__device 
*device);
 _hidden int libxl__parse_backend_path(libxl__gc *gc, const char *path,
                                       libxl__device *dev);
-_hidden int libxl__device_remove(libxl__gc *gc, libxl__device *dev, int wait);
+_hidden int libxl__device_remove(libxl__gc *gc, libxl__device *dev);
 _hidden int libxl__device_destroy(libxl__gc *gc, libxl__device *dev);
 _hidden int libxl__devices_destroy(libxl__gc *gc, uint32_t domid);
 _hidden int libxl__wait_for_backend(libxl__gc *gc, char *be_path, char *state);

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


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.