]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
pci: Remove error reporting from PCI VPD parsing
authorPeter Krempa <pkrempa@redhat.com>
Tue, 26 Mar 2024 14:06:58 +0000 (15:06 +0100)
committerPeter Krempa <pkrempa@redhat.com>
Thu, 28 Mar 2024 09:11:55 +0000 (10:11 +0100)
The PCI VPD (Vital Product Data) may be missing or the kernel can report
presence but not actually have the data. Also the data is specified by
the device vendor and thus may be invalid in some cases.

To avoid log spamming, since the only usage in the node device driver is
ignoring errors, remove all error reporting.

Closes: https://gitlab.com/libvirt/libvirt/-/issues/607
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
src/conf/node_device_conf.c
src/libvirt_private.syms
src/util/virpci.c
src/util/virpci.h

index 48140b17baa57e94e8064ea14f33c8c2abf651ee..32b69aae84f36274cf5e64bed4813cc7053d64b1 100644 (file)
@@ -3066,15 +3066,12 @@ virNodeDeviceGetPCIVPDDynamicCap(virNodeDevCapPCIDev *devCapPCIDev)
     if (!(pciDev = virPCIDeviceNew(&devAddr)))
         return -1;
 
-    if (virPCIDeviceHasVPD(pciDev)) {
-        /* VPD is optional in PCI(e) specs. If it is there, attempt to add it. */
-        if ((res = virPCIDeviceGetVPD(pciDev))) {
-            devCapPCIDev->flags |= VIR_NODE_DEV_CAP_FLAG_PCI_VPD;
-            devCapPCIDev->vpd = g_steal_pointer(&res);
-        } else {
-            virResetLastError();
-        }
+    /* VPD is optional in PCI(e) specs. If it is there, attempt to add it. */
+    if ((res = virPCIDeviceGetVPD(pciDev))) {
+        devCapPCIDev->flags |= VIR_NODE_DEV_CAP_FLAG_PCI_VPD;
+        devCapPCIDev->vpd = g_steal_pointer(&res);
     }
+
     return 0;
 }
 
index 6b6bcc368ac3555ba52f0cf24330a6b30bf2e6a8..84e30b711c67bf694a8d8908873c45d91fd8d741 100644 (file)
@@ -3107,7 +3107,6 @@ virPCIDeviceGetUnbindFromStub;
 virPCIDeviceGetUsedBy;
 virPCIDeviceGetVPD;
 virPCIDeviceHasPCIExpressLink;
-virPCIDeviceHasVPD;
 virPCIDeviceIsAssignable;
 virPCIDeviceIsPCIExpress;
 virPCIDeviceListAdd;
index 8becec4aa57f232cfb178466fc54e6cbfb544a09..289c0b330bf0735ac690e4d656939209920310e2 100644 (file)
@@ -3078,24 +3078,14 @@ virPCIGetVirtualFunctionInfo(const char *vf_sysfs_device_path,
 }
 
 
-bool
-virPCIDeviceHasVPD(virPCIDevice *dev)
-{
-    g_autofree char *vpdPath = virPCIFile(dev->name, "vpd");
-    bool ret = virFileIsRegular(vpdPath);
-
-    VIR_DEBUG("path='%s', exists='%d'", vpdPath, ret);
-
-    return ret;
-}
-
 /**
  * virPCIDeviceGetVPD:
  * @dev: a PCI device to get a PCI VPD for.
  *
  * Obtain a PCI device's Vital Product Data (VPD). VPD is optional in
  * both PCI Local Bus and PCIe specifications so there is no guarantee it
- * will be there for a particular device.
+ * will be there for a particular device. The VPD data is returned in @vpd if
+ * it's available or otherwise NULL is set.
  *
  * Returns: a pointer to virPCIVPDResource which needs to be freed by the caller
  * or NULL if getting it failed for some reason (e.g. invalid format, I/O error).
@@ -3104,26 +3094,16 @@ virPCIVPDResource *
 virPCIDeviceGetVPD(virPCIDevice *dev)
 {
     g_autofree char *vpdPath = virPCIFile(dev->name, "vpd");
-    virPCIVPDResource *ret = NULL;
     VIR_AUTOCLOSE fd = -1;
 
-    if (!virPCIDeviceHasVPD(dev)) {
-        virReportError(VIR_ERR_INTERNAL_ERROR, _("Device %1$s does not have a VPD"),
-                       virPCIDeviceGetName(dev));
-        return NULL;
-    }
+    fd = open(vpdPath, O_RDONLY);
 
-    if ((fd = open(vpdPath, O_RDONLY)) < 0) {
-        virReportSystemError(errno, _("Failed to open a VPD file '%1$s'"), vpdPath);
-        return NULL;
-    }
+    VIR_DEBUG("dev='%s' path='%s' fd='%d'", virPCIDeviceGetName(dev), vpdPath, fd);
 
-    if (!(ret = virPCIVPDParse(fd))) {
-        virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Failed to parse device VPD data"));
+    if (fd < 0)
         return NULL;
-    }
 
-    return ret;
+    return virPCIVPDParse(fd);
 }
 
 #else
@@ -3200,17 +3180,10 @@ virPCIGetVirtualFunctionInfo(const char *vf_sysfs_device_path G_GNUC_UNUSED,
     return -1;
 }
 
-bool
-virPCIDeviceHasVPD(virPCIDevice *dev G_GNUC_UNUSED)
-{
-    virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _(unsupported));
-    return NULL;
-}
 
 virPCIVPDResource *
 virPCIDeviceGetVPD(virPCIDevice *dev G_GNUC_UNUSED)
 {
-    virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _(unsupported));
     return NULL;
 }
 #endif /* __linux__ */
index a5bfe9c35da1ca3728c9ba59265bec4266d28040..ba5e0ae6f18d1bf5b4a8cff8211f1e1bc2c34596 100644 (file)
@@ -270,7 +270,6 @@ int virPCIGetVirtualFunctionInfo(const char *vf_sysfs_device_path,
                                  char **pfname,
                                  int *vf_index);
 
-bool virPCIDeviceHasVPD(virPCIDevice *dev);
 virPCIVPDResource * virPCIDeviceGetVPD(virPCIDevice *dev);
 
 int virPCIDeviceUnbind(virPCIDevice *dev);