[PATCH] qemu: Add test cases for 'host_cdrom' blockdev backend via <disk>

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

 



Simulate that the device is a cdrom when the path equals to /dev/cdrom
to provide testing for the 'host_cdrom' backend.

Signed-off-by: Peter Krempa <pkrempa@xxxxxxxxxx>
---

I've already posted this before but I mistakenly identified is as wrong
and self-NACKed it, but we don't really have a test for a <disk
type=cdrom> backed by a host device, so this patch makes sense.

 tests/qemuxml2argvdata/disk-cdrom.args               |  4 ++--
 tests/qemuxml2argvdata/disk-cdrom.x86_64-2.12.0.args |  4 ++--
 tests/qemuxml2argvdata/disk-cdrom.x86_64-latest.args |  6 +++---
 tests/qemuxml2argvdata/disk-cdrom.xml                |  5 +++--
 tests/qemuxml2argvtest.c                             | 11 +++++++++++
 tests/qemuxml2xmloutdata/disk-cdrom.xml              |  5 +++--
 6 files changed, 24 insertions(+), 11 deletions(-)

diff --git a/tests/qemuxml2argvdata/disk-cdrom.args b/tests/qemuxml2argvdata/disk-cdrom.args
index cbac368129..e506a4befe 100644
--- a/tests/qemuxml2argvdata/disk-cdrom.args
+++ b/tests/qemuxml2argvdata/disk-cdrom.args
@@ -25,8 +25,8 @@ server,nowait \
 -no-shutdown \
 -no-acpi \
 -usb \
--drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-ide0-0-0 \
--device ide-hd,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0,bootindex=1 \
+-drive file=/dev/cdrom,format=raw,if=none,id=drive-ide0-0-0,readonly=on \
+-device ide-cd,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0 \
 -drive file=/root/boot.iso,format=raw,if=none,id=drive-ide0-0-1,readonly=on \
 -device ide-cd,bus=ide.0,unit=1,drive=drive-ide0-0-1,id=ide0-0-1 \
 -drive if=none,id=drive-ide0-1-0,readonly=on \
diff --git a/tests/qemuxml2argvdata/disk-cdrom.x86_64-2.12.0.args b/tests/qemuxml2argvdata/disk-cdrom.x86_64-2.12.0.args
index 2440acc78a..0621746a3b 100644
--- a/tests/qemuxml2argvdata/disk-cdrom.x86_64-2.12.0.args
+++ b/tests/qemuxml2argvdata/disk-cdrom.x86_64-2.12.0.args
@@ -27,8 +27,8 @@ file=/tmp/lib/domain--1-QEMUGuest1/master-key.aes \
 -no-acpi \
 -boot strict=on \
 -device piix3-usb-uhci,id=usb,bus=pci.0,addr=0x1.0x2 \
--drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-ide0-0-0 \
--device ide-hd,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0,bootindex=1 \
+-drive file=/dev/cdrom,format=raw,if=none,id=drive-ide0-0-0,readonly=on \
+-device ide-cd,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0 \
 -drive file=/root/boot.iso,format=raw,if=none,id=drive-ide0-0-1,readonly=on \
 -device ide-cd,bus=ide.0,unit=1,drive=drive-ide0-0-1,id=ide0-0-1 \
 -drive if=none,id=drive-ide0-1-0,readonly=on \
diff --git a/tests/qemuxml2argvdata/disk-cdrom.x86_64-latest.args b/tests/qemuxml2argvdata/disk-cdrom.x86_64-latest.args
index 0d375ffd1c..beac75ec1d 100644
--- a/tests/qemuxml2argvdata/disk-cdrom.x86_64-latest.args
+++ b/tests/qemuxml2argvdata/disk-cdrom.x86_64-latest.args
@@ -29,11 +29,11 @@ file=/tmp/lib/domain--1-QEMUGuest1/master-key.aes \
 -no-acpi \
 -boot strict=on \
 -device piix3-usb-uhci,id=usb,bus=pci.0,addr=0x1.0x2 \
