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

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



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 redhat com    +1-801-349-2682
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature


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