VirtualBox

Changeset 26299 in vbox for trunk/src/VBox/Additions


Ignore:
Timestamp:
Feb 5, 2010 3:51:43 PM (15 years ago)
Author:
vboxsync
Message:

Updates

File:
1 edited

Legend:

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

    r26292 r26299  
    5353/** The semaphore we're blocking on. */
    5454static RTSEMEVENTMULTI  g_VMStatEvent = NIL_RTSEMEVENTMULTI;
    55 /** The vmstats interval (millseconds). */
    56 uint32_t                g_VMStatsInterval = 0;
    5755
    5856
     
    6765static DECLCALLBACK(int) VBoxServiceVMStatsOption(const char **ppszShort, int argc, char **argv, int *pi)
    6866{
    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;
    7668}
    7769
     
    9789    if (DeviceIoControl(gVBoxDriver, VBOXGUEST_IOCTL_VMMREQUEST(req.header.size), &req, req.header.size, &req, req.header.size, &cbReturned, NULL))
    9890    {
    99         Log(("VBoxStatsInit: new statistics interval %d seconds\n", req.u32StatInterval));
     91        VBoxServiceVerbose(3, "VBoxStatsInit: new statistics interval %d seconds\n", req.u32StatInterval);
    10092        gCtx.uStatInterval = req.u32StatInterval * 1000;
    10193    }
    10294    else
    103         Log(("VBoxStatsInit: DeviceIoControl failed with %d\n", GetLastError()));
     95        VBoxServiceVerbose(3, ("VBoxStatsInit: DeviceIoControl failed with %d\n", GetLastError());
    10496
    10597#ifdef RT_OS_WINDOWS
     
    149141static void VBoxServiceVMStatsReport(VBOXSTATSCONTEXT *pCtx)
    150142{
     143#ifdef RT_OS_WINDOWS
    151144    SYSTEM_INFO systemInfo;
    152145    PSYSTEM_PROCESSOR_PERFORMANCE_INFORMATION pProcInfo;
     
    254247
    255248    free(pProcInfo);
     249#else
     250    /* todo: implement for other platforms. */
     251    return;
     252#endif
    256253}
    257254
     
    262259    HANDLE gVBoxDriver = pCtx->pEnv->hDriver;
    263260    bool fTerminate = false;
    264     VBoxGuestFilterMaskInfo maskInfo;
    265     DWORD cbReturned;
    266261
    267262    int rc = VINF_SUCCESS;
     
    273268    RTThreadUserSignal(RTThreadSelf());
    274269
    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");
    284274        return 0;
    285275    }
     
    290280    for (;;)
    291281    {
    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();
    297291
    298292        /*
     
    315309    }
    316310
    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
    327318
    328319    RTSemEventMultiDestroy(g_VMStatsEvent);
     
    359350    "Virtual Machine Statistics",
    360351    /* pszUsage. */
    361     "[--vmstats-interval <ms>]"
    362     ,
     352    NULL,
    363353    /* 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,
    367355    /* methods */
    368356    VBoxServiceVMStatsPreInit,
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