--blockdev '{"driver":"host_device","filename":"/dev/HostVG/QEMUGuest1",\
+-blockdev '{"driver":"host_cdrom","filename":"/dev/cdrom",\
 "node-name":"libvirt-4-storage","auto-read-only":true,"discard":"unmap"}' \
--blockdev '{"node-name":"libvirt-4-format","read-only":false,"driver":"raw",\
+-blockdev '{"node-name":"libvirt-4-format","read-only":true,"driver":"raw",\
 "file":"libvirt-4-storage"}' \
--device ide-hd,bus=ide.0,unit=0,drive=libvirt-4-format,id=ide0-0-0,bootindex=1 \
+-device ide-cd,bus=ide.0,unit=0,drive=libvirt-4-format,id=ide0-0-0 \
 -blockdev '{"driver":"file","filename":"/root/boot.iso",\
 "node-name":"libvirt-3-storage","auto-read-only":true,"discard":"unmap"}' \
 -blockdev '{"node-name":"libvirt-3-format","read-only":true,"driver":"raw",\
diff --git a/tests/qemuxml2argvdata/disk-cdrom.xml b/tests/qemuxml2argvdata/disk-cdrom.xml
index b051b16642..54d2927ac3 100644
--- a/tests/qemuxml2argvdata/disk-cdrom.xml
+++ b/tests/qemuxml2argvdata/disk-cdrom.xml
@@ -14,10 +14,11 @@
   <on_crash>destroy</on_crash>
   <devices>
     <emulator>/usr/bin/qemu-system-i386</emulator>
-    <disk type='block' device='disk'>
+    <disk type='block' device='cdrom'>
       <driver name='qemu' type='raw'/>
-      <source dev='/dev/HostVG/QEMUGuest1'/>
+      <source dev='/dev/cdrom'/>
       <target dev='hda' bus='ide'/>
+      <readonly/>
       <address type='drive' controller='0' bus='0' target='0' unit='0'/>
     </disk>
     <disk type='file' device='cdrom'>
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index c5a0095e0d..ef8a871a19 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -407,6 +407,17 @@ testCompareXMLToArgvCreateArgs(virQEMUDriverPtr drv,
                                            VIR_QEMU_PROCESS_START_COLD) < 0)
         return NULL;

+    for (i = 0; i < vm->def->ndisks; i++) {
+        virDomainDiskDefPtr disk = vm->def->disks[i];
+
+        /* host cdrom requires special treatment in qemu, mock it */
+        if (disk->device == VIR_DOMAIN_DISK_DEVICE_CDROM &&
+            disk->src->format == VIR_STORAGE_FILE_RAW &&
+            virStorageSourceIsBlockLocal(disk->src) &&
+            STREQ(disk->src->path, "/dev/cdrom"))
+            disk->src->hostcdrom = true;
+    }
+
     for (i = 0; i < vm->def->nhostdevs; i++) {
         virDomainHostdevDefPtr hostdev = vm->def->hostdevs[i];

diff --git a/tests/qemuxml2xmloutdata/disk-cdrom.xml b/tests/qemuxml2xmloutdata/disk-cdrom.xml
index 3e6475c276..3a8c34761d 100644
--- a/tests/qemuxml2xmloutdata/disk-cdrom.xml
+++ b/tests/qemuxml2xmloutdata/disk-cdrom.xml
@@ -14,10 +14,11 @@
   <on_crash>destroy</on_crash>
   <devices>
     <emulator>/usr/bin/qemu-system-i386</emulator>
-    <disk type='block' device='disk'>
+    <disk type='block' device='cdrom'>
       <driver name='qemu' type='raw'/>
-      <source dev='/dev/HostVG/QEMUGuest1'/>
+      <source dev='/dev/cdrom'/>
       <target dev='hda' bus='ide'/>
+      <readonly/>
       <address type='drive' controller='0' bus='0' target='0' unit='0'/>
     </disk>
     <disk type='file' device='cdrom'>
-- 
2.26.2




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux