[PATCH v2 10/10] qemu: remove possible garbage left from previous rename/undefine

Nikolay Shirokovskiy nshirokovskiy at virtuozzo.com
Tue Nov 3 12:00:08 UTC 2020


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 <nshirokovskiy at virtuozzo.com>
---
 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 6c353a5..3b7d1d7 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;
@@ -19184,6 +19187,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 6f764b0..b4fb586 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 (!oldDef && qemuDomainNamePathsCleanup(cfg, vmdef->name, false) < 0)
+        goto error;
+
     if (virDomainDefSave(vmdef, driver->xmlopt, cfg->configDir) < 0 &&
         !ignoreSaveError)
         goto error;
-- 
1.8.3.1




More information about the libvir-list mailing list