From 82e8dd4cf80c6a34f74344943cadcbdaa6cba342 Mon Sep 17 00:00:00 2001 From: Chunyan Liu Date: Wed, 5 Mar 2014 19:56:17 +0800 Subject: [PATCH] Conditionally wait for kvm_assigned_device cleanup Only wait for kvm device cleanup if the driver is pci-stub --- src/qemu/qemu_hostdev.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/qemu/qemu_hostdev.c b/src/qemu/qemu_hostdev.c index 5fa6eb4db2..3a0653ff77 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, -- GitLab