On 7/6/22 11:57, minglei.liu wrote:
Qemu support hotplug cdrom device with usb or scsi bus,
just unblock these devices in qemuDomainAttachDeviceDiskLiveInternal
and qemuDomainDetachPrepDisk.
Fixes: #261
We like the full URL as it's easily clickable when viewing git log.
Signed-off-by: minglei.liu <minglei.liu(a)smartx.com>
---
src/qemu/qemu_hotplug.c | 13 +++-
tests/qemuhotplugtest.c | 18 ++++++
.../qemuhotplug-cdrom-scsi.xml | 6 ++
.../qemuhotplug-cdrom-usb.xml | 6 ++
.../qemuhotplug-base-live+cdrom-scsi.xml | 60 +++++++++++++++++++
.../qemuhotplug-base-live+cdrom-usb.xml | 60 +++++++++++++++++++
6 files changed, 160 insertions(+), 3 deletions(-)
create mode 100644 tests/qemuhotplugtestdevices/qemuhotplug-cdrom-scsi.xml
create mode 100644 tests/qemuhotplugtestdevices/qemuhotplug-cdrom-usb.xml
create mode 100644 tests/qemuhotplugtestdomains/qemuhotplug-base-live+cdrom-scsi.xml
create mode 100644 tests/qemuhotplugtestdomains/qemuhotplug-base-live+cdrom-usb.xml
diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
index 27e68370cf..d917086023 100644
--- a/src/qemu/qemu_hotplug.c
+++ b/src/qemu/qemu_hotplug.c
@@ -992,10 +992,9 @@ qemuDomainAttachDeviceDiskLiveInternal(virQEMUDriver *driver,
bool releaseSeclabel = false;
int ret = -1;
- if (disk->device == VIR_DOMAIN_DISK_DEVICE_CDROM ||
- disk->device == VIR_DOMAIN_DISK_DEVICE_FLOPPY) {
+ if (disk->device == VIR_DOMAIN_DISK_DEVICE_FLOPPY) {
virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s",
- _("cdrom/floppy device hotplug isn't supported"));
+ _("floppy device hotplug isn't supported"));
return -1;
}
@@ -1025,6 +1024,10 @@ qemuDomainAttachDeviceDiskLiveInternal(virQEMUDriver *driver,
break;
case VIR_DOMAIN_DISK_BUS_VIRTIO:
+ if (disk->device == VIR_DOMAIN_DISK_DEVICE_CDROM) {
+ virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s",
+ _("cdrom device with virtio bus isn't supported"));
Alignment.
+ }
if (qemuDomainEnsureVirtioAddress(&releaseVirtio, vm, dev) < 0)
goto cleanup;
break;
@@ -5414,6 +5417,10 @@ qemuDomainDetachPrepDisk(virDomainObj *vm,
case VIR_DOMAIN_DISK_DEVICE_CDROM:
case VIR_DOMAIN_DISK_DEVICE_FLOPPY:
+ if ((virDomainDiskBus) disk->bus == VIR_DOMAIN_DISK_BUS_USB ||
+ (virDomainDiskBus) disk->bus == VIR_DOMAIN_DISK_BUS_SCSI) {
No need for typecasting here. However, this allows floppy hotunplug
which I believe is not supported on QEMU side.
+ break;
+ }
virReportError(VIR_ERR_OPERATION_UNSUPPORTED,
_("disk device type '%s' cannot be detached"),
virDomainDiskDeviceTypeToString(disk->device));
I'm fixing all these minor issues before pushing.
Reviewed-by: Michal Privoznik <mprivozn(a)redhat.com>
Congratulations on your first libvirt contribution!
Michal