Re: [PATCH v2 9/9] Wait for iommmu device to go away before reprobing the host driver

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

 



On Mon, Nov 02, 2015 at 03:28:00 +0530, Shivaprasad G Bhat wrote:
> There could be a delay of 1 or 2 seconds before the vfio-pci driver
> is unbound and the device file /dev/vfio/<iommu> is actually
> removed. If the file exists, the host driver probing the device
> can lead to crash. So, wait and avoid the crash.
> 
> Signed-off-by: Shivaprasad G Bhat <sbhat@xxxxxxxxxxxxxxxxxx>
> ---
>  src/util/virpci.c  |   42 ++++++++++++++++++++++++++++++++++++++++++
>  tests/virpcimock.c |   14 ++++++++++++--
>  2 files changed, 54 insertions(+), 2 deletions(-)
> 
> diff --git a/src/util/virpci.c b/src/util/virpci.c
> index 0bb465b..68fd54c 100644
> --- a/src/util/virpci.c
> +++ b/src/util/virpci.c
> @@ -1098,6 +1098,43 @@ virPCIIsAKnownStub(char *driver)
>      return ret;
>  }
>  
> +#define VFIO_UNBIND_TIMEOUT 10
> +
> +/* It is not safe to initiate host driver probe if the vfio driver has not
> + * completely unbound the device. Usual wait time is 1 to 2 seconds.
> + * So, return if the unbind didn't complete in 10 seconds.
> + */
> +static int
> +virPCIWaitForVFIOUnbindCompletion(virPCIDevicePtr dev)
> +{
> +    int retry = 0;
> +    int ret = -1;
> +    char *path = NULL;
> +
> +    if (!(path = virPCIDeviceGetIOMMUGroupDev(dev)))
> +        goto cleanup;
> +
> +    while (retry++ < VFIO_UNBIND_TIMEOUT) {
> +        if (!virFileExists(path))
> +            break;
> +         sleep(1);

I don't particularly like the 1 second sleep granularity here. I'd
rather see a 1/10s or 1/100s delay so that if the time will be decreased
in the future we will not have to wait for a full second.

Peter

Attachment: signature.asc
Description: Digital signature

--
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]