1
0
mirror of https://gitlab.com/libvirt/libvirt.git synced 2025-03-07 17:28:15 +00:00

qemu: Do not wait if the PCI device is not managed when reattaching

Waiting for qemu-kvm cleaning up the PCI bar(s) mapping with long time
while the device is not managed is just waste of time.
This commit is contained in:
Osier Yang 2011-10-17 18:19:58 +08:00
parent c1bc3d892c
commit 7fb50e300c

View File

@ -322,20 +322,21 @@ void qemuReattachPciDevice(pciDevice *dev, struct qemud_driver *driver)
{ {
int retries = 100; int retries = 100;
if (!pciDeviceGetManaged(dev))
return;
while (pciWaitForDeviceCleanup(dev, "kvm_assigned_device") while (pciWaitForDeviceCleanup(dev, "kvm_assigned_device")
&& retries) { && retries) {
usleep(100*1000); usleep(100*1000);
retries--; retries--;
} }
if (pciDeviceGetManaged(dev)) {
if (pciReAttachDevice(dev, driver->activePciHostdevs) < 0) { if (pciReAttachDevice(dev, driver->activePciHostdevs) < 0) {
virErrorPtr err = virGetLastError(); virErrorPtr err = virGetLastError();
VIR_ERROR(_("Failed to re-attach PCI device: %s"), VIR_ERROR(_("Failed to re-attach PCI device: %s"),
err ? err->message : _("unknown error")); err ? err->message : _("unknown error"));
virResetError(err); virResetError(err);
} }
}
} }