mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-26 23:55:23 +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
|
static virNWFilterObjPtr
|
||||||
virNWFilterObjLoadConfig(virNWFilterObjListPtr nwfilters,
|
virNWFilterObjLoadConfig(virNWFilterObjListPtr nwfilters,
|
||||||
const char *configDir,
|
const char *configDir,
|
||||||
|
@ -81,6 +81,15 @@ virNWFilterObjAssignDef(virNWFilterObjListPtr nwfilters,
|
|||||||
int
|
int
|
||||||
virNWFilterObjTestUnassignDef(virNWFilterObjPtr nwfilter);
|
virNWFilterObjTestUnassignDef(virNWFilterObjPtr nwfilter);
|
||||||
|
|
||||||
|
typedef bool
|
||||||
|
(*virNWFilterObjListFilter)(virConnectPtr conn,
|
||||||
|
virNWFilterDefPtr def);
|
||||||
|
|
||||||
|
int
|
||||||
|
virNWFilterObjNumOfNWFilters(virNWFilterObjListPtr nwfilters,
|
||||||
|
virConnectPtr conn,
|
||||||
|
virNWFilterObjListFilter aclfilter);
|
||||||
|
|
||||||
int
|
int
|
||||||
virNWFilterObjLoadAllConfigs(virNWFilterObjListPtr nwfilters,
|
virNWFilterObjLoadAllConfigs(virNWFilterObjListPtr nwfilters,
|
||||||
const char *configDir);
|
const char *configDir);
|
||||||
|
@ -965,6 +965,7 @@ virNWFilterObjFindByUUID;
|
|||||||
virNWFilterObjListFree;
|
virNWFilterObjListFree;
|
||||||
virNWFilterObjLoadAllConfigs;
|
virNWFilterObjLoadAllConfigs;
|
||||||
virNWFilterObjLock;
|
virNWFilterObjLock;
|
||||||
|
virNWFilterObjNumOfNWFilters;
|
||||||
virNWFilterObjRemove;
|
virNWFilterObjRemove;
|
||||||
virNWFilterObjTestUnassignDef;
|
virNWFilterObjTestUnassignDef;
|
||||||
virNWFilterObjUnlock;
|
virNWFilterObjUnlock;
|
||||||
|
@ -414,22 +414,11 @@ nwfilterLookupByName(virConnectPtr conn,
|
|||||||
static int
|
static int
|
||||||
nwfilterConnectNumOfNWFilters(virConnectPtr conn)
|
nwfilterConnectNumOfNWFilters(virConnectPtr conn)
|
||||||
{
|
{
|
||||||
size_t i;
|
|
||||||
int n;
|
|
||||||
|
|
||||||
if (virConnectNumOfNWFiltersEnsureACL(conn) < 0)
|
if (virConnectNumOfNWFiltersEnsureACL(conn) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
n = 0;
|
return virNWFilterObjNumOfNWFilters(&driver->nwfilters, conn,
|
||||||
for (i = 0; i < driver->nwfilters.count; i++) {
|
virConnectNumOfNWFiltersCheckACL);
|
||||||
virNWFilterObjPtr obj = driver->nwfilters.objs[i];
|
|
||||||
virNWFilterObjLock(obj);
|
|
||||||
if (virConnectNumOfNWFiltersCheckACL(conn, obj->def))
|
|
||||||
n++;
|
|
||||||
virNWFilterObjUnlock(obj);
|
|
||||||
}
|
|
||||||
|
|
||||||
return n;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user