Changeset 26299 in vbox for trunk/src/VBox/Additions
- Timestamp:
- Feb 5, 2010 3:51:43 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/common/VBoxService/VBoxServiceStats.cpp
r26292 r26299 53 53 /** The semaphore we're blocking on. */ 54 54 static RTSEMEVENTMULTI g_VMStatEvent = NIL_RTSEMEVENTMULTI; 55 /** The vmstats interval (millseconds). */56 uint32_t g_VMStatsInterval = 0;57 55 58 56 … … 67 65 static DECLCALLBACK(int) VBoxServiceVMStatsOption(const char **ppszShort, int argc, char **argv, int *pi) 68 66 { 69 int rc = -1; 70 if (ppszShort) 71 /* no short options */; 72 else if (!strcmp(argv[*pi], "--vmstats-interval")) 73 rc = VBoxServiceArgUInt32(argc, argv, "", pi, 74 &g_VMStatsInterval, 1000, UINT32_MAX - 1); 75 return rc; 67 return VINF_SUCCESS; 76 68 } 77 69 … … 97 89 if (DeviceIoControl(gVBoxDriver, VBOXGUEST_IOCTL_VMMREQUEST(req.header.size), &req, req.header.size, &req, req.header.size, &cbReturned, NULL)) 98 90 { 99 Log(("VBoxStatsInit: new statistics interval %d seconds\n", req.u32StatInterval));91 VBoxServiceVerbose(3, "VBoxStatsInit: new statistics interval %d seconds\n", req.u32StatInterval); 100 92 gCtx.uStatInterval = req.u32StatInterval * 1000; 101 93 } 102 94 else 103 Log(("VBoxStatsInit: DeviceIoControl failed with %d\n", GetLastError()));95 VBoxServiceVerbose(3, ("VBoxStatsInit: DeviceIoControl failed with %d\n", GetLastError()); 104 96 105 97 #ifdef RT_OS_WINDOWS … … 149 141 static void VBoxServiceVMStatsReport(VBOXSTATSCONTEXT *pCtx) 150 142 { 143 #ifdef RT_OS_WINDOWS 151 144 SYSTEM_INFO systemInfo; 152 145 PSYSTEM_PROCESSOR_PERFORMANCE_INFORMATION pProcInfo; … … 254 247 255 248 free(pProcInfo); 249 #else 250 /* todo: implement for other platforms. */ 251 return; 252 #endif 256 253 } 257 254 … … 262 259 HANDLE gVBoxDriver = pCtx->pEnv->hDriver; 263 260 bool fTerminate = false; 264 VBoxGuestFilterMaskInfo maskInfo;265 DWORD cbReturned;266 261 267 262 int rc = VINF_SUCCESS; … … 273 268 RTThreadUserSignal(RTThreadSelf()); 274 269 275 maskInfo.u32OrMask = VMMDEV_EVENT_STATISTICS_INTERVAL_CHANGE_REQUEST; 276 maskInfo.u32NotMask = 0; 277 if (DeviceIoControl (gVBoxDriver, VBOXGUEST_IOCTL_CTL_FILTER_MASK, &maskInfo, sizeof (maskInfo), NULL, 0, &cbReturned, NULL)) 278 { 279 Log(("VBoxStatsThread: DeviceIOControl(CtlMask - or) succeeded\n")); 280 } 281 else 282 { 283 Log(("VBoxStatsThread: DeviceIOControl(CtlMask) failed, SeamlessChangeThread exited\n")); 270 rc = VbglR3CtlFilterMask(VMMDEV_EVENT_STATISTICS_INTERVAL_CHANGE_REQUEST, 0); 271 if (RT_FAILED(rc)) 272 { 273 VBoxServiceVerbose(3, ("VBoxStatsThread: DeviceIOControl(CtlMask) failed, SeamlessChangeThread exited\n"); 284 274 return 0; 285 275 } … … 290 280 for (;;) 291 281 { 292 /* Report statistics to the host */ 293 if (gCtx.pfnNtQuerySystemInformation) 294 { 295 VBoxServiceVMStatsReport(); 296 } 282 uint32_t fEvents = 0; 283 284 rc = VbglR3WaitEvent(VMMDEV_EVENT_STATISTICS_INTERVAL_CHANGE_REQUEST, 1000, &fEvents); 285 if ( RT_SUCCESS(rc) 286 && (fEvents & VMMDEV_EVENT_STATISTICS_INTERVAL_CHANGE_REQUEST)) 287 { 288 } 289 290 VBoxServiceVMStatsReport(); 297 291 298 292 /* … … 315 309 } 316 310 317 maskInfo.u32OrMask = 0; 318 maskInfo.u32NotMask = VMMDEV_EVENT_STATISTICS_INTERVAL_CHANGE_REQUEST; 319 if (DeviceIoControl (gVBoxDriver, VBOXGUEST_IOCTL_CTL_FILTER_MASK, &maskInfo, sizeof (maskInfo), NULL, 0, &cbReturned, NULL)) 320 { 321 Log(("VBoxStatsThread: DeviceIOControl(CtlMask - not) succeeded\n")); 322 } 323 else 324 { 325 Log(("VBoxStatsThread: DeviceIOControl(CtlMask) failed\n")); 326 } 311 rc = VbglR3CtlFilterMask(0, VMMDEV_EVENT_STATISTICS_INTERVAL_CHANGE_REQUEST); 312 if (RT_FAILED(rc)) 313 { 314 VBoxServiceVerbose(3, ("VBoxStatsThread: DeviceIOControl(CtlMask) failed, SeamlessChangeThread exited\n"); 315 return 0; 316 } 317 327 318 328 319 RTSemEventMultiDestroy(g_VMStatsEvent); … … 359 350 "Virtual Machine Statistics", 360 351 /* pszUsage. */ 361 "[--vmstats-interval <ms>]" 362 , 352 NULL, 363 353 /* pszOptions. */ 364 " --vmstats-interval Specifies the interval at which to retrieve the\n" 365 " VM statistcs. The default is 10000 ms.\n" 366 , 354 NULL, 367 355 /* methods */ 368 356 VBoxServiceVMStatsPreInit,
Note:
See TracChangeset
for help on using the changeset viewer.