[PATCH v2 02/11] virDomainObjListAddLocked: Set vm->def only in success path

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Because of past limitation of virDomainObjListAddObjLocked() we
had to set vm->def even before the object was on the domains
list.

Signed-off-by: Michal Privoznik <mprivozn@xxxxxxxxxx>
Reviewed-by: Nikolay Shirokovskiy <nshirokovskiy@xxxxxxxxxxxxx>
---
 src/conf/virdomainobjlist.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/src/conf/virdomainobjlist.c b/src/conf/virdomainobjlist.c
index 28cccd0035..1086aec421 100644
--- a/src/conf/virdomainobjlist.c
+++ b/src/conf/virdomainobjlist.c
@@ -337,12 +337,11 @@ virDomainObjListAddLocked(virDomainObjListPtr doms,
 
         if (!(vm = virDomainObjNew(xmlopt)))
             goto error;
+
+        if (virDomainObjListAddObjLocked(doms, vm, def->uuid, def->name) < 0)
+            goto error;
+
         vm->def = def;
-
-        if (virDomainObjListAddObjLocked(doms, vm, def->uuid, def->name) < 0) {
-            vm->def = NULL;
-            goto error;
-        }
     }
 
     return vm;
-- 
2.21.0

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



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux