VirtualBox

Changeset 26326 in vbox


Ignore:
Timestamp:
Feb 8, 2010 1:22:24 PM (15 years ago)
Author:
vboxsync
Message:

Updates for guest statistics and memory ballooning

Location:
trunk/src/VBox/Additions/common
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Additions/common/VBoxGuestLib/VBoxGuestR3LibMisc.cpp

    r26054 r26326  
    158158VBGLR3DECL(int) VbglR3CtlFilterMask(uint32_t fOr, uint32_t fNot)
    159159{
    160 #if defined(RT_OS_WINDOWS)
    161     /** @todo Not yet implemented. */
    162     return VERR_NOT_SUPPORTED;
    163 
    164 #else
    165 
    166160    VBoxGuestFilterMaskInfo Info;
    167161    Info.u32OrMask = fOr;
    168162    Info.u32NotMask = fNot;
    169163    return vbglR3DoIOCtl(VBOXGUEST_IOCTL_CTL_FILTER_MASK, &Info, sizeof(Info));
    170 #endif
    171164}
    172165
     
    196189#endif
    197190    return rc;
     191}
     192
     193/**
     194 * Query the current statistics update interval
     195 *
     196 * @returns IPRT status code
     197 * @param   pu32Interval    Update interval in ms (out)
     198 */
     199VBGLR3DECL(int) VbglR3StatQueryInterval(uint32_t *pu32Interval)
     200{
     201    VMMDevGetStatisticsChangeRequest Req;
     202
     203    vmmdevInitRequest(&Req.header, VMMDevReq_GetStatisticsChangeRequest);
     204    Req.eventAck = VMMDEV_EVENT_STATISTICS_INTERVAL_CHANGE_REQUEST;
     205    int rc = vbglR3GRPerform(&Req.header);
     206    if (RT_SUCCESS(rc))
     207        *pu32Interval = Req.u32StatInterval * 1000;
     208    return rc;
     209}
     210
     211
     212/**
     213 * Report guest statistics
     214 *
     215 * @returns IPRT status code
     216 * @param   pReq        Request packet with statistics
     217 */
     218VBGLR3DECL(int) VbglR3StatReport(VMMDevReportGuestStats *pReq)
     219{
     220    vmmdevInitRequest(&pReq->header, VMMDevReq_ReportGuestStats);
     221    return vbglR3GRPerform(&pReq->header);
     222}
     223
     224
     225/**
     226 * Refresh the memory balloon after a change
     227 *
     228 * @returns IPRT status code
     229 * @param   pu32Size    Memory balloon size in MBs (out)
     230 */
     231VBGLR3DECL(int) VbglR3MemBalloonRefresh(uint32_t *pu32Size)
     232{
     233    return vbglR3DoIOCtl(VBOXGUEST_IOCTL_CTL_CHECK_BALLOON_MASK, pu32Size, sizeof(*pu32Size));
    198234}
    199235
  • trunk/src/VBox/Additions/common/VBoxService/Makefile.kmk

    r26292 r26326  
    3434VBoxService_TEMPLATE      = VBOXGUESTR3EXE
    3535VBoxService_DEFS          = VBOXSERVICE_TIMESYNC
    36 VBoxService_DEFS.win     += _WIN32_WINNT=0x0501
    37 ##VBOXSERVICE_MANAGEMENT
     36VBoxService_DEFS.win     += _WIN32_WINNT=0x0501 VBOXSERVICE_MANAGEMENT
    3837VBoxService_DEFS.os2      = VBOX_WITH_HGCM VBOXSERVICE_CLIPBOARD
    3938ifdef VBOX_WITH_GUEST_PROPS
     
    6766VBoxService_SOURCES.win  += \
    6867        VBoxService-win.rc \
    69         VBoxService-win.cpp
    70 
    71 ##      VBoxServiceStats.cpp \
    72 ##      VBoxServiceBalloon.cpp
     68        VBoxService-win.cpp \
     69        VBoxServiceBalloon.cpp \
     70        VBoxServiceStats.cpp
    7371
    7472VBoxService_SOURCES.os2   = \
  • trunk/src/VBox/Additions/common/VBoxService/VBoxServiceBalloon.cpp

    r26292 r26326  
    1919 * additional information or have any questions.
    2020 */
    21 #define _WIN32_WINNT 0x0500
    22 #include <windows.h>
    23 #include <psapi.h>
    24 #include "VBoxTray.h"
    25 #include "VBoxMemBalloon.h"
    26 #include <VBoxDisplay.h>
    27 #include <VBox/VMMDev.h>
    28 #include <VBoxGuestInternal.h>
    2921#include <iprt/assert.h>
    30 #include "helpers.h"
    31 #include <winternl.h>
    32 
    33 typedef struct _VBOXMEMBALLOONCONTEXT
    34 {
    35     const VBOXSERVICEENV *pEnv;
    36     uint32_t              uMemBalloonSize;
    37 } VBOXMEMBALLOONCONTEXT;
     22#include <iprt/mem.h>
     23#include <iprt/thread.h>
     24#include <iprt/string.h>
     25#include <iprt/semaphore.h>
     26#include <iprt/system.h>
     27#include <iprt/time.h>
     28#include <VBox/VBoxGuestLib.h>
     29#include "VBoxServiceInternal.h"
     30#include "VBoxServiceUtils.h"
    3831
    3932
    40 static VBOXMEMBALLOONCONTEXT gCtx = {0};
    4133
     34/*******************************************************************************
     35*   Global Variables                                                           *
     36*******************************************************************************/
     37static uint32_t g_MemBalloonSize = 0;
    4238
    43 int VBoxMemBalloonInit(const VBOXSERVICEENV *pEnv, void **ppInstance, bool *pfStartThread)
     39/** The semaphore we're blocking on. */
     40static RTSEMEVENTMULTI  g_MemBalloonEvent = NIL_RTSEMEVENTMULTI;
     41
     42/** @copydoc VBOXSERVICE::pfnPreInit */
     43static DECLCALLBACK(int) VBoxServiceBalloonPreInit(void)
    4444{
    45     HANDLE gVBoxDriver = pEnv->hDriver;
    46     DWORD  cbReturned;
    47 
    48     Log(("VBoxMemBalloonInit: Init\n"));
    49 
    50     gCtx.pEnv                   = pEnv;
    51     gCtx.uMemBalloonSize        = 0;
    52 
    53     /* Check balloon size */
    54     DWORD dwMemBalloonSize;
    55     if (DeviceIoControl(gVBoxDriver, VBOXGUEST_IOCTL_CTL_CHECK_BALLOON_MASK, NULL, 0, &dwMemBalloonSize, sizeof(dwMemBalloonSize), &cbReturned, NULL))
    56     {
    57         Log(("VBoxMemBalloonInit: new balloon size %d MB\n", dwMemBalloonSize));
    58         gCtx.uMemBalloonSize = dwMemBalloonSize;
    59     }
    60     else
    61         Log(("VBoxMemBalloonInit: DeviceIoControl (balloon) failed with %d\n", GetLastError()));
    62 
    63     *pfStartThread = true;
    64     *ppInstance = &gCtx;
    6545    return VINF_SUCCESS;
    6646}
    6747
    6848
    69 void VBoxMemBalloonDestroy(const VBOXSERVICEENV *pEnv, void *pInstance)
     49/** @copydoc VBOXSERVICE::pfnOption */
     50static DECLCALLBACK(int) VBoxServiceBalloonOption(const char **ppszShort, int argc, char **argv, int *pi)
    7051{
    71     Log(("VBoxMemBalloonDestroy\n"));
     52    return VINF_SUCCESS;
     53}
     54
     55
     56/** @copydoc VBOXSERVICE::pfnInit */
     57static DECLCALLBACK(int) VBoxServiceBalloonInit(void)
     58{
     59    VBoxServiceVerbose(3, "VBoxServiceBalloonInit\n");
     60
     61    int rc = RTSemEventMultiCreate(&g_MemBalloonEvent);
     62    AssertRCReturn(rc, rc);
     63
     64    g_MemBalloonSize = 0;
     65
     66    /* Check balloon size */
     67    rc = VbglR3MemBalloonRefresh(&g_MemBalloonSize);
     68    if (RT_SUCCESS(rc))
     69        VBoxServiceVerbose(3, "VBoxMemBalloonInit: new balloon size %d MB\n", g_MemBalloonSize);
     70    else
     71        VBoxServiceVerbose(3, "VBoxMemBalloonInit: VbglR3MemBalloonRefresh failed with %d\n", rc);
     72
     73    return rc;
     74}
     75
     76
     77uint32_t VBoxServiceBalloonQuerySize()
     78{
     79    return g_MemBalloonSize;
     80}
     81
     82/** @copydoc VBOXSERVICE::pfnWorker */
     83DECLCALLBACK(int) VBoxServiceBalloonWorker(bool volatile *pfShutdown)
     84{
     85    int rc = VINF_SUCCESS;
     86
     87    /* Start monitoring of the stat event change event. */
     88    rc = VbglR3CtlFilterMask(VMMDEV_EVENT_BALLOON_CHANGE_REQUEST, 0);
     89    if (RT_FAILURE(rc))
     90    {
     91        VBoxServiceVerbose(3, "VBoxServiceBalloonWorker: VbglR3CtlFilterMask failed with %d\n", rc);
     92        return rc;
     93    }
     94
     95    /*
     96     * Tell the control thread that it can continue
     97     * spawning services.
     98     */
     99    RTThreadUserSignal(RTThreadSelf());
     100
     101    /*
     102     * Now enter the loop retrieving runtime data continuously.
     103     */
     104    for (;;)
     105    {
     106        uint32_t fEvents = 0;
     107
     108        /* Check if an update interval change is pending. */
     109        rc = VbglR3WaitEvent(VMMDEV_EVENT_BALLOON_CHANGE_REQUEST, 0 /* no wait */, &fEvents);
     110        if (    RT_SUCCESS(rc)
     111            &&  (fEvents & VMMDEV_EVENT_BALLOON_CHANGE_REQUEST))
     112        {
     113            rc = VbglR3MemBalloonRefresh(&g_MemBalloonSize);
     114            if (RT_SUCCESS(rc))
     115                VBoxServiceVerbose(3, "VBoxServiceBalloonWorker: new balloon size %d MB\n", g_MemBalloonSize);
     116            else
     117                VBoxServiceVerbose(3, "VBoxServiceBalloonWorker: VbglR3MemBalloonRefresh failed with %d\n", rc);
     118        }
     119
     120        /*
     121         * Block for a while.
     122         *
     123         * The event semaphore takes care of ignoring interruptions and it
     124         * allows us to implement service wakeup later.
     125         */
     126        if (*pfShutdown)
     127            break;
     128        int rc2 = RTSemEventMultiWait(g_MemBalloonEvent, 5000);
     129        if (*pfShutdown)
     130            break;
     131        if (rc2 != VERR_TIMEOUT && RT_FAILURE(rc2))
     132        {
     133            VBoxServiceError("RTSemEventMultiWait failed; rc2=%Rrc\n", rc2);
     134            rc = rc2;
     135            break;
     136        }
     137    }
     138
     139    /* Cancel monitoring of the memory balloon change event. */
     140    rc = VbglR3CtlFilterMask(0, VMMDEV_EVENT_BALLOON_CHANGE_REQUEST);
     141    if (RT_FAILURE(rc))
     142        VBoxServiceVerbose(3, "VBoxServiceBalloonWorker: VbglR3CtlFilterMask failed with %d\n", rc);
     143
     144    RTSemEventMultiDestroy(g_MemBalloonEvent);
     145    g_MemBalloonEvent = NIL_RTSEMEVENTMULTI;
     146
     147    VBoxServiceVerbose(3, "VBoxServiceBalloonWorker: finished mem balloon change request thread\n");
     148    return 0;
     149}
     150
     151/** @copydoc VBOXSERVICE::pfnTerm */
     152static DECLCALLBACK(void) VBoxServiceBalloonTerm(void)
     153{
     154    VBoxServiceVerbose(3, "VBoxServiceBalloonTerm\n");
    72155    return;
    73156}
    74157
    75 uint32_t VBoxMemBalloonQuerySize()
     158
     159/** @copydoc VBOXSERVICE::pfnStop */
     160static DECLCALLBACK(void) VBoxServiceBalloonStop(void)
    76161{
    77     return gCtx.uMemBalloonSize;
    78 }
    79 
    80 /**
    81  * Thread function to wait for and process seamless mode change
    82  * requests
    83  */
    84 unsigned __stdcall VBoxMemBalloonThread(void *pInstance)
    85 {
    86     VBOXMEMBALLOONCONTEXT *pCtx = (VBOXMEMBALLOONCONTEXT *)pInstance;
    87     HANDLE gVBoxDriver = pCtx->pEnv->hDriver;
    88     bool fTerminate = false;
    89     VBoxGuestFilterMaskInfo maskInfo;
    90     DWORD cbReturned;
    91 
    92     maskInfo.u32OrMask = VMMDEV_EVENT_BALLOON_CHANGE_REQUEST;
    93     maskInfo.u32NotMask = 0;
    94     if (DeviceIoControl (gVBoxDriver, VBOXGUEST_IOCTL_CTL_FILTER_MASK, &maskInfo, sizeof (maskInfo), NULL, 0, &cbReturned, NULL))
    95     {
    96         Log(("VBoxMemBalloonThread: DeviceIOControl(CtlMask - or) succeeded\n"));
    97     }
    98     else
    99     {
    100         Log(("VBoxMemBalloonThread: DeviceIOControl(CtlMask) failed, SeamlessChangeThread exited\n"));
    101         return 0;
    102     }
    103 
    104     do
    105     {
    106         /* wait for a seamless change event */
    107         VBoxGuestWaitEventInfo waitEvent;
    108         waitEvent.u32TimeoutIn = 5000;
    109         waitEvent.u32EventMaskIn = VMMDEV_EVENT_BALLOON_CHANGE_REQUEST;
    110         if (DeviceIoControl(gVBoxDriver, VBOXGUEST_IOCTL_WAITEVENT, &waitEvent, sizeof(waitEvent), &waitEvent, sizeof(waitEvent), &cbReturned, NULL))
    111         {
    112             Log(("VBoxMemBalloonThread: DeviceIOControl succeded\n"));
    113 
    114             /* are we supposed to stop? */
    115             if (WaitForSingleObject(pCtx->pEnv->hStopEvent, 0) == WAIT_OBJECT_0)
    116                 break;
    117 
    118             Log(("VBoxMemBalloonThread: checking event\n"));
    119 
    120             /* did we get the right event? */
    121             if (waitEvent.u32EventFlagsOut & VMMDEV_EVENT_BALLOON_CHANGE_REQUEST)
    122             {
    123                 DWORD dwMemBalloonSize;
    124                 if (DeviceIoControl(gVBoxDriver, VBOXGUEST_IOCTL_CTL_CHECK_BALLOON_MASK, NULL, 0, &dwMemBalloonSize, sizeof(dwMemBalloonSize), &cbReturned, NULL))
    125                 {
    126                     Log(("VBoxMemBalloonThread: new balloon size % MB\n", dwMemBalloonSize));
    127                     pCtx->uMemBalloonSize = dwMemBalloonSize;
    128                 }
    129                 else
    130                     Log(("VBoxMemBalloonThread: DeviceIoControl (balloon) failed with %d\n", GetLastError()));
    131             }
    132         }
    133         else
    134         {
    135             Log(("VBoxMemBalloonThread: error 0 from DeviceIoControl VBOXGUEST_IOCTL_WAITEVENT\n"));
    136 
    137             /* sleep a bit to not eat too much CPU in case the above call always fails */
    138             if (WaitForSingleObject(pCtx->pEnv->hStopEvent, 10) == WAIT_OBJECT_0)
    139             {
    140                 fTerminate = true;
    141                 break;
    142             }
    143         }
    144     }
    145     while (!fTerminate);
    146 
    147     maskInfo.u32OrMask = 0;
    148     maskInfo.u32NotMask = VMMDEV_EVENT_BALLOON_CHANGE_REQUEST;
    149     if (DeviceIoControl (gVBoxDriver, VBOXGUEST_IOCTL_CTL_FILTER_MASK, &maskInfo, sizeof (maskInfo), NULL, 0, &cbReturned, NULL))
    150     {
    151         Log(("VBoxMemBalloonThread: DeviceIOControl(CtlMask - not) succeeded\n"));
    152     }
    153     else
    154     {
    155         Log(("VBoxMemBalloonThread: DeviceIOControl(CtlMask) failed\n"));
    156     }
    157 
    158     Log(("VBoxMemBalloonThread: finished mem balloon change request thread\n"));
    159     return 0;
     162    RTSemEventMultiSignal(g_MemBalloonEvent);
    160163}
    161164
    162165
     166/**
     167 * The 'memballoon' service description.
     168 */
     169VBOXSERVICE g_MemBalloon =
     170{
     171    /* pszName. */
     172    "memballoon",
     173    /* pszDescription. */
     174    "Memory Ballooning",
     175    /* pszUsage. */
     176    NULL,
     177    /* pszOptions. */
     178    NULL,
     179    /* methods */
     180    VBoxServiceBalloonPreInit,
     181    VBoxServiceBalloonOption,
     182    VBoxServiceBalloonInit,
     183    VBoxServiceBalloonWorker,
     184    VBoxServiceBalloonStop,
     185    VBoxServiceBalloonTerm
     186};
  • trunk/src/VBox/Additions/common/VBoxService/VBoxServiceInternal.h

    r26292 r26326  
    2727# include <Windows.h>
    2828# include <process.h> /* Needed for file version information. */
    29 # include <Ntsecapi.h> /* Needed for process security information. */
    3029#endif
    3130
     
    153152#ifdef RT_OS_WINDOWS
    154153extern DWORD g_rcWinService;
    155 extern SERVICE_STATUS_HANDLE g_hWinServiceStatus;
    156154extern SERVICE_TABLE_ENTRY const g_aServiceTable[];     /** @todo generate on the fly, see comment in main() from the enabled sub services. */
    157155extern PFNWTSGETACTIVECONSOLESESSIONID g_pfnWTSGetActiveConsoleSessionId; /* VBoxServiceVMInfo-win.cpp */
     
    169167#endif /* RT_OS_WINDOWS */
    170168
     169#ifdef VBOXSERVICE_MANAGEMENT
     170extern uint32_t VBoxServiceBalloonQuerySize();
     171#endif
     172
    171173RT_C_DECLS_END
    172174
  • trunk/src/VBox/Additions/common/VBoxService/VBoxServiceStats.cpp

    r26299 r26326  
    1919 * additional information or have any questions.
    2020 */
    21 #define _WIN32_WINNT 0x0500
    2221#include <windows.h>
    2322#include <psapi.h>
    24 #include "VBoxTray.h"
    25 #include <VBoxDisplay.h>
    26 #include <VBox/VMMDev.h>
    27 #include <VBox/VBoxGuest.h>
    28 #include <VBoxGuestInternal.h>
     23#include <winternl.h>
     24
    2925#include <iprt/assert.h>
    30 #include "helpers.h"
    31 #include <winternl.h>
     26#include <iprt/mem.h>
     27#include <iprt/thread.h>
     28#include <iprt/string.h>
     29#include <iprt/semaphore.h>
     30#include <iprt/system.h>
     31#include <iprt/time.h>
     32#include <VBox/VBoxGuestLib.h>
     33#include "VBoxServiceInternal.h"
     34#include "VBoxServiceUtils.h"
    3235
    3336typedef struct _VBOXSTATSCONTEXT
     
    7780    AssertRCReturn(rc, rc);
    7881
    79     gCtx.pEnv                   = pEnv;
    80     gCtx.uStatInterval          = 0;     /* default */
     82    gCtx.uStatInterval          = 0;     /* default; update disabled */
    8183    gCtx.ullLastCpuLoad_Idle    = 0;
    8284    gCtx.ullLastCpuLoad_Kernel  = 0;
    8385    gCtx.ullLastCpuLoad_User    = 0;
    8486
    85     VMMDevGetStatisticsChangeRequest req;
    86     vmmdevInitRequest(&req.header, VMMDevReq_GetStatisticsChangeRequest);
    87     req.eventAck = 0;
    88 
    89     if (DeviceIoControl(gVBoxDriver, VBOXGUEST_IOCTL_VMMREQUEST(req.header.size), &req, req.header.size, &req, req.header.size, &cbReturned, NULL))
    90     {
    91         VBoxServiceVerbose(3, "VBoxStatsInit: new statistics interval %d seconds\n", req.u32StatInterval);
    92         gCtx.uStatInterval = req.u32StatInterval * 1000;
    93     }
     87    rc = VbglR3StatQueryInterval(&gCtx.uStatInterval);
     88    if (RT_SUCCESS(rc))
     89        VBoxServiceVerbose(3, "VBoxStatsInit: new statistics interval %d seconds\n", gCtx.uStatInterval);
    9490    else
    95         VBoxServiceVerbose(3, ("VBoxStatsInit: DeviceIoControl failed with %d\n", GetLastError());
     91        VBoxServiceVerbose(3, "VBoxStatsInit: DeviceIoControl failed with %d\n", rc);
    9692
    9793#ifdef RT_OS_WINDOWS
     
    139135
    140136
    141 static void VBoxServiceVMStatsReport(VBOXSTATSCONTEXT *pCtx)
     137static void VBoxServiceVMStatsReport()
    142138{
    143139#ifdef RT_OS_WINDOWS
     
    148144    uint32_t cbStruct;
    149145    DWORD    cbReturned;
    150     HANDLE   gVBoxDriver = pCtx->pEnv->hDriver;
    151146
    152147    Assert(gCtx.pfnGlobalMemoryStatusEx && gCtx.pfnNtQuerySystemInformation);
     
    154149        ||  !gCtx.pfnNtQuerySystemInformation)
    155150        return;
    156 
    157     vmmdevInitRequest(&req.header, VMMDevReq_ReportGuestStats);
    158151
    159152    /* Query and report guest statistics */
     
    169162    req.guestStats.u32PageFileSize      = (uint32_t)(memStatus.ullTotalPageFile / systemInfo.dwPageSize) - req.guestStats.u32PhysMemTotal;
    170163    req.guestStats.u32MemoryLoad        = memStatus.dwMemoryLoad;
    171     req.guestStats.u32PhysMemBalloon    = VBoxMemBalloonQuerySize() * (_1M/systemInfo.dwPageSize);    /* was in megabytes */
     164    req.guestStats.u32PhysMemBalloon    = VBoxServiceBalloonQuerySize() * (_1M/systemInfo.dwPageSize);    /* was in megabytes */
    172165    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;
    173166
     
    189182        }
    190183        else
    191             Log(("GetPerformanceInfo failed with %d\n", GetLastError()));
     184            VBoxServiceVerbose(3, "GetPerformanceInfo failed with %d\n", GetLastError());
    192185    }
    193186
     
    238231        req.guestStats.u32CpuId = i;
    239232
    240         if (DeviceIoControl(gVBoxDriver, VBOXGUEST_IOCTL_VMMREQUEST(req.header.size), &req, req.header.size, &req, req.header.size, &cbReturned, NULL))
    241         {
    242             Log(("VBoxStatsReportStatistics: new statistics reported successfully!\n"));
    243         }
    244         else
    245             Log(("VBoxStatsReportStatistics: DeviceIoControl (stats report) failed with %d\n", GetLastError()));
     233        rc = VbglR3StatReport(&req);
     234        if (RT_SUCCESS(rc))
     235        {
     236            VBoxServiceVerbose(3, "VBoxStatsReportStatistics: new statistics reported successfully!\n");
     237        }
     238        else
     239            VBoxServiceVerbose(3, "VBoxStatsReportStatistics: DeviceIoControl (stats report) failed with %d\n", GetLastError());
    246240    }
    247241
     
    256250DECLCALLBACK(int) VBoxServiceVMStatsWorker(bool volatile *pfShutdown)
    257251{
    258     VBOXSTATSCONTEXT *pCtx = (VBOXSTATSCONTEXT *)pInstance;
    259     HANDLE gVBoxDriver = pCtx->pEnv->hDriver;
    260     bool fTerminate = false;
    261 
    262252    int rc = VINF_SUCCESS;
     253
     254    /* Start monitoring of the stat event change event. */
     255    rc = VbglR3CtlFilterMask(VMMDEV_EVENT_STATISTICS_INTERVAL_CHANGE_REQUEST, 0);
     256    if (RT_FAILURE(rc))
     257    {
     258        VBoxServiceVerbose(3, "VBoxServiceVMStatsWorker: VbglR3CtlFilterMask failed with %d\n", rc);
     259        return rc;
     260    }
    263261
    264262    /*
     
    268266    RTThreadUserSignal(RTThreadSelf());
    269267
    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");
    274         return 0;
    275     }
    276 
    277268    /*
    278269     * Now enter the loop retrieving runtime data continuously.
     
    281272    {
    282273        uint32_t fEvents = 0;
    283 
    284         rc = VbglR3WaitEvent(VMMDEV_EVENT_STATISTICS_INTERVAL_CHANGE_REQUEST, 1000, &fEvents);
     274        uint32_t u32WaitMillies;
     275
     276        /* Check if an update interval change is pending. */
     277        rc = VbglR3WaitEvent(VMMDEV_EVENT_STATISTICS_INTERVAL_CHANGE_REQUEST, 0 /* no wait */, &fEvents);
    285278        if (    RT_SUCCESS(rc)
    286279            &&  (fEvents & VMMDEV_EVENT_STATISTICS_INTERVAL_CHANGE_REQUEST))
    287280        {
    288         }
    289 
    290         VBoxServiceVMStatsReport();
     281            VbglR3StatQueryInterval(&gCtx.uStatInterval);
     282        }
     283
     284        if (gCtx.uStatInterval)
     285        {
     286            VBoxServiceVMStatsReport();
     287            u32WaitMillies = gCtx.uStatInterval;
     288        }
     289        else
     290            u32WaitMillies = 3000;
    291291
    292292        /*
     
    298298        if (*pfShutdown)
    299299            break;
    300         int rc2 = RTSemEventMultiWait(g_VMStatEvent, g_VMStatsInterval);
     300        int rc2 = RTSemEventMultiWait(g_VMStatEvent, u32WaitMillies);
    301301        if (*pfShutdown)
    302302            break;
     
    309309    }
    310310
     311    /* Cancel monitoring of the stat event change event. */
    311312    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 
    318 
    319     RTSemEventMultiDestroy(g_VMStatsEvent);
    320     g_VMStatsEvent = NIL_RTSEMEVENTMULTI;
    321 
    322     Log(("VBoxStatsThread: finished statistics change request thread\n"));
     313    if (RT_FAILURE(rc))
     314        VBoxServiceVerbose(3, "VBoxServiceVMStatsWorker: VbglR3CtlFilterMask failed with %d\n", rc);
     315
     316    RTSemEventMultiDestroy(g_VMStatEvent);
     317    g_VMStatEvent = NIL_RTSEMEVENTMULTI;
     318
     319    VBoxServiceVerbose(3, "VBoxStatsThread: finished statistics change request thread\n");
    323320    return 0;
    324321}
     
    336333static DECLCALLBACK(void) VBoxServiceVMStatsStop(void)
    337334{
    338     RTSemEventMultiSignal(g_VMStatsEvent);
     335    RTSemEventMultiSignal(g_VMStatEvent);
    339336}
    340337
  • trunk/src/VBox/Additions/common/VBoxService/VBoxServiceVMInfo-win.cpp

    r26136 r26326  
    2727#include <wtsapi32.h>       /* For WTS* calls. */
    2828#include <psapi.h>          /* EnumProcesses. */
     29#include <Ntsecapi.h>       /* Needed for process security information. */
    2930
    3031#include <iprt/assert.h>
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