VirtualBox

Changeset 32643 in vbox


Ignore:
Timestamp:
Sep 20, 2010 2:30:38 PM (15 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
66050
Message:

Additions/VBoxService: introduced --timesync-set-on-restore (defaults to 1) to force re-syncing the guest time with the host after the VM was restored

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Additions/common/VBoxService/VBoxServiceTimeSync.cpp

    r30019 r32643  
    126126 * adjust it. This is used to implement --timesync-set-start.  */
    127127static bool volatile g_fTimeSyncSetNext = false;
     128/** Whether to set the time when the VM was restored. */
     129static bool g_fTimeSyncSetOnRestore = true;
    128130
    129131/** Current error count. Used to knowing when to bitch and when not to. */
     
    132134/** The semaphore we're blocking on. */
    133135static RTSEMEVENTMULTI g_TimeSyncEvent = NIL_RTSEMEVENTMULTI;
     136
     137/** The VM session ID. Changes whenever the VM is restored or reset. */
     138static uint64_t g_idTimeSyncSession;
    134139
    135140#ifdef RT_OS_WINDOWS
     
    202207            }
    203208        }
     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        }
    204218
    205219        VbglR3GuestPropDisconnect(uGuestPropSvcClientID);
     
    220234{
    221235    int rc = -1;
     236    uint32_t value;
    222237    if (ppszShort)
    223238        /* no short options */;
     
    242257        rc = VINF_SUCCESS;
    243258    }
     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    }
    244265
    245266    return rc;
     
    258279    if (!g_TimeSyncInterval)
    259280        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. */
    260284
    261285    int rc = RTSemEventMultiCreate(&g_TimeSyncEvent);
     
    503527            {
    504528                /*
     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                /*
    505546                 * Calculate the adjustment threshold and the current drift.
    506547                 */
     
    535576                     */
    536577
    537                     if (    AbsDriftMilli > g_TimeSyncSetThreshold
     578                    if (    AbsDriftMilli > TimeSyncSetThreshold
    538579                        ||  g_fTimeSyncSetNext
    539580                        ||  !VBoxServiceTimeSyncAdjust(&Drift))
     
    627668    "              [--timesync-latency-factor <x>] [--timesync-max-latency <ms>]\n"
    628669    "              [--timesync-set-threshold <ms>] [--timesync-set-start]"
     670    "              [--timesync-set-restore 0|1]\n"
    629671    ,
    630672    /* pszOptions. */
     
    645687    "                            adjust it. The default is 20 min.\n"
    646688    "    --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"
    647692    ,
    648693    /* methods */
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette