mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-24 06:35:24 +00:00
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:
parent
7b6b9d3863
commit
fa8a389ebb
@ -472,16 +472,22 @@ bhyveDomainDefineXML(virConnectPtr conn, const char *xml)
|
|||||||
def = NULL;
|
def = NULL;
|
||||||
vm->persistent = 1;
|
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);
|
dom = virGetDomain(conn, vm->def->name, vm->def->uuid);
|
||||||
if (dom)
|
if (dom)
|
||||||
dom->id = vm->def->id;
|
dom->id = vm->def->id;
|
||||||
|
|
||||||
if (virDomainSaveConfig(BHYVE_CONFIG_DIR, vm->def) < 0)
|
|
||||||
goto cleanup;
|
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
virObjectUnref(caps);
|
virObjectUnref(caps);
|
||||||
virDomainDefFree(def);
|
virDomainDefFree(def);
|
||||||
|
virDomainDefFree(oldDef);
|
||||||
|
if (vm)
|
||||||
virObjectUnlock(vm);
|
virObjectUnlock(vm);
|
||||||
|
|
||||||
return dom;
|
return dom;
|
||||||
|
Loading…
Reference in New Issue
Block a user