mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-03-07 17:28:15 +00:00
nodedev: report errors about missing integer properties
The helper methods for getting integer properties ignore a missing property setting its value to zero. This lack of error reporting resulted in missing the regression handling hotplug of USB devices with the vendor and model IDs getting set to zero silently. The few callers which relied on this silent defaulting have been fixed, so now we can report fatal errors immediately. Reviewed-by: Laine Stump <laine@redhat.com> Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
This commit is contained in:
parent
b3a2395313
commit
3fba30fc82
@ -169,10 +169,17 @@ udevGetIntProperty(struct udev_device *udev_device,
|
||||
const char *str = NULL;
|
||||
|
||||
str = udevGetDeviceProperty(udev_device, property_key);
|
||||
|
||||
if (str && virStrToLong_i(str, NULL, base, value) < 0) {
|
||||
if (!str) {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
_("Failed to convert '%s' to int"), str);
|
||||
_("Missing udev property '%s' on '%s'"),
|
||||
property_key, udev_device_get_sysname(udev_device));
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (virStrToLong_i(str, NULL, base, value) < 0) {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
_("Failed to parse int '%s' from udev property '%s' on '%s'"),
|
||||
str, property_key, udev_device_get_sysname(udev_device));
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
@ -188,10 +195,17 @@ udevGetUintProperty(struct udev_device *udev_device,
|
||||
const char *str = NULL;
|
||||
|
||||
str = udevGetDeviceProperty(udev_device, property_key);
|
||||
|
||||
if (str && virStrToLong_ui(str, NULL, base, value) < 0) {
|
||||
if (!str) {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
_("Failed to convert '%s' to int"), str);
|
||||
_("Missing udev property '%s' on '%s'"),
|
||||
property_key, udev_device_get_sysname(udev_device));
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (virStrToLong_ui(str, NULL, base, value) < 0) {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
_("Failed to parse uint '%s' from udev property '%s' on '%s'"),
|
||||
str, property_key, udev_device_get_sysname(udev_device));
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
|
Loading…
x
Reference in New Issue
Block a user