On 06/16/2016 06:11 AM, Jim Fehlig wrote:
> When converting domXML to xen xl.cfg, backendtype should
> not be emitted if <driver> is not specified. Moreover,
> <driver name='file'/> should be converted to backendtype
> qdisk, similar to handling of <driver> in libxlMakeDisk()
> in libxl_conf.c.
> 
> Prior to this change, connectDomainXMLToNative would
> produce incorrect xl.cfg when the input domXML contained
> <driver name='file'/>
> 
> domXML:
> 
>   <disk type="file" device="disk">
>     <driver name="file"/>
>     <source file="/image/file/path"/>
>     <target dev="xvda" bus="xen"/>
>   </disk>
> 
> virsh domxml-to-native xen-xl domXML
> 
> disk = [ "format=raw,vdev=xvda,access=rw,backendtype=target=/image/file/path" 
> ]
> 
> xl create xl.cfg
> config parsing error in disk specification: unknown value
> for backendtype: near `target=/image/file/path' in
> `format=raw,vdev=xvda,access=rw,backendtype=target=/image/file/path'
> 
> Signed-off-by: Jim Fehlig <jfeh...@suse.com>
FWIW looks good to me:

Reviewed-by: Joao Martins <joao.m.mart...@oracle.com>

> ---
>  src/xenconfig/xen_xl.c | 16 +++++++++-------
>  1 file changed, 9 insertions(+), 7 deletions(-)
> 
> diff --git a/src/xenconfig/xen_xl.c b/src/xenconfig/xen_xl.c
> index 5879c66..d524a82 100644
> --- a/src/xenconfig/xen_xl.c
> +++ b/src/xenconfig/xen_xl.c
> @@ -857,13 +857,15 @@ xenFormatXLDisk(virConfValuePtr list, 
> virDomainDiskDefPtr disk)
>      }
>  
>      /* backendtype */
> -    virBufferAddLit(&buf, "backendtype=");
> -    if (STREQ_NULLABLE(driver, "qemu"))
> -        virBufferAddLit(&buf, "qdisk,");
> -    else if (STREQ_NULLABLE(driver, "tap"))
> -        virBufferAddLit(&buf, "tap,");
> -    else if (STREQ_NULLABLE(driver, "phy"))
> -        virBufferAddLit(&buf, "phy,");
> +    if (driver) {
> +        virBufferAddLit(&buf, "backendtype=");
> +        if (STREQ(driver, "qemu") || STREQ(driver, "file"))
> +            virBufferAddLit(&buf, "qdisk,");
> +        else if (STREQ(driver, "tap"))
> +            virBufferAddLit(&buf, "tap,");
> +        else if (STREQ(driver, "phy"))
> +            virBufferAddLit(&buf, "phy,");
> +    }
>  
>      /* devtype */
>      if (disk->device == VIR_DOMAIN_DISK_DEVICE_CDROM)
> 

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Reply via email to