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
This commit is contained in:
Roman Bogorodskiy 2014-04-21 20:15:26 +04:00
parent 7b6b9d3863
commit fa8a389ebb

View File

@ -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;
}