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 v6 09/11] libxl__device_disk_local_attach: wait for state "connected"
Date: Fri, 18 May 2012 15:08:43 +0100 [thread overview]
Message-ID: <1337350125-30394-9-git-send-email-stefano.stabellini@eu.citrix.com> (raw)
In-Reply-To: <alpine.DEB.2.00.1205141546350.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>
Changes in v5:
- unify error paths.
Changes in v4:
- improve exit paths.
Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
---
tools/libxl/libxl_internal.c | 22 ++++++++++++++++++----
1 files changed, 18 insertions(+), 4 deletions(-)
diff --git a/tools/libxl/libxl_internal.c b/tools/libxl/libxl_internal.c
index d66f7b1..a11c75b 100644
--- a/tools/libxl/libxl_internal.c
+++ b/tools/libxl/libxl_internal.c
@@ -480,9 +480,10 @@ char * libxl__device_disk_local_attach(libxl__gc *gc,
const char *blkdev_start)
{
libxl_ctx *ctx = gc->owner;
- char *dev = NULL;
+ char *dev = NULL, *be_path = NULL;
char *ret = NULL;
int rc, xs_ret;
+ libxl__device device;
xs_transaction_t t = XBT_NULL;
if (in_disk->pdev_path == NULL)
@@ -563,12 +564,25 @@ char * libxl__device_disk_local_attach(libxl__gc *gc,
break;
}
- out:
- if (t != XBT_NULL)
- xs_transaction_end(ctx->xsh, t, 1);
+ if (disk->vdev != NULL) {
+ rc = libxl__device_from_disk(gc, LIBXL_TOOLSTACK_DOMID, disk, &device);
+ if (rc < 0)
+ goto out;
+ be_path = libxl__device_backend_path(gc, &device);
+ rc = libxl__wait_for_backend(gc, be_path, "4");
+ if (rc < 0)
+ goto out;
+ }
if (dev != NULL)
ret = strdup(dev);
return ret;
+
+ out:
+ if (t != XBT_NULL)
+ xs_transaction_end(ctx->xsh, t, 1);
+ else
+ libxl__device_disk_local_detach(gc, disk);
+ return NULL;
}
int libxl__device_disk_local_detach(libxl__gc *gc, libxl_device_disk *disk)
--
1.7.2.5
next prev parent reply other threads:[~2012-05-18 14:08 UTC|newest]
Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-05-18 14:07 [PATCH v6 0/11] qdisk local attach Stefano Stabellini
2012-05-18 14:08 ` [PATCH v6 01/11] libxl: make libxl_device_disk_local_attach/detach internal functions Stefano Stabellini
2012-05-18 14:26 ` Ian Jackson
2012-05-18 14:08 ` [PATCH v6 02/11] libxl: libxl__device_disk_local_attach return a new libxl_device_disk Stefano Stabellini
2012-05-18 14:33 ` Ian Jackson
2012-05-21 16:34 ` Stefano Stabellini
2012-05-18 14:08 ` [PATCH v6 03/11] libxl: add a transaction parameter to libxl__device_generic_add Stefano Stabellini
2012-05-18 14:08 ` [PATCH v6 04/11] libxl: move libxl__device_from_disk to libxl_internal.c Stefano Stabellini
2012-05-18 14:34 ` Ian Jackson
2012-05-18 14:55 ` Roger Pau Monne
2012-05-18 15:02 ` Ian Campbell
2012-05-18 15:16 ` Roger Pau Monne
2012-05-18 15:23 ` Ian Jackson
2012-05-21 16:31 ` Stefano Stabellini
2012-05-18 15:25 ` Ian Campbell
2012-05-21 16:33 ` Stefano Stabellini
2012-05-21 16:34 ` Ian Campbell
2012-05-18 14:08 ` [PATCH v6 05/11] libxl: introduce libxl__device_disk_add Stefano Stabellini
2012-05-18 14:36 ` Ian Jackson
2012-05-18 14:42 ` Ian Campbell
2012-05-18 14:47 ` Ian Jackson
2012-05-21 16:30 ` Stefano Stabellini
2012-05-21 16:48 ` Ian Jackson
2012-05-18 14:56 ` Roger Pau Monne
2012-05-18 14:08 ` [PATCH v6 06/11] xl/libxl: add a blkdev_start parameter Stefano Stabellini
2012-05-18 14:08 ` [PATCH v6 07/11] libxl: introduce libxl__alloc_vdev Stefano Stabellini
2012-05-18 14:40 ` Ian Jackson
2012-05-21 17:50 ` Stefano Stabellini
2012-05-21 18:02 ` Stefano Stabellini
2012-05-22 11:11 ` Ian Jackson
2012-05-18 14:08 ` [PATCH v6 08/11] xl/libxl: implement QDISK libxl_device_disk_local_attach Stefano Stabellini
2012-05-18 14:42 ` Ian Jackson
2012-05-18 14:08 ` Stefano Stabellini [this message]
2012-05-18 14:44 ` [PATCH v6 09/11] libxl__device_disk_local_attach: wait for state "connected" Ian Jackson
2012-05-18 14:08 ` [PATCH v6 10/11] libxl_string_to_backend: add qdisk Stefano Stabellini
2012-05-18 14:44 ` Ian Jackson
2012-05-18 14:08 ` [PATCH v6 11/11] main_blockdetach: destroy the disk on successful removal Stefano Stabellini
2012-05-18 14:44 ` Ian Jackson
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=1337350125-30394-9-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).