From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ian Campbell Subject: Re: [PATCH v5 8/8] libxl__device_disk_local_attach: wait for state "connected" Date: Fri, 4 May 2012 16:13:56 +0100 Message-ID: <1336144436.7535.22.camel@zakaz.uk.xensource.com> References: <1336130000-27261-8-git-send-email-stefano.stabellini@eu.citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1336130000-27261-8-git-send-email-stefano.stabellini@eu.citrix.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Stefano Stabellini Cc: "xen-devel@lists.xensource.com" , Ian Jackson List-Id: xen-devel@lists.xenproject.org On Fri, 2012-05-04 at 12:13 +0100, Stefano Stabellini wrote: > 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 > > Changes in v5: > - unify error paths. > > Changes in v4: > - improve exit paths. > > Signed-off-by: Stefano Stabellini > --- > tools/libxl/libxl_internal.c | 20 +++++++++++++++++--- > 1 files changed, 17 insertions(+), 3 deletions(-) > > diff --git a/tools/libxl/libxl_internal.c b/tools/libxl/libxl_internal.c > index e180498..05faff5 100644 > --- a/tools/libxl/libxl_internal.c > +++ b/tools/libxl/libxl_internal.c > @@ -517,8 +517,9 @@ 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; > int rc; > + libxl__device device; > xs_transaction_t t = XBT_NULL; > libxl_device_disk *disk = libxl__zalloc(gc, sizeof(libxl_device_disk)); > > @@ -598,11 +599,24 @@ char * libxl__device_disk_local_attach(libxl__gc *gc, > break; > } > > + 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; > + } > + > + *new_disk = disk; > + return dev; > out: > if (t != XBT_NULL) > xs_transaction_end(ctx->xsh, t, 1); There's no way to reach the preceding "return dev" with the transaction still open? Previously we would have fallen through and done it. > - *new_disk = disk; > - return dev; > + else > + libxl__device_disk_local_detach(gc, disk); > + return NULL; > } > > int libxl__device_disk_local_detach(libxl__gc *gc, libxl_device_disk *disk)