]> git.ipfire.org Git - thirdparty/libvirt.git/commit
nodedev: fix xml output for mdev parents in test suite
authorJonathon Jongsma <jjongsma@redhat.com>
Wed, 7 Jul 2021 20:01:20 +0000 (15:01 -0500)
committerJonathon Jongsma <jjongsma@redhat.com>
Fri, 6 Aug 2021 20:02:23 +0000 (15:02 -0500)
commita9c1febcf43544fb9b9e59e8b45161d11260d9aa
treee01baff80e858b22c12e5344f0e5cfeeb4c7eb00
parentfdfe4b2837c3408edc57f6d3bf393dc16cd0ac64
nodedev: fix xml output for mdev parents in test suite

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>
src/node_device/node_device_driver.c
tests/nodedevmdevctldata/mdevctl-list-multiple.out.xml
tests/nodedevmdevctltest.c