[libvirt] [PATCH] look for DMI information in /sys/class too

Hi, attached patch looks for the DMI information in /sys/class since older kernels (e.g. 2.6.26) have it there. Cheers, -- Guido

On Fri, Jan 08, 2010 at 09:35:36AM +0100, Guido Günther wrote:
Hi, attached patch looks for the DMI information in /sys/class since older kernels (e.g. 2.6.26) have it there. Cheers, -- Guido
From: =?UTF-8?q?Guido=20G=C3=BCnther?= <agx@sigxcpu.org> Date: Thu, 7 Jan 2010 10:13:51 +0100 Subject: [PATCH] Also look for dmi information in /sys/class
older kernels such as 2.6.26 have it there. --- src/node_device/node_device_udev.c | 7 ++++++- src/node_device/node_device_udev.h | 1 + 2 files changed, 7 insertions(+), 1 deletions(-)
diff --git a/src/node_device/node_device_udev.c b/src/node_device/node_device_udev.c index 22c5f2b..7a9c1e5 100644 --- a/src/node_device/node_device_udev.c +++ b/src/node_device/node_device_udev.c @@ -1407,7 +1407,12 @@ static int udevSetupSystemDev(void) device = udev_device_new_from_syspath(udev, DMI_DEVPATH); if (device == NULL) { VIR_ERROR("Failed to get udev device for syspath '%s'\n", DMI_DEVPATH); - goto out; + + device = udev_device_new_from_syspath(udev, DMI_DEVPATH_FALLBACK); + if (device == NULL) { + VIR_ERROR("Failed to get udev device for syspath '%s'\n", DMI_DEVPATH_FALLBACK); + goto out; + } }
data = &def->caps->data; diff --git a/src/node_device/node_device_udev.h b/src/node_device/node_device_udev.h index 0fd39ae..6c83412 100644 --- a/src/node_device/node_device_udev.h +++ b/src/node_device/node_device_udev.h @@ -26,6 +26,7 @@ #define SYSFS_DATA_SIZE 4096 #define DRV_STATE_UDEV_MONITOR(ds) ((struct udev_monitor *)((ds)->privateData)) #define DMI_DEVPATH "/sys/devices/virtual/dmi/id" +#define DMI_DEVPATH_FALLBACK "/sys/class/dmi/id" #define PROPERTY_FOUND 0 #define PROPERTY_MISSING 1 #define PROPERTY_ERROR -1 --
Looks safe to me, assuming the kernel information are exported in the same way, ACK Daniel -- Daniel Veillard | libxml Gnome XML XSLT toolkit http://xmlsoft.org/ daniel@veillard.com | Rpmfind RPM search engine http://rpmfind.net/ http://veillard.com/ | virtualization library http://libvirt.org/

On 01/11/2010 06:53 AM, Guido Günther wrote:
On Fri, Jan 08, 2010 at 11:50:17AM +0100, Daniel Veillard wrote:
Looks safe to me, assuming the kernel information are exported in the same way, Yes, it seems to be the same. Pushed now. Cheers, -- Guido
-- Libvir-list mailing list Libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
if (device == NULL) { VIR_ERROR("Failed to get udev device for syspath '%s'\n", DMI_DEVPATH); I don't think we want to log this message unless the device is not found either place. - goto out; + + device = udev_device_new_from_syspath(udev, DMI_DEVPATH_FALLBACK); + if (device == NULL) { + VIR_ERROR("Failed to get udev device for syspath '%s'\n", DMI_DEVPATH_FALLBACK); + goto out; + } } Dave

On Mon, Jan 11, 2010 at 04:15:45PM -0500, Dave Allan wrote:
On 01/11/2010 06:53 AM, Guido Günther wrote:
On Fri, Jan 08, 2010 at 11:50:17AM +0100, Daniel Veillard wrote:
Looks safe to me, assuming the kernel information are exported in the same way, Yes, it seems to be the same. Pushed now. Cheers, -- Guido
-- Libvir-list mailing list Libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
if (device == NULL) { VIR_ERROR("Failed to get udev device for syspath '%s'\n", DMI_DEVPATH);
I don't think we want to log this message unless the device is not found either place.
- goto out; + + device = udev_device_new_from_syspath(udev, DMI_DEVPATH_FALLBACK); + if (device == NULL) { + VIR_ERROR("Failed to get udev device for syspath '%s'\n", DMI_DEVPATH_FALLBACK); + goto out; + } } Ack. -- Guido

On Mon, Jan 11, 2010 at 04:15:45PM -0500, Dave Allan wrote:
On 01/11/2010 06:53 AM, Guido Günther wrote:
On Fri, Jan 08, 2010 at 11:50:17AM +0100, Daniel Veillard wrote:
Looks safe to me, assuming the kernel information are exported in the same way, Yes, it seems to be the same. Pushed now. Cheers, -- Guido
-- Libvir-list mailing list Libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
if (device == NULL) { VIR_ERROR("Failed to get udev device for syspath '%s'\n", DMI_DEVPATH);
I don't think we want to log this message unless the device is not found either place.
- goto out; + + device = udev_device_new_from_syspath(udev, DMI_DEVPATH_FALLBACK); + if (device == NULL) { + VIR_ERROR("Failed to get udev device for syspath '%s'\n", DMI_DEVPATH_FALLBACK); + goto out; + } }
Actually that patch while applied doesn't seem to do the expected if not found in DMI_DEVPATH but found in DMI_DEVPATH_FALLBACK, you will still emit the VIR_ERROR("Failed to get udev device for syspath '%s'", DMI_DEVPATH); so I'm suppressing that one and modify VIR_ERROR("Failed to get udev device for syspath '%s'", DMI_DEVPATH_FALLBACK); into VIR_ERROR("Failed to get udev device for syspath '%s' or '%s'", DMI_DEVPATH, DMI_DEVPATH_FALLBACK); I'm pushing the enclosed patch, thanks ! Daniel -- Daniel Veillard | libxml Gnome XML XSLT toolkit http://xmlsoft.org/ daniel@veillard.com | Rpmfind RPM search engine http://rpmfind.net/ http://veillard.com/ | virtualization library http://libvirt.org/
participants (3)
-
Daniel Veillard
-
Dave Allan
-
Guido Günther