Start a domain whilst undefine it, if starting failed duing ProcessLaunch, on which period qemu exited unexpectedly, the operation will lead to failure of undefine the domain until libvirtd restarted. The reason is that libvirtd will unlock vm during qemuProcessStart, qemuDomainUndefineFlags can get the lock and set vm->persistent 0 but not remove the "active" domain. Signed-off-by: Yi Wang <wang.yi59@xxxxxxxxxx> --- src/conf/domain_conf.h | 1 + src/qemu/qemu_driver.c | 6 ++++++ src/qemu/qemu_process.c | 3 +++ 3 files changed, 10 insertions(+) diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index af15ee8..f339f84 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -2468,6 +2468,7 @@ struct _virDomainObj { virDomainSnapshotObjPtr current_snapshot; bool hasManagedSave; + bool starting; void *privateData; void (*privateDataFreeFunc)(void *); diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 6568def..5d9acfc 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -7317,6 +7317,12 @@ qemuDomainUndefineFlags(virDomainPtr dom, if (!(vm = qemuDomObjFromDomain(dom))) return -1; + if (vm->starting) { + virReportError(VIR_ERR_OPERATION_INVALID, + "%s", _("cannot undefine during domain starting up")); + goto cleanup; + } + cfg = virQEMUDriverGetConfig(driver); if (virDomainUndefineFlagsEnsureACL(dom->conn, vm->def) < 0) diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 525521a..7b708be 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -5847,6 +5847,8 @@ qemuProcessStart(virConnectPtr conn, if (!migrateFrom && !snapshot) flags |= VIR_QEMU_PROCESS_START_NEW; + vm->starting = true; + if (qemuProcessInit(driver, vm, updatedCPU, asyncJob, !!migrateFrom, flags) < 0) goto cleanup; @@ -5892,6 +5894,7 @@ qemuProcessStart(virConnectPtr conn, ret = 0; cleanup: + vm->starting = false; qemuProcessIncomingDefFree(incoming); return ret; -- 1.8.3.1 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list