mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-11 23:37:42 +00:00
virDomainCreateXML: Don't remove persistent domains on error
https://bugzilla.redhat.com/show_bug.cgi?id=871452 Okay, so we allow users to 'virsh create' an already existing domain, providing completely different XML than the one stored in Libvirt. Well, as long as name and UUID matches. However, in some drivers the code that handles errors unconditionally removes the domain that failed to start even though the domain might have been persistent. Fortunately, the domain is removed just from the internal list of domains and the config file is kept around. Steps to reproduce: 1) virsh dumpxml $dom > /tmp/dom.xml 2) change XML so that it is still parse-able but won't boot, e.g. change guest agent path to /foo/bar 3) virsh create /tmp/dom.xml 4) virsh dumpxml $dom 5) Observe "No such domain" error Signed-off-by: Michal Privoznik <mprivozn@redhat.com> (cherry picked from commit 37405b910907bd1ad338fb0d6a967bfd23529cf6)
This commit is contained in:
parent
c22a4bb523
commit
e89b42ccc6
@ -1239,8 +1239,10 @@ lxcDomainCreateXMLWithFiles(virConnectPtr conn,
|
|||||||
(flags & VIR_DOMAIN_START_AUTODESTROY),
|
(flags & VIR_DOMAIN_START_AUTODESTROY),
|
||||||
VIR_DOMAIN_RUNNING_BOOTED) < 0) {
|
VIR_DOMAIN_RUNNING_BOOTED) < 0) {
|
||||||
virDomainAuditStart(vm, "booted", false);
|
virDomainAuditStart(vm, "booted", false);
|
||||||
virDomainObjListRemove(driver->domains, vm);
|
if (!vm->persistent) {
|
||||||
vm = NULL;
|
virDomainObjListRemove(driver->domains, vm);
|
||||||
|
vm = NULL;
|
||||||
|
}
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1751,7 +1751,8 @@ static virDomainPtr qemuDomainCreateXML(virConnectPtr conn,
|
|||||||
def = NULL;
|
def = NULL;
|
||||||
|
|
||||||
if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_MODIFY) < 0) {
|
if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_MODIFY) < 0) {
|
||||||
qemuDomainRemoveInactive(driver, vm);
|
if (!vm->persistent)
|
||||||
|
qemuDomainRemoveInactive(driver, vm);
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1761,7 +1762,8 @@ static virDomainPtr qemuDomainCreateXML(virConnectPtr conn,
|
|||||||
start_flags) < 0) {
|
start_flags) < 0) {
|
||||||
virDomainAuditStart(vm, "booted", false);
|
virDomainAuditStart(vm, "booted", false);
|
||||||
qemuDomainObjEndJob(driver, vm);
|
qemuDomainObjEndJob(driver, vm);
|
||||||
qemuDomainRemoveInactive(driver, vm);
|
if (!vm->persistent)
|
||||||
|
qemuDomainRemoveInactive(driver, vm);
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1621,8 +1621,13 @@ testDomainCreateXML(virConnectPtr conn, const char *xml,
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
def = NULL;
|
def = NULL;
|
||||||
|
|
||||||
if (testDomainStartState(privconn, dom, VIR_DOMAIN_RUNNING_BOOTED) < 0)
|
if (testDomainStartState(privconn, dom, VIR_DOMAIN_RUNNING_BOOTED) < 0) {
|
||||||
|
if (!dom->persistent) {
|
||||||
|
virDomainObjListRemove(privconn->domains, dom);
|
||||||
|
dom = NULL;
|
||||||
|
}
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
}
|
||||||
|
|
||||||
event = virDomainEventLifecycleNewFromObj(dom,
|
event = virDomainEventLifecycleNewFromObj(dom,
|
||||||
VIR_DOMAIN_EVENT_STARTED,
|
VIR_DOMAIN_EVENT_STARTED,
|
||||||
|
@ -1623,9 +1623,10 @@ static virDomainPtr umlDomainCreateXML(virConnectPtr conn, const char *xml,
|
|||||||
if (umlStartVMDaemon(conn, driver, vm,
|
if (umlStartVMDaemon(conn, driver, vm,
|
||||||
(flags & VIR_DOMAIN_START_AUTODESTROY)) < 0) {
|
(flags & VIR_DOMAIN_START_AUTODESTROY)) < 0) {
|
||||||
virDomainAuditStart(vm, "booted", false);
|
virDomainAuditStart(vm, "booted", false);
|
||||||
virDomainObjListRemove(driver->domains,
|
if (!vm->persistent) {
|
||||||
vm);
|
virDomainObjListRemove(driver->domains, vm);
|
||||||
vm = NULL;
|
vm = NULL;
|
||||||
|
}
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
virDomainAuditStart(vm, "booted", true);
|
virDomainAuditStart(vm, "booted", true);
|
||||||
|
@ -710,8 +710,10 @@ vmwareDomainCreateXML(virConnectPtr conn, const char *xml,
|
|||||||
vmdef = NULL;
|
vmdef = NULL;
|
||||||
|
|
||||||
if (vmwareStartVM(driver, vm) < 0) {
|
if (vmwareStartVM(driver, vm) < 0) {
|
||||||
virDomainObjListRemove(driver->domains, vm);
|
if (!vm->persistent) {
|
||||||
vm = NULL;
|
virDomainObjListRemove(driver->domains, vm);
|
||||||
|
vm = NULL;
|
||||||
|
}
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user