Changeset 69991 in vbox for trunk/src/VBox/Additions/common/VBoxService
- Timestamp:
- Dec 7, 2017 4:54:23 PM (7 years ago)
- Location:
- trunk/src/VBox/Additions/common/VBoxService
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/common/VBoxService/VBoxServiceTimeSync.cpp
r69990 r69991 207 207 || rc == VERR_NOT_FOUND) 208 208 { 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"); 212 210 if (RT_SUCCESS(rc)) 213 {214 211 g_fTimeSyncSetNext = true; 215 RTStrFree(pszValue);216 }217 212 } 218 213 if ( RT_SUCCESS(rc) 219 214 || rc == VERR_NOT_FOUND) 220 215 { 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"); 224 217 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; 226 226 } 227 227 if ( RT_SUCCESS(rc) … … 274 274 static DECLCALLBACK(int) vgsvcTimeSyncOption(const char **ppszShort, int argc, char **argv, int *pi) 275 275 { 276 int rc = -1; 277 uint32_t value; 276 int rc = VINF_SUCCESS; 278 277 if (ppszShort) 279 /* no short options */;278 rc = -1 ;/* no short options */ 280 279 else if (!strcmp(argv[*pi], "--timesync-interval")) 281 280 rc = VGSvcArgUInt32(argc, argv, "", pi, &g_TimeSyncInterval, 50, UINT32_MAX - 1); … … 289 288 rc = VGSvcArgUInt32(argc, argv, "", pi, &g_TimeSyncSetThreshold, 0, 7*24*60*60*1000); /* a week */ 290 289 else if (!strcmp(argv[*pi], "--timesync-set-start")) 291 {292 290 g_fTimeSyncSetNext = true; 293 rc = VINF_SUCCESS;294 }295 291 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; 301 297 302 298 return rc; … … 733 729 " [--timesync-latency-factor <x>] [--timesync-max-latency <ms>]\n" 734 730 " [--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]" 736 732 , 737 733 /* pszOptions. */ … … 752 748 " adjust it. The default is 20 min.\n" 753 749 " --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" 757 753 , 758 754 /* methods */ -
trunk/src/VBox/Additions/common/VBoxService/VBoxServiceUtils.cpp
r69500 r69991 43 43 * @param pszPropName The property name. 44 44 * @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. 46 46 * @param ppszFlags Where to return the value flags. Free it 47 47 * using RTStrFree(). Optional. … … 52 52 { 53 53 AssertPtrReturn(pszPropName, VERR_INVALID_POINTER); 54 AssertPtrReturn(ppszValue, VERR_INVALID_POINTER);55 54 56 55 uint32_t cbBuf = _1K; … … 58 57 int rc = VINF_SUCCESS; /* MSC can't figure out the loop */ 59 58 60 *ppszValue = NULL; 59 if (ppszValue) 60 *ppszValue = NULL; 61 61 62 62 for (unsigned cTries = 0; cTries < 10; cTries++) … … 93 93 94 94 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 } 101 104 } 102 105 … … 139 142 } 140 143 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 */ 156 int VGSvcCheckPropExist(uint32_t u32ClientId, const char *pszPropName) 157 { 158 return VGSvcReadProp(u32ClientId, pszPropName, NULL /*ppszValue*/, NULL /* ppszFlags */, NULL /* puTimestamp */); 141 159 } 142 160 -
trunk/src/VBox/Additions/common/VBoxService/VBoxServiceUtils.h
r69500 r69991 24 24 int VGSvcReadProp(uint32_t u32ClientId, const char *pszPropName, char **ppszValue, char **ppszFlags, uint64_t *puTimestamp); 25 25 int VGSvcReadPropUInt32(uint32_t u32ClientId, const char *pszPropName, uint32_t *pu32, uint32_t u32Min, uint32_t u32Max); 26 int VGSvcCheckPropExist(uint32_t u32ClientId, const char *pszPropName); 26 27 int VGSvcReadHostProp(uint32_t u32ClientId, const char *pszPropName, bool fReadOnly, char **ppszValue, char **ppszFlags, 27 28 uint64_t *puTimestamp);
Note:
See TracChangeset
for help on using the changeset viewer.