]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemu: Add test cases for 'host_cdrom' blockdev backend via <disk>
authorPeter Krempa <pkrempa@redhat.com>
Thu, 15 Oct 2020 11:47:46 +0000 (13:47 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Mon, 2 Nov 2020 13:14:51 +0000 (14:14 +0100)
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@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
tests/qemuxml2argvdata/disk-cdrom.args
tests/qemuxml2argvdata/disk-cdrom.x86_64-2.12.0.args
tests/qemuxml2argvdata/disk-cdrom.x86_64-latest.args
tests/qemuxml2argvdata/disk-cdrom.xml
tests/qemuxml2argvtest.c
tests/qemuxml2xmloutdata/disk-cdrom.xml

index cbac36812949cfc0743cfce9d324dd9d8480a3e3..e506a4befec59db45eea7b2f8dc93702756d9d27 100644 (file)
@@ -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 \
index 2440acc78a0f756ef9e5d96119b3afc4c237c129..0621746a3b01a89609c093a58fe3935fce6574fb 100644 (file)
@@ -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 \
index 0d375ffd1c09132dbb50ecbc4a8b4dce3d13930e..beac75ec1d757f8324f3813b6dbaae5877faa843 100644 (file)
@@ -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",\
index b051b1664268950d1e62521f07bc0eb92188721c..54d2927ac37d0a7f3987650e2d4b6eb1910fa3bd 100644 (file)
   <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'>
index c5a0095e0d9aa378f36792c283dd7f2a612510c3..ef8a871a19bafd2fe900154f44b840a4bbea2e63 100644 (file)
@@ -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];
 
index 3e6475c2768e9971bb27d253be3f9dc84000c708..3a8c34761d99104180c5f226c6b42ddcaf735d9d 100644 (file)
   <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'>