[libvirt] [PATCH 4/8] virHostdevReAttachPCIDevices: Construct pcidevs list earlier

Michal Privoznik mprivozn at redhat.com
Tue Jun 18 13:04:23 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 | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/src/util/virhostdev.c b/src/util/virhostdev.c
index 7b5ccf2daf..79a6ec86fe 100644
--- a/src/util/virhostdev.c
+++ b/src/util/virhostdev.c
@@ -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 */
 
-- 
2.21.0




More information about the libvir-list mailing list