[libvirt] [PATCH 14/15] nwfilter: Move save of config until after successful assign

John Ferlan posted 15 patches 8 years, 9 months ago
There is a newer version of this series
[libvirt] [PATCH 14/15] nwfilter: Move save of config until after successful assign
Posted by John Ferlan 8 years, 9 months ago
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>
---
 src/conf/virnwfilterobj.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/conf/virnwfilterobj.c b/src/conf/virnwfilterobj.c
index ec28b05..e37acf0 100644
--- a/src/conf/virnwfilterobj.c
+++ b/src/conf/virnwfilterobj.c
@@ -510,14 +510,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(configFile, def) < 0)
         goto error;
 
-    if (!(obj = virNWFilterObjListAssignDef(nwfilters, def)))
-        goto error;
-
     VIR_FREE(configFile);
     return obj;
 
-- 
2.9.3

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 14/15] nwfilter: Move save of config until after successful assign
Posted by Pavel Hrdina 8 years, 9 months ago
On Mon, Apr 24, 2017 at 03:18:43PM -0400, John Ferlan wrote:
> 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>
> ---
>  src/conf/virnwfilterobj.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)

ACK

Pavel
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list