[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[libvirt] [PATCH v2] qemu: Unlink managed state file when a domain is undefined



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 but different UUID with previous undefined
domain later.

v1 - v2:
   * Try to delete the managed state file before delete domain
config file, and goto fail if it failed to delete it.
---
 src/qemu/qemu_driver.c |   10 ++++++++++
 1 files changed, 10 insertions(+), 0 deletions(-)

diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 771678e..4c5edd4 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -3738,6 +3738,7 @@ static int qemudDomainUndefine(virDomainPtr dom) {
     struct qemud_driver *driver = dom->conn->privateData;
     virDomainObjPtr vm;
     virDomainEventPtr event = NULL;
+    char *managed_save = NULL;
     int ret = -1;
 
     qemuDriverLock(driver);
@@ -3763,6 +3764,15 @@ static int qemudDomainUndefine(virDomainPtr dom) {
         goto cleanup;
     }
 
+    if (!(managed_save = qemuDomainManagedSavePath(driver, vm)))
+        goto cleanup;
+
+    if (virFileExists(managed_save) && (unlink(managed_save) < 0)) {
+        virReportSystemError(errno, "%s",
+                             _("Failed to delete managed state file"));
+        goto cleanup;
+     }
+
     if (virDomainDeleteConfig(driver->configDir, driver->autostartDir, vm) < 0)
         goto cleanup;
 
-- 
1.7.4


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]