From 59a3adbcf268192960e9b52fddc08c5c3b94bfd7 Mon Sep 17 00:00:00 2001 From: Peter Krempa Date: Wed, 6 May 2020 12:09:47 +0200 Subject: [PATCH] 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 Reviewed-by: Michal Privoznik --- src/qemu/qemu_validate.c | 5 +++-- .../disk-cdrom-bus-other.x86_64-latest.args | 13 ++++++------- tests/qemuxml2argvdata/disk-cdrom-bus-other.xml | 11 ----------- tests/qemuxml2xmloutdata/disk-cdrom-bus-other.xml | 11 ----------- 4 files changed, 9 insertions(+), 31 deletions(-) diff --git a/src/qemu/qemu_validate.c b/src/qemu/qemu_validate.c index a7c918e5fd..f49181b639 100644 --- a/src/qemu/qemu_validate.c +++ b/src/qemu/qemu_validate.c @@ -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; } 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 b1c30dd4d8..be091f150f 100644 --- a/tests/qemuxml2argvdata/disk-cdrom-bus-other.x86_64-latest.args +++ b/tests/qemuxml2argvdata/disk-cdrom-bus-other.x86_64-latest.args @@ -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 diff --git a/tests/qemuxml2argvdata/disk-cdrom-bus-other.xml b/tests/qemuxml2argvdata/disk-cdrom-bus-other.xml index e73db8c6ab..e6bf1ea797 100644 --- a/tests/qemuxml2argvdata/disk-cdrom-bus-other.xml +++ b/tests/qemuxml2argvdata/disk-cdrom-bus-other.xml @@ -26,17 +26,6 @@ - - - - - - - - - - - diff --git a/tests/qemuxml2xmloutdata/disk-cdrom-bus-other.xml b/tests/qemuxml2xmloutdata/disk-cdrom-bus-other.xml index 10262e40d7..ec86d19f1d 100644 --- a/tests/qemuxml2xmloutdata/disk-cdrom-bus-other.xml +++ b/tests/qemuxml2xmloutdata/disk-cdrom-bus-other.xml @@ -26,17 +26,6 @@ - - - - - - - - - - -