The new generic domain re-factor introduced a small regression into the drive

handling code.  In particular, if you had a section of XML like:

    <disk type='file' device='cdrom'>
      <target dev='hdc' bus='ide'/>
      <readonly/>
    </disk>

This used to work with older libvirt, but now fails.  This is because we are
actually passing the literal string (null) to the qemu command-line, which qemu
barfs on.  This patch fixes it up by making it blank, which allows qemu to
continue on it's merry way.

Signed-off-by: Chris Lalancette <clalance@redhat.com>
This commit is contained in:
Chris Lalancette 2008-07-29 12:09:21 +00:00
parent 4779e0bcb2
commit 654c5714bf
5 changed files with 39 additions and 4 deletions

View File

@ -1,3 +1,11 @@
Tue Jul 29 14:08:00 CEST 2008 Chris Lalancette <clalance@redhat.com>
* src/qemu_conf.c: fix empty CD-ROM source device section
* tests/qemuxml2argvtest.c,
tests/qemuxml2argvdata/qemuxml2argv-disk-cdrom-empty.xml,
tests/qemuxml2argvdata/qemuxml2argv-disk-cdrom-empty.args: Add test
for empty source CD-ROM device section
Tue Jul 29 10:41:30 CEST 2008 Daniel Veillard <veillard@redhat.com>
* src/openvz_conf.c: fix compilation with new XPath interface

View File

@ -888,13 +888,11 @@ int qemudBuildCommandLine(virConnectPtr conn,
goto error;
}
if (disk->device == VIR_DOMAIN_DISK_DEVICE_CDROM)
media = "media=cdrom,";
switch (disk->device) {
case VIR_DOMAIN_DISK_DEVICE_CDROM:
bootable = bootCD;
bootCD = 0;
media = "media=cdrom,";
break;
case VIR_DOMAIN_DISK_DEVICE_FLOPPY:
bootable = bootFloppy;
@ -907,7 +905,7 @@ int qemudBuildCommandLine(virConnectPtr conn,
}
snprintf(opt, PATH_MAX, "file=%s,if=%s,%sindex=%d%s",
disk->src, bus,
disk->src ? disk->src : "", bus,
media ? media : "",
idx,
bootable &&

View File

@ -0,0 +1 @@
/usr/bin/qemu -S -M pc -m 214 -smp 1 -nographic -monitor pty -no-acpi -boot c -drive file=/dev/HostVG/QEMUGuest1,if=ide,index=0 -drive file=,if=ide,media=cdrom,index=2 -net none -serial none -parallel none -usb

View File

@ -0,0 +1,27 @@
<domain type='qemu'>
<name>QEMUGuest1</name>
<uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
<memory>219200</memory>
<currentMemory>219200</currentMemory>
<vcpu>1</vcpu>
<os>
<type arch='i686' machine='pc'>hvm</type>
<boot dev='hd'/>
</os>
<clock offset='utc'/>
<on_poweroff>destroy</on_poweroff>
<on_reboot>restart</on_reboot>
<on_crash>destroy</on_crash>
<devices>
<emulator>/usr/bin/qemu</emulator>
<disk type='block' device='disk'>
<source dev='/dev/HostVG/QEMUGuest1'/>
<target dev='hda' bus='ide'/>
</disk>
<disk type='file' device='cdrom'>
<target dev='hdc' bus='ide'/>
<readonly/>
</disk>
</devices>
</domain>

View File

@ -145,6 +145,7 @@ mymain(int argc, char **argv)
DO_TEST("clock-utc", 0);
DO_TEST("clock-localtime", 0);
DO_TEST("disk-cdrom", 0);
DO_TEST("disk-cdrom-empty", QEMUD_CMD_FLAG_DRIVE);
DO_TEST("disk-floppy", 0);
DO_TEST("disk-many", 0);
DO_TEST("disk-virtio", QEMUD_CMD_FLAG_DRIVE |