提交 5d884f3d 编写于 作者: P Peter Krempa

qemu: Forbid cdroms on virtio bus

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: NPeter Krempa <pkrempa@redhat.com>
上级 6b67eeef
......@@ -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;
}
......
......@@ -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>
......
......@@ -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
......@@ -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'/>
......
......@@ -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'/>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册