[libvirt] [PATCH]: ignore empty type attribute, was Re: empty type parameter in driver tag for disk in machine xml file

Eric Blake eblake at redhat.com
Tue Apr 20 14:20:35 UTC 2010


On 04/19/2010 10:16 AM, Guido Günther wrote:
>> It seems this part of the libvirt xml file was causing the problem:
>>
>>     <disk type='file' device='disk'>
>>       <driver name='qemu' type=''/>

Thanks for the analysis.

> This also popped up in Debian:
> 	http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=578347
> A patch for ignoring an empty type attribute is attached. O.k. apply?

> --- a/src/qemu/qemu_conf.c
> +++ b/src/qemu/qemu_conf.c
> @@ -2459,7 +2459,7 @@ qemuBuildDriveStr(virDomainDiskDefPtr disk,
>      if (disk->readonly &&
>          qemuCmdFlags & QEMUD_CMD_FLAG_DEVICE)
>          virBufferAddLit(&opt, ",readonly=on");
> -    if (disk->driverType &&
> +    if (disk->driverType && strlen(disk->driverType) &&

I'd rather see

*disk->driverType != '\0'

than your proposed

strlen(disk->driverType)

since the former is O(1) while the latter is nominally O(n) in the
common case of a non-empty string.  [Hmm, makes me wonder if gcc can
optimize the case of strlen being used in a boolean context].

But with that tweak, ACK.

-- 
Eric Blake   eblake at redhat.com    +1-801-349-2682
Libvirt virtualization library http://libvirt.org

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 619 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20100420/443b7381/attachment-0001.sig>


More information about the libvir-list mailing list