]> git.ipfire.org Git - thirdparty/open-vm-tools.git/commitdiff
Fix timesync state to be uncalibrated when adjustment is large (>60ms).
authorOliver Kurth <okurth@vmware.com>
Fri, 15 Sep 2017 18:23:31 +0000 (11:23 -0700)
committerOliver Kurth <okurth@vmware.com>
Fri, 15 Sep 2017 18:23:31 +0000 (11:23 -0700)
VMtools has timesync plugin to adjust guest time to match host time. Timesync
relies on a state machine (Uncalibrated, calibrating and PLL states) to
adjust the amount of guest time to match host time. If the guest and host
time differ by more than 60ms, state machine should reset to uncalibrated
state. There is a bug currently that would leave the state in PLL mode even
if the guest and host times differ by more than 60ms since absolute value of
adjustment is not considered. This causes the time sync to happen slower than
expected.

open-vm-tools/lib/include/vmware/tools/utils.h
open-vm-tools/services/plugins/timeSync/timeSync.c

index efe2e5ce79f4243f1f5ddc2e8c449d1f7dd4619f..b5968a432098499186c98c613882445ea3a8ae91 100644 (file)
@@ -1,5 +1,5 @@
 /*********************************************************
- * Copyright (C) 2008-2016 VMware, Inc. All rights reserved.
+ * Copyright (C) 2008-2017 VMware, Inc. All rights reserved.
  *
  * This program is free software; you can redistribute it and/or modify it
  * under the terms of the GNU Lesser General Public License as published
 #  define G_INLINE_FUNC static __inline
 #endif
 
+#ifndef ABS
+#  define ABS(x) (((x) >= 0) ? (x) : -(x))
+#endif
+
 
 /**
  * Converts an UTF-8 path to the local (i.e., glib) file name encoding.
index 8f3138ef20fcd0e2258263ac973adb00ca5a1aad..fbe509cf425fdd3f8712bb43a5a113083a7d51b1 100644 (file)
@@ -1,5 +1,5 @@
 /*********************************************************
- * Copyright (C) 2008-2016 VMware, Inc. All rights reserved.
+ * Copyright (C) 2008-2017 VMware, Inc. All rights reserved.
  *
  * This program is free software; you can redistribute it and/or modify it
  * under the terms of the GNU Lesser General Public License as published
@@ -430,7 +430,7 @@ TimeSyncSlewTime(TimeSyncData *data, int64 adjustment)
       return FALSE;
    }
 
-   if (adjustment > TIMESYNC_PLL_UNSYNC && 
+   if (ABS(adjustment) > TIMESYNC_PLL_UNSYNC && 
        data->slewState != TimeSyncUncalibrated) {
       g_debug("Adjustment too large (%"FMT64"d), resetting PLL state.\n", 
               adjustment);
@@ -443,7 +443,7 @@ TimeSyncSlewTime(TimeSyncData *data, int64 adjustment)
          data->slewState = TimeSyncUncalibrated;
          return FALSE;
       }
-      if (adjustment < TIMESYNC_PLL_ACTIVATE && TimeSync_PLLSupported()) {
+      if (ABS(adjustment) < TIMESYNC_PLL_ACTIVATE && TimeSync_PLLSupported()) {
          g_debug("Starting PLL calibration.\n");
          calibrationStart = now;
          /* Starting out the calibration period we are adjustment behind,