The managed state file is not useful anymore after the domain is
undefined, and perhaps cause confusion. E.g. define & start a domain
which has same name with previous undefined domain later.
---
src/qemu/qemu_driver.c | 8 ++++++++
1 files changed, 8 insertions(+), 0 deletions(-)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index f6e503a..874b455 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -3739,6 +3739,7 @@ static int qemudDomainUndefine(virDomainPtr dom) {
virDomainObjPtr vm;
virDomainEventPtr event = NULL;
int ret = -1;
+ char *managed_save = NULL;
qemuDriverLock(driver);
vm = virDomainFindByUUID(&driver->domains, dom->uuid);
@@ -3766,6 +3767,13 @@ static int qemudDomainUndefine(virDomainPtr dom) {
if (virDomainDeleteConfig(driver->configDir, driver->autostartDir, vm) < 0)
goto cleanup;
+ if (!(managed_save = qemuDomainManagedSavePath(driver, vm)))
+ goto cleanup;
+
+ if (virFileExists(managed_save) && (unlink(managed_save) < 0)) {
+ VIR_WARN("Failed to remove the managed state %s", managed_save);
+ }
+
event = virDomainEventNewFromObj(vm,
VIR_DOMAIN_EVENT_UNDEFINED,
VIR_DOMAIN_EVENT_UNDEFINED_REMOVED);
--
1.7.4