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

Re: [libvirt] [PATCH] libxl: default to qemu driver for network disks



On 24.05.2016 00:01, Jim Fehlig wrote:
> Xen only supports network-based disks with the qemu (aka qdisk) driver.
> Set the driverName to 'qemu' in libxlDomainDeviceDefPostParse() if
> not already set. When starting a domain with network-based disks,
> ensure the driverName is 'qemu'.
> 
> Signed-off-by: Jim Fehlig <jfehlig suse com>
> ---
>  src/libxl/libxl_conf.c   | 11 +++++++----
>  src/libxl/libxl_domain.c | 12 ++++++++++++
>  2 files changed, 19 insertions(+), 4 deletions(-)
> 
> diff --git a/src/libxl/libxl_conf.c b/src/libxl/libxl_conf.c
> index 13e56ac..78e9ee9 100644
> --- a/src/libxl/libxl_conf.c
> +++ b/src/libxl/libxl_conf.c
> @@ -1058,13 +1058,18 @@ libxlMakeNetworkDiskSrc(virStorageSourcePtr src, char **srcstr)
>  int
>  libxlMakeDisk(virDomainDiskDefPtr l_disk, libxl_device_disk *x_disk)
>  {
> -    const char *driver;
> -    int format;
> +    const char *driver = virDomainDiskGetDriver(l_disk);
> +    int format = virDomainDiskGetFormat(l_disk);
>      int actual_type = virStorageSourceGetActualType(l_disk->src);
>  
>      libxl_device_disk_init(x_disk);
>  
>      if (actual_type == VIR_STORAGE_TYPE_NETWORK) {
> +        if (driver && STRNEQ(driver, "qemu")) {

or STRNEQ_NULLABLE() for short.

> +            virReportError(VIR_ERR_OPERATION_INVALID, "%s",
> +                           _("only the 'qemu' driver can be used with network disks"));
> +            return -1;
> +        }
>          if (libxlMakeNetworkDiskSrc(l_disk->src, &x_disk->pdev_path) < 0)
>              return -1;
>      } else {
> @@ -1075,8 +1080,6 @@ libxlMakeDisk(virDomainDiskDefPtr l_disk, libxl_device_disk *x_disk)
>      if (VIR_STRDUP(x_disk->vdev, l_disk->dst) < 0)
>          return -1;
>  
> -    driver = virDomainDiskGetDriver(l_disk);
> -    format = virDomainDiskGetFormat(l_disk);
>      if (driver) {
>          if (STREQ(driver, "tap") || STREQ(driver, "tap2")) {
>              switch (format) {
> diff --git a/src/libxl/libxl_domain.c b/src/libxl/libxl_domain.c
> index 113942b..8a3866f 100644
> --- a/src/libxl/libxl_domain.c
> +++ b/src/libxl/libxl_domain.c
> @@ -364,6 +364,18 @@ libxlDomainDeviceDefPostParse(virDomainDeviceDefPtr dev,
>          }
>      }
>  
> +    /* for network-based disks, set 'qemu' as the default driver */
> +    if (dev->type == VIR_DOMAIN_DEVICE_DISK) {
> +        virDomainDiskDefPtr disk = dev->data.disk;
> +        int actual_type = virStorageSourceGetActualType(disk->src);
> +
> +        if (actual_type == VIR_STORAGE_TYPE_NETWORK) {
> +            if (!virDomainDiskGetDriver(disk) &&
> +                virDomainDiskSetDriver(disk, "qemu") < 0)
> +                return -1;
> +        }
> +    }
> +
>      return 0;
>  }
>  
> 

ACK

Michal


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