提交 0ae7def6 编写于 作者: M Michal Privoznik

network_conf: Introduce virNetworkObjListNumOfNetworks

An accessor following pattern laid out by virDomainObjList* APIs.
Signed-off-by: NMichal Privoznik <mprivozn@redhat.com>
上级 5a13c48b
......@@ -4355,3 +4355,29 @@ virNetworkObjListGetNames(virNetworkObjListPtr nets,
VIR_FREE(names[i]);
return -1;
}
int
virNetworkObjListNumOfNetworks(virNetworkObjListPtr nets,
bool active,
virNetworkObjListFilter filter,
virConnectPtr conn)
{
int count = 0;
size_t i;
for (i = 0; i < nets->count; i++) {
virNetworkObjPtr obj = nets->objs[i];
virNetworkObjLock(obj);
if (filter && !filter(conn, obj->def)) {
virNetworkObjUnlock(obj);
continue;
}
if ((active && virNetworkObjIsActive(obj)) ||
(!active && !virNetworkObjIsActive(obj)))
count++;
virNetworkObjUnlock(obj);
}
return count;
}
......@@ -459,6 +459,11 @@ int virNetworkObjListGetNames(virNetworkObjListPtr nets,
virNetworkObjListFilter filter,
virConnectPtr conn);
int virNetworkObjListNumOfNetworks(virNetworkObjListPtr nets,
bool active,
virNetworkObjListFilter filter,
virConnectPtr conn);
/* for testing */
int
virNetworkDefUpdateSection(virNetworkDefPtr def,
......
......@@ -572,6 +572,7 @@ virNetworkObjListExport;
virNetworkObjListForEach;
virNetworkObjListFree;
virNetworkObjListGetNames;
virNetworkObjListNumOfNetworks;
virNetworkObjLock;
virNetworkObjReplacePersistentDef;
virNetworkObjSetDefTransient;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册