mirror of https://gitee.com/openkylin/libvirt.git
qemu: hotplug: Introduce hot unplug for mediated devices
Mediated devices support hot-{plug,unplug} since their introduction in kernel 4.10, however libvirt has still been missing support for this. Signed-off-by: Erik Skultety <eskultet@redhat.com>
This commit is contained in:
parent
70d193de19
commit
5905291402
|
@ -4030,6 +4030,17 @@ qemuDomainRemoveSCSIVHostDevice(virQEMUDriverPtr driver,
|
||||||
qemuHostdevReAttachSCSIVHostDevices(driver, vm->def->name, &hostdev, 1);
|
qemuHostdevReAttachSCSIVHostDevices(driver, vm->def->name, &hostdev, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
qemuDomainRemoveMediatedDevice(virQEMUDriverPtr driver,
|
||||||
|
virDomainObjPtr vm,
|
||||||
|
virDomainHostdevDefPtr hostdev)
|
||||||
|
{
|
||||||
|
qemuHostdevReAttachMediatedDevices(driver, vm->def->name, &hostdev, 1);
|
||||||
|
qemuDomainReleaseDeviceAddress(vm, hostdev->info, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
qemuDomainRemoveHostDevice(virQEMUDriverPtr driver,
|
qemuDomainRemoveHostDevice(virQEMUDriverPtr driver,
|
||||||
virDomainObjPtr vm,
|
virDomainObjPtr vm,
|
||||||
|
@ -4132,6 +4143,7 @@ qemuDomainRemoveHostDevice(virQEMUDriverPtr driver,
|
||||||
qemuDomainRemoveSCSIVHostDevice(driver, vm, hostdev);
|
qemuDomainRemoveSCSIVHostDevice(driver, vm, hostdev);
|
||||||
break;
|
break;
|
||||||
case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_MDEV:
|
case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_MDEV:
|
||||||
|
qemuDomainRemoveMediatedDevice(driver, vm, hostdev);
|
||||||
break;
|
break;
|
||||||
case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_LAST:
|
case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_LAST:
|
||||||
break;
|
break;
|
||||||
|
@ -5062,6 +5074,32 @@ qemuDomainDetachSCSIVHostDevice(virQEMUDriverPtr driver,
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static int
|
||||||
|
qemuDomainDetachMediatedDevice(virQEMUDriverPtr driver,
|
||||||
|
virDomainObjPtr vm,
|
||||||
|
virDomainHostdevDefPtr detach)
|
||||||
|
{
|
||||||
|
int ret = -1;
|
||||||
|
qemuDomainObjPrivatePtr priv = vm->privateData;
|
||||||
|
|
||||||
|
if (!detach->info->alias) {
|
||||||
|
virReportError(VIR_ERR_OPERATION_FAILED, "%s",
|
||||||
|
_("device cannot be detached without a device alias"));
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
qemuDomainMarkDeviceForRemoval(vm, detach->info);
|
||||||
|
|
||||||
|
qemuDomainObjEnterMonitor(driver, vm);
|
||||||
|
ret = qemuMonitorDelDevice(priv->mon, detach->info->alias);
|
||||||
|
if (qemuDomainObjExitMonitor(driver, vm) < 0)
|
||||||
|
ret = -1;
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
qemuDomainDetachThisHostDevice(virQEMUDriverPtr driver,
|
qemuDomainDetachThisHostDevice(virQEMUDriverPtr driver,
|
||||||
virDomainObjPtr vm,
|
virDomainObjPtr vm,
|
||||||
|
@ -5085,6 +5123,9 @@ qemuDomainDetachThisHostDevice(virQEMUDriverPtr driver,
|
||||||
case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI_HOST:
|
case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI_HOST:
|
||||||
ret = qemuDomainDetachSCSIVHostDevice(driver, vm, detach);
|
ret = qemuDomainDetachSCSIVHostDevice(driver, vm, detach);
|
||||||
break;
|
break;
|
||||||
|
case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_MDEV:
|
||||||
|
ret = qemuDomainDetachMediatedDevice(driver, vm, detach);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
||||||
_("hot unplug is not supported for hostdev subsys type '%s'"),
|
_("hot unplug is not supported for hostdev subsys type '%s'"),
|
||||||
|
@ -5114,6 +5155,7 @@ int qemuDomainDetachHostDevice(virQEMUDriverPtr driver,
|
||||||
virDomainHostdevSubsysUSBPtr usbsrc = &subsys->u.usb;
|
virDomainHostdevSubsysUSBPtr usbsrc = &subsys->u.usb;
|
||||||
virDomainHostdevSubsysPCIPtr pcisrc = &subsys->u.pci;
|
virDomainHostdevSubsysPCIPtr pcisrc = &subsys->u.pci;
|
||||||
virDomainHostdevSubsysSCSIPtr scsisrc = &subsys->u.scsi;
|
virDomainHostdevSubsysSCSIPtr scsisrc = &subsys->u.scsi;
|
||||||
|
virDomainHostdevSubsysMediatedDevPtr mdevsrc = &subsys->u.mdev;
|
||||||
virDomainHostdevDefPtr detach = NULL;
|
virDomainHostdevDefPtr detach = NULL;
|
||||||
int idx;
|
int idx;
|
||||||
|
|
||||||
|
@ -5162,6 +5204,11 @@ int qemuDomainDetachHostDevice(virQEMUDriverPtr driver,
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_MDEV:
|
||||||
|
virReportError(VIR_ERR_DEVICE_MISSING,
|
||||||
|
_("mediated device '%s' not found"),
|
||||||
|
mdevsrc->uuidstr);
|
||||||
|
break;
|
||||||
case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI_HOST:
|
case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI_HOST:
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
|
Loading…
Reference in New Issue