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

Michal Privoznik posted 8 patches 6 years, 7 months ago
[libvirt] [PATCH 3/8] virHostdevPreparePCIDevices: Construct pcidevs list earlier
Posted by Michal Privoznik 6 years, 7 months ago
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>
---
 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

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 3/8] virHostdevPreparePCIDevices: Construct pcidevs list earlier
Posted by Ján Tomko 6 years, 7 months ago
On Tue, Jun 18, 2019 at 03:04:22PM +0200, Michal Privoznik wrote:
>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>
>---
> src/util/virhostdev.c | 10 +++++-----
> 1 file changed, 5 insertions(+), 5 deletions(-)
>

Reviewed-by: Ján Tomko <jtomko@redhat.com>

Jano
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list