mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-02-08 12:41:29 +00:00
nwfilter: Push configFile building into LoadConfig
This matches the pattern used for network object APIs, and we want configDir in LoadConfig for upcoming patches
This commit is contained in:
parent
ab05abdbc3
commit
0feb1c6c24
@ -3156,30 +3156,38 @@ virNWFilterObjAssignDef(virNWFilterObjListPtr nwfilters,
|
|||||||
|
|
||||||
|
|
||||||
static virNWFilterObjPtr
|
static virNWFilterObjPtr
|
||||||
virNWFilterObjLoad(virNWFilterObjListPtr nwfilters,
|
virNWFilterLoadConfig(virNWFilterObjListPtr nwfilters,
|
||||||
const char *file,
|
const char *configDir,
|
||||||
const char *path)
|
const char *name)
|
||||||
{
|
{
|
||||||
virNWFilterDefPtr def;
|
virNWFilterDefPtr def = NULL;
|
||||||
virNWFilterObjPtr nwfilter;
|
virNWFilterObjPtr nwfilter;
|
||||||
|
char *configFile = NULL;
|
||||||
|
|
||||||
if (!(def = virNWFilterDefParseFile(path)))
|
if (!(configFile = virFileBuildPath(configDir, name, ".xml")))
|
||||||
return NULL;
|
goto error;
|
||||||
|
|
||||||
if (!virFileMatchesNameSuffix(file, def->name, ".xml")) {
|
if (!(def = virNWFilterDefParseFile(configFile)))
|
||||||
|
goto error;
|
||||||
|
|
||||||
|
if (STRNEQ(name, def->name)) {
|
||||||
virReportError(VIR_ERR_XML_ERROR,
|
virReportError(VIR_ERR_XML_ERROR,
|
||||||
_("network filter config filename '%s' does not match name '%s'"),
|
_("network filter config filename '%s' "
|
||||||
path, def->name);
|
"does not match name '%s'"),
|
||||||
virNWFilterDefFree(def);
|
configFile, def->name);
|
||||||
return NULL;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(nwfilter = virNWFilterObjAssignDef(nwfilters, def))) {
|
if (!(nwfilter = virNWFilterObjAssignDef(nwfilters, def)))
|
||||||
virNWFilterDefFree(def);
|
goto error;
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
VIR_FREE(configFile);
|
||||||
return nwfilter;
|
return nwfilter;
|
||||||
|
|
||||||
|
error:
|
||||||
|
VIR_FREE(configFile);
|
||||||
|
virNWFilterDefFree(def);
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -3200,23 +3208,17 @@ virNWFilterLoadAllConfigs(virNWFilterObjListPtr nwfilters,
|
|||||||
}
|
}
|
||||||
|
|
||||||
while ((ret = virDirRead(dir, &entry, configDir)) > 0) {
|
while ((ret = virDirRead(dir, &entry, configDir)) > 0) {
|
||||||
char *path;
|
|
||||||
virNWFilterObjPtr nwfilter;
|
virNWFilterObjPtr nwfilter;
|
||||||
|
|
||||||
if (entry->d_name[0] == '.')
|
if (entry->d_name[0] == '.')
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (!virFileHasSuffix(entry->d_name, ".xml"))
|
if (!virFileStripSuffix(entry->d_name, ".xml"))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (!(path = virFileBuildPath(configDir, entry->d_name, NULL)))
|
nwfilter = virNWFilterLoadConfig(nwfilters, configDir, entry->d_name);
|
||||||
continue;
|
|
||||||
|
|
||||||
nwfilter = virNWFilterObjLoad(nwfilters, entry->d_name, path);
|
|
||||||
if (nwfilter)
|
if (nwfilter)
|
||||||
virNWFilterObjUnlock(nwfilter);
|
virNWFilterObjUnlock(nwfilter);
|
||||||
|
|
||||||
VIR_FREE(path);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
closedir(dir);
|
closedir(dir);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user