[PATCH] qemu: Do not unlink managedsave image if restoring fails.

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

 



Both "qemuDomainStartWithFlags" and "qemuAutostartDomain" try to
restore the domain from managedsave'ed image if it exists (by
invoking "qemuDomainObjRestore"), but it unlinks the image even
if restoring fails, which causes data loss.

However, I'm not sure if it's the very correct way to fix it,
if restoring fails, and we didn't remove the image, it will
trys to restore from the image again next time, if that's
not the user expected (e.g. the user made quite many changes
on the guest), then it's a new problem.
---
 src/qemu/qemu_driver.c |   12 +++++++-----
 1 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 48fe266..22c29e4 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -3423,18 +3423,20 @@ static int qemudDomainObjStart(virConnectPtr conn,
 
     /*
      * If there is a managed saved state restore it instead of starting
-     * from scratch. In any case the old state is removed.
+     * from scratch.
      */
     managed_save = qemuDomainManagedSavePath(driver, vm);
     if ((managed_save) && (virFileExists(managed_save))) {
         ret = qemuDomainObjRestore(conn, driver, vm, managed_save);
 
-        if (unlink(managed_save) < 0) {
-            VIR_WARN("Failed to remove the managed state %s", managed_save);
-        }
+        if (ret == 0) {
+            if (unlink(managed_save) < 0)
+                VIR_WARN("Failed to remove the managed state %s", managed_save);
 
-        if (ret == 0)
             goto cleanup;
+        } else {
+            VIR_WARN("Failed to restore from the managed state %s", managed_save);
+        }
     }
 
     ret = qemuProcessStart(conn, driver, vm, NULL, start_paused, -1, NULL,
-- 
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]