[libvirt] [PATCH 2/8] Add iommu group number info to virPCIDevice

Andrea Bolognani abologna at redhat.com
Fri Oct 30 15:02:20 UTC 2015


n Fri, 2015-10-30 at 04:56 +0530, Shivaprasad G Bhat wrote:
> The iommu group number need not be fetched from the sysfs
> everytime as it remains constant. Fetch it once during
> allocation
> 
> Signed-off-by: Shivaprasad G Bhat <sbhat at linux.vnet.ibm.com>
> ---
>  src/util/virpci.c |    5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/src/util/virpci.c b/src/util/virpci.c
> index 5acf486..eba285a 100644
> --- a/src/util/virpci.c
> +++ b/src/util/virpci.c
> @@ -75,6 +75,7 @@ struct _virPCIDevice {
>      bool          has_pm_reset;
>      bool          managed;
>      char          *stubDriver;
> +    unsigned int  iommuGroup;

This can't be unsigned int, as
virPCIDeviceAddressGetIOMMUGroupNum() will return -2 if
there is no IOMMU group for the device.

>  
>      /* used by reattach function */
>      bool          unbind_from_stub;
> @@ -1565,6 +1566,8 @@ virPCIDeviceNew(unsigned int domain,
>      char *product = NULL;
>      char *drvpath = NULL;
>      char *driver = NULL;
> +    virPCIDeviceAddress devAddr = { domain, bus,
> +                                    slot, function };
>  
>      if (VIR_ALLOC(dev) < 0)
>          return NULL;
> @@ -1618,6 +1621,8 @@ virPCIDeviceNew(unsigned int domain,
>      if (virPCIIsAKnownStub(driver))
>          dev->stubDriver = driver;
>  
> +    dev->iommuGroup = virPCIDeviceAddressGetIOMMUGroupNum(&devAddr);
> +
>      VIR_DEBUG("%s %s: initialized", dev->id, dev->name);
>  
>   cleanup:

Cheers.

-- 
Andrea Bolognani
Software Engineer - Virtualization Team




More information about the libvir-list mailing list