On 03/03/2010 05:32 PM, Ed Swierk wrote:
The udev node device driver tries to glean a few tidbits of information from /sys/devices/virtual/dmi/id. If either the BIOS or the kernel does not support DMI, libvirtd logs the error Failed to get udev device for syspath '/sys/devices/virtual/dmi/id' or '/sys/class/dmi/id' and refuses to start. This seems a bit extreme; information obtained from DMI, like the system board vendor and BIOS version, is useful but not critical to libvirt's operation.
Agreed.
This patch eliminates the hard dependency on DMI. On systems without DMI, libvirtd logs a warning, and leaves the "computer" node device's properties empty.
Although I use goto a lot, I generally try to avoid multiple labels within a function, just because I think it gets out of hand really quickly. Although it's a slightly more invasive patch, would you refactor the code to look something like what I've attached? I haven't even compile tested it as I'm running late, but that's the idea.
Dave
Signed-off-by: Ed Swierk<eswierk@xxxxxxxxxxxxxxxxxx> --- Index: libvirt-0.7.6/src/node_device/node_device_udev.c =================================================================== --- libvirt-0.7.6.orig/src/node_device/node_device_udev.c +++ libvirt-0.7.6/src/node_device/node_device_udev.c @@ -1471,9 +1471,9 @@ static int udevSetupSystemDev(void) if (device == NULL) { device = udev_device_new_from_syspath(udev, DMI_DEVPATH_FALLBACK); if (device == NULL) { - VIR_ERROR("Failed to get udev device for syspath '%s' or '%s'", - DMI_DEVPATH, DMI_DEVPATH_FALLBACK); - goto out; + VIR_WARN("Failed to get udev device for syspath '%s' or '%s'", + DMI_DEVPATH, DMI_DEVPATH_FALLBACK); + goto out2; } } @@ -1532,6 +1532,7 @@ static int udevSetupSystemDev(void) udev_device_unref(device); +out2: dev = virNodeDeviceAssignDef(&driverState->devs, def); if (dev == NULL) { VIR_ERROR("Failed to create device for '%s'", def->name); -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list
diff --git a/src/node_device/node_device_udev.c b/src/node_device/node_device_udev.c index eee44c4..0feb53f 100644 --- a/src/node_device/node_device_udev.c +++ b/src/node_device/node_device_udev.c @@ -1439,46 +1439,12 @@ out: return; } - -static int udevSetupSystemDev(void) +static int +udevGetDMIData(union _virNodeDevCapData *data, + struct udev_device *device) { - virNodeDeviceDefPtr def = NULL; - virNodeDeviceObjPtr dev = NULL; - struct udev *udev = NULL; - struct udev_device *device = NULL; - union _virNodeDevCapData *data = NULL; - char *tmp = NULL; int ret = -1; - if (VIR_ALLOC(def) != 0) { - virReportOOMError(); - goto out; - } - - def->name = strdup("computer"); - if (def->name == NULL) { - virReportOOMError(); - goto out; - } - - if (VIR_ALLOC(def->caps) != 0) { - virReportOOMError(); - goto out; - } - - udev = udev_monitor_get_udev(DRV_STATE_UDEV_MONITOR(driverState)); - device = udev_device_new_from_syspath(udev, DMI_DEVPATH); - if (device == NULL) { - device = udev_device_new_from_syspath(udev, DMI_DEVPATH_FALLBACK); - if (device == NULL) { - VIR_ERROR("Failed to get udev device for syspath '%s' or '%s'", - DMI_DEVPATH, DMI_DEVPATH_FALLBACK); - goto out; - } - } - - data = &def->caps->data; - if (udevGetStringSysfsAttr(device, "product_name", &data->system.product_name) == PROPERTY_ERROR) { @@ -1530,7 +1496,49 @@ static int udevSetupSystemDev(void) goto out; } - udev_device_unref(device); + ret = 0; +out: + return ret; +} + + +static int udevSetupSystemDev(void) +{ + virNodeDeviceDefPtr def = NULL; + virNodeDeviceObjPtr dev = NULL; + struct udev *udev = NULL; + struct udev_device *device = NULL; + char *tmp = NULL; + int ret = -1; + + if (VIR_ALLOC(def) != 0) { + virReportOOMError(); + goto out; + } + + def->name = strdup("computer"); + if (def->name == NULL) { + virReportOOMError(); + goto out; + } + + if (VIR_ALLOC(def->caps) != 0) { + virReportOOMError(); + goto out; + } + + udev = udev_monitor_get_udev(DRV_STATE_UDEV_MONITOR(driverState)); + device = udev_device_new_from_syspath(udev, DMI_DEVPATH); + if (device == NULL) { + device = udev_device_new_from_syspath(udev, DMI_DEVPATH_FALLBACK); + if (device == NULL) { + VIR_ERROR("Failed to get udev device for syspath '%s' or '%s'", + DMI_DEVPATH, DMI_DEVPATH_FALLBACK); + } + } else { + udevGetDMIData(&def->caps->data, device); + udev_device_unref(device); + } dev = virNodeDeviceAssignDef(&driverState->devs, def); if (dev == NULL) {
-- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list