[PATCH v13 38/49] extract general code of NodeDeviceReAttach

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

 



Signed-off-by: Chunyan Liu <cyliu@xxxxxxxx>
---
 src/qemu/qemu_driver.c |   67 ++++++++++++++++++++++++++++--------------------
 1 files changed, 39 insertions(+), 28 deletions(-)

diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 46d975e..1b81689 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -11317,37 +11317,11 @@ qemuNodeDeviceDettach(virNodeDevicePtr dev)
 }
 
 static int
-qemuNodeDeviceReAttach(virNodeDevicePtr dev)
+virHostdevPciNodeDeviceReAttach(virHostdevManagerPtr hostdev_mgr,
+                                virPCIDevicePtr pci)
 {
-    virPCIDevicePtr pci = NULL;
     virPCIDevicePtr other;
-    unsigned domain = 0, bus = 0, slot = 0, function = 0;
     int ret = -1;
-    virNodeDeviceDefPtr def = NULL;
-    char *xml = NULL;
-    virHostdevManagerPtr hostdev_mgr;
-
-    xml = virNodeDeviceGetXMLDesc(dev, 0);
-    if (!xml)
-        goto cleanup;
-
-    def = virNodeDeviceDefParseString(xml, EXISTING_DEVICE, NULL);
-    if (!def)
-        goto cleanup;
-
-    if (virNodeDeviceReAttachEnsureACL(dev->conn, def) < 0)
-        goto cleanup;
-
-    if (qemuNodeDeviceGetPciInfo(def, &domain, &bus, &slot, &function) < 0)
-        goto cleanup;
-
-    pci = virPCIDeviceNew(domain, bus, slot, function);
-    if (!pci)
-        goto cleanup;
-
-    hostdev_mgr = virHostdevManagerGetDefault();
-    if (hostdev_mgr == NULL)
-        goto cleanup_pci;
 
     virObjectLock(hostdev_mgr->activePciHostdevs);
     virObjectLock(hostdev_mgr->inactivePciHostdevs);
@@ -11380,6 +11354,43 @@ qemuNodeDeviceReAttach(virNodeDevicePtr dev)
 out:
     virObjectUnlock(hostdev_mgr->inactivePciHostdevs);
     virObjectUnlock(hostdev_mgr->activePciHostdevs);
+    return ret;
+}
+
+static int
+qemuNodeDeviceReAttach(virNodeDevicePtr dev)
+{
+    virPCIDevicePtr pci = NULL;
+    unsigned domain = 0, bus = 0, slot = 0, function = 0;
+    int ret = -1;
+    virNodeDeviceDefPtr def = NULL;
+    char *xml = NULL;
+    virHostdevManagerPtr hostdev_mgr;
+
+    xml = virNodeDeviceGetXMLDesc(dev, 0);
+    if (!xml)
+        goto cleanup;
+
+    def = virNodeDeviceDefParseString(xml, EXISTING_DEVICE, NULL);
+    if (!def)
+        goto cleanup;
+
+    if (virNodeDeviceReAttachEnsureACL(dev->conn, def) < 0)
+        goto cleanup;
+
+    if (qemuNodeDeviceGetPciInfo(def, &domain, &bus, &slot, &function) < 0)
+        goto cleanup;
+
+    pci = virPCIDeviceNew(domain, bus, slot, function);
+    if (!pci)
+        goto cleanup;
+
+    hostdev_mgr = virHostdevManagerGetDefault();
+    if (hostdev_mgr == NULL)
+        goto cleanup_pci;
+
+    ret = virHostdevPciNodeDeviceReAttach(hostdev_mgr, pci);
+
 cleanup_pci:
     virPCIDeviceFree(pci);
 cleanup:
-- 
1.6.0.2

--
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]