[libvirt] [PATCH 4/8] Wait for vfio-pci device cleanups before reassinging the device to host driver

Andrea Bolognani abologna at redhat.com
Fri Oct 30 15:31:48 UTC 2015


On Fri, 2015-10-30 at 04:58 +0530, Shivaprasad G Bhat wrote:
> Before unbind from stub driver libvirt should be sure the guest is not using
> the device anymore. The libvirt today waits for pci-stub driver alone in /proc/iommu.
> The same wait is needed for vfio devices too.
> 
> Signed-off-by: Shivaprasad G Bhat <sbhat at linux.vnet.ibm.com>
> ---
>  src/util/virhostdev.c |    7 +++++++
>  1 file changed, 7 insertions(+)
> 
> diff --git a/src/util/virhostdev.c b/src/util/virhostdev.c
> index 91f28e9..6247477 100644
> --- a/src/util/virhostdev.c
> +++ b/src/util/virhostdev.c
> @@ -756,6 +756,13 @@ virHostdevReattachPCIDevice(virPCIDevicePtr dev, virHostdevManagerPtr mgr)
>              usleep(100*1000);
>              retries--;
>          }
> +    } else if (STREQ(virPCIDeviceGetStubDriver(dev), "vfio-pci")) {
> +        int retries = 100;
> +        while (virPCIDeviceWaitForCleanup(dev, "vfio-pci")
> +               && retries) {
> +            usleep(100*1000);
> +            retries--;
> +        }
>      }
>  
>      if (virPCIDeviceReattach(dev, mgr->activePCIHostdevs,

This looks good.

Weak ACK, we need somebody who's more familiar with this area
of libvirt to go over the whole series anyway.

Cheers.

-- 
Andrea Bolognani
Software Engineer - Virtualization Team




More information about the libvir-list mailing list