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

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

 



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

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list


[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]