[libvirt] [PATCH 1/3] interface: Introduce virInterfaceObjNumOfInterfaces

Michal Privoznik mprivozn at redhat.com
Mon Apr 10 08:11:20 UTC 2017


On 04/06/2017 04:08 PM, John Ferlan wrote:
> Unlike other drivers, this is a test driver only API. Still combining
> the logic of testConnectNumOfInterfaces and testConnectNumOfDefinedInterfaces
> makes things a bit easier in the long run.
>
> Signed-off-by: John Ferlan <jferlan at redhat.com>
> ---
>  src/conf/virinterfaceobj.c | 20 ++++++++++++++++++++
>  src/conf/virinterfaceobj.h |  4 ++++
>  src/libvirt_private.syms   |  1 +
>  src/test/test_driver.c     | 24 ++++++------------------
>  4 files changed, 31 insertions(+), 18 deletions(-)
>
> diff --git a/src/conf/virinterfaceobj.c b/src/conf/virinterfaceobj.c
> index 3af972b..0407c1f 100644
> --- a/src/conf/virinterfaceobj.c
> +++ b/src/conf/virinterfaceobj.c
> @@ -215,3 +215,23 @@ virInterfaceObjRemove(virInterfaceObjListPtr interfaces,
>          virInterfaceObjUnlock(interfaces->objs[i]);
>      }
>  }
> +
> +
> +int
> +virInterfaceObjNumOfInterfaces(virInterfaceObjListPtr interfaces,
> +                               bool wantActive)
> +{
> +    size_t i;
> +    int ninterfaces = 0;
> +
> +    for (i = 0; (i < interfaces->count); i++) {
> +        virInterfaceObjPtr obj = interfaces->objs[i];
> +        virInterfaceObjLock(obj);
> +        if ((wantActive && virInterfaceObjIsActive(obj)) ||
> +            (!wantActive && !virInterfaceObjIsActive(obj)))

Or simply: if (wantActive == virInterfaceObjIsActive(obj));

> +            ninterfaces++;
> +        virInterfaceObjUnlock(obj);
> +    }

ACK

Michal




More information about the libvir-list mailing list