Move the function into nwfilterobj, rename it to virNWFilterObjSaveConfig, and alter the order of the arguments. Signed-off-by: John Ferlan <jferlan@xxxxxxxxxx> --- src/conf/nwfilter_conf.c | 27 --------------------------- src/conf/nwfilter_conf.h | 4 ---- src/conf/virnwfilterobj.c | 30 +++++++++++++++++++++++++++++- src/conf/virnwfilterobj.h | 4 ++++ src/libvirt_private.syms | 2 +- src/nwfilter/nwfilter_driver.c | 2 +- 6 files changed, 35 insertions(+), 34 deletions(-) diff --git a/src/conf/nwfilter_conf.c b/src/conf/nwfilter_conf.c index fba792a..bcff4b6 100644 --- a/src/conf/nwfilter_conf.c +++ b/src/conf/nwfilter_conf.c @@ -2766,33 +2766,6 @@ virNWFilterDefParseFile(const char *filename) } -int -virNWFilterSaveConfig(const char *configDir, - virNWFilterDefPtr def) -{ - int ret = -1; - char *xml; - char uuidstr[VIR_UUID_STRING_BUFLEN]; - char *configFile = NULL; - - if (!(xml = virNWFilterDefFormat(def))) - goto cleanup; - - if (!(configFile = virFileBuildPath(configDir, def->name, ".xml"))) - goto cleanup; - - virUUIDFormat(def->uuid, uuidstr); - ret = virXMLSaveFile(configFile, - virXMLPickShellSafeComment(def->name, uuidstr), - "nwfilter-edit", xml); - - cleanup: - VIR_FREE(configFile); - VIR_FREE(xml); - return ret; -} - - int nCallbackDriver; #define MAX_CALLBACK_DRIVER 10 static virNWFilterCallbackDriverPtr callbackDrvArray[MAX_CALLBACK_DRIVER]; diff --git a/src/conf/nwfilter_conf.h b/src/conf/nwfilter_conf.h index 4bf5b7c..ac6aee9 100644 --- a/src/conf/nwfilter_conf.h +++ b/src/conf/nwfilter_conf.h @@ -580,10 +580,6 @@ virNWFilterDefParseNode(xmlDocPtr xml, char * virNWFilterDefFormat(const virNWFilterDef *def); -int -virNWFilterSaveConfig(const char *configDir, - virNWFilterDefPtr def); - virNWFilterDefPtr virNWFilterDefParseString(const char *xml); diff --git a/src/conf/virnwfilterobj.c b/src/conf/virnwfilterobj.c index 0343c0a..5834b9d 100644 --- a/src/conf/virnwfilterobj.c +++ b/src/conf/virnwfilterobj.c @@ -478,6 +478,34 @@ virNWFilterObjListExport(virConnectPtr conn, } +int +virNWFilterObjSaveConfig(virNWFilterObjPtr obj, + const char *configDir) +{ + virNWFilterDefPtr def = obj->def; + int ret = -1; + char *xml; + char uuidstr[VIR_UUID_STRING_BUFLEN]; + char *configFile = NULL; + + if (!(xml = virNWFilterDefFormat(def))) + goto cleanup; + + if (!(configFile = virFileBuildPath(configDir, def->name, ".xml"))) + goto cleanup; + + virUUIDFormat(def->uuid, uuidstr); + ret = virXMLSaveFile(configFile, + virXMLPickShellSafeComment(def->name, uuidstr), + "nwfilter-edit", xml); + + cleanup: + VIR_FREE(configFile); + VIR_FREE(xml); + return ret; +} + + static virNWFilterObjPtr virNWFilterObjListLoadConfig(virNWFilterObjListPtr nwfilters, const char *configDir, @@ -512,7 +540,7 @@ virNWFilterObjListLoadConfig(virNWFilterObjListPtr nwfilters, * object as a future load would regenerate a UUID and try again, * but the existing config would still exist and can be used. */ if (!objdef->uuid_specified && - virNWFilterSaveConfig(configDir, objdef) < 0) + virNWFilterObjSaveConfig(objdef, configDir) < 0) VIR_INFO("failed to save generated UUID for filter '%s'", objdef->name); VIR_FREE(configFile); diff --git a/src/conf/virnwfilterobj.h b/src/conf/virnwfilterobj.h index 29d9086..16f4e1b 100644 --- a/src/conf/virnwfilterobj.h +++ b/src/conf/virnwfilterobj.h @@ -98,6 +98,10 @@ virNWFilterObjListExport(virConnectPtr conn, virNWFilterObjListFilter aclfilter); int +virNWFilterObjSaveConfig(virNWFilterObjPtr obj, + const char *configDir); + +int virNWFilterObjListLoadAllConfigs(virNWFilterObjListPtr nwfilters, const char *configDir); diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 429b095..cda5f92 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -744,7 +744,6 @@ virNWFilterRuleIsProtocolEthernet; virNWFilterRuleIsProtocolIPv4; virNWFilterRuleIsProtocolIPv6; virNWFilterRuleProtocolTypeToString; -virNWFilterSaveConfig; virNWFilterTriggerVMFilterRebuild; virNWFilterUnlockFilterUpdates; virNWFilterUnRegisterCallbackDriver; @@ -979,6 +978,7 @@ virNWFilterObjListNew; virNWFilterObjListNumOfNWFilters; virNWFilterObjListRemove; virNWFilterObjLock; +virNWFilterObjSaveConfig; virNWFilterObjTestUnassignDef; virNWFilterObjUnlock; virNWFilterObjWantRemoved; diff --git a/src/nwfilter/nwfilter_driver.c b/src/nwfilter/nwfilter_driver.c index 5e62023..c6139d9 100644 --- a/src/nwfilter/nwfilter_driver.c +++ b/src/nwfilter/nwfilter_driver.c @@ -517,7 +517,7 @@ nwfilterDefineXML(virConnectPtr conn, def = NULL; objdef = virNWFilterObjGetDef(obj); - if (virNWFilterSaveConfig(driver->configDir, objdef) < 0) { + if (virNWFilterObjSaveConfig(obj, driver->configDir) < 0) { virNWFilterObjListRemove(driver->nwfilters, obj); goto cleanup; } -- 2.9.4 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list