[PATCH 26/32] qemu: Forbid cdroms on virtio bus

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

 



Attempting to create an empty virtio-blk drive results into:
-device virtio-blk-pci,scsi=off,bus=pci.0,addr=0xc,drive=drive-virtio-disk1,id=virtio-disk1: Device needs media, but drive is empty

Attempting to eject media from virtio-blk based drive results into:
error: internal error: unable to execute QEMU command 'eject': Device 'drive-virtio-disk0' is not removable

Forbid configurations where users would attempt to use cdroms in virtio
bus.

Test fallout apart from the recently added case contains one more wrong
example which is not really relevant to the tested code, thus I've
changed the type.

Signed-off-by: Peter Krempa <pkrempa@xxxxxxxxxx>
---
 src/qemu/qemu_domain.c                              |  8 ++++++++
 .../disk-cdrom-bus-other.x86_64-latest.args         |  7 -------
 tests/qemuxml2argvdata/disk-cdrom-bus-other.xml     | 11 -----------
 .../disk-scsi-disk-vpd-build-error.xml              |  2 +-
 tests/qemuxml2argvdata/pci-autofill-addr.args       |  4 ++--
 tests/qemuxml2argvdata/pci-autofill-addr.xml        |  2 +-
 tests/qemuxml2xmloutdata/disk-cdrom-bus-other.xml   | 13 -------------
 tests/qemuxml2xmloutdata/pci-autofill-addr.xml      |  2 +-
 8 files changed, 13 insertions(+), 36 deletions(-)

diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index f42903a343..560abf5291 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -5075,6 +5075,14 @@ qemuDomainDeviceDefValidateDisk(const virDomainDiskDef *disk,
             return -1;
     }

+    if (disk->device == VIR_DOMAIN_DISK_DEVICE_CDROM &&
+        disk->bus == VIR_DOMAIN_DISK_BUS_VIRTIO) {
+        virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+                       _("disk type 'virtio' of '%s' does not support ejectable media"),
+                       disk->dst);
+        return -1;
+    }
+
     return 0;
 }

diff --git a/tests/qemuxml2argvdata/disk-cdrom-bus-other.x86_64-latest.args b/tests/qemuxml2argvdata/disk-cdrom-bus-other.x86_64-latest.args
index c38819fac0..34849c2e96 100644
--- a/tests/qemuxml2argvdata/disk-cdrom-bus-other.x86_64-latest.args
+++ b/tests/qemuxml2argvdata/disk-cdrom-bus-other.x86_64-latest.args
@@ -31,13 +31,6 @@ removable=off \
 -drive if=none,id=drive-usb-disk1,media=cdrom \
 -device usb-storage,bus=usb.0,port=2,drive=drive-usb-disk1,id=usb-disk1,\
 removable=off \
--drive file=/root/boot1.iso,format=raw,if=none,id=drive-virtio-disk0,\
-media=cdrom,readonly=on,cache=none \
--device virtio-blk-pci,scsi=off,bus=pci.0,addr=0x2,drive=drive-virtio-disk0,\
-id=virtio-disk0,write-cache=on \
--drive if=none,id=drive-virtio-disk1,media=cdrom \
--device virtio-blk-pci,scsi=off,bus=pci.0,addr=0x3,drive=drive-virtio-disk1,\
-id=virtio-disk1,write-cache=on \
 -drive file=/root/boot2.iso,format=raw,if=sd,index=2,media=cdrom,readonly=on \
 -drive if=sd,index=3,media=cdrom \
 -sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,\
diff --git a/tests/qemuxml2argvdata/disk-cdrom-bus-other.xml b/tests/qemuxml2argvdata/disk-cdrom-bus-other.xml
index 2ed86b0900..a142373afb 100644
--- a/tests/qemuxml2argvdata/disk-cdrom-bus-other.xml
+++ b/tests/qemuxml2argvdata/disk-cdrom-bus-other.xml
@@ -26,17 +26,6 @@
       <target dev='sdb' bus='usb'/>
       <readonly/>
     </disk>
-    <disk type='file' device='cdrom'>
-      <driver name='qemu' type='raw' cache='none'/>
-      <source file='/root/boot1.iso'/>
-      <target dev='vda' bus='virtio'/>
-      <readonly/>
-    </disk>
-    <disk type='file' device='cdrom'>
-      <driver name='qemu' type='raw' cache='none'/>
-      <target dev='vdb' bus='virtio'/>
-      <readonly/>
-    </disk>
     <disk type='file' device='cdrom'>
       <driver name='qemu' type='raw'/>
       <source file='/root/boot2.iso'/>
