VirtualBox

Changeset 70018 in vbox


Ignore:
Timestamp:
Dec 8, 2017 12:07:41 PM (7 years ago)
Author:
vboxsync
Message:

VMM/TM: Added a CFGM value TM/UTCTouchFileOnJump to give a file to be written to every time the UTC time used by time sync jumps.

Location:
trunk/src/VBox/VMM
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/VMM/VMMR3/TM.cpp

    r69952 r70018  
    148148#include <iprt/asm-math.h>
    149149#include <iprt/assert.h>
     150#include <iprt/file.h>
    150151#include <iprt/thread.h>
    151152#include <iprt/time.h>
     
    347348                              "CatchUpPrecentage8|CatchUpPrecentage9|"
    348349                              "UTCOffset|"
     350                              "UTCTouchFileOnJump|"
    349351                              "WarpDrivePercentage|"
    350352                              "HostHzMax|"
     
    354356                              "HostHzFudgeFactorCatchUp200|"
    355357                              "HostHzFudgeFactorCatchUp400|"
    356                               "TimerMillies",
     358                              "TimerMillies"
     359                              ,
    357360                              "",
    358361                              "TM", 0);
     
    538541        return VMSetError(pVM, rc, RT_SRC_POS,
    539542                          N_("Configuration error: Failed to querying 64-bit integer value \"UTCOffset\""));
     543
     544    /** @cfgm{/TM/UTCTouchFileOnJump, string, none}
     545     * File to be written to everytime the host time jumps.  */
     546    rc = CFGMR3QueryStringAlloc(pCfgHandle, "UTCTouchFileOnJump", &pVM->tm.s.pszUtcTouchFileOnJump);
     547    if (rc == VERR_CFGM_VALUE_NOT_FOUND)
     548        pVM->tm.s.pszUtcTouchFileOnJump = NULL;
     549    else if (RT_FAILURE(rc))
     550        return VMSetError(pVM, rc, RT_SRC_POS,
     551                          N_("Configuration error: Failed to querying string value \"UTCTouchFileOnJump\""));
    540552
    541553    /*
     
    28372849    int64_t cNsDelta = RTTimeSpecGetNano(pTime) - nsPrev;
    28382850    if ((uint64_t)RT_ABS(cNsDelta) > RT_NS_1HOUR / 2)
    2839         LogRel(("TMR3UtcNow: nsNow=%'RI64 nsPrev=%'RI64 -> cNsDelta=%'RI64 (offLag=%'RI64 offVirtualSync=%'RU64 offVirtualSyncGivenUp=%'RU64)\n",
    2840                 RTTimeSpecGetNano(pTime), nsPrev, cNsDelta, offLag, offVirtualSync, offVirtualSyncGivenUp));
     2851    {
     2852        RTTIMESPEC NowAgain;
     2853        RTTimeNow(&NowAgain);
     2854        LogRel(("TMR3UtcNow: nsNow=%'RI64 nsPrev=%'RI64 -> cNsDelta=%'RI64 (offLag=%'RI64 offVirtualSync=%'RU64 offVirtualSyncGivenUp=%'RU64, NowAgain=%'RI64)\n",
     2855                RTTimeSpecGetNano(pTime), nsPrev, cNsDelta, offLag, offVirtualSync, offVirtualSyncGivenUp, RTTimeSpecGetNano(&NowAgain)));
     2856        if (pVM->tm.s.pszUtcTouchFileOnJump && nsPrev != 0)
     2857        {
     2858            RTFILE hFile;
     2859            int rc = RTFileOpen(&hFile, pVM->tm.s.pszUtcTouchFileOnJump,
     2860                                RTFILE_O_WRITE | RTFILE_O_APPEND | RTFILE_O_OPEN_CREATE | RTFILE_O_DENY_NONE);
     2861            if (RT_SUCCESS(rc))
     2862            {
     2863                char   szMsg[256];
     2864                size_t cch;
     2865                cch = RTStrPrintf(szMsg, sizeof(szMsg),
     2866                                  "TMR3UtcNow: nsNow=%'RI64 nsPrev=%'RI64 -> cNsDelta=%'RI64 (offLag=%'RI64 offVirtualSync=%'RU64 offVirtualSyncGivenUp=%'RU64, NowAgain=%'RI64)\n",
     2867                                  RTTimeSpecGetNano(pTime), nsPrev, cNsDelta, offLag, offVirtualSync, offVirtualSyncGivenUp, RTTimeSpecGetNano(&NowAgain));
     2868                RTFileWrite(hFile, szMsg, cch, NULL);
     2869                RTFileClose(hFile);
     2870            }
     2871        }
     2872    }
    28412873
    28422874    return pTime;
  • trunk/src/VBox/VMM/include/TMInternal.h

    r69950 r70018  
    495495    /** The last value TMR3UtcNow returned. */
    496496    int64_t volatile            nsLastUtcNow;
     497    /** File to touch on UTC jump. */
     498    R3PTRTYPE(char *)           pszUtcTouchFileOnJump;
     499    /** Just to avoid dealing with 32-bit alignment trouble. */
     500    R3PTRTYPE(char *)           pszAlignment2b;
    497501
    498502    /** Timer queues for the different clock types - R3 Ptr */
Note: See TracChangeset for help on using the changeset viewer.

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