mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-26 03:21:44 +03:00
nwfilter: Make _virNWFilterObjList private
Move from virnwfilterobj.h to virnwfilterobj.c. Create the virNWFilterObjListNew() API in order to allocate. Signed-off-by: John Ferlan <jferlan@redhat.com>
This commit is contained in:
parent
5ebe530e09
commit
6181e404d9
@ -42,6 +42,11 @@ struct _virNWFilterObj {
|
||||
virNWFilterDefPtr newDef;
|
||||
};
|
||||
|
||||
struct _virNWFilterObjList {
|
||||
size_t count;
|
||||
virNWFilterObjPtr *objs;
|
||||
};
|
||||
|
||||
|
||||
static virNWFilterObjPtr
|
||||
virNWFilterObjNew(void)
|
||||
@ -105,8 +110,18 @@ virNWFilterObjListFree(virNWFilterObjListPtr nwfilters)
|
||||
size_t i;
|
||||
for (i = 0; i < nwfilters->count; i++)
|
||||
virNWFilterObjFree(nwfilters->objs[i]);
|
||||
VIR_FREE(nwfilters->objs);
|
||||
nwfilters->count = 0;
|
||||
VIR_FREE(nwfilters);
|
||||
}
|
||||
|
||||
|
||||
virNWFilterObjListPtr
|
||||
virNWFilterObjListNew(void)
|
||||
{
|
||||
virNWFilterObjListPtr nwfilters;
|
||||
|
||||
if (VIR_ALLOC(nwfilters) < 0)
|
||||
return NULL;
|
||||
return nwfilters;
|
||||
}
|
||||
|
||||
|
||||
|
@ -28,11 +28,6 @@ typedef virNWFilterObj *virNWFilterObjPtr;
|
||||
|
||||
typedef struct _virNWFilterObjList virNWFilterObjList;
|
||||
typedef virNWFilterObjList *virNWFilterObjListPtr;
|
||||
struct _virNWFilterObjList {
|
||||
size_t count;
|
||||
virNWFilterObjPtr *objs;
|
||||
};
|
||||
|
||||
|
||||
typedef struct _virNWFilterDriverState virNWFilterDriverState;
|
||||
typedef virNWFilterDriverState *virNWFilterDriverStatePtr;
|
||||
@ -40,7 +35,7 @@ struct _virNWFilterDriverState {
|
||||
virMutex lock;
|
||||
bool privileged;
|
||||
|
||||
virNWFilterObjList nwfilters;
|
||||
virNWFilterObjListPtr nwfilters;
|
||||
|
||||
char *configDir;
|
||||
bool watchingFirewallD;
|
||||
@ -55,6 +50,9 @@ virNWFilterObjGetNewDef(virNWFilterObjPtr obj);
|
||||
bool
|
||||
virNWFilterObjWantRemoved(virNWFilterObjPtr obj);
|
||||
|
||||
virNWFilterObjListPtr
|
||||
virNWFilterObjListNew(void);
|
||||
|
||||
void
|
||||
virNWFilterObjListFree(virNWFilterObjListPtr nwfilters);
|
||||
|
||||
|
@ -971,6 +971,7 @@ virNWFilterObjListFindByUUID;
|
||||
virNWFilterObjListFree;
|
||||
virNWFilterObjListGetNames;
|
||||
virNWFilterObjListLoadAllConfigs;
|
||||
virNWFilterObjListNew;
|
||||
virNWFilterObjListNumOfNWFilters;
|
||||
virNWFilterObjListRemove;
|
||||
virNWFilterObjLock;
|
||||
|
@ -237,7 +237,10 @@ nwfilterStateInitialize(bool privileged,
|
||||
|
||||
VIR_FREE(base);
|
||||
|
||||
if (virNWFilterObjListLoadAllConfigs(&driver->nwfilters, driver->configDir) < 0)
|
||||
if (!(driver->nwfilters = virNWFilterObjListNew()))
|
||||
goto error;
|
||||
|
||||
if (virNWFilterObjListLoadAllConfigs(driver->nwfilters, driver->configDir) < 0)
|
||||
goto error;
|
||||
|
||||
nwfilterDriverUnlock();
|
||||
@ -289,7 +292,7 @@ nwfilterStateReload(void)
|
||||
virNWFilterWriteLockFilterUpdates();
|
||||
virNWFilterCallbackDriversLock();
|
||||
|
||||
virNWFilterObjListLoadAllConfigs(&driver->nwfilters, driver->configDir);
|
||||
virNWFilterObjListLoadAllConfigs(driver->nwfilters, driver->configDir);
|
||||
|
||||
virNWFilterCallbackDriversUnlock();
|
||||
virNWFilterUnlockFilterUpdates();
|
||||
@ -340,7 +343,7 @@ nwfilterStateCleanup(void)
|
||||
nwfilterDriverRemoveDBusMatches();
|
||||
|
||||
/* free inactive nwfilters */
|
||||
virNWFilterObjListFree(&driver->nwfilters);
|
||||
virNWFilterObjListFree(driver->nwfilters);
|
||||
|
||||
VIR_FREE(driver->configDir);
|
||||
nwfilterDriverUnlock();
|
||||
@ -362,7 +365,7 @@ nwfilterLookupByUUID(virConnectPtr conn,
|
||||
virNWFilterPtr ret = NULL;
|
||||
|
||||
nwfilterDriverLock();
|
||||
obj = virNWFilterObjListFindByUUID(&driver->nwfilters, uuid);
|
||||
obj = virNWFilterObjListFindByUUID(driver->nwfilters, uuid);
|
||||
nwfilterDriverUnlock();
|
||||
|
||||
if (!obj) {
|
||||
@ -393,7 +396,7 @@ nwfilterLookupByName(virConnectPtr conn,
|
||||
virNWFilterPtr ret = NULL;
|
||||
|
||||
nwfilterDriverLock();
|
||||
obj = virNWFilterObjListFindByName(&driver->nwfilters, name);
|
||||
obj = virNWFilterObjListFindByName(driver->nwfilters, name);
|
||||
nwfilterDriverUnlock();
|
||||
|
||||
if (!obj) {
|
||||
@ -421,7 +424,7 @@ nwfilterConnectNumOfNWFilters(virConnectPtr conn)
|
||||
if (virConnectNumOfNWFiltersEnsureACL(conn) < 0)
|
||||
return -1;
|
||||
|
||||
return virNWFilterObjListNumOfNWFilters(&driver->nwfilters, conn,
|
||||
return virNWFilterObjListNumOfNWFilters(driver->nwfilters, conn,
|
||||
virConnectNumOfNWFiltersCheckACL);
|
||||
}
|
||||
|
||||
@ -437,7 +440,7 @@ nwfilterConnectListNWFilters(virConnectPtr conn,
|
||||
return -1;
|
||||
|
||||
nwfilterDriverLock();
|
||||
nnames = virNWFilterObjListGetNames(&driver->nwfilters, conn,
|
||||
nnames = virNWFilterObjListGetNames(driver->nwfilters, conn,
|
||||
virConnectListNWFiltersCheckACL,
|
||||
names, maxnames);
|
||||
nwfilterDriverUnlock();
|
||||
@ -458,7 +461,7 @@ nwfilterConnectListAllNWFilters(virConnectPtr conn,
|
||||
return -1;
|
||||
|
||||
nwfilterDriverLock();
|
||||
ret = virNWFilterObjListExport(conn, &driver->nwfilters, filters,
|
||||
ret = virNWFilterObjListExport(conn, driver->nwfilters, filters,
|
||||
virConnectListAllNWFiltersCheckACL);
|
||||
nwfilterDriverUnlock();
|
||||
|
||||
@ -490,13 +493,13 @@ nwfilterDefineXML(virConnectPtr conn,
|
||||
if (virNWFilterDefineXMLEnsureACL(conn, def) < 0)
|
||||
goto cleanup;
|
||||
|
||||
if (!(obj = virNWFilterObjListAssignDef(&driver->nwfilters, def)))
|
||||
if (!(obj = virNWFilterObjListAssignDef(driver->nwfilters, def)))
|
||||
goto cleanup;
|
||||
def = NULL;
|
||||
objdef = virNWFilterObjGetDef(obj);
|
||||
|
||||
if (virNWFilterSaveDef(driver->configDir, objdef) < 0) {
|
||||
virNWFilterObjListRemove(&driver->nwfilters, obj);
|
||||
virNWFilterObjListRemove(driver->nwfilters, obj);
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
@ -525,7 +528,7 @@ nwfilterUndefine(virNWFilterPtr nwfilter)
|
||||
virNWFilterWriteLockFilterUpdates();
|
||||
virNWFilterCallbackDriversLock();
|
||||
|
||||
obj = virNWFilterObjListFindByUUID(&driver->nwfilters, nwfilter->uuid);
|
||||
obj = virNWFilterObjListFindByUUID(driver->nwfilters, nwfilter->uuid);
|
||||
if (!obj) {
|
||||
virReportError(VIR_ERR_NO_NWFILTER,
|
||||
"%s", _("no nwfilter with matching uuid"));
|
||||
@ -546,7 +549,7 @@ nwfilterUndefine(virNWFilterPtr nwfilter)
|
||||
if (virNWFilterDeleteDef(driver->configDir, def) < 0)
|
||||
goto cleanup;
|
||||
|
||||
virNWFilterObjListRemove(&driver->nwfilters, obj);
|
||||
virNWFilterObjListRemove(driver->nwfilters, obj);
|
||||
obj = NULL;
|
||||
ret = 0;
|
||||
|
||||
@ -572,7 +575,7 @@ nwfilterGetXMLDesc(virNWFilterPtr nwfilter,
|
||||
virCheckFlags(0, NULL);
|
||||
|
||||
nwfilterDriverLock();
|
||||
obj = virNWFilterObjListFindByUUID(&driver->nwfilters, nwfilter->uuid);
|
||||
obj = virNWFilterObjListFindByUUID(driver->nwfilters, nwfilter->uuid);
|
||||
nwfilterDriverUnlock();
|
||||
|
||||
if (!obj) {
|
||||
|
@ -383,7 +383,7 @@ virNWFilterIncludeDefToRuleInst(virNWFilterDriverStatePtr driver,
|
||||
int ret = -1;
|
||||
|
||||
VIR_DEBUG("Instantiating filter %s", inc->filterref);
|
||||
obj = virNWFilterObjListFindByName(&driver->nwfilters,
|
||||
obj = virNWFilterObjListFindByName(driver->nwfilters,
|
||||
inc->filterref);
|
||||
if (!obj) {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
@ -545,7 +545,7 @@ virNWFilterDetermineMissingVarsRec(virNWFilterDefPtr filter,
|
||||
break;
|
||||
} else if (inc) {
|
||||
VIR_DEBUG("Following filter %s", inc->filterref);
|
||||
obj = virNWFilterObjListFindByName(&driver->nwfilters, inc->filterref);
|
||||
obj = virNWFilterObjListFindByName(driver->nwfilters, inc->filterref);
|
||||
if (obj) {
|
||||
|
||||
if (virNWFilterObjWantRemoved(obj)) {
|
||||
@ -812,7 +812,7 @@ __virNWFilterInstantiateFilter(virNWFilterDriverStatePtr driver,
|
||||
|
||||
VIR_DEBUG("filter name: %s", filtername);
|
||||
|
||||
obj = virNWFilterObjListFindByName(&driver->nwfilters, filtername);
|
||||
obj = virNWFilterObjListFindByName(driver->nwfilters, filtername);
|
||||
if (!obj) {
|
||||
virReportError(VIR_ERR_NO_NWFILTER,
|
||||
_("Could not find filter '%s'"),
|
||||
|
Loading…
Reference in New Issue
Block a user