]> xenbits.xensource.com Git - libvirt.git/commitdiff
virHostdevReAttachPCIDevices: Construct pcidevs list earlier
authorMichal Privoznik <mprivozn@redhat.com>
Mon, 10 Jun 2019 15:19:01 +0000 (17:19 +0200)
committerMichal Privoznik <mprivozn@redhat.com>
Thu, 20 Jun 2019 08:29:54 +0000 (10:29 +0200)
There's no need to translate virDomainHostdevDef-s into
virPCIDevice-s with locked list of PCI devices.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
src/util/virhostdev.c

index 7b5ccf2dafa0b9aff68d62bc3a514e423bb078ae..91359a310d64f6321ae2252db830bc01f23b4571 100644 (file)
@@ -963,16 +963,16 @@ virHostdevReAttachPCIDevices(virHostdevManagerPtr mgr,
     if (!nhostdevs)
         return;
 
-    virObjectLock(mgr->activePCIHostdevs);
-    virObjectLock(mgr->inactivePCIHostdevs);
-
     if (!(pcidevs = virHostdevGetPCIHostDeviceList(hostdevs, nhostdevs))) {
         VIR_ERROR(_("Failed to allocate PCI device list: %s"),
                   virGetLastErrorMessage());
         virResetLastError();
-        goto cleanup;
+        return;
     }
 
+    virObjectLock(mgr->activePCIHostdevs);
+    virObjectLock(mgr->inactivePCIHostdevs);
+
     /* Reattaching devices to the host involves several steps; each
      * of them is described at length below */
 
@@ -1088,10 +1088,9 @@ virHostdevReAttachPCIDevices(virHostdevManagerPtr mgr,
                       virPCIDeviceGetName(actual));
     }
 
- cleanup:
-    virObjectUnref(pcidevs);
     virObjectUnlock(mgr->activePCIHostdevs);
     virObjectUnlock(mgr->inactivePCIHostdevs);
+    virObjectUnref(pcidevs);
 }
 
 int