mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-23 14:15:28 +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,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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user