[RFC PATCH v2 4/7] virtManager: object: domain: Set time on unpause and revert

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

 



Wire up setting of guest time on snapshot restore and resume from pause.
Do not try to set time if the restored snapshot does not contain a
running domain state.

Signed-off-by: Michael Weiser <michael.weiser@xxxxxx>
Suggested-by: Cole Robinson <crobinso@xxxxxxxxxx>
---
 virtManager/object/domain.py | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/virtManager/object/domain.py b/virtManager/object/domain.py
index 24c2ca75..bad7108e 100644
--- a/virtManager/object/domain.py
+++ b/virtManager/object/domain.py
@@ -156,6 +156,11 @@ class vmmDomainSnapshot(vmmLibvirtObject):
             log.debug("Unknown status %d, using NOSTATE", status)
             status = libvirt.VIR_DOMAIN_NOSTATE
         return LibvirtEnumMap.VM_STATUS_ICONS[status]
+    def is_running(self):
+        """
+        Captured state is a running domain.
+        """
+        return self._state_str_to_int() in [libvirt.VIR_DOMAIN_RUNNING]
 
     def is_current(self):
         return self._backend.isCurrent()
@@ -1044,7 +1049,14 @@ class vmmDomain(vmmLibvirtObject):
 
     @vmmLibvirtObject.lifecycle_action
     def revert_to_snapshot(self, snap):
+        # no use trying to set the guest time if is going to be switched off
+        # after reverting to the snapshot
+        target_run_state = snap.is_running()
         self._backend.revertToSnapshot(snap.get_backend())
+        # looking at the domain state after revert will always come back as
+        # paused, so look at the snapshot state instead
+        if target_run_state == libvirt.VIR_DOMAIN_RUNNING:
+            self._set_time()
 
     def create_snapshot(self, xml, redefine=False):
         flags = 0
@@ -1369,6 +1381,7 @@ class vmmDomain(vmmLibvirtObject):
     @vmmLibvirtObject.lifecycle_action
     def resume(self):
         self._backend.resume()
+        self._set_time()
 
     @vmmLibvirtObject.lifecycle_action
     def save(self, meter=None):
-- 
2.24.0


_______________________________________________
virt-tools-list mailing list
virt-tools-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/virt-tools-list




[Index of Archives]     [Linux Virtualization]     [KVM Development]     [CentOS Virtualization]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite Forum]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]     [Video 4 Linux]

  Powered by Linux