Move the structure to virnwfilterobj.c and create necessary accessor API's
for the various fields.
Also make virNWFilterObjFree static since there's no external callers.
Signed-off-by: John Ferlan <jferlan(a)redhat.com>
---
src/conf/virnwfilterobj.c | 32 +++++++++++++++++++++++++++++++-
src/conf/virnwfilterobj.h | 22 +++++++++-------------
src/libvirt_private.syms | 3 +++
src/nwfilter/nwfilter_driver.c | 10 +++++-----
src/nwfilter/nwfilter_gentech_driver.c | 30 ++++++++++++++++++------------
5 files changed, 66 insertions(+), 31 deletions(-)
diff --git a/src/conf/virnwfilterobj.c b/src/conf/virnwfilterobj.c
index 6e5c5b7..9846751 100644
--- a/src/conf/virnwfilterobj.c
+++ b/src/conf/virnwfilterobj.c
@@ -33,8 +33,38 @@
VIR_LOG_INIT("conf.virnwfilterobj");
+struct _virNWFilterObj {
+ virMutex lock;
-void
+ bool wantRemoved;
+
+ virNWFilterDefPtr def;
+ virNWFilterDefPtr newDef;
+};
+
+
+virNWFilterDefPtr
+virNWFilterObjGetDef(virNWFilterObjPtr obj)
+{
+ return obj->def;
+}
+
+
+virNWFilterDefPtr
+virNWFilterObjGetNewDef(virNWFilterObjPtr obj)
+{
+ return obj->newDef;
+}
+
+
+bool
+virNWFilterObjWantRemoved(virNWFilterObjPtr obj)
+{
+ return obj->wantRemoved;
+}
+
+
+static void
virNWFilterObjFree(virNWFilterObjPtr obj)
{
virNWFilterDefPtr def;
diff --git a/src/conf/virnwfilterobj.h b/src/conf/virnwfilterobj.h
index f31938d..b02dcfa 100644
--- a/src/conf/virnwfilterobj.h
+++ b/src/conf/virnwfilterobj.h
@@ -26,16 +26,6 @@
typedef struct _virNWFilterObj virNWFilterObj;
typedef virNWFilterObj *virNWFilterObjPtr;
-struct _virNWFilterObj {
- virMutex lock;
-
- bool wantRemoved;
-
- virNWFilterDefPtr def;
- virNWFilterDefPtr newDef;
-};
-
-
typedef struct _virNWFilterObjList virNWFilterObjList;
typedef virNWFilterObjList *virNWFilterObjListPtr;
struct _virNWFilterObjList {
@@ -56,6 +46,15 @@ struct _virNWFilterDriverState {
bool watchingFirewallD;
};
+virNWFilterDefPtr
+virNWFilterObjGetDef(virNWFilterObjPtr obj);
+
+virNWFilterDefPtr
+virNWFilterObjGetNewDef(virNWFilterObjPtr obj);
+
+bool
+virNWFilterObjWantRemoved(virNWFilterObjPtr obj);
+
void
virNWFilterObjListFree(virNWFilterObjListPtr nwfilters);
@@ -63,9 +62,6 @@ void
virNWFilterObjRemove(virNWFilterObjListPtr nwfilters,
virNWFilterObjPtr obj);
-void
-virNWFilterObjFree(virNWFilterObjPtr obj);
-
virNWFilterObjPtr
virNWFilterObjFindByUUID(virNWFilterObjListPtr nwfilters,
const unsigned char *uuid);
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 83e979a..dd6cb98 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -965,7 +965,9 @@ virNodeDeviceObjUnlock;
virNWFilterObjAssignDef;
virNWFilterObjFindByName;
virNWFilterObjFindByUUID;
+virNWFilterObjGetDef;
virNWFilterObjGetNames;
+virNWFilterObjGetNewDef;
virNWFilterObjListExport;
virNWFilterObjListFree;
virNWFilterObjLoadAllConfigs;
@@ -974,6 +976,7 @@ virNWFilterObjNumOfNWFilters;
virNWFilterObjRemove;
virNWFilterObjTestUnassignDef;
virNWFilterObjUnlock;
+virNWFilterObjWantRemoved;
# conf/virsecretobj.h
diff --git a/src/nwfilter/nwfilter_driver.c b/src/nwfilter/nwfilter_driver.c
index 7e88a40..dd3645a 100644
--- a/src/nwfilter/nwfilter_driver.c
+++ b/src/nwfilter/nwfilter_driver.c
@@ -370,7 +370,7 @@ nwfilterLookupByUUID(virConnectPtr conn,
"%s", _("no nwfilter with matching uuid"));
goto cleanup;
}
- def = obj->def;
+ def = virNWFilterObjGetDef(obj);
if (virNWFilterLookupByUUIDEnsureACL(conn, def) < 0)
goto cleanup;
@@ -401,7 +401,7 @@ nwfilterLookupByName(virConnectPtr conn,
_("no nwfilter with matching name '%s'"),
name);
goto cleanup;
}
- def = obj->def;
+ def = virNWFilterObjGetDef(obj);
if (virNWFilterLookupByNameEnsureACL(conn, def) < 0)
goto cleanup;
@@ -493,7 +493,7 @@ nwfilterDefineXML(virConnectPtr conn,
if (!(obj = virNWFilterObjAssignDef(&driver->nwfilters, def)))
goto cleanup;
def = NULL;
- objdef = obj->def;
+ objdef = virNWFilterObjGetDef(obj);
if (virNWFilterSaveDef(driver->configDir, objdef) < 0) {
virNWFilterObjRemove(&driver->nwfilters, obj);
@@ -531,7 +531,7 @@ nwfilterUndefine(virNWFilterPtr nwfilter)
"%s", _("no nwfilter with matching uuid"));
goto cleanup;
}
- def = obj->def;
+ def = virNWFilterObjGetDef(obj);
if (virNWFilterUndefineEnsureACL(nwfilter->conn, def) < 0)
goto cleanup;
@@ -580,7 +580,7 @@ nwfilterGetXMLDesc(virNWFilterPtr nwfilter,
"%s", _("no nwfilter with matching uuid"));
goto cleanup;
}
- def = obj->def;
+ def = virNWFilterObjGetDef(obj);
if (virNWFilterGetXMLDescEnsureACL(nwfilter->conn, def) < 0)
goto cleanup;
diff --git a/src/nwfilter/nwfilter_gentech_driver.c
b/src/nwfilter/nwfilter_gentech_driver.c
index 761a01b..b356d87 100644
--- a/src/nwfilter/nwfilter_gentech_driver.c
+++ b/src/nwfilter/nwfilter_gentech_driver.c
@@ -379,6 +379,7 @@ virNWFilterIncludeDefToRuleInst(virNWFilterDriverStatePtr driver,
virNWFilterObjPtr obj;
virNWFilterHashTablePtr tmpvars = NULL;
virNWFilterDefPtr childdef;
+ virNWFilterDefPtr newChilddef;
int ret = -1;
VIR_DEBUG("Instantiating filter %s", inc->filterref);
@@ -390,7 +391,7 @@ virNWFilterIncludeDefToRuleInst(virNWFilterDriverStatePtr driver,
inc->filterref);
goto cleanup;
}
- if (obj->wantRemoved) {
+ if (virNWFilterObjWantRemoved(obj)) {
virReportError(VIR_ERR_NO_NWFILTER,
_("Filter '%s' is in use."),
inc->filterref);
@@ -402,12 +403,13 @@ virNWFilterIncludeDefToRuleInst(virNWFilterDriverStatePtr driver,
vars)))
goto cleanup;
- childdef = obj->def;
+ childdef = virNWFilterObjGetDef(obj);
switch (useNewFilter) {
case INSTANTIATE_FOLLOW_NEWFILTER:
- if (obj->newDef) {
- childdef = obj->newDef;
+ newChilddef = virNWFilterObjGetNewDef(obj);
+ if (newChilddef) {
+ childdef = newChilddef;
*foundNewFilter = true;
}
break;
@@ -505,6 +507,7 @@ virNWFilterDetermineMissingVarsRec(virNWFilterDefPtr filter,
int rc = 0;
size_t i, j;
virNWFilterDefPtr next_filter;
+ virNWFilterDefPtr newNext_filter;
virNWFilterVarValuePtr val;
for (i = 0; i < filter->nentries; i++) {
@@ -545,7 +548,7 @@ virNWFilterDetermineMissingVarsRec(virNWFilterDefPtr filter,
obj = virNWFilterObjFindByName(&driver->nwfilters,
inc->filterref);
if (obj) {
- if (obj->wantRemoved) {
+ if (virNWFilterObjWantRemoved(obj)) {
virReportError(VIR_ERR_NO_NWFILTER,
_("Filter '%s' is in use."),
inc->filterref);
@@ -564,12 +567,13 @@ virNWFilterDetermineMissingVarsRec(virNWFilterDefPtr filter,
break;
}
- next_filter = obj->def;
+ next_filter = virNWFilterObjGetDef(obj);
switch (useNewFilter) {
case INSTANTIATE_FOLLOW_NEWFILTER:
- if (obj->newDef)
- next_filter = obj->newDef;
+ newNext_filter = virNWFilterObjGetNewDef(obj);
+ if (newNext_filter)
+ next_filter = newNext_filter;
break;
case INSTANTIATE_ALWAYS:
break;
@@ -790,6 +794,7 @@ __virNWFilterInstantiateFilter(virNWFilterDriverStatePtr driver,
virNWFilterObjPtr obj;
virNWFilterHashTablePtr vars, vars1;
virNWFilterDefPtr filter;
+ virNWFilterDefPtr newFilter;
char vmmacaddr[VIR_MAC_STRING_BUFLEN] = {0};
char *str_macaddr = NULL;
virNWFilterVarValuePtr ipaddr;
@@ -815,7 +820,7 @@ __virNWFilterInstantiateFilter(virNWFilterDriverStatePtr driver,
return -1;
}
- if (obj->wantRemoved) {
+ if (virNWFilterObjWantRemoved(obj)) {
virReportError(VIR_ERR_NO_NWFILTER,
_("Filter '%s' is in use."),
filtername);
@@ -847,12 +852,13 @@ __virNWFilterInstantiateFilter(virNWFilterDriverStatePtr driver,
goto err_exit_vars1;
}
- filter = obj->def;
+ filter = virNWFilterObjGetDef(obj);
switch (useNewFilter) {
case INSTANTIATE_FOLLOW_NEWFILTER:
- if (obj->newDef) {
- filter = obj->newDef;
+ newFilter = virNWFilterObjGetNewDef(obj);
+ if (newFilter) {
+ filter = newFilter;
*foundNewFilter = true;
}
break;
--
2.9.3