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