]> xenbits.xensource.com Git - libvirt.git/commitdiff
virHostdevGetPCIHostDeviceList: Add @pci a bit later
authorMichal Privoznik <mprivozn@redhat.com>
Sat, 15 Jun 2019 06:25:33 +0000 (08:25 +0200)
committerMichal Privoznik <mprivozn@redhat.com>
Thu, 20 Jun 2019 08:29:54 +0000 (10:29 +0200)
This function is a good candidate for VIR_AUTOPTR() conversion.
But this conversion will be easier if we only add @pci device
onto @pcidevs list after it was all set up.

This is no functional change.

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

index fe176f35e4194752c7f02573f17ed132985a2b2e..9c63d0aebd5c159a9c70d4cf340fd7516dbfeebc 100644 (file)
@@ -240,11 +240,6 @@ virHostdevGetPCIHostDeviceList(virDomainHostdevDefPtr *hostdevs, int nhostdevs)
             virObjectUnref(pcidevs);
             return NULL;
         }
-        if (virPCIDeviceListAdd(pcidevs, pci) < 0) {
-            virPCIDeviceFree(pci);
-            virObjectUnref(pcidevs);
-            return NULL;
-        }
 
         virPCIDeviceSetManaged(pci, hostdev->managed);
 
@@ -254,6 +249,12 @@ virHostdevGetPCIHostDeviceList(virDomainHostdevDefPtr *hostdevs, int nhostdevs)
             virPCIDeviceSetStubDriver(pci, VIR_PCI_STUB_DRIVER_XEN);
         else
             virPCIDeviceSetStubDriver(pci, VIR_PCI_STUB_DRIVER_KVM);
+
+        if (virPCIDeviceListAdd(pcidevs, pci) < 0) {
+            virPCIDeviceFree(pci);
+            virObjectUnref(pcidevs);
+            return NULL;
+        }
     }
 
     return pcidevs;