[libvirt] [PATCH RESEND] qemu_driver: unlink new domain cfg file when rollback

Chen Hanxiao chen_han_xiao at 126.com
Fri Oct 28 00:45:41 UTC 2016


From: Chen Hanxiao <chenhanxiao at gmail.com>

If we failed to unlink old dom cfg file, we goto rollback.
But inside rollback, we fogot to unlink the new dom cfg file.
This patch fixes this issue.

Signed-off-by: Chen Hanxiao <chenhanxiao at gmail.com>
---
 src/qemu/qemu_driver.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index e6f845d..3f4a2fb 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -19869,6 +19869,7 @@ qemuDomainRenameCallback(virDomainObjPtr vm,
     char *new_dom_name = NULL;
     char *old_dom_name = NULL;
     char *old_dom_cfg_file = NULL;
+    char *new_dom_cfg_file = NULL;
 
     virCheckFlags(0, ret);
 
@@ -19882,6 +19883,11 @@ qemuDomainRenameCallback(virDomainObjPtr vm,
         goto cleanup;
     }
 
+    if (!(new_dom_cfg_file = virDomainConfigFile(cfg->configDir,
+                                                 new_dom_name))) {
+        goto cleanup;
+    }
+
     event_old = virDomainEventLifecycleNewFromObj(vm,
                                             VIR_DOMAIN_EVENT_UNDEFINED,
                                             VIR_DOMAIN_EVENT_UNDEFINED_RENAMED);
@@ -19909,6 +19915,7 @@ qemuDomainRenameCallback(virDomainObjPtr vm,
 
  cleanup:
     VIR_FREE(old_dom_cfg_file);
+    VIR_FREE(new_dom_cfg_file);
     VIR_FREE(old_dom_name);
     VIR_FREE(new_dom_name);
     qemuDomainEventQueue(driver, event_old);
@@ -19922,6 +19929,10 @@ qemuDomainRenameCallback(virDomainObjPtr vm,
         vm->def->name = old_dom_name;
         old_dom_name = NULL;
     }
+
+    if (virFileExists(new_dom_cfg_file))
+        unlink(new_dom_cfg_file);
+
     goto cleanup;
 }
 
-- 
1.8.3.1





More information about the libvir-list mailing list