mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-03-20 07:59:00 +00:00
Improve nodedev parent/child relationships
* If a nodedev has a parent that we don't want to display, we should continue walking up the udev device tree to see if any of its earlier ancestors are devices that we display. It makes the tree much nicer looking than having a whole lot of devices hanging off the root node.
This commit is contained in:
parent
1a5c465ee5
commit
8b46a7bbdb
@ -1223,31 +1223,43 @@ static int udevSetParent(struct udev_device *device,
|
||||
virNodeDeviceObjPtr dev = NULL;
|
||||
int ret = -1;
|
||||
|
||||
parent_device = udev_device_get_parent(device);
|
||||
if (parent_device == NULL) {
|
||||
VIR_INFO("Could not find udev parent for device with sysfs path '%s'",
|
||||
udev_device_get_syspath(device));
|
||||
}
|
||||
parent_device = device;
|
||||
do {
|
||||
|
||||
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));
|
||||
parent_sysfs_path = "";
|
||||
}
|
||||
parent_device = udev_device_get_parent(parent_device);
|
||||
if (parent_device == NULL) {
|
||||
break;
|
||||
}
|
||||
|
||||
def->parent_sysfs_path = strdup(parent_sysfs_path);
|
||||
if (def->parent_sysfs_path == NULL) {
|
||||
virReportOOMError();
|
||||
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(parent_device));
|
||||
}
|
||||
|
||||
dev = virNodeDeviceFindBySysfsPath(&driverState->devs, parent_sysfs_path);
|
||||
if (dev == NULL) {
|
||||
dev = virNodeDeviceFindBySysfsPath(&driverState->devs,
|
||||
parent_sysfs_path);
|
||||
if (dev != NULL) {
|
||||
def->parent = strdup(dev->def->name);
|
||||
virNodeDeviceObjUnlock(dev);
|
||||
|
||||
if (def->parent == NULL) {
|
||||
virReportOOMError();
|
||||
goto out;
|
||||
}
|
||||
|
||||
def->parent_sysfs_path = strdup(parent_sysfs_path);
|
||||
if (def->parent_sysfs_path == NULL) {
|
||||
virReportOOMError();
|
||||
goto out;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
} while (def->parent == NULL && parent_device != NULL);
|
||||
|
||||
if (def->parent == NULL) {
|
||||
def->parent = strdup("computer");
|
||||
} else {
|
||||
def->parent = strdup(dev->def->name);
|
||||
virNodeDeviceObjUnlock(dev);
|
||||
}
|
||||
|
||||
if (def->parent == NULL) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user