]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemu: use g_autoptr for a virPCIDevice
authorLaine Stump <laine@redhat.com>
Tue, 24 Nov 2020 21:56:52 +0000 (16:56 -0500)
committerLaine Stump <laine@redhat.com>
Sat, 12 Dec 2020 23:36:10 +0000 (18:36 -0500)
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>
src/qemu/qemu_domain_address.c

index d872f75b38f82f42bd8cd7df913617ee807edb73..b07672e2f4c6166e9cb195a7dbb7143de774e2fe 100644 (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;