Re: [PATCH 04/10] pci: Introduce virPCIDeviceIOMMUGroupIterate()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, 2015-12-03 at 14:06 -0500, Laine Stump wrote:
> 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?

I think you already mentioned doing so in the past, and it's
definitely a good idea.

I'll get to it. After the change, we'll be able to just use

  virPCIDeviceAddressIOMMUGroupIterate(virPCIDeviceGetAddress(dev),
                                       actor,
                                       data);

with virPCIDeviceGetAddress() returning a pointer to the
address stored inside the device instead of a newly-allocated
object.

Cheers.

-- 
Andrea Bolognani
Software Engineer - Virtualization Team

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]