[libvirt] [PATCH] Include sysfs devices lacking a device symlink as node devices

The udev node device driver relies on the "device" symlink in sysfs to populate the node device's parent property. Loopback, vlan and bridge network interfaces don't have a real hardware parent but could be useful to include as node devices anyway (and the hal node device driver does include them). This patch allows the udev node device driver to include network interfaces lacking a "device" symlink as node devices, and sets the parent property to "computer". Signed-off-by: Ed Swierk <eswierk@aristanetworks.com> --- 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 @@ -1220,14 +1220,13 @@ static int udevSetParent(struct udev_dev if (parent_device == NULL) { VIR_INFO("Could not find udev parent for device with sysfs path '%s'", udev_device_get_syspath(device)); - goto out; } parent_sysfs_path = udev_device_get_syspath(parent_device); if (parent_sysfs_path == NULL) { VIR_INFO("Could not get syspath for parent of '%s'", udev_device_get_syspath(device)); - goto out; + parent_sysfs_path = ""; } def->parent_sysfs_path = strdup(parent_sysfs_path);

On 03/03/2010 03:58 PM, Ed Swierk wrote:
The udev node device driver relies on the "device" symlink in sysfs to populate the node device's parent property. Loopback, vlan and bridge network interfaces don't have a real hardware parent but could be useful to include as node devices anyway (and the hal node device driver does include them).
This patch allows the udev node device driver to include network interfaces lacking a "device" symlink as node devices, and sets the parent property to "computer".
Signed-off-by: Ed Swierk <eswierk@aristanetworks.com>
--- 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 @@ -1220,14 +1220,13 @@ static int udevSetParent(struct udev_dev if (parent_device == NULL) { VIR_INFO("Could not find udev parent for device with sysfs path '%s'", udev_device_get_syspath(device)); - goto out; }
parent_sysfs_path = udev_device_get_syspath(parent_device);
Where is udev_device_get_syspath declared? I'm assuming it's generated, since 'git grep' didn't find it. The only concern I have is whether it sanely reacts to a NULL argument, but since I couldn't find it, I'm not sure. If it gracefully returns NULL on a NULL argument, then...
if (parent_sysfs_path == NULL) { VIR_INFO("Could not get syspath for parent of '%s'", udev_device_get_syspath(device)); - goto out; + parent_sysfs_path = ""; }
ACK -- Eric Blake eblake@redhat.com +1-801-349-2682 Libvirt virtualization library http://libvirt.org

On Tue, Mar 9, 2010 at 10:55 AM, Eric Blake <eblake@redhat.com> wrote:
Where is udev_device_get_syspath declared? I'm assuming it's generated, since 'git grep' didn't find it. The only concern I have is whether it sanely reacts to a NULL argument, but since I couldn't find it, I'm not sure. If it gracefully returns NULL on a NULL argument, then...
udev_device_get_syspath() comes from libudev: /** * udev_device_get_syspath: * @udev_device: udev device * * Retrieve the sys path of the udev device. The path is an * absolute path and starts with the sys mount point. * * Returns: the sys path of the udev device **/ const char *udev_device_get_syspath(struct udev_device *udev_device) { if (udev_device == NULL) return NULL; return udev_device->syspath; } --Ed

On 03/09/2010 02:31 PM, Ed Swierk wrote:
On Tue, Mar 9, 2010 at 10:55 AM, Eric Blake <eblake@redhat.com> wrote:
Where is udev_device_get_syspath declared? I'm assuming it's generated, since 'git grep' didn't find it. The only concern I have is whether it sanely reacts to a NULL argument, but since I couldn't find it, I'm not sure. If it gracefully returns NULL on a NULL argument, then...
udev_device_get_syspath() comes from libudev:
Aha. No wonder I didn't find it in libvirt. Thanks for the clue-bat.
const char *udev_device_get_syspath(struct udev_device *udev_device) { if (udev_device == NULL) return NULL;
Good - my ACK stands. -- Eric Blake eblake@redhat.com +1-801-349-2682 Libvirt virtualization library http://libvirt.org

On 03/09/2010 01:55 PM, Eric Blake wrote:
On 03/03/2010 03:58 PM, Ed Swierk wrote:
The udev node device driver relies on the "device" symlink in sysfs to populate the node device's parent property. Loopback, vlan and bridge network interfaces don't have a real hardware parent but could be useful to include as node devices anyway (and the hal node device driver does include them).
This patch allows the udev node device driver to include network interfaces lacking a "device" symlink as node devices, and sets the parent property to "computer".
Signed-off-by: Ed Swierk<eswierk@aristanetworks.com>
--- 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 @@ -1220,14 +1220,13 @@ static int udevSetParent(struct udev_dev if (parent_device == NULL) { VIR_INFO("Could not find udev parent for device with sysfs path '%s'", udev_device_get_syspath(device)); - goto out; }
parent_sysfs_path = udev_device_get_syspath(parent_device);
Where is udev_device_get_syspath declared? I'm assuming it's generated, since 'git grep' didn't find it. The only concern I have is whether it sanely reacts to a NULL argument, but since I couldn't find it, I'm not sure. If it gracefully returns NULL on a NULL argument, then...
if (parent_sysfs_path == NULL) { VIR_INFO("Could not get syspath for parent of '%s'", udev_device_get_syspath(device)); - goto out; + parent_sysfs_path = ""; }
ACK
+1 Dave

On 03/09/2010 06:00 PM, Dave Allan wrote:
On 03/09/2010 01:55 PM, Eric Blake wrote:
On 03/03/2010 03:58 PM, Ed Swierk wrote:
The udev node device driver relies on the "device" symlink in sysfs to populate the node device's parent property. Loopback, vlan and bridge network interfaces don't have a real hardware parent but could be useful to include as node devices anyway (and the hal node device driver does include them).
This patch allows the udev node device driver to include network interfaces lacking a "device" symlink as node devices, and sets the parent property to "computer".
Signed-off-by: Ed Swierk<eswierk@aristanetworks.com>
--- 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 @@ -1220,14 +1220,13 @@ static int udevSetParent(struct udev_dev if (parent_device == NULL) { VIR_INFO("Could not find udev parent for device with sysfs path '%s'", udev_device_get_syspath(device)); - goto out; }
parent_sysfs_path = udev_device_get_syspath(parent_device);
Where is udev_device_get_syspath declared? I'm assuming it's generated, since 'git grep' didn't find it. The only concern I have is whether it sanely reacts to a NULL argument, but since I couldn't find it, I'm not sure. If it gracefully returns NULL on a NULL argument, then...
if (parent_sysfs_path == NULL) { VIR_INFO("Could not get syspath for parent of '%s'", udev_device_get_syspath(device)); - goto out; + parent_sysfs_path = ""; }
ACK
+1
Dave
Ok, pushed. Dave
participants (3)
-
Dave Allan
-
Ed Swierk
-
Eric Blake