mirror of
https://github.com/virt-manager/virt-manager.git
synced 2025-02-25 18:55:27 -06:00
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>
This commit is contained in:
parent
8084639cd8
commit
a8c25450bd
@ -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,
|
||||
|
@ -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()
|
||||
|
Loading…
Reference in New Issue
Block a user