Signed-off-by: Chunyan Liu <cyliu(a)suse.com>
---
src/qemu/qemu_driver.c | 33 ++++++++++++++++++++++-----------
1 files changed, 22 insertions(+), 11 deletions(-)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 7d924b2..46d975e 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -11207,6 +11207,27 @@ out:
}
static int
+virHostdevPciNodeDeviceDetach(virHostdevManagerPtr hostdev_mgr,
+ virPCIDevicePtr pci)
+{
+ int ret = -1;
+
+ virObjectLock(hostdev_mgr->activePciHostdevs);
+ virObjectLock(hostdev_mgr->inactivePciHostdevs);
+
+ if (virPCIDeviceDetach(pci, hostdev_mgr->activePciHostdevs,
+ hostdev_mgr->inactivePciHostdevs) < 0) {
+ goto out;
+ }
+
+ ret = 0;
+out:
+ virObjectUnlock(hostdev_mgr->inactivePciHostdevs);
+ virObjectUnlock(hostdev_mgr->activePciHostdevs);
+ return ret;
+}
+
+static int
qemuNodeDeviceDetachFlags(virNodeDevicePtr dev,
const char *driverName,
unsigned int flags)
@@ -11280,18 +11301,8 @@ qemuNodeDeviceDetachFlags(virNodeDevicePtr dev,
hostdev_mgr = virHostdevManagerGetDefault();
if (hostdev_mgr == NULL)
goto cleanup;
- virObjectLock(hostdev_mgr->activePciHostdevs);
- virObjectLock(hostdev_mgr->inactivePciHostdevs);
- if (virPCIDeviceDetach(pci, hostdev_mgr->activePciHostdevs,
- hostdev_mgr->inactivePciHostdevs) < 0) {
- goto out;
- }
-
- ret = 0;
-out:
- virObjectUnlock(hostdev_mgr->inactivePciHostdevs);
- virObjectUnlock(hostdev_mgr->activePciHostdevs);
+ ret = virHostdevPciNodeDeviceDetach(hostdev_mgr, pci);
cleanup:
virPCIDeviceFree(pci);
virNodeDeviceDefFree(def);
--
1.6.0.2