Move from virnwfilterobj.h to virnwfilterobj.c.
Create the virNWFilterObjListNew() API in order to allocate
Signed-off-by: John Ferlan <jferlan(a)redhat.com>
---
src/conf/virnwfilterobj.c | 16 ++++++++++++++++
src/conf/virnwfilterobj.h | 10 ++++------
src/libvirt_private.syms | 1 +
src/nwfilter/nwfilter_driver.c | 29 ++++++++++++++++-------------
src/nwfilter/nwfilter_gentech_driver.c | 6 +++---
5 files changed, 40 insertions(+), 22 deletions(-)
diff --git a/src/conf/virnwfilterobj.c b/src/conf/virnwfilterobj.c
index 28425ba..c1d2042 100644
--- a/src/conf/virnwfilterobj.c
+++ b/src/conf/virnwfilterobj.c
@@ -42,6 +42,11 @@ struct _virNWFilterObj {
virNWFilterDefPtr newDef;
};
+struct _virNWFilterObjList {
+ size_t count;
+ virNWFilterObjPtr *objs;
+};
+
static virNWFilterObjPtr
virNWFilterObjNew(void)
@@ -110,6 +115,17 @@ virNWFilterObjListFree(virNWFilterObjListPtr nwfilters)
}
+virNWFilterObjListPtr
+virNWFilterObjListNew(void)
+{
+ virNWFilterObjListPtr nwfilters;
+
+ if (VIR_ALLOC(nwfilters) < 0)
+ return NULL;
+ return nwfilters;
+}
+
+
void
virNWFilterObjListRemove(virNWFilterObjListPtr nwfilters,
virNWFilterObjPtr obj)
diff --git a/src/conf/virnwfilterobj.h b/src/conf/virnwfilterobj.h
index 4c19223..29d9086 100644
--- a/src/conf/virnwfilterobj.h
+++ b/src/conf/virnwfilterobj.h
@@ -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);
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 453d0fe..13f2ab9 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -971,6 +971,7 @@ virNWFilterObjListFindByUUID;
virNWFilterObjListFree;
virNWFilterObjListGetNames;
virNWFilterObjListLoadAllConfigs;
+virNWFilterObjListNew;
virNWFilterObjListNumOfNWFilters;
virNWFilterObjListRemove;
virNWFilterObjLock;
diff --git a/src/nwfilter/nwfilter_driver.c b/src/nwfilter/nwfilter_driver.c
index 6516053..650c528 100644
--- a/src/nwfilter/nwfilter_driver.c
+++ b/src/nwfilter/nwfilter_driver.c
@@ -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) {
diff --git a/src/nwfilter/nwfilter_gentech_driver.c
b/src/nwfilter/nwfilter_gentech_driver.c
index 23f1999..82e20de 100644
--- a/src/nwfilter/nwfilter_gentech_driver.c
+++ b/src/nwfilter/nwfilter_gentech_driver.c
@@ -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'"),
--
2.9.3