[libvirt] [PATCH] bhyve: bhyveDomainDefineXML fixes

Roman Bogorodskiy bogorodskiy at gmail.com
Mon Apr 21 16:22:23 UTC 2014


- do not loose new definition for an active domain
- do not leak oldDef
- do not set dom->id if virDomainSaveConfig() fails
- do not call virObjectUnlock(vm) if vm is NULL
---
 src/bhyve/bhyve_driver.c | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/src/bhyve/bhyve_driver.c b/src/bhyve/bhyve_driver.c
index 0cafe4c..6d681fd 100644
--- a/src/bhyve/bhyve_driver.c
+++ b/src/bhyve/bhyve_driver.c
@@ -472,17 +472,23 @@ bhyveDomainDefineXML(virConnectPtr conn, const char *xml)
     def = NULL;
     vm->persistent = 1;
 
+    if (virDomainSaveConfig(BHYVE_CONFIG_DIR,
+                            vm->newDef ? vm->newDef : vm->def) < 0) {
+        virDomainObjListRemove(privconn->domains, vm);
+        vm = NULL;
+        goto cleanup;
+    }
+
     dom = virGetDomain(conn, vm->def->name, vm->def->uuid);
     if (dom)
         dom->id = vm->def->id;
 
-    if (virDomainSaveConfig(BHYVE_CONFIG_DIR, vm->def) < 0)
-        goto cleanup;
-
  cleanup:
     virObjectUnref(caps);
     virDomainDefFree(def);
-    virObjectUnlock(vm);
+    virDomainDefFree(oldDef);
+    if (vm)
+        virObjectUnlock(vm);
 
     return dom;
 }
-- 
1.9.0




More information about the libvir-list mailing list