]> xenbits.xensource.com Git - libvirt.git/commitdiff
virHostdevPreparePCIDevices: Construct pcidevs list earlier
authorMichal Privoznik <mprivozn@redhat.com>
Fri, 7 Jun 2019 11:56:46 +0000 (13:56 +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 5935d926aac0f4d308fe55aeb6421667efbbc456..7b5ccf2dafa0b9aff68d62bc3a514e423bb078ae 100644 (file)
@@ -639,12 +639,12 @@ virHostdevPreparePCIDevices(virHostdevManagerPtr mgr,
     if (!nhostdevs)
         return 0;
 
+    if (!(pcidevs = virHostdevGetPCIHostDeviceList(hostdevs, nhostdevs)))
+        return -1;
+
     virObjectLock(mgr->activePCIHostdevs);
     virObjectLock(mgr->inactivePCIHostdevs);
 
-    if (!(pcidevs = virHostdevGetPCIHostDeviceList(hostdevs, nhostdevs)))
-        goto cleanup;
-
     /* Detaching devices from the host involves several steps; each
      * of them is described at length below.
      *
@@ -912,9 +912,9 @@ virHostdevPreparePCIDevices(virHostdevManagerPtr mgr,
     }
 
  cleanup:
-    virObjectUnref(pcidevs);
     virObjectUnlock(mgr->activePCIHostdevs);
     virObjectUnlock(mgr->inactivePCIHostdevs);
+    virObjectUnref(pcidevs);
 
     return ret;
 }