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

[Xen-devel] [PATCH 08 of 29 RFC] libxl: remove force parameter from libxl__device_remove



# HG changeset patch
# User Roger Pau Monne <roger.pau@xxxxxxxxxxxxx>
# Date 1328176666 -3600
# Node ID 1efb9ee82433896e5a68f9a510f1f5542f071bd3
# Parent  7b7a3fb7c90a2a08da7348075ba4589d4f2cc19b
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 7b7a3fb7c90a -r 1efb9ee82433 tools/libxl/libxl.c
--- a/tools/libxl/libxl.c       Thu Feb 02 10:54:45 2012 +0100
+++ b/tools/libxl/libxl.c       Thu Feb 02 10:57:46 2012 +0100
@@ -1149,7 +1149,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;
@@ -1617,7 +1617,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;
@@ -1957,7 +1957,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;
@@ -2074,7 +2074,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 7b7a3fb7c90a -r 1efb9ee82433 tools/libxl/libxl_device.c
--- a/tools/libxl/libxl_device.c        Thu Feb 02 10:54:45 2012 +0100
+++ b/tools/libxl/libxl_device.c        Thu Feb 02 10:57:46 2012 +0100
@@ -461,13 +461,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:
@@ -498,18 +499,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 7b7a3fb7c90a -r 1efb9ee82433 tools/libxl/libxl_internal.h
--- a/tools/libxl/libxl_internal.h      Thu Feb 02 10:54:45 2012 +0100
+++ b/tools/libxl/libxl_internal.h      Thu Feb 02 10:57:46 2012 +0100
@@ -303,7 +303,7 @@ typedef struct {
 _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®.