]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
The new generic domain re-factor introduced a small regression into the drive
authorChris Lalancette <clalance@redhat.com>
Tue, 29 Jul 2008 12:09:21 +0000 (12:09 +0000)
committerChris Lalancette <clalance@redhat.com>
Tue, 29 Jul 2008 12:09:21 +0000 (12:09 +0000)
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>
ChangeLog
src/qemu_conf.c
tests/qemuxml2argvdata/qemuxml2argv-disk-cdrom-empty.args [new file with mode: 0644]
tests/qemuxml2argvdata/qemuxml2argv-disk-cdrom-empty.xml [new file with mode: 0644]
tests/qemuxml2argvtest.c

index 24f38112b2d9f5f46303d0bbe3e44d4f3dc938e8..d5eb4f93047b488e99b3162ef997e86ce2d059d3 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -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
index 9cd8c1e5d22eb802e321ebd9a759c62b47ee0fa5..f5d12c7ddf3b8458ba171f4212be404e4b400ddc 100644 (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 &&
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-cdrom-empty.args b/tests/qemuxml2argvdata/qemuxml2argv-disk-cdrom-empty.args
new file mode 100644 (file)
index 0000000..95d8171
--- /dev/null
@@ -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
\ No newline at end of file
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-cdrom-empty.xml b/tests/qemuxml2argvdata/qemuxml2argv-disk-cdrom-empty.xml
new file mode 100644 (file)
index 0000000..257d4ef
--- /dev/null
@@ -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>
+
index 5e1871d7100812e62abc3d55da9228a3bc90d39a..d136a1346dec7ebfc5cc9b30c4c000f7a2761414 100644 (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 |