]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemu: Forbid cdroms on virtio bus
authorPeter Krempa <pkrempa@redhat.com>
Mon, 28 Jan 2019 16:18:55 +0000 (17:18 +0100)
committerPeter Krempa <pkrempa@redhat.com>
Fri, 8 Feb 2019 07:41:40 +0000 (08:41 +0100)
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.

Fix few wrong examples which are not really relevant to the tested code.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
src/qemu/qemu_domain.c
tests/qemuxml2argvdata/disk-scsi-disk-vpd-build-error.xml
tests/qemuxml2argvdata/pci-autofill-addr.args
tests/qemuxml2argvdata/pci-autofill-addr.xml
tests/qemuxml2xmloutdata/pci-autofill-addr.xml

index b6c1a0e4e5841d39bcec4f3499fa53da3052841a..fde0f9e19ecfd081a44c0a43144bc7c2c50de23e 100644 (file)
@@ -5078,6 +5078,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;
 }
 
index e116aff11412eac7d1b5cc32e8d443fd51ae3ef7..6c83715be20fc542351157a304c4f6375def1763 100644 (file)
@@ -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>
index b546443db32db378312b813232907f7fa440c687..1508787f8bf5da26b0dc38f1de23e9e56755fe6d 100644 (file)
@@ -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
index 0d10ec863515f30e73aeb937b439a8c1d1804b0d..a601c50ab938edf146dbfd6f5810a6fff12654d0 100644 (file)
@@ -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'/>
index 581d42f11ef0a146f452c666c3e838ac851a1d3a..84cf1043e3a5875e5ec3a80daeec684258e12924 100644 (file)
@@ -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'/>