[libvirt] [PATCH 3/8] virHostdevPreparePCIDevices: Construct pcidevs list earlier

Michal Privoznik mprivozn at redhat.com
Tue Jun 18 13:04:22 UTC 2019


There's no need to translate virDomainHostdevDef-s into
virPCIDevice-s with locked list of PCI devices.

Signed-off-by: Michal Privoznik <mprivozn at redhat.com>
---
 src/util/virhostdev.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/src/util/virhostdev.c b/src/util/virhostdev.c
index 5935d926aa..7b5ccf2daf 100644
--- a/src/util/virhostdev.c
+++ b/src/util/virhostdev.c
@@ -639,11 +639,11 @@ virHostdevPreparePCIDevices(virHostdevManagerPtr mgr,
     if (!nhostdevs)
         return 0;
 
-    virObjectLock(mgr->activePCIHostdevs);
-    virObjectLock(mgr->inactivePCIHostdevs);
-
     if (!(pcidevs = virHostdevGetPCIHostDeviceList(hostdevs, nhostdevs)))
-        goto cleanup;
+        return -1;
+
+    virObjectLock(mgr->activePCIHostdevs);
+    virObjectLock(mgr->inactivePCIHostdevs);
 
     /* 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;
 }
-- 
2.21.0




More information about the libvir-list mailing list