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

Re: [Xen-devel] [PATCH 03 of 10] libxl: Accept disk name in libxl_devid_to_device_disk



On Thu, 2011-06-02 at 23:35 +0100, Marek Marczykowski wrote:
> # HG changeset patch
> # User Marek Marczykowski <marmarek@xxxxxxxxxxxx>
> # Date 1306962929 -7200
> # Node ID 81df382694fd6e208255197d8da19bfe435a2cbd
> # Parent  59cff6b471f3f0c1e91349ed6653a47a40d4fd55
> libxl: Accept disk name in libxl_devid_to_device_disk
> 
> Accept disk name in xl block-detach.
> 
> Signed-off-by: Marek Marczykowski <marmarek@xxxxxxxxxxxx>
> 
> diff --git a/tools/libxl/libxl_utils.c b/tools/libxl/libxl_utils.c
> --- a/tools/libxl/libxl_utils.c
> +++ b/tools/libxl/libxl_utils.c
> @@ -529,18 +529,18 @@
>                                 const char *devid, libxl_device_disk *disk)
>  {
>      libxl__gc gc = LIBXL_INIT_GC(ctx);
> -    char *endptr, *val;
> +    char *val;
>      char *dompath, *diskpath, *be_path;
>      unsigned int devid_n;
>      int rc = ERROR_INVAL;
>  
> -    devid_n = strtoul(devid, &endptr, 10);
> -    if (devid == endptr) {
> +    devid_n = libxl__device_disk_dev_number((char *)devid);

This function takes 3 parameters in xen-unstable.hg so this won't work.
Please can you rebase.

Also casting away the const like that is probably unsafe (it's likely a
const for a reason) and should have raised alarm bells.

libxl__device_disk_dev_number should take a const, it looks like that
would be a trivial change since the function doesn't appear to actually
modify the string, although I could be mistaken, in which case
libxl__device_disk_dev_number needs fixing to not modify the string.

Cheers,
Ian.


> +    if (devid_n < 0) {
>          goto out;
>      }
>      rc = ERROR_FAIL;
>      dompath = libxl__xs_get_dompath(&gc, domid);
> -    diskpath = libxl__sprintf(&gc, "%s/device/vbd/%s", dompath, devid);
> +    diskpath = libxl__sprintf(&gc, "%s/device/vbd/%d", dompath, devid_n);
>      if (!diskpath) {
>          goto out;
>      }
> 
> 
> 
> _______________________________________________
> Xen-devel mailing list
> Xen-devel@xxxxxxxxxxxxxxxxxxx
> http://lists.xensource.com/xen-devel



_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel


 


Rackspace

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