[libvirt PATCH v2 1/7] qemu: use g_autoptr for a virPCIDevice

Laine Stump laine at redhat.com
Fri Dec 11 15:47:22 UTC 2020


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 at redhat.com>
---
 src/qemu/qemu_domain_address.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/src/qemu/qemu_domain_address.c b/src/qemu/qemu_domain_address.c
index d872f75b38..b07672e2f4 100644
--- a/src/qemu/qemu_domain_address.c
+++ b/src/qemu/qemu_domain_address.c
@@ -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;
-- 
2.28.0




More information about the libvir-list mailing list