[libvirt] empty type parameter in driver tag for disk in machine xml file

I updated my system from libvirt 0.7.1 to 0.7.7, one of my qemu-kvm VMs was not starting anymore, with this error: LC_ALL=C PATH=/sbin:/usr/sbin:/bin:/usr/bin HOME=/ TMPDIR=/tmp QEMU_AUDIO_DRV=none /usr/bin/qemu-kvm -S -M pc-0.11 -enable-kvm -m 512 - smp 1,sockets=1,cores=1,threads=1 -name debian-testing -uuid 54f57a86- b84c-61ba-7f2a-c69f39f80a41 -nodefaults -chardev socket,id=monitor,path=/ var/lib/libvirt/qemu/debian-testing.monitor,server,nowait -mon chardev=monitor,mode=readline -rtc base=utc -boot c -drive file=/home/ frederik/Software/iso/debian-testing-amd64- netinst.iso,if=none,media=cdrom,id=drive-ide0-1-0 -device ide- drive,bus=ide.1,unit=0,drive=drive-ide0-1-0,id=ide0-1-0 -drive file=/home/ frederik/VM/debian-testing.img,if=none,id=drive-virtio- disk0,boot=on,format= -device virtio-blk- pci,bus=pci.0,addr=0x4,drive=drive-virtio-disk0,id=virtio-disk0 -device virtio-net-pci,vlan=0,id=net0,mac=52:54:00:25:9c:a0,bus=pci.0,addr=0x5 - net tap,fd=19,vlan=0,name=hostnet0 -chardev pty,id=serial0 -device isa- serial,chardev=serial0 -usb -device usb-tablet,id=input0 -vnc 127.0.0.1:1 -k fr-be -vga vmware -device ES1370,id=sound0,bus=pci.0,addr=0x6 -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3 char device redirected to /dev/pts/6 qemu: '' invalid format It seems this part of the libvirt xml file was causing the problem: <disk type='file' device='disk'> <driver name='qemu' type=''/> <source file='/home/frederik/VM/debian-testing.img'/> <target dev='vda' bus='virtio'/> <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/> </disk> Notice the empty type parameter in the driver tag. Removing type='' completely, makes the machine start fine. Is this a bug which should be fixed, so that libvirt can deal empty type tags, possible set by older versions? -- Frederik Himpe

Hi, On Tue, Apr 06, 2010 at 12:50:31PM +0000, Frederik Himpe wrote:
I updated my system from libvirt 0.7.1 to 0.7.7, one of my qemu-kvm VMs was not starting anymore, with this error:
LC_ALL=C PATH=/sbin:/usr/sbin:/bin:/usr/bin HOME=/ TMPDIR=/tmp QEMU_AUDIO_DRV=none /usr/bin/qemu-kvm -S -M pc-0.11 -enable-kvm -m 512 - smp 1,sockets=1,cores=1,threads=1 -name debian-testing -uuid 54f57a86- b84c-61ba-7f2a-c69f39f80a41 -nodefaults -chardev socket,id=monitor,path=/ var/lib/libvirt/qemu/debian-testing.monitor,server,nowait -mon chardev=monitor,mode=readline -rtc base=utc -boot c -drive file=/home/ frederik/Software/iso/debian-testing-amd64- netinst.iso,if=none,media=cdrom,id=drive-ide0-1-0 -device ide- drive,bus=ide.1,unit=0,drive=drive-ide0-1-0,id=ide0-1-0 -drive file=/home/ frederik/VM/debian-testing.img,if=none,id=drive-virtio- disk0,boot=on,format= -device virtio-blk- pci,bus=pci.0,addr=0x4,drive=drive-virtio-disk0,id=virtio-disk0 -device virtio-net-pci,vlan=0,id=net0,mac=52:54:00:25:9c:a0,bus=pci.0,addr=0x5 - net tap,fd=19,vlan=0,name=hostnet0 -chardev pty,id=serial0 -device isa- serial,chardev=serial0 -usb -device usb-tablet,id=input0 -vnc 127.0.0.1:1 -k fr-be -vga vmware -device ES1370,id=sound0,bus=pci.0,addr=0x6 -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3 char device redirected to /dev/pts/6 qemu: '' invalid format
It seems this part of the libvirt xml file was causing the problem:
<disk type='file' device='disk'> <driver name='qemu' type=''/> <source file='/home/frederik/VM/debian-testing.img'/> <target dev='vda' bus='virtio'/> <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/> </disk>
Notice the empty type parameter in the driver tag. Removing type='' completely, makes the machine start fine.
Is this a bug which should be fixed, so that libvirt can deal empty type tags, possible set by older versions? 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? Cheers, -- Guido

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

On Tue, Apr 20, 2010 at 08:20:35AM -0600, Eric Blake wrote:
On 04/19/2010 10:16 AM, Guido Günther wrote: [..snip..] since the former is O(1) while the latter is nominally O(n) in the Good point. New patch attached. -- Guido

On 04/20/2010 02:18 PM, Guido Günther wrote:
On Tue, Apr 20, 2010 at 08:20:35AM -0600, Eric Blake wrote:
On 04/19/2010 10:16 AM, Guido Günther wrote: [..snip..] since the former is O(1) while the latter is nominally O(n) in the Good point. New patch attached.
Looks good; you have my ACK for pushing. -- Eric Blake eblake@redhat.com +1-801-349-2682 Libvirt virtualization library http://libvirt.org

On Tue, Apr 20, 2010 at 02:20:05PM -0600, Eric Blake wrote:
On 04/20/2010 02:18 PM, Guido Günther wrote:
On Tue, Apr 20, 2010 at 08:20:35AM -0600, Eric Blake wrote:
On 04/19/2010 10:16 AM, Guido Günther wrote: [..snip..] since the former is O(1) while the latter is nominally O(n) in the Good point. New patch attached.
Looks good; you have my ACK for pushing. Pushed now. -- Guido
participants (3)
-
Eric Blake
-
Frederik Himpe
-
Guido Günther