From nobody Sun Feb 8 22:06:40 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1493061540761288.4662282328693; Mon, 24 Apr 2017 12:19:00 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 888216584C; Mon, 24 Apr 2017 19:18:58 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 5B76C174BB; Mon, 24 Apr 2017 19:18:58 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 06BD918523D6; Mon, 24 Apr 2017 19:18:58 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v3OJInCL015147 for ; Mon, 24 Apr 2017 15:18:49 -0400 Received: by smtp.corp.redhat.com (Postfix) id 5FC4188F28; Mon, 24 Apr 2017 19:18:49 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-126-74.rdu2.redhat.com [10.10.126.74]) by smtp.corp.redhat.com (Postfix) with ESMTP id 227B81899C for ; Mon, 24 Apr 2017 19:18:49 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 888216584C Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=libvir-list-bounces@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 888216584C From: John Ferlan To: libvir-list@redhat.com Date: Mon, 24 Apr 2017 15:18:34 -0400 Message-Id: <20170424191844.6245-6-jferlan@redhat.com> In-Reply-To: <20170424191844.6245-1-jferlan@redhat.com> References: <20170424191844.6245-1-jferlan@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 05/15] nwfilter: Make _virNWFilterObjPtr private X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Mon, 24 Apr 2017 19:18:59 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" 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 --- 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 @@ =20 VIR_LOG_INIT("conf.virnwfilterobj"); =20 +struct _virNWFilterObj { + virMutex lock; =20 -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; =20 -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; }; =20 +virNWFilterDefPtr +virNWFilterObjGetDef(virNWFilterObjPtr obj); + +virNWFilterDefPtr +virNWFilterObjGetNewDef(virNWFilterObjPtr obj); + +bool +virNWFilterObjWantRemoved(virNWFilterObjPtr obj); + void virNWFilterObjListFree(virNWFilterObjListPtr nwfilters); =20 @@ -63,9 +62,6 @@ void virNWFilterObjRemove(virNWFilterObjListPtr nwfilters, virNWFilterObjPtr obj); =20 -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; =20 =20 # 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 =3D obj->def; + def =3D virNWFilterObjGetDef(obj); =20 if (virNWFilterLookupByUUIDEnsureACL(conn, def) < 0) goto cleanup; @@ -401,7 +401,7 @@ nwfilterLookupByName(virConnectPtr conn, _("no nwfilter with matching name '%s'"), name); goto cleanup; } - def =3D obj->def; + def =3D virNWFilterObjGetDef(obj); =20 if (virNWFilterLookupByNameEnsureACL(conn, def) < 0) goto cleanup; @@ -493,7 +493,7 @@ nwfilterDefineXML(virConnectPtr conn, if (!(obj =3D virNWFilterObjAssignDef(&driver->nwfilters, def))) goto cleanup; def =3D NULL; - objdef =3D obj->def; + objdef =3D virNWFilterObjGetDef(obj); =20 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 =3D obj->def; + def =3D virNWFilterObjGetDef(obj); =20 if (virNWFilterUndefineEnsureACL(nwfilter->conn, def) < 0) goto cleanup; @@ -580,7 +580,7 @@ nwfilterGetXMLDesc(virNWFilterPtr nwfilter, "%s", _("no nwfilter with matching uuid")); goto cleanup; } - def =3D obj->def; + def =3D virNWFilterObjGetDef(obj); =20 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(virNWFilterDriverStateP= tr driver, virNWFilterObjPtr obj; virNWFilterHashTablePtr tmpvars =3D NULL; virNWFilterDefPtr childdef; + virNWFilterDefPtr newChilddef; int ret =3D -1; =20 VIR_DEBUG("Instantiating filter %s", inc->filterref); @@ -390,7 +391,7 @@ virNWFilterIncludeDefToRuleInst(virNWFilterDriverStateP= tr 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(virNWFilterDriverStat= ePtr driver, vars))) goto cleanup; =20 - childdef =3D obj->def; + childdef =3D virNWFilterObjGetDef(obj); =20 switch (useNewFilter) { case INSTANTIATE_FOLLOW_NEWFILTER: - if (obj->newDef) { - childdef =3D obj->newDef; + newChilddef =3D virNWFilterObjGetNewDef(obj); + if (newChilddef) { + childdef =3D newChilddef; *foundNewFilter =3D true; } break; @@ -505,6 +507,7 @@ virNWFilterDetermineMissingVarsRec(virNWFilterDefPtr fi= lter, int rc =3D 0; size_t i, j; virNWFilterDefPtr next_filter; + virNWFilterDefPtr newNext_filter; virNWFilterVarValuePtr val; =20 for (i =3D 0; i < filter->nentries; i++) { @@ -545,7 +548,7 @@ virNWFilterDetermineMissingVarsRec(virNWFilterDefPtr fi= lter, obj =3D virNWFilterObjFindByName(&driver->nwfilters, inc->filt= erref); if (obj) { =20 - 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; } =20 - next_filter =3D obj->def; + next_filter =3D virNWFilterObjGetDef(obj); =20 switch (useNewFilter) { case INSTANTIATE_FOLLOW_NEWFILTER: - if (obj->newDef) - next_filter =3D obj->newDef; + newNext_filter =3D virNWFilterObjGetNewDef(obj); + if (newNext_filter) + next_filter =3D newNext_filter; break; case INSTANTIATE_ALWAYS: break; @@ -790,6 +794,7 @@ __virNWFilterInstantiateFilter(virNWFilterDriverStatePt= r driver, virNWFilterObjPtr obj; virNWFilterHashTablePtr vars, vars1; virNWFilterDefPtr filter; + virNWFilterDefPtr newFilter; char vmmacaddr[VIR_MAC_STRING_BUFLEN] =3D {0}; char *str_macaddr =3D NULL; virNWFilterVarValuePtr ipaddr; @@ -815,7 +820,7 @@ __virNWFilterInstantiateFilter(virNWFilterDriverStatePt= r driver, return -1; } =20 - if (obj->wantRemoved) { + if (virNWFilterObjWantRemoved(obj)) { virReportError(VIR_ERR_NO_NWFILTER, _("Filter '%s' is in use."), filtername); @@ -847,12 +852,13 @@ __virNWFilterInstantiateFilter(virNWFilterDriverState= Ptr driver, goto err_exit_vars1; } =20 - filter =3D obj->def; + filter =3D virNWFilterObjGetDef(obj); =20 switch (useNewFilter) { case INSTANTIATE_FOLLOW_NEWFILTER: - if (obj->newDef) { - filter =3D obj->newDef; + newFilter =3D virNWFilterObjGetNewDef(obj); + if (newFilter) { + filter =3D newFilter; *foundNewFilter =3D true; } break; --=20 2.9.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list