mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-10-01 20:05:46 +00:00
qemu: support CDROM hotplug cdrom with USB/SCSI bus
QEMU supports hotplug of a cdrom device with USB or SCSI bus. Just unblock these devices in qemuDomainAttachDeviceDiskLiveInternal() and qemuDomainDetachPrepDisk(). Fixes: https://gitlab.com/libvirt/libvirt/-/issues/261 Signed-off-by: minglei.liu <minglei.liu@smartx.com> Signed-off-by: Michal Privoznik <mprivozn@redhat.com> Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
7b28561c85
commit
3078799fef
@ -992,10 +992,9 @@ qemuDomainAttachDeviceDiskLiveInternal(virQEMUDriver *driver,
|
|||||||
bool releaseSeclabel = false;
|
bool releaseSeclabel = false;
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
|
|
||||||
if (disk->device == VIR_DOMAIN_DISK_DEVICE_CDROM ||
|
if (disk->device == VIR_DOMAIN_DISK_DEVICE_FLOPPY) {
|
||||||
disk->device == VIR_DOMAIN_DISK_DEVICE_FLOPPY) {
|
|
||||||
virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s",
|
virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s",
|
||||||
_("cdrom/floppy device hotplug isn't supported"));
|
_("floppy device hotplug isn't supported"));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1025,6 +1024,10 @@ qemuDomainAttachDeviceDiskLiveInternal(virQEMUDriver *driver,
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case VIR_DOMAIN_DISK_BUS_VIRTIO:
|
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"));
|
||||||
|
}
|
||||||
if (qemuDomainEnsureVirtioAddress(&releaseVirtio, vm, dev) < 0)
|
if (qemuDomainEnsureVirtioAddress(&releaseVirtio, vm, dev) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
break;
|
break;
|
||||||
@ -5413,6 +5416,12 @@ qemuDomainDetachPrepDisk(virDomainObj *vm,
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case VIR_DOMAIN_DISK_DEVICE_CDROM:
|
case VIR_DOMAIN_DISK_DEVICE_CDROM:
|
||||||
|
if (disk->bus == VIR_DOMAIN_DISK_BUS_USB ||
|
||||||
|
disk->bus == VIR_DOMAIN_DISK_BUS_SCSI) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
G_GNUC_FALLTHROUGH;
|
||||||
|
|
||||||
case VIR_DOMAIN_DISK_DEVICE_FLOPPY:
|
case VIR_DOMAIN_DISK_DEVICE_FLOPPY:
|
||||||
virReportError(VIR_ERR_OPERATION_UNSUPPORTED,
|
virReportError(VIR_ERR_OPERATION_UNSUPPORTED,
|
||||||
_("disk device type '%s' cannot be detached"),
|
_("disk device type '%s' cannot be detached"),
|
||||||
|
@ -860,6 +860,24 @@ mymain(void)
|
|||||||
DO_TEST_DETACH("base-live", "guestfwd", false, false,
|
DO_TEST_DETACH("base-live", "guestfwd", false, false,
|
||||||
"netdev_del", QMP_OK);
|
"netdev_del", QMP_OK);
|
||||||
|
|
||||||
|
DO_TEST_ATTACH("base-live", "cdrom-usb", false, true,
|
||||||
|
"human-monitor-command", HMP("OK\\r\\n"),
|
||||||
|
"device_add", QMP_OK);
|
||||||
|
DO_TEST_DETACH("base-live", "cdrom-usb", true, true,
|
||||||
|
"device_del", QMP_OK);
|
||||||
|
DO_TEST_DETACH("base-live", "cdrom-usb", false, false,
|
||||||
|
"device_del", QMP_DEVICE_DELETED("usb-disk4") QMP_OK,
|
||||||
|
"human-monitor-command", HMP(""));
|
||||||
|
|
||||||
|
DO_TEST_ATTACH("base-live", "cdrom-scsi", false, true,
|
||||||
|
"human-monitor-command", HMP("OK\\r\\n"),
|
||||||
|
"device_add", QMP_OK);
|
||||||
|
DO_TEST_DETACH("base-live", "cdrom-scsi", true, true,
|
||||||
|
"device_del", QMP_OK);
|
||||||
|
DO_TEST_DETACH("base-live", "cdrom-scsi", false, false,
|
||||||
|
"device_del", QMP_DEVICE_DELETED("scsi0-0-0-4") QMP_OK,
|
||||||
|
"human-monitor-command", HMP(""));
|
||||||
|
|
||||||
#define DO_TEST_CPU_GROUP(prefix, vcpus, modernhp, expectfail) \
|
#define DO_TEST_CPU_GROUP(prefix, vcpus, modernhp, expectfail) \
|
||||||
do { \
|
do { \
|
||||||
cpudata.test = prefix; \
|
cpudata.test = prefix; \
|
||||||
|
6
tests/qemuhotplugtestdevices/qemuhotplug-cdrom-scsi.xml
Normal file
6
tests/qemuhotplugtestdevices/qemuhotplug-cdrom-scsi.xml
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
<disk type='file' device='cdrom'>
|
||||||
|
<driver name='qemu' type='raw' cache='none'/>
|
||||||
|
<source file='/dev/null'/>
|
||||||
|
<target dev='sde' bus='scsi'/>
|
||||||
|
<readonly/>
|
||||||
|
</disk>
|
6
tests/qemuhotplugtestdevices/qemuhotplug-cdrom-usb.xml
Normal file
6
tests/qemuhotplugtestdevices/qemuhotplug-cdrom-usb.xml
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
<disk type='file' device='cdrom'>
|
||||||
|
<driver name='qemu' type='raw' cache='none'/>
|
||||||
|
<source file='/dev/null'/>
|
||||||
|
<target dev='sde' bus='usb'/>
|
||||||
|
<readonly/>
|
||||||
|
</disk>
|
@ -0,0 +1,60 @@
|
|||||||
|
<domain type='kvm' id='7'>
|
||||||
|
<name>hotplug</name>
|
||||||
|
<uuid>d091ea82-29e6-2e34-3005-f02617b36e87</uuid>
|
||||||
|
<memory unit='KiB'>4194304</memory>
|
||||||
|
<currentMemory unit='KiB'>4194304</currentMemory>
|
||||||
|
<vcpu placement='static'>4</vcpu>
|
||||||
|
<os>
|
||||||
|
<type arch='x86_64' machine='pc'>hvm</type>
|
||||||
|
<boot dev='hd'/>
|
||||||
|
</os>
|
||||||
|
<features>
|
||||||
|
<acpi/>
|
||||||
|
<apic/>
|
||||||
|
<pae/>
|
||||||
|
</features>
|
||||||
|
<clock offset='utc'/>
|
||||||
|
<on_poweroff>destroy</on_poweroff>
|
||||||
|
<on_reboot>restart</on_reboot>
|
||||||
|
<on_crash>restart</on_crash>
|
||||||
|
<devices>
|
||||||
|
<emulator>/usr/bin/qemu-system-x86_64</emulator>
|
||||||
|
<disk type='file' device='cdrom'>
|
||||||
|
<driver name='qemu' type='raw' cache='none'/>
|
||||||
|
<source file='/dev/null'/>
|
||||||
|
<backingStore/>
|
||||||
|
<target dev='sde' bus='scsi'/>
|
||||||
|
<readonly/>
|
||||||
|
<alias name='scsi0-0-0-4'/>
|
||||||
|
<address type='drive' controller='0' bus='0' target='0' unit='4'/>
|
||||||
|
</disk>
|
||||||
|
<controller type='usb' index='0'>
|
||||||
|
<alias name='usb'/>
|
||||||
|
<address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/>
|
||||||
|
</controller>
|
||||||
|
<controller type='ide' index='0'>
|
||||||
|
<alias name='ide'/>
|
||||||
|
<address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/>
|
||||||
|
</controller>
|
||||||
|
<controller type='scsi' index='0' model='virtio-scsi'>
|
||||||
|
<alias name='scsi0'/>
|
||||||
|
<address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
|
||||||
|
</controller>
|
||||||
|
<controller type='pci' index='0' model='pci-root'>
|
||||||
|
<alias name='pci'/>
|
||||||
|
</controller>
|
||||||
|
<controller type='virtio-serial' index='0'>
|
||||||
|
<alias name='virtio-serial0'/>
|
||||||
|
<address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
|
||||||
|
</controller>
|
||||||
|
<input type='mouse' bus='ps2'>
|
||||||
|
<alias name='input0'/>
|
||||||
|
</input>
|
||||||
|
<input type='keyboard' bus='ps2'>
|
||||||
|
<alias name='input1'/>
|
||||||
|
</input>
|
||||||
|
<audio id='1' type='none'/>
|
||||||
|
<memballoon model='none'/>
|
||||||
|
</devices>
|
||||||
|
<seclabel type='none' model='none'/>
|
||||||
|
</domain>
|
@ -0,0 +1,60 @@
|
|||||||
|
<domain type='kvm' id='7'>
|
||||||
|
<name>hotplug</name>
|
||||||
|
<uuid>d091ea82-29e6-2e34-3005-f02617b36e87</uuid>
|
||||||
|
<memory unit='KiB'>4194304</memory>
|
||||||
|
<currentMemory unit='KiB'>4194304</currentMemory>
|
||||||
|
<vcpu placement='static'>4</vcpu>
|
||||||
|
<os>
|
||||||
|
<type arch='x86_64' machine='pc'>hvm</type>
|
||||||
|
<boot dev='hd'/>
|
||||||
|
</os>
|
||||||
|
<features>
|
||||||
|
<acpi/>
|
||||||
|
<apic/>
|
||||||
|
<pae/>
|
||||||
|
</features>
|
||||||
|
<clock offset='utc'/>
|
||||||
|
<on_poweroff>destroy</on_poweroff>
|
||||||
|
<on_reboot>restart</on_reboot>
|
||||||
|
<on_crash>restart</on_crash>
|
||||||
|
<devices>
|
||||||
|
<emulator>/usr/bin/qemu-system-x86_64</emulator>
|
||||||
|
<disk type='file' device='cdrom'>
|
||||||
|
<driver name='qemu' type='raw' cache='none'/>
|
||||||
|
<source file='/dev/null'/>
|
||||||
|
<backingStore/>
|
||||||
|
<target dev='sde' bus='usb'/>
|
||||||
|
<readonly/>
|
||||||
|
<alias name='usb-disk4'/>
|
||||||
|
<address type='usb' bus='0' port='1'/>
|
||||||
|
</disk>
|
||||||
|
<controller type='usb' index='0'>
|
||||||
|
<alias name='usb'/>
|
||||||
|
<address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/>
|
||||||
|
</controller>
|
||||||
|
<controller type='ide' index='0'>
|
||||||
|
<alias name='ide'/>
|
||||||
|
<address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/>
|
||||||
|
</controller>
|
||||||
|
<controller type='scsi' index='0' model='virtio-scsi'>
|
||||||
|
<alias name='scsi0'/>
|
||||||
|
<address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
|
||||||
|
</controller>
|
||||||
|
<controller type='pci' index='0' model='pci-root'>
|
||||||
|
<alias name='pci'/>
|
||||||
|
</controller>
|
||||||
|
<controller type='virtio-serial' index='0'>
|
||||||
|
<alias name='virtio-serial0'/>
|
||||||
|
<address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
|
||||||
|
</controller>
|
||||||
|
<input type='mouse' bus='ps2'>
|
||||||
|
<alias name='input0'/>
|
||||||
|
</input>
|
||||||
|
<input type='keyboard' bus='ps2'>
|
||||||
|
<alias name='input1'/>
|
||||||
|
</input>
|
||||||
|
<audio id='1' type='none'/>
|
||||||
|
<memballoon model='none'/>
|
||||||
|
</devices>
|
||||||
|
<seclabel type='none' model='none'/>
|
||||||
|
</domain>
|
Loading…
Reference in New Issue
Block a user