mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-03-07 17:28:15 +00:00
qemu: Honor the original properties of PCI device when detaching
This patch fixes two problems: 1) The device will be reattached to host even if it's not managed, as there is a "pciDeviceSetManaged". 2) The device won't be reattached to host with original driver properly. As it doesn't honor the device original properties which are maintained by driver->activePciHostdevs.
This commit is contained in:
parent
6e53293812
commit
a0aec362e8
@ -1960,6 +1960,7 @@ int qemuDomainDetachHostPciDevice(struct qemud_driver *driver,
|
|||||||
qemuDomainObjPrivatePtr priv = vm->privateData;
|
qemuDomainObjPrivatePtr priv = vm->privateData;
|
||||||
int i, ret;
|
int i, ret;
|
||||||
pciDevice *pci;
|
pciDevice *pci;
|
||||||
|
pciDevice *activePci;
|
||||||
|
|
||||||
for (i = 0 ; i < vm->def->nhostdevs ; i++) {
|
for (i = 0 ; i < vm->def->nhostdevs ; i++) {
|
||||||
if (vm->def->hostdevs[i]->mode != VIR_DOMAIN_HOSTDEV_MODE_SUBSYS ||
|
if (vm->def->hostdevs[i]->mode != VIR_DOMAIN_HOSTDEV_MODE_SUBSYS ||
|
||||||
@ -2019,16 +2020,16 @@ int qemuDomainDetachHostPciDevice(struct qemud_driver *driver,
|
|||||||
detach->source.subsys.u.pci.bus,
|
detach->source.subsys.u.pci.bus,
|
||||||
detach->source.subsys.u.pci.slot,
|
detach->source.subsys.u.pci.slot,
|
||||||
detach->source.subsys.u.pci.function);
|
detach->source.subsys.u.pci.function);
|
||||||
if (!pci)
|
if (pci) {
|
||||||
|
activePci = pciDeviceListSteal(driver->activePciHostdevs, pci);
|
||||||
|
if (pciResetDevice(activePci, driver->activePciHostdevs, NULL))
|
||||||
|
qemuReattachPciDevice(activePci, driver);
|
||||||
|
else
|
||||||
ret = -1;
|
ret = -1;
|
||||||
else {
|
|
||||||
pciDeviceSetManaged(pci, detach->managed);
|
|
||||||
pciDeviceListDel(driver->activePciHostdevs, pci);
|
|
||||||
if (pciResetDevice(pci, driver->activePciHostdevs, NULL) < 0)
|
|
||||||
ret = -1;
|
|
||||||
pciDeviceReAttachInit(pci);
|
|
||||||
qemuReattachPciDevice(pci, driver);
|
|
||||||
pciFreeDevice(pci);
|
pciFreeDevice(pci);
|
||||||
|
pciFreeDevice(activePci);
|
||||||
|
} else {
|
||||||
|
ret = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (qemuCapsGet(priv->qemuCaps, QEMU_CAPS_DEVICE) &&
|
if (qemuCapsGet(priv->qemuCaps, QEMU_CAPS_DEVICE) &&
|
||||||
|
Loading…
x
Reference in New Issue
Block a user