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@xxxxxxxxxx> --- 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 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list