diff --git a/tests/qemuxml2argvdata/disk-scsi-disk-vpd-build-error.xml b/tests/qemuxml2argvdata/disk-scsi-disk-vpd-build-error.xml
index e116aff114..6c83715be2 100644
--- a/tests/qemuxml2argvdata/disk-scsi-disk-vpd-build-error.xml
+++ b/tests/qemuxml2argvdata/disk-scsi-disk-vpd-build-error.xml
@@ -14,7 +14,7 @@
   <on_crash>destroy</on_crash>
   <devices>
     <emulator>/usr/bin/qemu-system-i686</emulator>
-    <disk type='block' device='cdrom'>
+    <disk type='block' device='disk'>
       <source dev='/dev/HostVG/QEMUGuest1'/>
       <target dev='sda' bus='virtio'/>
       <vendor>SEAGATE</vendor>
diff --git a/tests/qemuxml2argvdata/pci-autofill-addr.args b/tests/qemuxml2argvdata/pci-autofill-addr.args
index b546443db3..1508787f8b 100644
--- a/tests/qemuxml2argvdata/pci-autofill-addr.args
+++ b/tests/qemuxml2argvdata/pci-autofill-addr.args
@@ -22,8 +22,8 @@ server,nowait \
 -no-acpi \
 -usb \
 -drive file=/var/iso/f18kde.iso,format=raw,if=none,id=drive-virtio-disk0,\
-media=cdrom,readonly=on \
+readonly=on \
 -device virtio-blk-pci,bus=pci.0,addr=0x3,drive=drive-virtio-disk0,\
-id=virtio-disk0 \
+id=virtio-disk0,bootindex=1 \
 -vga cirrus \
 -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x4
diff --git a/tests/qemuxml2argvdata/pci-autofill-addr.xml b/tests/qemuxml2argvdata/pci-autofill-addr.xml
index 0d10ec8635..a601c50ab9 100644
--- a/tests/qemuxml2argvdata/pci-autofill-addr.xml
+++ b/tests/qemuxml2argvdata/pci-autofill-addr.xml
@@ -10,7 +10,7 @@
   </os>
   <devices>
     <emulator>/usr/bin/qemu-system-x86_64</emulator>
-    <disk type='file' device='cdrom'>
+    <disk type='file' device='disk'>
       <driver name='qemu' type='raw'/>
       <source file='/var/iso/f18kde.iso'/>
       <target dev='vda' bus='virtio'/>
diff --git a/tests/qemuxml2xmloutdata/disk-cdrom-bus-other.xml b/tests/qemuxml2xmloutdata/disk-cdrom-bus-other.xml
index a9f2806777..e5eb7d6a98 100644
--- a/tests/qemuxml2xmloutdata/disk-cdrom-bus-other.xml
+++ b/tests/qemuxml2xmloutdata/disk-cdrom-bus-other.xml
@@ -26,19 +26,6 @@
       <target dev='sdb' bus='usb'/>
       <readonly/>
     </disk>
-    <disk type='file' device='cdrom'>
-      <driver name='qemu' type='raw' cache='none'/>
-      <source file='/root/boot1.iso'/>
-      <target dev='vda' bus='virtio'/>
-      <readonly/>
-      <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
-    </disk>
-    <disk type='file' device='cdrom'>
-      <driver name='qemu' type='raw' cache='none'/>
-      <target dev='vdb' bus='virtio'/>
-      <readonly/>
-      <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
-    </disk>
     <disk type='file' device='cdrom'>
       <driver name='qemu' type='raw'/>
       <source file='/root/boot2.iso'/>
diff --git a/tests/qemuxml2xmloutdata/pci-autofill-addr.xml b/tests/qemuxml2xmloutdata/pci-autofill-addr.xml
index 581d42f11e..84cf1043e3 100644
--- a/tests/qemuxml2xmloutdata/pci-autofill-addr.xml
+++ b/tests/qemuxml2xmloutdata/pci-autofill-addr.xml
@@ -14,7 +14,7 @@
   <on_crash>destroy</on_crash>
   <devices>
     <emulator>/usr/bin/qemu-system-x86_64</emulator>
-    <disk type='file' device='cdrom'>
+    <disk type='file' device='disk'>
       <driver name='qemu' type='raw'/>
       <source file='/var/iso/f18kde.iso'/>
       <target dev='vda' bus='virtio'/>
-- 
2.20.1

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[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