Re: [PATCH v4 05/10] Split reprobe action from the virPCIUnbindFromStub into a new function

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

 



On 14.11.2015 09:36, Shivaprasad G Bhat wrote:
> The reprobe needs to be called multiple times for vfio devices for each
> device in the iommu group in future patch. So split the reprobe into a
> new function. No functional change.
> 
> Signed-off-by: Shivaprasad G Bhat <sbhat@xxxxxxxxxxxxxxxxxx>
> ---
>  src/util/virpci.c |   47 +++++++++++++++++++++++++++++++----------------
>  1 file changed, 31 insertions(+), 16 deletions(-)
> 
> diff --git a/src/util/virpci.c b/src/util/virpci.c
> index 89e69e2..febf100 100644
> --- a/src/util/virpci.c
> +++ b/src/util/virpci.c
> @@ -1099,6 +1099,36 @@ virPCIIsKnownStub(char *driver)
>  }
>  
>  static int
> +virPCIDeviceReprobeHostDriver(virPCIDevicePtr dev,
> +                              const char *driver,
> +                              const char *drvdir)
> +{
> +    char *path = NULL;
> +    int ret = -1;
> +
> +    /* Trigger a re-probe of the device is not in the stub's dynamic
> +     * ID table. If the stub is available, but 'remove_id' isn't
> +     * available, then re-probing would just cause the device to be
> +     * re-bound to the stub.
> +     */
> +    if (driver && !(path = virPCIDriverFile(driver, "remove_id")))
> +        goto cleanup;
> +
> +    if (!driver || !virFileExists(drvdir) || virFileExists(path)) {
> +        if (virFileWriteStr(PCI_SYSFS "drivers_probe", dev->name, 0) < 0) {
> +            virReportSystemError(errno,
> +                                 _("Failed to trigger a re-probe for PCI device '%s'"),
> +                                 dev->name);
> +            goto cleanup;
> +        }
> +    }
> +    ret = 0;
> + cleanup:
> +    VIR_FREE(path);
> +    return ret;
> +}
> +
> +static int
>  virPCIDeviceUnbindFromStub(virPCIDevicePtr dev)
>  {
>      int result = -1;
> @@ -1150,24 +1180,9 @@ virPCIDeviceUnbindFromStub(virPCIDevicePtr dev)
>          goto cleanup;
>      }
>  
> -    /* Trigger a re-probe of the device is not in the stub's dynamic
> -     * ID table. If the stub is available, but 'remove_id' isn't
> -     * available, then re-probing would just cause the device to be
> -     * re-bound to the stub.
> -     */
> -    VIR_FREE(path);
> -    if (driver && !(path = virPCIDriverFile(driver, "remove_id")))
> +    if (virPCIDeviceReprobeHostDriver(dev, driver, drvdir) < 0)
>          goto cleanup;
>  
> -    if (!driver || !virFileExists(drvdir) || virFileExists(path)) {
> -        if (virFileWriteStr(PCI_SYSFS "drivers_probe", dev->name, 0) < 0) {
> -            virReportSystemError(errno,
> -                                 _("Failed to trigger a re-probe for PCI device '%s'"),
> -                                 dev->name);
> -            goto cleanup;
> -        }
> -    }
> -
>      result = 0;
>  
>   cleanup:
> 

ACK

Michal

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