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;
|
virNWFilterDefPtr newDef;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct _virNWFilterObjList {
|
||||||
|
size_t count;
|
||||||
|
virNWFilterObjPtr *objs;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
static virNWFilterObjPtr
|
static virNWFilterObjPtr
|
||||||
virNWFilterObjNew(void)
|
virNWFilterObjNew(void)
|
||||||
@ -105,8 +110,18 @@ virNWFilterObjListFree(virNWFilterObjListPtr nwfilters)
|
|||||||
size_t i;
|
size_t i;
|
||||||
for (i = 0; i < nwfilters->count; i++)
|
for (i = 0; i < nwfilters->count; i++)
|
||||||
virNWFilterObjFree(nwfilters->objs[i]);
|
virNWFilterObjFree(nwfilters->objs[i]);
|
||||||
VIR_FREE(nwfilters->objs);
|
VIR_FREE(nwfilters);
|
||||||
nwfilters->count = 0;
|
}
|
||||||
|
|
||||||
|
|
||||||
|
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 struct _virNWFilterObjList virNWFilterObjList;
|
||||||
typedef virNWFilterObjList *virNWFilterObjListPtr;
|
typedef virNWFilterObjList *virNWFilterObjListPtr;
|
||||||
struct _virNWFilterObjList {
|
|
||||||
size_t count;
|
|
||||||
virNWFilterObjPtr *objs;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
typedef struct _virNWFilterDriverState virNWFilterDriverState;
|
typedef struct _virNWFilterDriverState virNWFilterDriverState;
|
||||||
typedef virNWFilterDriverState *virNWFilterDriverStatePtr;
|
typedef virNWFilterDriverState *virNWFilterDriverStatePtr;
|
||||||
@ -40,7 +35,7 @@ struct _virNWFilterDriverState {
|
|||||||
virMutex lock;
|
virMutex lock;
|
||||||
bool privileged;
|
bool privileged;
|
||||||
|
|
||||||
virNWFilterObjList nwfilters;
|
virNWFilterObjListPtr nwfilters;
|
||||||
|
|
||||||
char *configDir;
|
char *configDir;
|
||||||
bool watchingFirewallD;
|
bool watchingFirewallD;
|
||||||
@ -55,6 +50,9 @@ virNWFilterObjGetNewDef(virNWFilterObjPtr obj);
|
|||||||
bool
|
bool
|
||||||
virNWFilterObjWantRemoved(virNWFilterObjPtr obj);
|
virNWFilterObjWantRemoved(virNWFilterObjPtr obj);
|
||||||
|
|
||||||
|
virNWFilterObjListPtr
|
||||||
|
virNWFilterObjListNew(void);
|
||||||
|
|
||||||
void
|
void
|
||||||
virNWFilterObjListFree(virNWFilterObjListPtr nwfilters);
|
virNWFilterObjListFree(virNWFilterObjListPtr nwfilters);
|
||||||
|
|
||||||
|
@ -971,6 +971,7 @@ virNWFilterObjListFindByUUID;
|
|||||||
virNWFilterObjListFree;
|
virNWFilterObjListFree;
|
||||||
virNWFilterObjListGetNames;
|
virNWFilterObjListGetNames;
|
||||||
virNWFilterObjListLoadAllConfigs;
|
virNWFilterObjListLoadAllConfigs;
|
||||||
|
virNWFilterObjListNew;
|
||||||
virNWFilterObjListNumOfNWFilters;
|
virNWFilterObjListNumOfNWFilters;
|
||||||
virNWFilterObjListRemove;
|
virNWFilterObjListRemove;
|
||||||
virNWFilterObjLock;
|
virNWFilterObjLock;
|
||||||
|
@ -237,7 +237,10 @@ nwfilterStateInitialize(bool privileged,
|
|||||||
|
|
||||||
VIR_FREE(base);
|
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;
|
goto error;
|
||||||
|
|
||||||
nwfilterDriverUnlock();
|
nwfilterDriverUnlock();
|
||||||
@ -289,7 +292,7 @@ nwfilterStateReload(void)
|
|||||||
virNWFilterWriteLockFilterUpdates();
|
virNWFilterWriteLockFilterUpdates();
|
||||||
virNWFilterCallbackDriversLock();
|
virNWFilterCallbackDriversLock();
|
||||||
|
|
||||||
virNWFilterObjListLoadAllConfigs(&driver->nwfilters, driver->configDir);
|
virNWFilterObjListLoadAllConfigs(driver->nwfilters, driver->configDir);
|
||||||
|
|
||||||
virNWFilterCallbackDriversUnlock();
|
virNWFilterCallbackDriversUnlock();
|
||||||
virNWFilterUnlockFilterUpdates();
|
virNWFilterUnlockFilterUpdates();
|
||||||
@ -340,7 +343,7 @@ nwfilterStateCleanup(void)
|
|||||||
nwfilterDriverRemoveDBusMatches();
|
nwfilterDriverRemoveDBusMatches();
|
||||||
|
|
||||||
/* free inactive nwfilters */
|
/* free inactive nwfilters */
|
||||||
virNWFilterObjListFree(&driver->nwfilters);
|
virNWFilterObjListFree(driver->nwfilters);
|
||||||
|
|
||||||
VIR_FREE(driver->configDir);
|
VIR_FREE(driver->configDir);
|
||||||
nwfilterDriverUnlock();
|
nwfilterDriverUnlock();
|
||||||
@ -362,7 +365,7 @@ nwfilterLookupByUUID(virConnectPtr conn,
|
|||||||
virNWFilterPtr ret = NULL;
|
virNWFilterPtr ret = NULL;
|
||||||
|
|
||||||
nwfilterDriverLock();
|
nwfilterDriverLock();
|
||||||
obj = virNWFilterObjListFindByUUID(&driver->nwfilters, uuid);
|
obj = virNWFilterObjListFindByUUID(driver->nwfilters, uuid);
|
||||||
nwfilterDriverUnlock();
|
nwfilterDriverUnlock();
|
||||||
|
|
||||||
if (!obj) {
|
if (!obj) {
|
||||||
@ -393,7 +396,7 @@ nwfilterLookupByName(virConnectPtr conn,
|
|||||||
virNWFilterPtr ret = NULL;
|
virNWFilterPtr ret = NULL;
|
||||||
|
|
||||||
nwfilterDriverLock();
|
nwfilterDriverLock();
|
||||||
obj = virNWFilterObjListFindByName(&driver->nwfilters, name);
|
obj = virNWFilterObjListFindByName(driver->nwfilters, name);
|
||||||
nwfilterDriverUnlock();
|
nwfilterDriverUnlock();
|
||||||
|
|
||||||
if (!obj) {
|
if (!obj) {
|
||||||
@ -421,7 +424,7 @@ nwfilterConnectNumOfNWFilters(virConnectPtr conn)
|
|||||||
if (virConnectNumOfNWFiltersEnsureACL(conn) < 0)
|
if (virConnectNumOfNWFiltersEnsureACL(conn) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
return virNWFilterObjListNumOfNWFilters(&driver->nwfilters, conn,
|
return virNWFilterObjListNumOfNWFilters(driver->nwfilters, conn,
|
||||||
virConnectNumOfNWFiltersCheckACL);
|
virConnectNumOfNWFiltersCheckACL);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -437,7 +440,7 @@ nwfilterConnectListNWFilters(virConnectPtr conn,
|
|||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
nwfilterDriverLock();
|
nwfilterDriverLock();
|
||||||
nnames = virNWFilterObjListGetNames(&driver->nwfilters, conn,
|
nnames = virNWFilterObjListGetNames(driver->nwfilters, conn,
|
||||||
virConnectListNWFiltersCheckACL,
|
virConnectListNWFiltersCheckACL,
|
||||||
names, maxnames);
|
names, maxnames);
|
||||||
nwfilterDriverUnlock();
|
nwfilterDriverUnlock();
|
||||||
@ -458,7 +461,7 @@ nwfilterConnectListAllNWFilters(virConnectPtr conn,
|
|||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
nwfilterDriverLock();
|
nwfilterDriverLock();
|
||||||
ret = virNWFilterObjListExport(conn, &driver->nwfilters, filters,
|
ret = virNWFilterObjListExport(conn, driver->nwfilters, filters,
|
||||||
virConnectListAllNWFiltersCheckACL);
|
virConnectListAllNWFiltersCheckACL);
|
||||||
nwfilterDriverUnlock();
|
nwfilterDriverUnlock();
|
||||||
|
|
||||||
@ -490,13 +493,13 @@ nwfilterDefineXML(virConnectPtr conn,
|
|||||||
if (virNWFilterDefineXMLEnsureACL(conn, def) < 0)
|
if (virNWFilterDefineXMLEnsureACL(conn, def) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (!(obj = virNWFilterObjListAssignDef(&driver->nwfilters, def)))
|
if (!(obj = virNWFilterObjListAssignDef(driver->nwfilters, def)))
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
def = NULL;
|
def = NULL;
|
||||||
objdef = virNWFilterObjGetDef(obj);
|
objdef = virNWFilterObjGetDef(obj);
|
||||||
|
|
||||||
if (virNWFilterSaveDef(driver->configDir, objdef) < 0) {
|
if (virNWFilterSaveDef(driver->configDir, objdef) < 0) {
|
||||||
virNWFilterObjListRemove(&driver->nwfilters, obj);
|
virNWFilterObjListRemove(driver->nwfilters, obj);
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -525,7 +528,7 @@ nwfilterUndefine(virNWFilterPtr nwfilter)
|
|||||||
virNWFilterWriteLockFilterUpdates();
|
virNWFilterWriteLockFilterUpdates();
|
||||||
virNWFilterCallbackDriversLock();
|
virNWFilterCallbackDriversLock();
|
||||||
|
|
||||||
obj = virNWFilterObjListFindByUUID(&driver->nwfilters, nwfilter->uuid);
|
obj = virNWFilterObjListFindByUUID(driver->nwfilters, nwfilter->uuid);
|
||||||
if (!obj) {
|
if (!obj) {
|
||||||
virReportError(VIR_ERR_NO_NWFILTER,
|
virReportError(VIR_ERR_NO_NWFILTER,
|
||||||
"%s", _("no nwfilter with matching uuid"));
|
"%s", _("no nwfilter with matching uuid"));
|
||||||
@ -546,7 +549,7 @@ nwfilterUndefine(virNWFilterPtr nwfilter)
|
|||||||
if (virNWFilterDeleteDef(driver->configDir, def) < 0)
|
if (virNWFilterDeleteDef(driver->configDir, def) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
virNWFilterObjListRemove(&driver->nwfilters, obj);
|
virNWFilterObjListRemove(driver->nwfilters, obj);
|
||||||
obj = NULL;
|
obj = NULL;
|
||||||
ret = 0;
|
ret = 0;
|
||||||
|
|
||||||
@ -572,7 +575,7 @@ nwfilterGetXMLDesc(virNWFilterPtr nwfilter,
|
|||||||
virCheckFlags(0, NULL);
|
virCheckFlags(0, NULL);
|
||||||
|
|
||||||
nwfilterDriverLock();
|
nwfilterDriverLock();
|
||||||
obj = virNWFilterObjListFindByUUID(&driver->nwfilters, nwfilter->uuid);
|
obj = virNWFilterObjListFindByUUID(driver->nwfilters, nwfilter->uuid);
|
||||||
nwfilterDriverUnlock();
|
nwfilterDriverUnlock();
|
||||||
|
|
||||||
if (!obj) {
|
if (!obj) {
|
||||||
|
@ -383,7 +383,7 @@ virNWFilterIncludeDefToRuleInst(virNWFilterDriverStatePtr driver,
|
|||||||
int ret = -1;
|
int ret = -1;
|
||||||
|
|
||||||
VIR_DEBUG("Instantiating filter %s", inc->filterref);
|
VIR_DEBUG("Instantiating filter %s", inc->filterref);
|
||||||
obj = virNWFilterObjListFindByName(&driver->nwfilters,
|
obj = virNWFilterObjListFindByName(driver->nwfilters,
|
||||||
inc->filterref);
|
inc->filterref);
|
||||||
if (!obj) {
|
if (!obj) {
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
@ -545,7 +545,7 @@ virNWFilterDetermineMissingVarsRec(virNWFilterDefPtr filter,
|
|||||||
break;
|
break;
|
||||||
} else if (inc) {
|
} else if (inc) {
|
||||||
VIR_DEBUG("Following filter %s", inc->filterref);
|
VIR_DEBUG("Following filter %s", inc->filterref);
|
||||||
obj = virNWFilterObjListFindByName(&driver->nwfilters, inc->filterref);
|
obj = virNWFilterObjListFindByName(driver->nwfilters, inc->filterref);
|
||||||
if (obj) {
|
if (obj) {
|
||||||
|
|
||||||
if (virNWFilterObjWantRemoved(obj)) {
|
if (virNWFilterObjWantRemoved(obj)) {
|
||||||
@ -812,7 +812,7 @@ __virNWFilterInstantiateFilter(virNWFilterDriverStatePtr driver,
|
|||||||
|
|
||||||
VIR_DEBUG("filter name: %s", filtername);
|
VIR_DEBUG("filter name: %s", filtername);
|
||||||
|
|
||||||
obj = virNWFilterObjListFindByName(&driver->nwfilters, filtername);
|
obj = virNWFilterObjListFindByName(driver->nwfilters, filtername);
|
||||||
if (!obj) {
|
if (!obj) {
|
||||||
virReportError(VIR_ERR_NO_NWFILTER,
|
virReportError(VIR_ERR_NO_NWFILTER,
|
||||||
_("Could not find filter '%s'"),
|
_("Could not find filter '%s'"),
|
||||||
|
Loading…
Reference in New Issue
Block a user