mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-11 09:17:52 +03:00
network_conf: Introduce virNetworkObjListNumOfNetworks
An accessor following pattern laid out by virDomainObjList* APIs. Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
5a13c48b73
commit
0ae7def635
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user