mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-10 23:07:44 +00:00
libxl: use pci init and dispose functions
Rearrange code so that the local variable is always initialized and disposed. Signed-off-by: Olaf Hering <olaf@aepfle.de> Cc: Jim Fehlig <jfehlig@suse.com>
This commit is contained in:
parent
247b2c5388
commit
f54391b447
@ -2893,12 +2893,14 @@ libxlDomainAttachHostPCIDevice(libxlDriverPrivatePtr driver,
|
||||
virDomainHostdevDefPtr hostdev)
|
||||
{
|
||||
libxlDriverConfigPtr cfg = libxlDriverConfigGet(driver);
|
||||
libxl_device_pci pcidev;
|
||||
libxl_device_pci pcidev;
|
||||
virDomainHostdevDefPtr found;
|
||||
virHostdevManagerPtr hostdev_mgr = driver->hostdevMgr;
|
||||
virDomainHostdevSubsysPCIPtr pcisrc = &hostdev->source.subsys.u.pci;
|
||||
int ret = -1;
|
||||
|
||||
libxl_device_pci_init(&pcidev);
|
||||
|
||||
if (hostdev->source.subsys.type != VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI)
|
||||
goto cleanup;
|
||||
|
||||
@ -2939,6 +2941,7 @@ libxlDomainAttachHostPCIDevice(libxlDriverPrivatePtr driver,
|
||||
|
||||
cleanup:
|
||||
virObjectUnref(cfg);
|
||||
libxl_device_pci_dispose(&pcidev);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -3234,6 +3237,8 @@ libxlDomainDetachHostPCIDevice(libxlDriverPrivatePtr driver,
|
||||
virHostdevManagerPtr hostdev_mgr = driver->hostdevMgr;
|
||||
int ret = -1;
|
||||
|
||||
libxl_device_pci_init(&pcidev);
|
||||
|
||||
if (subsys->type != VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI)
|
||||
goto cleanup;
|
||||
|
||||
@ -3255,8 +3260,6 @@ libxlDomainDetachHostPCIDevice(libxlDriverPrivatePtr driver,
|
||||
}
|
||||
|
||||
|
||||
libxl_device_pci_init(&pcidev);
|
||||
|
||||
if (libxlMakePCI(detach, &pcidev) < 0)
|
||||
goto error;
|
||||
|
||||
@ -3269,7 +3272,6 @@ libxlDomainDetachHostPCIDevice(libxlDriverPrivatePtr driver,
|
||||
goto error;
|
||||
}
|
||||
|
||||
libxl_device_pci_dispose(&pcidev);
|
||||
|
||||
virDomainHostdevRemove(vm->def, idx);
|
||||
|
||||
@ -3283,6 +3285,7 @@ libxlDomainDetachHostPCIDevice(libxlDriverPrivatePtr driver,
|
||||
|
||||
cleanup:
|
||||
virObjectUnref(cfg);
|
||||
libxl_device_pci_dispose(&pcidev);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user