[libvirt] [PATCH v4 01/10] Implement virPCIIsKnownStub function

Michal Privoznik mprivozn at redhat.com
Mon Nov 23 17:05:01 UTC 2015


On 14.11.2015 09:34, Shivaprasad G Bhat wrote:
> The checks to known stubs can be easily done having this
> implementation.
> 
> Signed-off-by: Shivaprasad G Bhat <sbhat at linux.vnet.ibm.com>
> ---
>  src/util/virpci.c |   28 ++++++++++++++++++----------
>  1 file changed, 18 insertions(+), 10 deletions(-)
> 
> diff --git a/src/util/virpci.c b/src/util/virpci.c
> index 35b1459..bff37d7 100644
> --- a/src/util/virpci.c
> +++ b/src/util/virpci.c
> @@ -1080,6 +1080,23 @@ static const char *virPCIKnownStubs[] = {
>      NULL
>  };
>  
> +static bool
> +virPCIIsKnownStub(char *driver)
> +{
> +    const char **stubTest;
> +    bool ret = false;
> +
> +    for (stubTest = virPCIKnownStubs; *stubTest != NULL; stubTest++) {
> +        if (STREQ_NULLABLE(driver, *stubTest)) {
> +            ret = true;
> +            VIR_DEBUG("Found stub driver %s", *stubTest);
> +            break;
> +        }
> +    }
> +
> +    return ret;
> +}
> +
>  static int
>  virPCIDeviceUnbindFromStub(virPCIDevicePtr dev)
>  {
> @@ -1087,8 +1104,6 @@ virPCIDeviceUnbindFromStub(virPCIDevicePtr dev)
>      char *drvdir = NULL;
>      char *path = NULL;
>      char *driver = NULL;
> -    const char **stubTest;
> -    bool isStub = false;
>  
>      /* If the device is currently bound to one of the "well known"
>       * stub drivers, then unbind it, otherwise ignore it.
> @@ -1105,14 +1120,7 @@ virPCIDeviceUnbindFromStub(virPCIDevicePtr dev)
>          goto remove_slot;
>  
>      /* If the device isn't bound to a known stub, skip the unbind. */
> -    for (stubTest = virPCIKnownStubs; *stubTest != NULL; stubTest++) {
> -        if (STREQ(driver, *stubTest)) {
> -            isStub = true;
> -            VIR_DEBUG("Found stub driver %s", *stubTest);
> -            break;
> -        }
> -    }
> -    if (!isStub)
> +    if (!virPCIIsKnownStub(driver))
>          goto remove_slot;
>  
>      if (virPCIDeviceUnbind(dev, dev->reprobe) < 0)
> 

ACK

Michal




More information about the libvir-list mailing list