virHostdevGetPCIHostDeviceList: Add @pci a bit later

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>
This commit is contained in:
Michal Privoznik 2019-06-15 08:25:33 +02:00
parent 7979066b69
commit 7cf2963017

View 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;