]> xenbits.xensource.com Git - libvirt.git/commitdiff
virHostdevReAttachPCIDevices: Separate out function body
authorMichal Privoznik <mprivozn@redhat.com>
Tue, 11 Jun 2019 08:24:04 +0000 (10:24 +0200)
committerMichal Privoznik <mprivozn@redhat.com>
Tue, 17 Dec 2019 09:04:43 +0000 (10:04 +0100)
In near future we will have a list of PCI devices we want to
re-attach to the host (held in virPCIDeviceListPtr) but we don't
have virDomainHostdevDefPtr. That's okay because
virHostdevReAttachPCIDevices() works with virPCIDeviceListPtr
mostly anyway. And in very few places where it needs
virDomainHostdevDefPtr are not interesting for our case.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
ACKed-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Cole Robinson <crobinso@redhat.com>
src/util/virhostdev.c

index b8e6e2bc36990912eec41a3684271f75554c6d37..94a0185597611d3963897e5a73a45ea418412b7b 100644 (file)
@@ -1002,30 +1002,17 @@ virHostdevPreparePCIDevices(virHostdevManagerPtr mgr,
 }
 
 
-/* @oldStateDir:
- * For upgrade purpose: see virHostdevRestoreNetConfig
- */
-void
-virHostdevReAttachPCIDevices(virHostdevManagerPtr mgr,
-                             const char *drv_name,
-                             const char *dom_name,
-                             virDomainHostdevDefPtr *hostdevs,
-                             int nhostdevs,
-                             const char *oldStateDir)
+static void
+virHostdevReAttachPCIDevicesImpl(virHostdevManagerPtr mgr,
+                                 const char *drv_name,
+                                 const char *dom_name,
+                                 virPCIDeviceListPtr pcidevs,
+                                 virDomainHostdevDefPtr *hostdevs,
+                                 int nhostdevs,
+                                 const char *oldStateDir)
 {
-    g_autoptr(virPCIDeviceList) pcidevs = NULL;
     size_t i;
 
-    if (!nhostdevs)
-        return;
-
-    if (!(pcidevs = virHostdevGetPCIHostDeviceList(hostdevs, nhostdevs))) {
-        VIR_ERROR(_("Failed to allocate PCI device list: %s"),
-                  virGetLastErrorMessage());
-        virResetLastError();
-        return;
-    }
-
     virObjectLock(mgr->activePCIHostdevs);
     virObjectLock(mgr->inactivePCIHostdevs);
 
@@ -1121,6 +1108,35 @@ virHostdevReAttachPCIDevices(virHostdevManagerPtr mgr,
     virObjectUnlock(mgr->inactivePCIHostdevs);
 }
 
+
+/* @oldStateDir:
+ * For upgrade purpose: see virHostdevRestoreNetConfig
+ */
+void
+virHostdevReAttachPCIDevices(virHostdevManagerPtr mgr,
+                             const char *drv_name,
+                             const char *dom_name,
+                             virDomainHostdevDefPtr *hostdevs,
+                             int nhostdevs,
+                             const char *oldStateDir)
+{
+    g_autoptr(virPCIDeviceList) pcidevs = NULL;
+
+    if (!nhostdevs)
+        return;
+
+    if (!(pcidevs = virHostdevGetPCIHostDeviceList(hostdevs, nhostdevs))) {
+        VIR_ERROR(_("Failed to allocate PCI device list: %s"),
+                  virGetLastErrorMessage());
+        virResetLastError();
+        return;
+    }
+
+    virHostdevReAttachPCIDevicesImpl(mgr, drv_name, dom_name, pcidevs,
+                                     hostdevs, nhostdevs, oldStateDir);
+}
+
+
 int
 virHostdevUpdateActivePCIDevices(virHostdevManagerPtr mgr,
                                  virDomainHostdevDefPtr *hostdevs,