qemu: Forbid 'cdrom' on 'sd' bus

We can't set the type of the device on the 'sd' bus and realistically a
cdrom doesn't even make sense there. Forbid it.

Note that the output of in disk-cdrom-bus-other.x86_64-latest.args
switched to blockdev as it's no longer locked out due to use of a disk
on 'sd' bus.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
Peter Krempa 2020-05-06 12:09:47 +02:00
parent 7288da8dc8
commit 59a3adbcf2
4 changed files with 9 additions and 31 deletions

View File

@ -1946,9 +1946,10 @@ qemuValidateDomainDeviceDefDiskFrontend(const virDomainDiskDef *disk,
}
if (disk->device == VIR_DOMAIN_DISK_DEVICE_CDROM &&
disk->bus == VIR_DOMAIN_DISK_BUS_VIRTIO) {
(disk->bus == VIR_DOMAIN_DISK_BUS_VIRTIO ||
disk->bus == VIR_DOMAIN_DISK_BUS_SD)) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("disk type 'virtio' of '%s' does not support ejectable media"),
_("disk type of '%s' does not support ejectable media"),
disk->dst);
return -1;
}

View File

@ -28,14 +28,13 @@ 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=/root/boot.iso,format=raw,if=none,id=drive-usb-disk0,readonly=on \
-device usb-storage,bus=usb.0,port=1,drive=drive-usb-disk0,id=usb-disk0,\
-blockdev '{"driver":"file","filename":"/root/boot.iso",\
"node-name":"libvirt-2-storage","auto-read-only":true,"discard":"unmap"}' \
-blockdev '{"node-name":"libvirt-2-format","read-only":true,"driver":"raw",\
"file":"libvirt-2-storage"}' \
-device usb-storage,bus=usb.0,port=1,drive=libvirt-2-format,id=usb-disk0,\
removable=off \
-drive if=none,id=drive-usb-disk1,readonly=on \
-device usb-storage,bus=usb.0,port=2,drive=drive-usb-disk1,id=usb-disk1,\
removable=off \
-drive file=/root/boot2.iso,format=raw,if=sd,index=2,readonly=on \
-drive if=sd,index=3,readonly=on \
-device usb-storage,bus=usb.0,port=2,id=usb-disk1,removable=off \
-sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,\
resourcecontrol=deny \
-msg timestamp=on

View File

@ -26,17 +26,6 @@
<target dev='sdb' bus='usb'/>
<readonly/>
</disk>
<disk type='file' device='cdrom'>
<driver name='qemu' type='raw'/>
<source file='/root/boot2.iso'/>
<target dev='sdc' bus='sd'/>
<readonly/>
</disk>
<disk type='file' device='cdrom'>
<driver name='qemu' type='raw'/>
<target dev='sdd' bus='sd'/>
<readonly/>
</disk>
<controller type='usb' index='0'/>
<controller type='ide' index='0'/>
<controller type='pci' index='0' model='pci-root'/>

View File

@ -26,17 +26,6 @@
<target dev='sdb' bus='usb'/>
<readonly/>
</disk>
<disk type='file' device='cdrom'>
<driver name='qemu' type='raw'/>
<source file='/root/boot2.iso'/>
<target dev='sdc' bus='sd'/>
<readonly/>
</disk>
<disk type='file' device='cdrom'>
<driver name='qemu' type='raw'/>
<target dev='sdd' bus='sd'/>
<readonly/>
</disk>
<controller type='usb' index='0'>
<address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/>
</controller>