VirtualBox

Ignore:
Timestamp:
Dec 7, 2017 4:54:23 PM (7 years ago)
Author:
vboxsync
Message:

VBoxServiceTimeSync.cpp: Dropped the number from --timesync-set-on-restore and added --timesync-no-set-on-restore for disabling it. This should be safe since it wasn't possible to specify 0 and nobody needed to set it to 1 as that was the default.

Location:
trunk/src/VBox/Additions/common/VBoxService
Files:
3 edited

Legend:

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

    r69990 r69991  
    207207            || rc == VERR_NOT_FOUND)
    208208        {
    209             char *pszValue;
    210             rc = VGSvcReadProp(uGuestPropSvcClientID, "/VirtualBox/GuestAdd/VBoxService/--timesync-set-start",
    211                                &pszValue, NULL /* ppszFlags */, NULL /* puTimestamp */);
     209            rc = VGSvcCheckPropExist(uGuestPropSvcClientID, "/VirtualBox/GuestAdd/VBoxService/--timesync-set-start");
    212210            if (RT_SUCCESS(rc))
    213             {
    214211                g_fTimeSyncSetNext = true;
    215                 RTStrFree(pszValue);
    216             }
    217212        }
    218213        if (   RT_SUCCESS(rc)
    219214            || rc == VERR_NOT_FOUND)
    220215        {
    221             uint32_t uValue;
    222             rc = VGSvcReadPropUInt32(uGuestPropSvcClientID, "/VirtualBox/GuestAdd/VBoxService/--timesync-set-on-restore",
    223                                      &uValue, 0 /*uMin*/, 1 /*uMax*/);
     216            rc = VGSvcCheckPropExist(uGuestPropSvcClientID, "/VirtualBox/GuestAdd/VBoxService/--timesync-set-on-restore");
    224217            if (RT_SUCCESS(rc))
    225                 g_fTimeSyncSetOnRestore = uValue != 0;
     218                g_fTimeSyncSetOnRestore = true;
     219        }
     220        if (   RT_SUCCESS(rc)
     221            || rc == VERR_NOT_FOUND)
     222        {
     223            rc = VGSvcCheckPropExist(uGuestPropSvcClientID, "/VirtualBox/GuestAdd/VBoxService/--timesync-no-set-on-restore");
     224            if (RT_SUCCESS(rc))
     225                g_fTimeSyncSetOnRestore = false;
    226226        }
    227227        if (   RT_SUCCESS(rc)
     
    274274static DECLCALLBACK(int) vgsvcTimeSyncOption(const char **ppszShort, int argc, char **argv, int *pi)
    275275{
    276     int rc = -1;
    277     uint32_t value;
     276    int rc = VINF_SUCCESS;
    278277    if (ppszShort)
    279         /* no short options */;
     278        rc = -1 ;/* no short options */
    280279    else if (!strcmp(argv[*pi], "--timesync-interval"))
    281280        rc = VGSvcArgUInt32(argc, argv, "", pi, &g_TimeSyncInterval, 50, UINT32_MAX - 1);
     
    289288        rc = VGSvcArgUInt32(argc, argv, "", pi, &g_TimeSyncSetThreshold, 0, 7*24*60*60*1000); /* a week */
    290289    else if (!strcmp(argv[*pi], "--timesync-set-start"))
    291     {
    292290        g_fTimeSyncSetNext = true;
    293         rc = VINF_SUCCESS;
    294     }
    295291    else if (!strcmp(argv[*pi], "--timesync-set-on-restore"))
    296     {
    297         rc = VGSvcArgUInt32(argc, argv, "", pi, &value, 1, 1);
    298         if (RT_SUCCESS(rc))
    299             g_fTimeSyncSetOnRestore = !!value;
    300     }
     292        g_fTimeSyncSetOnRestore = true;
     293    else if (!strcmp(argv[*pi], "--timesync-no-set-on-restore"))
     294        g_fTimeSyncSetOnRestore = false;
     295    else
     296        rc = -1;
    301297
    302298    return rc;
     
    733729    "              [--timesync-latency-factor <x>] [--timesync-max-latency <ms>]\n"
    734730    "              [--timesync-set-threshold <ms>] [--timesync-set-start]\n"
    735     "              [--timesync-set-on-restore 0|1]"
     731    "              [--timesync-set-on-restore|--timesync-no-set-on-restore]"
    736732    ,
    737733    /* pszOptions. */
     
    752748    "                            adjust it. The default is 20 min.\n"
    753749    "    --timesync-set-start    Set the time when starting the time sync service.\n"
    754     "    --timesync-set-on-restore 0|1\n"
    755     "                            Immediately set the time when the VM was restored.\n"
    756     "                            1 = set (default), 0 = don't set.\n"
     750    "    --timesync-set-on-restore, --timesync-no-set-on-restore\n"
     751    "                            Whether to immediately set the time when the VM is\n"
     752    "                            restored or not.  Default: --timesync-set-on-restore\n"
    757753    ,
    758754    /* methods */
  • trunk/src/VBox/Additions/common/VBoxService/VBoxServiceUtils.cpp

    r69500 r69991  
    4343 * @param   pszPropName         The property name.
    4444 * @param   ppszValue           Where to return the value.  This is always set
    45  *                              to NULL.  Free it using RTStrFree().
     45 *                              to NULL.  Free it using RTStrFree().  Optional.
    4646 * @param   ppszFlags           Where to return the value flags. Free it
    4747 *                              using RTStrFree().  Optional.
     
    5252{
    5353    AssertPtrReturn(pszPropName, VERR_INVALID_POINTER);
    54     AssertPtrReturn(ppszValue, VERR_INVALID_POINTER);
    5554
    5655    uint32_t    cbBuf = _1K;
     
    5857    int         rc    = VINF_SUCCESS;  /* MSC can't figure out the loop */
    5958
    60     *ppszValue = NULL;
     59    if (ppszValue)
     60        *ppszValue = NULL;
    6161
    6262    for (unsigned cTries = 0; cTries < 10; cTries++)
     
    9393
    9494        VGSvcVerbose(2, "Guest Property: Read '%s' = '%s', timestamp %RU64n\n", pszPropName, pszValue, uTimestamp);
    95         *ppszValue = RTStrDup(pszValue);
    96         if (!*ppszValue)
    97         {
    98             VGSvcError("Guest Property: RTStrDup failed for '%s'\n", pszValue);
    99             rc = VERR_NO_MEMORY;
    100             break;
     95        if (ppszValue)
     96        {
     97            *ppszValue = RTStrDup(pszValue);
     98            if (!*ppszValue)
     99            {
     100                VGSvcError("Guest Property: RTStrDup failed for '%s'\n", pszValue);
     101                rc = VERR_NO_MEMORY;
     102                break;
     103            }
    101104        }
    102105
     
    139142    }
    140143    return rc;
     144}
     145
     146/**
     147 * Checks if @a pszPropName exists.
     148 *
     149 * @returns VBox status code.
     150 * @retval  VINF_SUCCESS if it exists.
     151 * @retval  VERR_NOT_FOUND if not found.
     152 *
     153 * @param   u32ClientId         The HGCM client ID for the guest property session.
     154 * @param   pszPropName         The property name.
     155 */
     156int VGSvcCheckPropExist(uint32_t u32ClientId, const char *pszPropName)
     157{
     158    return VGSvcReadProp(u32ClientId, pszPropName, NULL /*ppszValue*/, NULL /* ppszFlags */, NULL /* puTimestamp */);
    141159}
    142160
  • trunk/src/VBox/Additions/common/VBoxService/VBoxServiceUtils.h

    r69500 r69991  
    2424int VGSvcReadProp(uint32_t u32ClientId, const char *pszPropName, char **ppszValue, char **ppszFlags, uint64_t *puTimestamp);
    2525int VGSvcReadPropUInt32(uint32_t u32ClientId, const char *pszPropName, uint32_t *pu32, uint32_t u32Min, uint32_t u32Max);
     26int VGSvcCheckPropExist(uint32_t u32ClientId, const char *pszPropName);
    2627int VGSvcReadHostProp(uint32_t u32ClientId, const char *pszPropName, bool fReadOnly, char **ppszValue, char **ppszFlags,
    2728                      uint64_t *puTimestamp);
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