[PATCH v14 37/49] extract general code of NodeDeviceDetach

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Signed-off-by: Chunyan Liu <cyliu@xxxxxxxx>
---
 src/qemu/qemu_driver.c | 34 ++++++++++++++++++++++------------
 1 file changed, 22 insertions(+), 12 deletions(-)

diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 3d25d14..b980725 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -11267,6 +11267,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)
@@ -11338,18 +11359,7 @@ qemuNodeDeviceDetachFlags(virNodeDevicePtr dev,
         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.9.0

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]