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

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



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 <stefano.stabellini@xxxxxxxxxxxxx>
> 
> Changes in v5:
> - unify error paths.
> 
> Changes in v4:
> - improve exit paths.
> 
> Signed-off-by: Stefano Stabellini <stefano.stabellini@xxxxxxxxxxxxx>
> ---
>  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)



_______________________________________________
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®.