qemu: command: Drop formatting of 'media=cdrom' from -drive

For SCSI, IDE, and AHCI cdroms the appropriate device types which select
the correct media are used. In qemu there's one other code path that
looks at -drive media=cdrom in the XEN pv code. Thankfully we don't
support it with qemu (see qemuBuildDiskDeviceStr). All other devices
ignore it as the comment states, thus we can drop that code.

The test fallout is expectedly only in the test added for uncommon cdrom
types.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
This commit is contained in:
Peter Krempa 2019-01-28 17:18:56 +01:00
parent ea13c12940
commit 1328a830ce
2 changed files with 4 additions and 14 deletions

View File

@ -1757,15 +1757,6 @@ qemuBuildDriveStr(virDomainDiskDefPtr disk,
if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_USB_STORAGE_WERROR))
qemuBuildDiskFrontendAttributeErrorPolicy(disk, &opt);
/* While this is a frontend attribute, it only makes sense to be used when
* legacy -drive is used. In modern qemu the 'ide-cd' or 'scsi-cd' are used.
* virtio and other just ignore the attribute anyways */
if (disk->device == VIR_DOMAIN_DISK_DEVICE_CDROM &&
disk->bus != VIR_DOMAIN_DISK_BUS_SCSI &&
disk->bus != VIR_DOMAIN_DISK_BUS_IDE)
virBufferAddLit(&opt, ",media=cdrom");
if (disk->src->readonly)
virBufferAddLit(&opt, ",readonly=on");

View File

@ -24,15 +24,14 @@ 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,media=cdrom,\
readonly=on \
-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,\
removable=off \
-drive if=none,id=drive-usb-disk1,media=cdrom,readonly=on \
-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,media=cdrom,readonly=on \
-drive if=sd,index=3,media=cdrom,readonly=on \
-drive file=/root/boot2.iso,format=raw,if=sd,index=2,readonly=on \
-drive if=sd,index=3,readonly=on \
-sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,\
resourcecontrol=deny \
-msg timestamp=on