[libvirt] [PATCH 1/8] virHostdevGetPCIHostDeviceList: Add @pci a bit later

Michal Privoznik posted 8 patches 6 years, 7 months ago
[libvirt] [PATCH 1/8] virHostdevGetPCIHostDeviceList: Add @pci a bit later
Posted by Michal Privoznik 6 years, 7 months ago
This function is a good candidate for VIR_AUTOPTR() conversion.
But things 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>
---
 src/util/virhostdev.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/src/util/virhostdev.c b/src/util/virhostdev.c
index fe176f35e4..9c63d0aebd 100644
--- a/src/util/virhostdev.c
+++ b/src/util/virhostdev.c
@@ -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;
-- 
2.21.0

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 1/8] virHostdevGetPCIHostDeviceList: Add @pci a bit later
Posted by Ján Tomko 6 years, 7 months ago
On Tue, Jun 18, 2019 at 03:04:20PM +0200, Michal Privoznik wrote:
>This function is a good candidate for VIR_AUTOPTR() conversion.
>But things conversion will be easier if we only add @pci device

s/things/this/

>onto @pcidevs list after it was all set up.
>
>This is no functional change.
>
>Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
>---
> src/util/virhostdev.c | 11 ++++++-----
> 1 file changed, 6 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