On 10/17/2011 05:07 AM, Osier Yang wrote:
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. --- src/qemu/qemu_hotplug.c | 16 ++++++++-------- 1 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index bfa524b..f3f0060 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -1956,6 +1956,7 @@ int qemuDomainDetachHostPciDevice(struct qemud_driver *driver, qemuDomainObjPrivatePtr priv = vm->privateData; int i, ret; pciDevice *pci; + pciDevice *activePci; for (i = 0 ; i< vm->def->nhostdevs ; i++) { if (vm->def->hostdevs[i]->mode != VIR_DOMAIN_HOSTDEV_MODE_SUBSYS || @@ -2015,16 +2016,15 @@ int qemuDomainDetachHostPciDevice(struct qemud_driver *driver, detach->source.subsys.u.pci.bus, detach->source.subsys.u.pci.slot, detach->source.subsys.u.pci.function); - if (!pci) - ret = -1; - else { - pciDeviceSetManaged(pci, detach->managed); - pciDeviceListDel(driver->activePciHostdevs, pci); - if (pciResetDevice(pci, driver->activePciHostdevs, NULL)< 0) + if (pci) { + activePci = pciDeviceListSteal(driver->activePciHostdevs, pci); + if (pciResetDevice(activePci, driver->activePciHostdevs, NULL)< 0) ret = -1; - pciDeviceReAttachInit(pci); - qemuReattachPciDevice(pci, driver); + qemuReattachPciDevice(activePci, driver);
This calls qemuReattachPciDevice even if pciResetDevice failed. I don't think that is right.
However, I agree with you that hot-unplug cannot make a device managed if it was not already managed, and also that it should be using the device attributes from driver->activePciHostdevs rather than from the just-created pci in order to properly decide how much work to do on the unplug event.
-- Eric Blake eblake@xxxxxxxxxx +1-801-349-2682 Libvirt virtualization library http://libvirt.org -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list