Changeset 32643 in vbox
- Timestamp:
- Sep 20, 2010 2:30:38 PM (15 years ago)
- svn:sync-xref-src-repo-rev:
- 66050
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/common/VBoxService/VBoxServiceTimeSync.cpp
r30019 r32643 126 126 * adjust it. This is used to implement --timesync-set-start. */ 127 127 static bool volatile g_fTimeSyncSetNext = false; 128 /** Whether to set the time when the VM was restored. */ 129 static bool g_fTimeSyncSetOnRestore = true; 128 130 129 131 /** Current error count. Used to knowing when to bitch and when not to. */ … … 132 134 /** The semaphore we're blocking on. */ 133 135 static RTSEMEVENTMULTI g_TimeSyncEvent = NIL_RTSEMEVENTMULTI; 136 137 /** The VM session ID. Changes whenever the VM is restored or reset. */ 138 static uint64_t g_idTimeSyncSession; 134 139 135 140 #ifdef RT_OS_WINDOWS … … 202 207 } 203 208 } 209 if ( RT_SUCCESS(rc) 210 || rc == VERR_NOT_FOUND) 211 { 212 uint32_t value; 213 rc = VBoxServiceReadPropUInt32(uGuestPropSvcClientID, "/VirtualBox/GuestAdd/VBoxService/--timesync-set-on-restore", 214 &value, 1, 1); 215 if (RT_SUCCESS(rc)) 216 g_fTimeSyncSetOnRestore = !!value; 217 } 204 218 205 219 VbglR3GuestPropDisconnect(uGuestPropSvcClientID); … … 220 234 { 221 235 int rc = -1; 236 uint32_t value; 222 237 if (ppszShort) 223 238 /* no short options */; … … 242 257 rc = VINF_SUCCESS; 243 258 } 259 else if (!strcmp(argv[*pi], "----timesync-set-on-restore")) 260 rc = VBoxServiceArgUInt32(argc, argv, "", pi, 261 &value, 1, 1); 262 { 263 g_fTimeSyncSetOnRestore = !!value; 264 } 244 265 245 266 return rc; … … 258 279 if (!g_TimeSyncInterval) 259 280 g_TimeSyncInterval = 10 * 1000; 281 282 VbglR3GetSessionId(&g_idTimeSyncSession); 283 /* The status code is ignored as this information is not available with VBox < 3.2.10. */ 260 284 261 285 int rc = RTSemEventMultiCreate(&g_TimeSyncEvent); … … 503 527 { 504 528 /* 529 * Set the time once after we were restored. 530 * (Of course only if the drift is bigger than MinAdjust) 531 */ 532 uint32_t TimeSyncSetThreshold = g_TimeSyncSetThreshold; 533 if (g_fTimeSyncSetOnRestore) 534 { 535 uint64_t idNewSession = g_idTimeSyncSession; 536 VbglR3GetSessionId(&idNewSession); 537 if (idNewSession != g_idTimeSyncSession) 538 { 539 VBoxServiceVerbose(3, "TimeSync: The VM session ID changed, forcing resync.\n"); 540 TimeSyncSetThreshold = 0; 541 g_idTimeSyncSession = idNewSession; 542 } 543 } 544 545 /* 505 546 * Calculate the adjustment threshold and the current drift. 506 547 */ … … 535 576 */ 536 577 537 if ( AbsDriftMilli > g_TimeSyncSetThreshold578 if ( AbsDriftMilli > TimeSyncSetThreshold 538 579 || g_fTimeSyncSetNext 539 580 || !VBoxServiceTimeSyncAdjust(&Drift)) … … 627 668 " [--timesync-latency-factor <x>] [--timesync-max-latency <ms>]\n" 628 669 " [--timesync-set-threshold <ms>] [--timesync-set-start]" 670 " [--timesync-set-restore 0|1]\n" 629 671 , 630 672 /* pszOptions. */ … … 645 687 " adjust it. The default is 20 min.\n" 646 688 " --timesync-set-start Set the time when starting the time sync service.\n" 689 " --timesync-set-on-restore 0|1\n" 690 " Immediately set the time when the VM was restored.\n" 691 " 1 = set (default), 0 = don't set.\n" 647 692 , 648 693 /* methods */
Note:
See TracChangeset
for help on using the changeset viewer.