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

[Xen-devel] [PATCH v4 8/8] libxl__device_disk_local_attach: wait for state "connected"



In order to make sure that the block device is available and ready to be
used, wait for state "connected" in the backend before returning.

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

Changes in v4:
- improve exit paths.

Signed-off-by: Stefano Stabellini <stefano.stabellini@xxxxxxxxxxxxx>
---
 tools/libxl/libxl_internal.c |   16 +++++++++++++++-
 1 files changed, 15 insertions(+), 1 deletions(-)

diff --git a/tools/libxl/libxl_internal.c b/tools/libxl/libxl_internal.c
index bb75491..98a67d6 100644
--- a/tools/libxl/libxl_internal.c
+++ b/tools/libxl/libxl_internal.c
@@ -508,8 +508,9 @@ _hidden char * libxl__device_disk_local_attach(libxl__gc 
*gc,
         char *blkdev_start)
 {
     libxl_ctx *ctx = gc->owner;
-    char *dev = NULL;
+    char *dev = NULL, *be_path = NULL;
     int rc;
+    libxl__device device;
     xs_transaction_t t = XBT_NULL;
     libxl_device_disk *tmpdisk = libxl__zalloc(gc, sizeof(libxl_device_disk));
     if (tmpdisk == NULL) goto out;
@@ -596,10 +597,23 @@ _hidden char * libxl__device_disk_local_attach(libxl__gc 
*gc,
             break;
     }
 
+    if (tmpdisk->vdev != NULL) {
+        rc = libxl__device_from_disk(gc, 0, tmpdisk, &device);
+        if (rc < 0)
+            goto out_wait_err;
+        be_path = libxl__device_backend_path(gc, &device);
+        rc = libxl__wait_for_backend(gc, be_path, "4");
+        if (rc < 0)
+            goto out_wait_err;
+    }
+
  out:
     if (t != XBT_NULL)
         xs_transaction_end(ctx->xsh, t, 1);
     return dev;
+ out_wait_err:
+    libxl__device_disk_local_detach(gc, tmpdisk);
+    return NULL;
 }
 
 _hidden int libxl__device_disk_local_detach(libxl__gc *gc, libxl_device_disk 
*disk)
-- 
1.7.2.5


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel


 


Rackspace

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