]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
virPCIDeviceGetVPD: Handle errors in callers
authorPeter Krempa <pkrempa@redhat.com>
Mon, 29 Jan 2024 21:32:33 +0000 (22:32 +0100)
committerPeter Krempa <pkrempa@redhat.com>
Wed, 31 Jan 2024 16:24:07 +0000 (17:24 +0100)
Until now 'virPCIDeviceGetVPD' couldn't reallistically raise an error,
but that will change. Handle the errors by either resetting it if we'd
be ignoring it or forward it.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
src/conf/node_device_conf.c
tests/virpcitest.c

index c68ac3af78791364c07f01714d98770d07c14693..b8c91d6ecda5b18b3d2ec0a0034dc95b3a45a950 100644 (file)
@@ -3052,6 +3052,8 @@ virNodeDeviceGetPCIVPDDynamicCap(virNodeDevCapPCIDev *devCapPCIDev)
         if ((res = virPCIDeviceGetVPD(pciDev))) {
             devCapPCIDev->flags |= VIR_NODE_DEV_CAP_FLAG_PCI_VPD;
             devCapPCIDev->vpd = g_steal_pointer(&res);
+        } else {
+            virResetLastError();
         }
     }
     return 0;
index d69a1b511834f7598598b83a79ba256d2f33549d..017c283a44414bba5eeba82f169e969378550bf6 100644 (file)
@@ -344,7 +344,8 @@ testVirPCIDeviceGetVPD(const void *opaque)
     if (!dev)
         return -1;
 
-    res = virPCIDeviceGetVPD(dev);
+    if (!(res = virPCIDeviceGetVPD(dev)))
+        return -1;
 
     /* Only basic checks - full parser validation is done elsewhere. */
     if (res->ro == NULL)