nwfilter: Move save of config until after successful assign

Only save the config when using a generated UUID if we were able to
create an object for the def. There could have been "other reasons"
for the assignment to fail, so saving the config could be incorrect.

Signed-off-by: John Ferlan <jferlan@redhat.com>
This commit is contained in:
John Ferlan 2017-04-20 11:51:22 -04:00
parent 245f1d8521
commit b3e71a8830

View File

@ -500,14 +500,14 @@ virNWFilterObjListLoadConfig(virNWFilterObjListPtr nwfilters,
goto error;
}
if (!(obj = virNWFilterObjListAssignDef(nwfilters, def)))
goto error;
/* We generated a UUID, make it permanent by saving the config to disk */
if (!def->uuid_specified &&
virNWFilterSaveConfig(configDir, def) < 0)
goto error;
if (!(obj = virNWFilterObjListAssignDef(nwfilters, def)))
goto error;
VIR_FREE(configFile);
return obj;