mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-24 14:45:24 +00:00
qemu: support persistent hotplug of <hostdev> devices
For some reason, although live hotplug of <hostdev> devices is supported, persistent hotplug is not. This patch adds the proper VIR_DOMAIN_DEVICE_HOSTDEV cases to the switches in qemuDomainAttachDeviceConfig and qemuDomainDetachDeviceConfig.
This commit is contained in:
parent
0208face59
commit
edb6fc3a7f
@ -5367,6 +5367,7 @@ qemuDomainAttachDeviceConfig(virDomainDefPtr vmdef,
|
|||||||
{
|
{
|
||||||
virDomainDiskDefPtr disk;
|
virDomainDiskDefPtr disk;
|
||||||
virDomainNetDefPtr net;
|
virDomainNetDefPtr net;
|
||||||
|
virDomainHostdevDefPtr hostdev;
|
||||||
virDomainLeaseDefPtr lease;
|
virDomainLeaseDefPtr lease;
|
||||||
|
|
||||||
switch (dev->type) {
|
switch (dev->type) {
|
||||||
@ -5408,6 +5409,22 @@ qemuDomainAttachDeviceConfig(virDomainDefPtr vmdef,
|
|||||||
return -1;
|
return -1;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case VIR_DOMAIN_DEVICE_HOSTDEV:
|
||||||
|
hostdev = dev->data.hostdev;
|
||||||
|
if (virDomainHostdevFind(vmdef, hostdev, NULL) >= 0) {
|
||||||
|
qemuReportError(VIR_ERR_INVALID_ARG, "%s",
|
||||||
|
_("device is already in the domain configuration"));
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
if (virDomainHostdevInsert(vmdef, hostdev)) {
|
||||||
|
virReportOOMError();
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
dev->data.hostdev = NULL;
|
||||||
|
if (qemuDomainAssignAddresses(vmdef) < 0)
|
||||||
|
return -1;
|
||||||
|
break;
|
||||||
|
|
||||||
case VIR_DOMAIN_DEVICE_LEASE:
|
case VIR_DOMAIN_DEVICE_LEASE:
|
||||||
lease = dev->data.lease;
|
lease = dev->data.lease;
|
||||||
if (virDomainLeaseIndex(vmdef, lease) >= 0) {
|
if (virDomainLeaseIndex(vmdef, lease) >= 0) {
|
||||||
@ -5438,6 +5455,7 @@ qemuDomainDetachDeviceConfig(virDomainDefPtr vmdef,
|
|||||||
{
|
{
|
||||||
virDomainDiskDefPtr disk, det_disk;
|
virDomainDiskDefPtr disk, det_disk;
|
||||||
virDomainNetDefPtr net, det_net;
|
virDomainNetDefPtr net, det_net;
|
||||||
|
virDomainHostdevDefPtr hostdev, det_hostdev;
|
||||||
virDomainLeaseDefPtr lease, det_lease;
|
virDomainLeaseDefPtr lease, det_lease;
|
||||||
|
|
||||||
switch (dev->type) {
|
switch (dev->type) {
|
||||||
@ -5464,6 +5482,20 @@ qemuDomainDetachDeviceConfig(virDomainDefPtr vmdef,
|
|||||||
virDomainNetDefFree(det_net);
|
virDomainNetDefFree(det_net);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case VIR_DOMAIN_DEVICE_HOSTDEV: {
|
||||||
|
int idx;
|
||||||
|
|
||||||
|
hostdev = dev->data.hostdev;
|
||||||
|
if ((idx = virDomainHostdevFind(vmdef, hostdev, &det_hostdev)) < 0) {
|
||||||
|
qemuReportError(VIR_ERR_INVALID_ARG, "%s",
|
||||||
|
_("device not present in domain configuration"));
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
virDomainHostdevRemove(vmdef, idx);
|
||||||
|
virDomainHostdevDefFree(det_hostdev);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case VIR_DOMAIN_DEVICE_LEASE:
|
case VIR_DOMAIN_DEVICE_LEASE:
|
||||||
lease = dev->data.lease;
|
lease = dev->data.lease;
|
||||||
if (!(det_lease = virDomainLeaseRemove(vmdef, lease))) {
|
if (!(det_lease = virDomainLeaseRemove(vmdef, lease))) {
|
||||||
|
Loading…
Reference in New Issue
Block a user