There are chances that libvirt process is killed and it resulting in stale managed save dirs. So check for it, and cleanup it there's any. Signed-off-by: Purna Pavan Chandra Aekkaladevi <paekkaladevi@xxxxxxxxxxxxxxxxxxx> --- src/ch/ch_driver.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/ch/ch_driver.c b/src/ch/ch_driver.c index 218e2ec56f..09cd6b90e7 100644 --- a/src/ch/ch_driver.c +++ b/src/ch/ch_driver.c @@ -206,6 +206,7 @@ chDomainCreateXML(virConnectPtr conn, virDomainObj *vm = NULL; virDomainPtr dom = NULL; unsigned int parse_flags = VIR_DOMAIN_DEF_PARSE_INACTIVE; + g_autofree char *managed_save_path = NULL; virCheckFlags(VIR_DOMAIN_START_VALIDATE, NULL); @@ -228,6 +229,15 @@ chDomainCreateXML(virConnectPtr conn, NULL))) goto cleanup; + /* cleanup if there's any stale managedsave dir */ + managed_save_path = chDomainManagedSavePath(driver, vm); + if (virFileDeleteTree(managed_save_path) < 0) { + virReportSystemError(errno, + _("Failed to cleanup stale managed save dir '%1$s'"), + managed_save_path); + goto cleanup; + } + if (virDomainObjBeginJob(vm, VIR_JOB_MODIFY) < 0) goto cleanup; @@ -315,6 +325,7 @@ chDomainDefineXMLFlags(virConnectPtr conn, const char *xml, unsigned int flags) g_autoptr(virDomainDef) vmdef = NULL; virDomainObj *vm = NULL; virDomainPtr dom = NULL; + g_autofree char *managed_save_path = NULL; unsigned int parse_flags = VIR_DOMAIN_DEF_PARSE_INACTIVE; virCheckFlags(VIR_DOMAIN_DEFINE_VALIDATE, NULL); @@ -337,6 +348,15 @@ chDomainDefineXMLFlags(virConnectPtr conn, const char *xml, unsigned int flags) 0, NULL))) goto cleanup; + /* cleanup if there's any stale managedsave dir */ + managed_save_path = chDomainManagedSavePath(driver, vm); + if (virFileDeleteTree(managed_save_path) < 0) { + virReportSystemError(errno, + _("Failed to cleanup stale managed save dir '%1$s'"), + managed_save_path); + goto cleanup; + } + vm->persistent = 1; dom = virGetDomain(conn, vm->def->name, vm->def->uuid, vm->def->id); -- 2.34.1 _______________________________________________ Devel mailing list -- devel@xxxxxxxxxxxxxxxxx To unsubscribe send an email to devel-leave@xxxxxxxxxxxxxxxxx