From b814d499a7f2813004d5b5022b6c5f1349446e2a Mon Sep 17 00:00:00 2001 From: Nikolay Shirokovskiy Date: Tue, 3 Nov 2020 10:16:21 +0300 Subject: [PATCH] qemu: remove possible garbage left from previous rename/undefine Due to failures to unlink on previous rename/undefine we can already have autolink etc files for the domain to be defined. Remove them. Signed-off-by: Nikolay Shirokovskiy Reviewed-by: Daniel Henrique Barboza --- src/qemu/qemu_driver.c | 6 ++++++ src/qemu/qemu_migration.c | 3 +++ 2 files changed, 9 insertions(+) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index cb7da97b8e..8e20a931a2 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -6719,6 +6719,9 @@ qemuDomainDefineXMLFlags(virConnectPtr conn, goto cleanup; def = NULL; + if (!oldDef && qemuDomainNamePathsCleanup(cfg, vm->def->name, false) < 0) + goto cleanup; + if (virDomainDefSave(vm->newDef ? vm->newDef : vm->def, driver->xmlopt, cfg->configDir) < 0) goto cleanup; @@ -19179,6 +19182,9 @@ qemuDomainRenameCallback(virDomainObjPtr vm, vm->def->name))) return -1; + if (qemuDomainNamePathsCleanup(cfg, new_name, false) < 0) + goto cleanup; + if (vm->autostart) { if (!(new_dom_autostart_link = virDomainConfigFile(cfg->autostartDir, new_dom_name)) || diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c index 8c3af7f04a..fef0be63a1 100644 --- a/src/qemu/qemu_migration.c +++ b/src/qemu/qemu_migration.c @@ -5137,6 +5137,9 @@ qemuMigrationDstPersist(virQEMUDriverPtr driver, priv->qemuCaps))) goto error; + if (!oldPersist && qemuDomainNamePathsCleanup(cfg, vmdef->name, false) < 0) + goto error; + if (virDomainDefSave(vmdef, driver->xmlopt, cfg->configDir) < 0 && !ignoreSaveError) goto error;