[gnome-boxes/gnome-3-34] libvirt-machine: Update time using host time as fallback



commit 2cb305703d30dcdb5f0f94314a73be6e4be920ec
Author: Dor Askayo <dor askayo gmail com>
Date:   Fri Nov 1 19:08:31 2019 +0200

    libvirt-machine: Update time using host time as fallback
    
    A Real-time Clock (RTC) may not be available to guest agents in some
    scenarios, such as on Windows guest machines.
    
    Fixes #434
    
    (cherry picked from commit 13b094f4a48ea150c386a84bc7722488797db70f)

 src/libvirt-machine.vala | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
---
diff --git a/src/libvirt-machine.vala b/src/libvirt-machine.vala
index 3b19dbac..d9d27e96 100644
--- a/src/libvirt-machine.vala
+++ b/src/libvirt-machine.vala
@@ -649,7 +649,13 @@ else if (state == MachineState.SLEEPING) {
                 try {
                     yield domain.set_time_async (null, 0, null);
                 } catch (GLib.Error error) {
-                    debug ("Failed to update clock on %s: %s", name, error.message);
+                    debug ("Failed to update clock using RTC on %s: %s", name, error.message);
+
+                    try {
+                        yield domain.set_time_async (new DateTime.now_utc (), 0, null);
+                    } catch (GLib.Error error) {
+                        debug ("Failed to update clock using host time on %s: %s", name, error.message);
+                    }
                 }
             }
         }


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