mirror of https://gitee.com/openkylin/libvirt.git
pci: Remove error reporting from PCI VPD parsing
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>
This commit is contained in:
parent
34f7ca668f
commit
0e566614ff
|
@ -3066,15 +3066,12 @@ virNodeDeviceGetPCIVPDDynamicCap(virNodeDevCapPCIDev *devCapPCIDev)
|
||||||
if (!(pciDev = virPCIDeviceNew(&devAddr)))
|
if (!(pciDev = virPCIDeviceNew(&devAddr)))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (virPCIDeviceHasVPD(pciDev)) {
|
/* VPD is optional in PCI(e) specs. If it is there, attempt to add it. */
|
||||||
/* VPD is optional in PCI(e) specs. If it is there, attempt to add it. */
|
if ((res = virPCIDeviceGetVPD(pciDev))) {
|
||||||
if ((res = virPCIDeviceGetVPD(pciDev))) {
|
devCapPCIDev->flags |= VIR_NODE_DEV_CAP_FLAG_PCI_VPD;
|
||||||
devCapPCIDev->flags |= VIR_NODE_DEV_CAP_FLAG_PCI_VPD;
|
devCapPCIDev->vpd = g_steal_pointer(&res);
|
||||||
devCapPCIDev->vpd = g_steal_pointer(&res);
|
|
||||||
} else {
|
|
||||||
virResetLastError();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3107,7 +3107,6 @@ virPCIDeviceGetUnbindFromStub;
|
||||||
virPCIDeviceGetUsedBy;
|
virPCIDeviceGetUsedBy;
|
||||||
virPCIDeviceGetVPD;
|
virPCIDeviceGetVPD;
|
||||||
virPCIDeviceHasPCIExpressLink;
|
virPCIDeviceHasPCIExpressLink;
|
||||||
virPCIDeviceHasVPD;
|
|
||||||
virPCIDeviceIsAssignable;
|
virPCIDeviceIsAssignable;
|
||||||
virPCIDeviceIsPCIExpress;
|
virPCIDeviceIsPCIExpress;
|
||||||
virPCIDeviceListAdd;
|
virPCIDeviceListAdd;
|
||||||
|
|
|
@ -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:
|
* virPCIDeviceGetVPD:
|
||||||
* @dev: a PCI device to get a PCI VPD for.
|
* @dev: a PCI device to get a PCI VPD for.
|
||||||
*
|
*
|
||||||
* Obtain a PCI device's Vital Product Data (VPD). VPD is optional in
|
* 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
|
* 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
|
* 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).
|
* or NULL if getting it failed for some reason (e.g. invalid format, I/O error).
|
||||||
|
@ -3104,26 +3094,16 @@ virPCIVPDResource *
|
||||||
virPCIDeviceGetVPD(virPCIDevice *dev)
|
virPCIDeviceGetVPD(virPCIDevice *dev)
|
||||||
{
|
{
|
||||||
g_autofree char *vpdPath = virPCIFile(dev->name, "vpd");
|
g_autofree char *vpdPath = virPCIFile(dev->name, "vpd");
|
||||||
virPCIVPDResource *ret = NULL;
|
|
||||||
VIR_AUTOCLOSE fd = -1;
|
VIR_AUTOCLOSE fd = -1;
|
||||||
|
|
||||||
if (!virPCIDeviceHasVPD(dev)) {
|
fd = open(vpdPath, O_RDONLY);
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR, _("Device %1$s does not have a VPD"),
|
|
||||||
virPCIDeviceGetName(dev));
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((fd = open(vpdPath, O_RDONLY)) < 0) {
|
VIR_DEBUG("dev='%s' path='%s' fd='%d'", virPCIDeviceGetName(dev), vpdPath, fd);
|
||||||
virReportSystemError(errno, _("Failed to open a VPD file '%1$s'"), vpdPath);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!(ret = virPCIVPDParse(fd))) {
|
if (fd < 0)
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Failed to parse device VPD data"));
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
|
||||||
|
|
||||||
return ret;
|
return virPCIVPDParse(fd);
|
||||||
}
|
}
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
@ -3200,17 +3180,10 @@ virPCIGetVirtualFunctionInfo(const char *vf_sysfs_device_path G_GNUC_UNUSED,
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
|
||||||
virPCIDeviceHasVPD(virPCIDevice *dev G_GNUC_UNUSED)
|
|
||||||
{
|
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _(unsupported));
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
virPCIVPDResource *
|
virPCIVPDResource *
|
||||||
virPCIDeviceGetVPD(virPCIDevice *dev G_GNUC_UNUSED)
|
virPCIDeviceGetVPD(virPCIDevice *dev G_GNUC_UNUSED)
|
||||||
{
|
{
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _(unsupported));
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
#endif /* __linux__ */
|
#endif /* __linux__ */
|
||||||
|
|
|
@ -270,7 +270,6 @@ int virPCIGetVirtualFunctionInfo(const char *vf_sysfs_device_path,
|
||||||
char **pfname,
|
char **pfname,
|
||||||
int *vf_index);
|
int *vf_index);
|
||||||
|
|
||||||
bool virPCIDeviceHasVPD(virPCIDevice *dev);
|
|
||||||
virPCIVPDResource * virPCIDeviceGetVPD(virPCIDevice *dev);
|
virPCIVPDResource * virPCIDeviceGetVPD(virPCIDevice *dev);
|
||||||
|
|
||||||
int virPCIDeviceUnbind(virPCIDevice *dev);
|
int virPCIDeviceUnbind(virPCIDevice *dev);
|
||||||
|
|
Loading…
Reference in New Issue