Re: [PATCH 3/8] Refuse to reattach from vfio if the iommu group is in use by any domain

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

 



On Fri, 2015-10-30 at 04:57 +0530, Shivaprasad G Bhat wrote:
> It is incorrect to attempt the device reattach of a function,
> when some other domain is using some functions belonging to the same iommu
> group.
> 
> Signed-off-by: Shivaprasad G Bhat <sbhat@xxxxxxxxxxxxxxxxxx>
> ---
>  src/util/virhostdev.c |   11 ++++++++++-
>  1 file changed, 10 insertions(+), 1 deletion(-)
> 
> diff --git a/src/util/virhostdev.c b/src/util/virhostdev.c
> index de029a0..91f28e9 100644
> --- a/src/util/virhostdev.c
> +++ b/src/util/virhostdev.c
> @@ -1590,6 +1590,7 @@ virHostdevPCINodeDeviceReAttach(virHostdevManagerPtr hostdev_mgr,
>                                  virPCIDevicePtr pci)
>  {
>      virPCIDeviceAddressPtr devAddr = NULL;
> +    bool usesVfio = STREQ_NULLABLE(virPCIDeviceGetStubDriver(pci), "vfio-pci");
>      struct virHostdevIsPCINodeDeviceUsedData data = {hostdev_mgr, NULL,
>                                                       false};
>      int ret = -1;
> @@ -1600,8 +1601,16 @@ virHostdevPCINodeDeviceReAttach(virHostdevManagerPtr hostdev_mgr,
>      if (!(devAddr = virPCIDeviceGetAddress(pci)))
>          goto out;
>  
> -    if (virHostdevIsPCINodeDeviceUsed(devAddr, &data))
> +    if (usesVfio) {
> +    /* Doesn't matter which function. If any domain is actively using the
> +       iommu group, refuse to reattach */

Please indent this comment properly. The second line should
start with * as well.

> +        if (virPCIDeviceAddressIOMMUGroupIterate(devAddr,
> +                                                 virHostdevIsPCINodeDeviceUsed,
> +                                                 &data) < 0)
> +            goto out;
> +    } else if (virHostdevIsPCINodeDeviceUsed(devAddr, &data)) {
>          goto out;
> +    }
>  
>      virPCIDeviceReattachInit(pci);

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]