The referenced commit removed trimming newline resulting in errors like:
Unusual value in /sys/bus/pci//devices/0000:00:17.0/class: 0x010601
It's a perfectly valid class, it's just the newline that virStrToLong_ui
didn't like (as it wasn't parsed and endptr is given NULL).
Restore stripping newline, but do so a bit nicer than hardcoded offset.
Fixes: 58b3a78aff "virPCIDeviceReadClass: Don't write beyond end of buffer from
virFileReadAll"
Signed-off-by: Marek Marczykowski-Górecki <[email protected]>
---
src/util/virpci.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/src/util/virpci.c b/src/util/virpci.c
index 34fc70e261..66500132c9 100644
--- a/src/util/virpci.c
+++ b/src/util/virpci.c
@@ -488,6 +488,8 @@ virPCIDeviceReadClass(virPCIDevice *dev, uint16_t
*device_class)
if (virFileReadAll(path, 9, &id_str) < 0)
return -1;
+ virStringTrimOptionalNewline(id_str);
+
if (virStrToLong_ui(id_str, NULL, 16, &value) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Unusual value in %1$s/devices/%2$s/class: %3$s"),
--
2.54.0