xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
To: xen-devel@lists.xensource.com
Cc: Ian.Jackson@eu.citrix.com, Ian.Campbell@citrix.com,
	Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Subject: [PATCH v3 7/7] libxl__device_disk_local_attach: wait for state "connected"
Date: Mon, 16 Apr 2012 19:33:10 +0100	[thread overview]
Message-ID: <1334601190-14187-7-git-send-email-stefano.stabellini@eu.citrix.com> (raw)
In-Reply-To: <alpine.DEB.2.00.1204161848030.26786@kaball-desktop>

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@eu.citrix.com>
---
 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 ba7b395..c955bf4 100644
--- a/tools/libxl/libxl_internal.c
+++ b/tools/libxl/libxl_internal.c
@@ -504,8 +504,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;
     libxl_device_disk *tmpdisk = libxl__zalloc(gc, sizeof(libxl_device_disk));
     if (tmpdisk == NULL) goto out;
 
@@ -581,6 +582,19 @@ _hidden char * libxl__device_disk_local_attach(libxl__gc *gc,
                 "type: %d", tmpdisk->backend);
             break;
     }
+    if (tmpdisk->vdev != NULL) {
+        rc = libxl__device_from_disk(gc, 0, tmpdisk, &device);
+        if (rc < 0) {
+            libxl__device_disk_local_detach(gc, tmpdisk);
+            return NULL;
+        }
+        be_path = libxl__device_backend_path(gc, &device);
+        rc = libxl__wait_for_backend(gc, be_path, "4");
+        if (rc < 0) {
+            libxl__device_disk_local_detach(gc, tmpdisk);
+            return NULL;
+        }
+    }
 
  out:
     return dev;
-- 
1.7.2.5

  parent reply	other threads:[~2012-04-16 18:33 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-04-16 18:32 [PATCH v3 0/7] qdisk local attach Stefano Stabellini
2012-04-16 18:33 ` [PATCH v3 1/7] libxl: libxl__device_disk_local_attach return a new libxl_device_disk Stefano Stabellini
2012-04-17 17:25   ` Ian Jackson
2012-04-18  8:34     ` Ian Campbell
2012-04-20 13:58     ` Stefano Stabellini
2012-04-16 18:33 ` [PATCH v3 2/7] libxl: add a transaction parameter to libxl__device_generic_add Stefano Stabellini
2012-04-17 17:27   ` Ian Jackson
2012-04-18  8:41   ` Ian Campbell
2012-04-20 15:13     ` Stefano Stabellini
2012-04-16 18:33 ` [PATCH v3 3/7] libxl: introduce libxl__device_disk_add_t Stefano Stabellini
2012-04-17 17:37   ` Ian Jackson
2012-04-20 14:00     ` Stefano Stabellini
2012-04-16 18:33 ` [PATCH v3 4/7] xl/libxl: add a blkdev_start parameter Stefano Stabellini
2012-04-17 17:47   ` Ian Jackson
2012-04-20 14:04     ` Stefano Stabellini
2012-04-20 14:08       ` Ian Campbell
2012-04-23 17:40         ` Stefano Stabellini
2012-04-24  9:20           ` Ian Campbell
2012-04-20 14:22       ` Ian Jackson
2012-04-16 18:33 ` [PATCH v3 5/7] libxl: introduce libxl__alloc_vdev Stefano Stabellini
2012-04-17 17:53   ` Ian Jackson
2012-04-20 14:14     ` Stefano Stabellini
2012-04-20 14:28       ` Ian Jackson
2012-04-23 17:40         ` Stefano Stabellini
2012-04-16 18:33 ` [PATCH v3 6/7] xl/libxl: implement QDISK libxl_device_disk_local_attach Stefano Stabellini
2012-04-17 17:58   ` Ian Jackson
2012-04-20 14:24     ` Stefano Stabellini
2012-04-20 14:37       ` Ian Jackson
2012-04-23 17:40         ` Stefano Stabellini
2012-04-16 18:33 ` Stefano Stabellini [this message]
2012-04-17 18:01   ` [PATCH v3 7/7] libxl__device_disk_local_attach: wait for state "connected" Ian Jackson
2012-04-20 14:35     ` Stefano Stabellini

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1334601190-14187-7-git-send-email-stefano.stabellini@eu.citrix.com \
    --to=stefano.stabellini@eu.citrix.com \
    --cc=Ian.Campbell@citrix.com \
    --cc=Ian.Jackson@eu.citrix.com \
    --cc=xen-devel@lists.xensource.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).