qemu: use g_autoptr for a virPCIDevice

The one instance of a virPCIDevice in
qemuDomainDeviceCalculatePCIConnectFlags() needs to be converted to
use g_autoptr as a prerequisite for a bugfix. It's in this patch by
itself (rather than in a patch converting all virPCIDevice usages to
g_autoptr) to simplify any backport of said bugfix.

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
Laine Stump 2020-11-24 16:56:52 -05:00
parent 04fd7865f2
commit 01e421c16a

View File

@ -803,7 +803,7 @@ qemuDomainDeviceCalculatePCIConnectFlags(virDomainDeviceDefPtr dev,
case VIR_DOMAIN_DEVICE_HOSTDEV: {
virDomainHostdevDefPtr hostdev = dev->data.hostdev;
bool isExpress = false;
virPCIDevicePtr pciDev;
g_autoptr(virPCIDevice) pciDev = NULL;
virPCIDeviceAddressPtr hostAddr = &hostdev->source.subsys.u.pci.addr;
if (!virHostdevIsMdevDevice(hostdev) &&
@ -891,8 +891,6 @@ qemuDomainDeviceCalculatePCIConnectFlags(virDomainDeviceDefPtr dev,
off_t configLen
= virFileLength(virPCIDeviceGetConfigPath(pciDev), -1);
virPCIDeviceFree(pciDev);
if (configLen == 256)
return pciFlags;
@ -904,7 +902,6 @@ qemuDomainDeviceCalculatePCIConnectFlags(virDomainDeviceDefPtr dev,
* a definitive answer.
*/
isExpress = virPCIDeviceIsPCIExpress(pciDev);
virPCIDeviceFree(pciDev);
if (isExpress)
return pcieFlags;