From fa8a389ebb25f73ad4c8d561750e7d2e049990d5 Mon Sep 17 00:00:00 2001 From: Roman Bogorodskiy Date: Mon, 21 Apr 2014 20:15:26 +0400 Subject: [PATCH] bhyve: bhyveDomainDefineXML fixes - do not lose 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 0cafe4cc41..6d681fd6e4 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; }