mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-02-01 17:35:17 +00:00
a9c1febcf4
Commit 51fbbfdce8 attempted to get the proper nodedev name for the parent of an defined mdev by traversing the filesystem and looking for a device that had the appropriate sysfs path. This works, but it would be cleaner to to avoid mucking around in the filesystem and instead just just examine the list of devices we have in memory. We already had a function nodeDeviceFindAddressByName() which constructs an address for parent device in a format that can be used with mdevctl. So if we refactor this function into a a function that simply formats an address for an arbitrary virNodeDeviceObj*, then we can use this function as a predicate for our new virNodeDeviceObjListFind() function from the previous commit. This will search our list of devices for one whose address matches the address we get from mdevctl. One nice benefit of this approach is that our test cases will now display xml output with the proper parent name for mdevs (assuming that we've added the appropriate mock parent devices to the test driver). Previously they just displayed 'computer' for the parent because the alternative would have required specially constructing a mock filesystem environment with a sysfs that mapped to the appropriate parent. Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com> Reviewed-by: Michal Privoznik <mprivozn@redhat.com>