summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Weiser <michael.weiser@gmx.de>2019-12-19 22:52:33 +0100
committerCole Robinson <crobinso@redhat.com>2019-12-23 16:27:52 -0500
commita8c25450bd25092009b7ba3b82d3b5b764f12915 (patch)
tree3402d33ac821a18c4fd4587e6673fa8cb6b55ac1
parent8084639cd807b02ad096ed6e36bf882d86a22089 (diff)
downloadvirt-manager-a8c25450bd25092009b7ba3b82d3b5b764f12915.tar.gz
details: snapshots: Drop saved state on restore
Refuse to restore a non-running state from snapshot while there is saved memory state in order to avoid filesystem corruption. Present a message to the user to that effect and let them choose to either abort the operation or drop the saved state before restoring the snapshot. Reviewed-by: Cole Robinson <crobinso@redhat.com> Signed-off-by: Michael Weiser <michael.weiser@gmx.de> Suggested-by: Cole Robinson <crobinso@redhat.com>
-rw-r--r--virtManager/details/snapshots.py14
-rw-r--r--virtManager/object/domain.py6
2 files changed, 20 insertions, 0 deletions
diff --git a/virtManager/details/snapshots.py b/virtManager/details/snapshots.py
index 65d014a5..bc5b915a 100644
--- a/virtManager/details/snapshots.py
+++ b/virtManager/details/snapshots.py
@@ -656,6 +656,20 @@ class vmmSnapshotPage(vmmGObjectUI):
if not result:
return
+ if self.vm.has_managed_save() and not snap.has_run_state():
+ result = self.err.ok_cancel(
+ _("Saved state will be removed to avoid filesystem corruption"),
+ _("Snapshot '%s' contains only disk and no memory state. "
+ "Restoring the snapshot would leave the existing saved state "
+ "in place, effectively switching a disk underneath a running "
+ "system. Running the domain afterwards would likely result in "
+ "extensive filesystem corruption. Therefore the saved state "
+ "will be removed before restoring the snapshot."
+ ) % snap.get_name())
+ if not result:
+ return
+ self.vm.remove_saved_image()
+
log.debug("Running snapshot '%s'", snap.get_name())
vmmAsyncJob.simple_async(self.vm.revert_to_snapshot,
[snap], self,
diff --git a/virtManager/object/domain.py b/virtManager/object/domain.py
index 778d1fee..ec62b354 100644
--- a/virtManager/object/domain.py
+++ b/virtManager/object/domain.py
@@ -161,6 +161,12 @@ class vmmDomainSnapshot(vmmLibvirtObject):
Captured state is a running domain.
"""
return self._state_str_to_int() in [libvirt.VIR_DOMAIN_RUNNING]
+ def has_run_state(self):
+ """
+ Captured state contains run state in addition to disk state.
+ """
+ return self._state_str_to_int() in [libvirt.VIR_DOMAIN_RUNNING,
+ libvirt.VIR_DOMAIN_PAUSED]
def is_current(self):
return self._backend.isCurrent()