Conditionally wait for kvm_assigned_device cleanup

Only wait for kvm device cleanup if the driver is pci-stub
This commit is contained in:
Chunyan Liu 2014-03-05 19:56:17 +08:00 committed by Daniel P. Berrange
parent 4e46107e43
commit 82e8dd4cf8

View File

@ -1256,8 +1256,6 @@ qemuPrepareHostDevices(virQEMUDriverPtr driver,
static void static void
qemuReattachPciDevice(virPCIDevicePtr dev, virHostdevManagerPtr mgr) qemuReattachPciDevice(virPCIDevicePtr dev, virHostdevManagerPtr mgr)
{ {
int retries = 100;
/* If the device is not managed and was attached to guest /* If the device is not managed and was attached to guest
* successfully, it must have been inactive. * successfully, it must have been inactive.
*/ */
@ -1267,10 +1265,14 @@ qemuReattachPciDevice(virPCIDevicePtr dev, virHostdevManagerPtr mgr)
return; return;
} }
while (virPCIDeviceWaitForCleanup(dev, "kvm_assigned_device") /* Wait for device cleanup if it is qemu/kvm */
&& retries) { if (STREQ(virPCIDeviceGetStubDriver(dev), "pci-stub")) {
usleep(100*1000); int retries = 100;
retries--; while (virPCIDeviceWaitForCleanup(dev, "kvm_assigned_device")
&& retries) {
usleep(100*1000);
retries--;
}
} }
if (virPCIDeviceReattach(dev, mgr->activePciHostdevs, if (virPCIDeviceReattach(dev, mgr->activePciHostdevs,