Changeset 4594 in vbox for trunk/src/VBox
- Timestamp:
- Sep 7, 2007 8:53:27 AM (17 years ago)
- Location:
- trunk/src/VBox/Additions/WINNT/VBoxService
- Files:
-
- 2 edited
- 2 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/WINNT/VBoxService/Makefile.kmk
r4540 r4594 33 33 VBoxVRDP.cpp \ 34 34 VBoxRestore.cpp \ 35 VBoxGuest.cpp \ 35 VBoxStatistics.cpp \ 36 VBoxMemBalloon.cpp \ 36 37 helpers.cpp \ 37 38 VBoxService.rc -
trunk/src/VBox/Additions/WINNT/VBoxService/VBoxService.cpp
r4540 r4594 21 21 #include "VBoxRestore.h" 22 22 #include "VBoxVRDP.h" 23 #include "VBoxGuest.h" 23 #include "VBoxStatistics.h" 24 #include "VBoxMemBalloon.h" 24 25 #include <VBoxHook.h> 25 26 #include "resource.h" … … 100 101 #ifdef VBOX_WITH_MANAGEMENT 101 102 { 102 "Guest Management", 103 VBoxGuestInit, 104 VBoxGuestThread, 105 VBoxGuestDestroy, 103 "Memory Balloon", 104 VBoxMemBalloonInit, 105 VBoxMemBalloonThread, 106 VBoxMemBalloonDestroy, 107 }, 108 { 109 "Guest Statistics", 110 VBoxStatsInit, 111 VBoxStatsThread, 112 VBoxStatsDestroy, 106 113 }, 107 114 #endif -
trunk/src/VBox/Additions/WINNT/VBoxService/VBoxStatistics.cpp
r4585 r4594 1 1 /** @file 2 2 * 3 * VBox Guest - Guest managementnotification3 * VBoxStats - Guest statistics notification 4 4 * 5 5 */ … … 20 20 #include <psapi.h> 21 21 #include "VBoxService.h" 22 #include "VBoxGuest.h" 22 #include "VBoxStatistics.h" 23 #include "VBoxMemBalloon.h" 23 24 #include <VBoxDisplay.h> 24 25 #include <VBox/VBoxDev.h> 26 #include <VBox/VBoxGuest.h> 25 27 #include <VBoxGuestInternal.h> 26 28 #include <iprt/assert.h> … … 28 30 #include <winternl.h> 29 31 30 typedef struct _VBOX GUESTCONTEXT32 typedef struct _VBOXSTATSCONTEXT 31 33 { 32 34 const VBOXSERVICEENV *pEnv; 33 35 uint32_t uStatInterval; 34 uint32_t uMemBalloonSize;35 36 36 37 uint64_t ullLastCpuLoad_Idle; … … 41 42 void (WINAPI *pfnGlobalMemoryStatusEx)(LPMEMORYSTATUSEX lpBuffer); 42 43 BOOL (WINAPI *pfnGetPerformanceInfo)(PPERFORMANCE_INFORMATION pPerformanceInformation, DWORD cb); 43 } VBOX GUESTCONTEXT;44 45 46 static VBOX GUESTCONTEXT gCtx = {0};47 48 49 int VBox GuestInit(const VBOXSERVICEENV *pEnv, void **ppInstance, bool *pfStartThread)44 } VBOXSTATSCONTEXT; 45 46 47 static VBOXSTATSCONTEXT gCtx = {0}; 48 49 50 int VBoxStatsInit(const VBOXSERVICEENV *pEnv, void **ppInstance, bool *pfStartThread) 50 51 { 51 52 HANDLE gVBoxDriver = pEnv->hDriver; 52 53 DWORD cbReturned; 53 54 54 dprintf(("VBox GuestInit\n"));55 dprintf(("VBoxStatsInit\n")); 55 56 56 57 gCtx.pEnv = pEnv; … … 59 60 gCtx.ullLastCpuLoad_Kernel = 0; 60 61 gCtx.ullLastCpuLoad_User = 0; 61 gCtx.uMemBalloonSize = 0;62 62 63 63 VMMDevGetStatisticsChangeRequest req; … … 67 67 if (DeviceIoControl(gVBoxDriver, IOCTL_VBOXGUEST_VMMREQUEST, &req, req.header.size, &req, req.header.size, &cbReturned, NULL)) 68 68 { 69 dprintf(("VBox GuestThread: new statistics interval %d seconds\n", req.u32StatInterval));69 dprintf(("VBoxStatsThread: new statistics interval %d seconds\n", req.u32StatInterval)); 70 70 gCtx.uStatInterval = req.u32StatInterval * 1000; 71 71 } 72 72 else 73 dprintf(("VBox GuestThread: DeviceIoControl failed with %d\n", GetLastError()));73 dprintf(("VBoxStatsThread: DeviceIoControl failed with %d\n", GetLastError())); 74 74 75 75 /* NtQuerySystemInformation might be dropped in future releases, so load it dynamically as per Microsoft's recommendation */ … … 111 111 } 112 112 113 /* Check balloon size */114 DWORD dwMemBalloonSize;115 if (DeviceIoControl(gVBoxDriver, IOCTL_VBOXGUEST_CTL_CHECK_BALLOON, NULL, 0, &dwMemBalloonSize, sizeof(dwMemBalloonSize), &cbReturned, NULL))116 {117 dprintf(("VBoxGuestThread: new balloon size % MB\n", dwMemBalloonSize));118 gCtx.uMemBalloonSize = dwMemBalloonSize;119 }120 else121 dprintf(("VBoxGuestThread: DeviceIoControl (balloon) failed with %d\n", GetLastError()));122 123 113 *pfStartThread = true; 124 114 *ppInstance = &gCtx; … … 127 117 128 118 129 void VBox GuestDestroy(const VBOXSERVICEENV *pEnv, void *pInstance)130 { 131 dprintf(("VBox GuestDestroy\n"));119 void VBoxStatsDestroy(const VBOXSERVICEENV *pEnv, void *pInstance) 120 { 121 dprintf(("VBoxStatsDestroy\n")); 132 122 return; 133 123 } 134 124 135 void VBox GuestReportStatistics(VBOXGUESTCONTEXT *pCtx)125 void VBoxStatsReportStatistics(VBOXSTATSCONTEXT *pCtx) 136 126 { 137 127 SYSTEM_INFO systemInfo; … … 160 150 req.guestStats.u32PageFileSize = (uint32_t)(memStatus.ullTotalPageFile / systemInfo.dwPageSize); 161 151 req.guestStats.u32MemoryLoad = memStatus.dwMemoryLoad; 162 req.guestStats.u32PhysMemBalloon = pCtx->uMemBalloonSize* (_1M/systemInfo.dwPageSize); /* was in megabytes */152 req.guestStats.u32PhysMemBalloon = VBoxMemBalloonQuerySize() * (_1M/systemInfo.dwPageSize); /* was in megabytes */ 163 153 req.guestStats.u32StatCaps = VBOX_GUEST_STAT_PHYS_MEM_TOTAL | VBOX_GUEST_STAT_PHYS_MEM_AVAIL | VBOX_GUEST_STAT_PAGE_FILE_SIZE | VBOX_GUEST_STAT_MEMORY_LOAD | VBOX_GUEST_STAT_PHYS_MEM_BALLOON; 164 154 … … 229 219 if (DeviceIoControl(gVBoxDriver, IOCTL_VBOXGUEST_VMMREQUEST, &req, req.header.size, &req, req.header.size, &cbReturned, NULL)) 230 220 { 231 dprintf(("VBox GuestThread: new statistics reported successfully!\n"));232 } 233 else 234 dprintf(("VBox GuestThread: DeviceIoControl (stats report) failed with %d\n", GetLastError()));221 dprintf(("VBoxStatsThread: new statistics reported successfully!\n")); 222 } 223 else 224 dprintf(("VBoxStatsThread: DeviceIoControl (stats report) failed with %d\n", GetLastError())); 235 225 } 236 226 … … 242 232 * requests 243 233 */ 244 unsigned __stdcall VBox GuestThread(void *pInstance)245 { 246 VBOX GUESTCONTEXT *pCtx = (VBOXGUESTCONTEXT *)pInstance;234 unsigned __stdcall VBoxStatsThread(void *pInstance) 235 { 236 VBOXSTATSCONTEXT *pCtx = (VBOXSTATSCONTEXT *)pInstance; 247 237 HANDLE gVBoxDriver = pCtx->pEnv->hDriver; 248 238 bool fTerminate = false; … … 250 240 DWORD cbReturned; 251 241 252 maskInfo.u32OrMask = VMMDEV_EVENT_ BALLOON_CHANGE_REQUEST | VMMDEV_EVENT_STATISTICS_INTERVAL_CHANGE_REQUEST;242 maskInfo.u32OrMask = VMMDEV_EVENT_STATISTICS_INTERVAL_CHANGE_REQUEST; 253 243 maskInfo.u32NotMask = 0; 254 244 if (DeviceIoControl (gVBoxDriver, IOCTL_VBOXGUEST_CTL_FILTER_MASK, &maskInfo, sizeof (maskInfo), NULL, 0, &cbReturned, NULL)) 255 245 { 256 dprintf(("VBox GuestThread: DeviceIOControl(CtlMask - or) succeeded\n"));246 dprintf(("VBoxStatsThread: DeviceIOControl(CtlMask - or) succeeded\n")); 257 247 } 258 248 else 259 249 { 260 dprintf(("VBox GuestThread: DeviceIOControl(CtlMask) failed, SeamlessChangeThread exited\n"));250 dprintf(("VBoxStatsThread: DeviceIOControl(CtlMask) failed, SeamlessChangeThread exited\n")); 261 251 return 0; 262 252 } … … 267 257 VBoxGuestWaitEventInfo waitEvent; 268 258 waitEvent.u32TimeoutIn = (pCtx->uStatInterval) ? pCtx->uStatInterval : 1000; 269 waitEvent.u32EventMaskIn = VMMDEV_EVENT_ BALLOON_CHANGE_REQUEST | VMMDEV_EVENT_STATISTICS_INTERVAL_CHANGE_REQUEST;259 waitEvent.u32EventMaskIn = VMMDEV_EVENT_STATISTICS_INTERVAL_CHANGE_REQUEST; 270 260 if (DeviceIoControl(gVBoxDriver, IOCTL_VBOXGUEST_WAITEVENT, &waitEvent, sizeof(waitEvent), &waitEvent, sizeof(waitEvent), &cbReturned, NULL)) 271 261 { 272 dprintf(("VBox GuestThread: DeviceIOControl succeded\n"));262 dprintf(("VBoxStatsThread: DeviceIOControl succeded\n")); 273 263 274 264 /* are we supposed to stop? */ … … 276 266 break; 277 267 278 dprintf(("VBox GuestThread: checking event\n"));268 dprintf(("VBoxStatsThread: checking event\n")); 279 269 280 270 /* did we get the right event? */ 281 if (waitEvent.u32EventFlagsOut & VMMDEV_EVENT_BALLOON_CHANGE_REQUEST)282 {283 DWORD dwMemBalloonSize;284 if (DeviceIoControl(gVBoxDriver, IOCTL_VBOXGUEST_CTL_CHECK_BALLOON, NULL, 0, &dwMemBalloonSize, sizeof(dwMemBalloonSize), &cbReturned, NULL))285 {286 dprintf(("VBoxGuestThread: new balloon size % MB\n", dwMemBalloonSize));287 pCtx->uMemBalloonSize = dwMemBalloonSize;288 }289 else290 dprintf(("VBoxGuestThread: DeviceIoControl (balloon) failed with %d\n", GetLastError()));291 }292 271 if (waitEvent.u32EventFlagsOut & VMMDEV_EVENT_STATISTICS_INTERVAL_CHANGE_REQUEST) 293 272 { … … 298 277 if (DeviceIoControl(gVBoxDriver, IOCTL_VBOXGUEST_VMMREQUEST, &req, req.header.size, &req, req.header.size, &cbReturned, NULL)) 299 278 { 300 dprintf(("VBox GuestThread: new statistics interval %d seconds\n", req.u32StatInterval));279 dprintf(("VBoxStatsThread: new statistics interval %d seconds\n", req.u32StatInterval)); 301 280 pCtx->uStatInterval = req.u32StatInterval * 1000; 302 281 } 303 282 else 304 dprintf(("VBox GuestThread: DeviceIoControl (stat) failed with %d\n", GetLastError()));283 dprintf(("VBoxStatsThread: DeviceIoControl (stat) failed with %d\n", GetLastError())); 305 284 } 306 285 } 307 286 else 308 287 { 309 dprintf(("VBox GuestThread: error 0 from DeviceIoControl IOCTL_VBOXGUEST_WAITEVENT\n"));288 dprintf(("VBoxStatsThread: error 0 from DeviceIoControl IOCTL_VBOXGUEST_WAITEVENT\n")); 310 289 311 290 /* sleep a bit to not eat too much CPU in case the above call always fails */ … … 320 299 && gCtx.pfnNtQuerySystemInformation) 321 300 { 322 VBox GuestReportStatistics(pCtx);301 VBoxStatsReportStatistics(pCtx); 323 302 } 324 303 } … … 326 305 327 306 maskInfo.u32OrMask = 0; 328 maskInfo.u32NotMask = VMMDEV_EVENT_ BALLOON_CHANGE_REQUEST | VMMDEV_EVENT_STATISTICS_INTERVAL_CHANGE_REQUEST;307 maskInfo.u32NotMask = VMMDEV_EVENT_STATISTICS_INTERVAL_CHANGE_REQUEST; 329 308 if (DeviceIoControl (gVBoxDriver, IOCTL_VBOXGUEST_CTL_FILTER_MASK, &maskInfo, sizeof (maskInfo), NULL, 0, &cbReturned, NULL)) 330 309 { 331 dprintf(("VBox GuestThread: DeviceIOControl(CtlMask - not) succeeded\n"));310 dprintf(("VBoxStatsThread: DeviceIOControl(CtlMask - not) succeeded\n")); 332 311 } 333 312 else 334 313 { 335 dprintf(("VBox GuestThread: DeviceIOControl(CtlMask) failed\n"));336 } 337 338 dprintf(("VBox GuestThread: finished seamless change request thread\n"));314 dprintf(("VBoxStatsThread: DeviceIOControl(CtlMask) failed\n")); 315 } 316 317 dprintf(("VBoxStatsThread: finished seamless change request thread\n")); 339 318 return 0; 340 319 } -
trunk/src/VBox/Additions/WINNT/VBoxService/VBoxStatistics.h
r4584 r4594 1 1 /** @file 2 * VBoxGuest - Guest managementnotification2 * VBoxGuest - Guest statistics notification 3 3 */ 4 4 … … 15 15 */ 16 16 17 #ifndef __VBOXSERVICE GUEST__H18 #define __VBOXSERVICE GUEST__H17 #ifndef __VBOXSERVICESTATS__H 18 #define __VBOXSERVICESTATS__H 19 19 20 20 /* The guest management service prototypes. */ 21 int VBox GuestInit (const VBOXSERVICEENV *pEnv, void **ppInstance, bool *pfStartThread);22 unsigned __stdcall VBox GuestThread (void *pInstance);23 void VBox GuestDestroy (const VBOXSERVICEENV *pEnv, void *pInstance);21 int VBoxStatsInit (const VBOXSERVICEENV *pEnv, void **ppInstance, bool *pfStartThread); 22 unsigned __stdcall VBoxStatsThread (void *pInstance); 23 void VBoxStatsDestroy (const VBOXSERVICEENV *pEnv, void *pInstance); 24 24 25 #endif /* __VBOXSERVICE GUEST__H */25 #endif /* __VBOXSERVICESTATS__H */
Note:
See TracChangeset
for help on using the changeset viewer.