72 lines
2.4 KiB
Diff
72 lines
2.4 KiB
Diff
Subject: snapshots: default to same snapshot mode as currently used snapshot
|
|
From: Pavel Hrdina phrdina@redhat.com Tue Jan 21 11:09:00 2025 +0100
|
|
Date: Mon Jan 27 22:59:56 2025 +0100:
|
|
Git: 40d86086b6b903982b5d0f97bd6763fc54bfb115
|
|
|
|
Using internal and external snapshot mode for the same VM has some
|
|
limitations. When creating new snapshot default to the same mode as
|
|
already existing currently used snapshot. If there is no existing
|
|
snapshot default to external snapshot.
|
|
|
|
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
|
|
|
|
diff --git a/virtManager/details/snapshots.py b/virtManager/details/snapshots.py
|
|
index a4f38de6d..00aa00708 100644
|
|
--- a/virtManager/details/snapshots.py
|
|
+++ b/virtManager/details/snapshots.py
|
|
@@ -138,7 +138,14 @@ class vmmSnapshotNew(vmmGObjectUI):
|
|
mode_external = self.widget("snapshot-new-mode-external")
|
|
mode_internal = self.widget("snapshot-new-mode-internal")
|
|
|
|
- if mode_external.is_sensitive():
|
|
+ use_external = mode_external.is_sensitive()
|
|
+
|
|
+ if use_external:
|
|
+ current_mode = self._get_current_mode()
|
|
+ if current_mode == "internal":
|
|
+ use_external = False
|
|
+
|
|
+ if use_external:
|
|
mode_external.set_active(True)
|
|
else:
|
|
mode_internal.set_active(True)
|
|
@@ -342,6 +349,17 @@ class vmmSnapshotNew(vmmGObjectUI):
|
|
self.topwin)
|
|
progWin.run()
|
|
|
|
+ def _get_current_mode(self):
|
|
+ current = self.vm.get_current_snapshot()
|
|
+
|
|
+ if current is None:
|
|
+ return None
|
|
+
|
|
+ if current.is_external():
|
|
+ return "external"
|
|
+
|
|
+ return "internal"
|
|
+
|
|
|
|
################
|
|
# UI listeners #
|
|
diff --git a/virtManager/object/domain.py b/virtManager/object/domain.py
|
|
index dbb932162..5aade01d8 100644
|
|
--- a/virtManager/object/domain.py
|
|
+++ b/virtManager/object/domain.py
|
|
@@ -1156,6 +1156,16 @@ class vmmDomain(vmmLibvirtObject):
|
|
self._snapshot_list = newlist
|
|
return self._snapshot_list[:]
|
|
|
|
+ def get_current_snapshot(self):
|
|
+
|
|
+ if self._backend.hasCurrentSnapshot(0):
|
|
+ rawsnap = self._backend.snapshotCurrent(0)
|
|
+ obj = vmmDomainSnapshot(self.conn, rawsnap)
|
|
+ obj.init_libvirt_state()
|
|
+ return obj
|
|
+
|
|
+ return None
|
|
+
|
|
@vmmLibvirtObject.lifecycle_action
|
|
def revert_to_snapshot(self, snap):
|
|
# no use trying to set the guest time if is going to be switched off
|