mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-25 23:25:24 +00:00
nwfilter: Introduce virNWFilterObjNumOfNWFilters
Mostly code motion from nwfilter_driver to virnwfilterobj with one caveat to add the virNWFilterObjListFilter typedef and pass it as an 'aclfilter' argument to allow for future possible test driver adjustments to count the number of filters (similar to how node device has done this). Signed-off-by: John Ferlan <jferlan@redhat.com>
This commit is contained in:
parent
84f178bdc7
commit
0c22162836
@ -305,6 +305,26 @@ virNWFilterObjAssignDef(virNWFilterObjListPtr nwfilters,
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
virNWFilterObjNumOfNWFilters(virNWFilterObjListPtr nwfilters,
|
||||
virConnectPtr conn,
|
||||
virNWFilterObjListFilter aclfilter)
|
||||
{
|
||||
size_t i;
|
||||
int nfilters = 0;
|
||||
|
||||
for (i = 0; i < nwfilters->count; i++) {
|
||||
virNWFilterObjPtr obj = nwfilters->objs[i];
|
||||
virNWFilterObjLock(obj);
|
||||
if (!aclfilter || aclfilter(conn, obj->def))
|
||||
nfilters++;
|
||||
virNWFilterObjUnlock(obj);
|
||||
}
|
||||
|
||||
return nfilters;
|
||||
}
|
||||
|
||||
|
||||
static virNWFilterObjPtr
|
||||
virNWFilterObjLoadConfig(virNWFilterObjListPtr nwfilters,
|
||||
const char *configDir,
|
||||
|
@ -81,6 +81,15 @@ virNWFilterObjAssignDef(virNWFilterObjListPtr nwfilters,
|
||||
int
|
||||
virNWFilterObjTestUnassignDef(virNWFilterObjPtr nwfilter);
|
||||
|
||||
typedef bool
|
||||
(*virNWFilterObjListFilter)(virConnectPtr conn,
|
||||
virNWFilterDefPtr def);
|
||||
|
||||
int
|
||||
virNWFilterObjNumOfNWFilters(virNWFilterObjListPtr nwfilters,
|
||||
virConnectPtr conn,
|
||||
virNWFilterObjListFilter aclfilter);
|
||||
|
||||
int
|
||||
virNWFilterObjLoadAllConfigs(virNWFilterObjListPtr nwfilters,
|
||||
const char *configDir);
|
||||
|
@ -965,6 +965,7 @@ virNWFilterObjFindByUUID;
|
||||
virNWFilterObjListFree;
|
||||
virNWFilterObjLoadAllConfigs;
|
||||
virNWFilterObjLock;
|
||||
virNWFilterObjNumOfNWFilters;
|
||||
virNWFilterObjRemove;
|
||||
virNWFilterObjTestUnassignDef;
|
||||
virNWFilterObjUnlock;
|
||||
|
@ -414,22 +414,11 @@ nwfilterLookupByName(virConnectPtr conn,
|
||||
static int
|
||||
nwfilterConnectNumOfNWFilters(virConnectPtr conn)
|
||||
{
|
||||
size_t i;
|
||||
int n;
|
||||
|
||||
if (virConnectNumOfNWFiltersEnsureACL(conn) < 0)
|
||||
return -1;
|
||||
|
||||
n = 0;
|
||||
for (i = 0; i < driver->nwfilters.count; i++) {
|
||||
virNWFilterObjPtr obj = driver->nwfilters.objs[i];
|
||||
virNWFilterObjLock(obj);
|
||||
if (virConnectNumOfNWFiltersCheckACL(conn, obj->def))
|
||||
n++;
|
||||
virNWFilterObjUnlock(obj);
|
||||
}
|
||||
|
||||
return n;
|
||||
return virNWFilterObjNumOfNWFilters(&driver->nwfilters, conn,
|
||||
virConnectNumOfNWFiltersCheckACL);
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user