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

Re: [Xen-devel] [PATCH 5/6] libxl: introduce libxl__alloc_vdev



Stefano Stabellini writes ("[PATCH 5/6] libxl: introduce libxl__alloc_vdev"):
> Introduce libxl__alloc_vdev: find a spare virtual block device in the
> domain passed as argument.
...
> +static int libxl__vdev_to_index(libxl__gc *gc, char *vdev)
> +{
> +    if (vdev == NULL)
> +        return 0;
> +    if (strlen(vdev) > 4 || strlen(vdev) < 4)
> +        return 0;
> +    /* assume xvdz is the last one available */

This is a broken half-reimplementation of
libxl__device_disk_dev_number.

> +    free(disks);
> +    return libxl__index_to_vdev(gc, max_idx);

And you don't need this function because you can use the disk number
directly (converted to a string of decimal digits) as the vdev.

Of course you can't then using the resulting vdev as a pathname in
/dev/ but that's nonportable anyway; different guest OSs (and here we
are playing the role of the guest) may have different conventions.
You need a separate function to convert vdev numbers (as returned from
_disk_dev_number) to pathnames in /dev.

> +    for (i = 0; i < num; i++) {
> +        idx = libxl__vdev_to_index(gc, disks[i].vdev);

Furthermore, for the purpose for which you're using this, you should
not start at zero (xvda).  You should start at at least 26 (xvdA) and
possibly later.  That way you are less likely to clash with other
statically-allocated vbds.

Ian.

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