WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

[Xen-devel] Re: [PATCH] libxl: basic support for virtio disk

On Mon, 30 May 2011, Wei Liu wrote:
> I hope that I catch your ideas correctly.
> 

yes, pretty close


> ------8<--------------
> 
> commit 0d173004c1f023121680bff0483f7cfe8f2c494e
> Author: Wei Liu <liuw@xxxxxxxxx>
> Date:   Fri May 27 10:22:05 2011 +0800
> 
>     libxl: basic virtio disk support.
> 
>     Use "vd*" in vm config file to enable virtio disk.
> 
>     Virtio disk is not storing any information in Xenstore, since it is not
>     backed by any backend. A new backend type NONE is added. More work is
>     needed to support hotplug virtio disk.
> 
>     Signed-off-by: Wei Liu <liuw@xxxxxxxxx>
> 
> diff --git a/docs/misc/vbd-interface.txt b/docs/misc/vbd-interface.txt
> index d97c458..83cbe39 100644
> --- a/docs/misc/vbd-interface.txt
> +++ b/docs/misc/vbd-interface.txt
> @@ -8,7 +8,7 @@ emulated IDE or SCSI disks.
>  The abstract interface involves specifying, for each block device:
> 
>   * Nominal disk type: Xen virtual disk (aka xvd*, the default); SCSI
> -   (sd*); IDE (hd*).
> +   (sd*); IDE (hd*); Virtio disk (vd*).
> 
>     For HVM guests, each whole-disk hd* and and sd* device is made
>     available _both_ via emulated IDE resp. SCSI controller, _and_ as a
> diff --git a/tools/libxl/libxl.c b/tools/libxl/libxl.c
> index ccf6518..0df9a18 100644
> --- a/tools/libxl/libxl.c
> +++ b/tools/libxl/libxl.c
> @@ -975,6 +975,10 @@ int libxl_device_disk_add(libxl_ctx *ctx,
> uint32_t domid, libxl_device_disk *dis
>                 " virtual disk identifier %s", disk->vdev);
>          rc = ERROR_INVAL;
>          goto out_free;
> +    } else if (devid==-2) {
> +        LIBXL__LOG(ctx, LIBXL__LOG_INFO, "Using QEMU virtio backend for"
> +                   " virtual disk %s", disk->vdev);
> +        goto out_free;
>      }
> 
>      device.backend_devid = devid;
> @@ -1028,6 +1032,9 @@ int libxl_device_disk_add(libxl_ctx *ctx,
> uint32_t domid, libxl_device_disk *dis
> 
> libxl__device_disk_string_of_format(disk->format), disk->pdev_path));
>              device.backend_kind = DEVICE_QDISK;
>              break;
> +        case LIBXL_DISK_BACKEND_NONE:
> +         /* Nothing to do, not a Xen VBD */
> +         break;
>          default:
>              LIBXL__LOG(ctx, LIBXL__LOG_ERROR, "unrecognized disk
> backend type: %d\n", disk->backend);
>              rc = ERROR_INVAL;
> @@ -1095,6 +1102,10 @@ int libxl_device_disk_del(libxl_ctx *ctx, uint32_t 
> domid,
>          case LIBXL_DISK_BACKEND_QDISK:
>              device.backend_kind = DEVICE_QDISK;
>              break;
> +        case LIBXL_DISK_BACKEND_NONE:
> +            LIBXL__LOG(ctx, LIBXL__LOG_ERROR, "unable to delete a
> none backend\n");
> +            rc = ERROR_INVAL;
> +            goto out_free;
>          default:
>              LIBXL__LOG(ctx, LIBXL__LOG_ERROR, "unrecognized disk
> backend type: %d\n",
>                         disk->backend);
> @@ -1167,6 +1178,8 @@ char * libxl_device_disk_local_attach(libxl_ctx
> *ctx, libxl_device_disk *disk)
>                  disk->pdev_path);
>              dev = disk->pdev_path;
>              break;
> +        case LIBXL_DISK_BACKEND_NONE:
> +            LIBXL__LOG(ctx, LIBXL__LOG_ERROR, "unable to attach a
> none backend\n");

I think you are missing a break; here.

>          case LIBXL_DISK_BACKEND_UNKNOWN:
>          default:
>              LIBXL__LOG(ctx, LIBXL__LOG_ERROR, "unrecognized disk backend "
> diff --git a/tools/libxl/libxl.idl b/tools/libxl/libxl.idl
> index a5be66f..6b27eae 100644
> --- a/tools/libxl/libxl.idl
> +++ b/tools/libxl/libxl.idl
> @@ -54,6 +54,7 @@ libxl_disk_backend = Enumeration("disk_backend", [
>      (1, "PHY"),
>      (2, "TAP"),
>      (3, "QDISK"),
> +    (4, "NONE"),
>      ])
> 
>  libxl_nic_type = Enumeration("nic_type", [
> diff --git a/tools/libxl/libxl_device.c b/tools/libxl/libxl_device.c
> index 5d85822..25b783c 100644
> --- a/tools/libxl/libxl_device.c
> +++ b/tools/libxl/libxl_device.c
> @@ -239,6 +239,13 @@ int libxl__device_disk_dev_number(char *virtpath,
> int *pdisk, int *ppartition)
>          if (ppartition) *ppartition = partition;
>          return (8 << 8) | (disk << 4) | partition;
>      }
> +    if (device_virtdisk_matches(virtpath, "vd",
> +                                &disk, 15,
> +                                &partition, 15)) {
> +        if (pdisk) *pdisk = disk;
> +        if (ppartition) *ppartition = partition;
> +        return -2;

is 15 really the limit for virtio disks and partitions?


> +    }
>      return -1;
>  }
> 

you missed libxl__device_disk_string_of_backend in this file.
The rest looks good to me.

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