
On 12/02/2015 12:39 PM, Andrea Bolognani wrote:
This is a straightforward wrapper around virPCIDeviceAddressIOMMUGroupIterate() that will make some code less awkward to write later on. --- src/libvirt_private.syms | 1 + src/util/virpci.c | 26 ++++++++++++++++++++++++++ src/util/virpci.h | 8 ++++++-- 3 files changed, 33 insertions(+), 2 deletions(-)
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index c1fd9f6..f8aaa4c 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -1967,6 +1967,7 @@ virPCIDeviceGetStubDriver; virPCIDeviceGetUnbindFromStub; virPCIDeviceGetUsedBy; virPCIDeviceHasPCIExpressLink; +virPCIDeviceIOMMUGroupIterate; virPCIDeviceIsAssignable; virPCIDeviceIsPCIExpress; virPCIDeviceListAdd; diff --git a/src/util/virpci.c b/src/util/virpci.c index e82583a..d3b2c7e 100644 --- a/src/util/virpci.c +++ b/src/util/virpci.c @@ -1786,6 +1786,32 @@ void virPCIDeviceReattachInit(virPCIDevicePtr pci) pci->reprobe = true; }
+/** + * virPCIDeviceIOMMUGroupIterate: + * @dev: PCI device + * @actor: function to be called for all PCI addresses in @dev's IOMMU group + * @opaque: data passed as the last parameter to @actor + * + * Convenience wrapper around virPCIDeviceAddressIOMMUGroupIterate(). + * + * Behaves exactly the same, except it takes a virPCIDevicePtr instead of a + * virPCIDeviceAddressPtr as its first argument. + * + * Returns: 0 on success, <0 on failure. + */ +int +virPCIDeviceIOMMUGroupIterate(virPCIDevicePtr dev, + virPCIDeviceAddressActor actor, + void *opaque) +{ + virPCIDeviceAddress devAddr = { dev->domain, dev->bus, + dev->slot, dev->function }; + + return virPCIDeviceAddressIOMMUGroupIterate(&devAddr, + actor, + opaque); +}
Instead of creating this new function, how about if we change virPCIDevice to contain a virPCIDeviceAddress rather than individual domain, bus, slot, and function?