VirtualBox

Changeset 4524 in vbox


Ignore:
Timestamp:
Sep 5, 2007 8:34:25 AM (17 years ago)
Author:
vboxsync
Message:

Updates for guest statistics

Location:
trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/VBox/VBoxGuest.h

    r4519 r4524  
    146146    VMMDevReq_ReportGuestStats           = 110,
    147147    VMMDevReq_GetMemBalloonChangeRequest = 111,
     148    VMMDevReq_GetStatisticsChangeRequest = 112,
    148149    VMMDevReq_LogString                  = 200,
    149150    VMMDevReq_SizeHack                   = 0x7fffffff
     
    403404    uint32_t            eventAck;
    404405} VMMDevGetMemBalloonChangeRequest;
     406
     407/** guest statistics interval change request structure */
     408typedef struct
     409{
     410    /** header */
     411    VMMDevRequestHeader header;
     412    uint32_t            u32StatInterval; /* interval in seconds */
     413    uint32_t            eventAck;
     414} VMMDevGetStatisticsChangeRequest;
    405415 
    406416/** display change request structure */
     
    969979
    970980/** Host mouse capabilities has been changed. */
    971 #define VMMDEV_EVENT_MOUSE_CAPABILITIES_CHANGED     BIT(0)
     981#define VMMDEV_EVENT_MOUSE_CAPABILITIES_CHANGED             BIT(0)
    972982/** HGCM event. */
    973 #define VMMDEV_EVENT_HGCM                           BIT(1)
     983#define VMMDEV_EVENT_HGCM                                   BIT(1)
    974984/** A display change request has been issued. */
    975 #define VMMDEV_EVENT_DISPLAY_CHANGE_REQUEST         BIT(2)
     985#define VMMDEV_EVENT_DISPLAY_CHANGE_REQUEST                 BIT(2)
    976986/** Credentials are available for judgement. */
    977 #define VMMDEV_EVENT_JUDGE_CREDENTIALS              BIT(3)
     987#define VMMDEV_EVENT_JUDGE_CREDENTIALS                      BIT(3)
    978988/** The guest has been restored. */
    979 #define VMMDEV_EVENT_RESTORED                       BIT(4)
     989#define VMMDEV_EVENT_RESTORED                               BIT(4)
    980990/** Seamless mode state changed */
    981 #define VMMDEV_EVENT_SEAMLESS_MODE_CHANGE_REQUEST   BIT(5)
     991#define VMMDEV_EVENT_SEAMLESS_MODE_CHANGE_REQUEST           BIT(5)
    982992/** Memory balloon size changed */
    983 #define VMMDEV_EVENT_BALLOON_CHANGE_REQUEST         BIT(6)
     993#define VMMDEV_EVENT_BALLOON_CHANGE_REQUEST                 BIT(6)
     994/** Statistics interval changed */
     995#define VMMDEV_EVENT_STATISTICS_INTERVAL_CHANGE_REQUEST     BIT(7)
    984996/** VRDP status changed. */
    985997#define VMMDEV_EVENT_VRDP                           BIT(7)
     
    13051317        case VMMDevReq_GetMemBalloonChangeRequest:
    13061318            return sizeof(VMMDevGetMemBalloonChangeRequest);
     1319        case VMMDevReq_GetStatisticsChangeRequest:
     1320            return sizeof(VMMDevGetStatisticsChangeRequest);
    13071321        case VMMDevReq_LogString:
    13081322            return sizeof(VMMDevReqLogString);
  • trunk/include/VBox/pdmifs.h

    r4492 r4524  
    14131413    DECLR3CALLBACKMEMBER(int, pfnSetMemoryBalloon,(PPDMIVMMDEVPORT pInterface, uint32_t ulBalloonSize));
    14141414
     1415    /**
     1416     * Issue a statistcs interval change request.
     1417     *
     1418     * Note that there can only one request in the queue and that in case the guest does
     1419     * not process it, issuing another request will overwrite the previous.
     1420     *
     1421     * @returns VBox status code
     1422     * @param   ulStatInterval  Statistics query interval in seconds (0=disable)
     1423     */
     1424    DECLR3CALLBACKMEMBER(int, pfnSetStatisticsInterval,(PPDMIVMMDEVPORT pInterface, uint32_t ulStatInterval));
     1425
    14151426} PDMIVMMDEVPORT;
    14161427
  • trunk/src/VBox/Additions/WINNT/VBoxGuest/VBoxGuest.cpp

    r4301 r4524  
    428428}
    429429
     430static NTSTATUS VBoxGuestQueryMemoryBalloon(PVBOXGUESTDEVEXT pDevExt)
     431{
     432    /* just perform the request */
     433    VMMDevGetMemBalloonChangeRequest *req = NULL;
     434
     435    Log(("VBoxGuestQueryMemoryBalloon\n"));
     436
     437    int rc = VbglGRAlloc((VMMDevRequestHeader **)&req, sizeof(VMMDevGetMemBalloonChangeRequest), VMMDevReq_GetMemBalloonChangeRequest);
     438    vmmdevInitRequest(&req->header, VMMDevReq_GetMemBalloonChangeRequest);
     439    req->eventAck = VMMDEV_EVENT_BALLOON_CHANGE_REQUEST;
     440
     441    if (VBOX_SUCCESS(rc))
     442    {
     443        rc = VbglGRPerform(&req->header);
     444
     445        if (VBOX_FAILURE(rc) || VBOX_FAILURE(req->header.rc))
     446        {
     447            dprintf(("VBoxGuest::VBoxGuestDeviceControl IOCTL_VBOXGUEST_CTL_CHECK_BALLOON: error issuing request to VMMDev!"
     448                     "rc = %d, VMMDev rc = %Vrc\n", rc, req->header.rc));
     449            Status = STATUS_UNSUCCESSFUL;
     450        }
     451        else
     452        {
     453
     454        }
     455
     456        VbglGRFree(&req->header);
     457    }
     458    else
     459    {
     460        Status = STATUS_UNSUCCESSFUL;
     461    }
     462}
     463
     464
    430465/**
    431466 * Device I/O Control entry point.
     
    770805                pDevExt->ulOldActiveConsoleId    = 0;
    771806            }
     807            break;
     808        }
     809#endif
     810
     811#ifdef VBOX_WITH_MANAGEMENT
     812        case IOCTL_VBOXGUEST_CTL_CHECK_BALLOON:
     813        {
     814            Status = VBoxGuestQueryMemoryBalloon(pDevExt);
    772815            break;
    773816        }
  • trunk/src/VBox/Additions/WINNT/VBoxService/VBoxGuest.cpp

    r4516 r4524  
    2525#include <iprt/assert.h>
    2626#include "helpers.h"
     27#include <winternl.h>
    2728
    2829typedef struct _VBOXGUESTCONTEXT
    2930{
    3031    const VBOXSERVICEENV *pEnv;
     32    uint32_t              uStatInterval;
     33
     34    NTSTATUS (WINAPI *pfnNtQuerySystemInformation)(SYSTEM_INFORMATION_CLASS SystemInformationClass, PVOID SystemInformation, ULONG SystemInformationLength, PULONG ReturnLength);
    3135} VBOXGUESTCONTEXT;
    3236
     
    3741int VBoxGuestInit(const VBOXSERVICEENV *pEnv, void **ppInstance, bool *pfStartThread)
    3842{
     43    HANDLE gVBoxDriver = pEnv->hDriver;
     44    DWORD  cbReturned;
     45
    3946    dprintf(("VBoxGuestInit\n"));
    4047
    41     gCtx.pEnv      = pEnv;
     48    gCtx.pEnv          = pEnv;
     49    gCtx.uStatInterval = 0;     /* default */
     50
     51    VMMDevGetStatisticsChangeRequest req;
     52    vmmdevInitRequest(&req.header, VMMDevReq_GetStatisticsChangeRequest);
     53    req.eventAck = 0;
     54
     55    if (DeviceIoControl(gVBoxDriver, IOCTL_VBOXGUEST_VMMREQUEST, &req, req.header.size, &req, req.header.size, &cbReturned, NULL))
     56    {
     57        dprintf(("VBoxGuestThread: new statistics interval %d seconds\n", req.u32StatInterval));
     58        gCtx.uStatInterval = req.u32StatInterval * 1000;
     59    }
     60    else
     61        dprintf(("VBoxGuestThread: DeviceIoControl failed with %d\n", GetLastError()));
     62
     63    HMODULE hMod = LoadLibrary("NTDLL.DLL");
     64    if (hMod)
     65    {
     66        *(uintptr_t *)&gCtx.pfnNtQuerySystemInformation = (uintptr_t)GetProcAddress(hMod, "NtQuerySystemInformation");
     67        if (gCtx.pfnNtQuerySystemInformation)
     68            dprintf(("gCtx.pfnNtQuerySystemInformation = %x\n", gCtx.pfnNtQuerySystemInformation));
     69        else
     70            dprintf(("NTDLL.NtQuerySystemInformation not found!!\n"));
     71    }
    4272
    4373    *pfStartThread = true;
     
    81111        /* wait for a seamless change event */
    82112        VBoxGuestWaitEventInfo waitEvent;
    83         waitEvent.u32TimeoutIn = 1000;
    84         waitEvent.u32EventMaskIn = VMMDEV_EVENT_BALLOON_CHANGE_REQUEST;
     113        waitEvent.u32TimeoutIn = (pCtx->uStatInterval) ? pCtx->uStatInterval : 1000;
     114        waitEvent.u32EventMaskIn = VMMDEV_EVENT_BALLOON_CHANGE_REQUEST | VMMDEV_EVENT_STATISTICS_INTERVAL_CHANGE_REQUEST;
    85115        if (DeviceIoControl(gVBoxDriver, IOCTL_VBOXGUEST_WAITEVENT, &waitEvent, sizeof(waitEvent), &waitEvent, sizeof(waitEvent), &cbReturned, NULL))
    86116        {
     
    98128                DeviceIoControl(gVBoxDriver, IOCTL_VBOXGUEST_CTL_CHECK_BALLOON, NULL, 0, NULL, 0, NULL, NULL);
    99129            }
     130            if (waitEvent.u32EventFlagsOut & VMMDEV_EVENT_STATISTICS_INTERVAL_CHANGE_REQUEST)
     131            {
     132                VMMDevGetStatisticsChangeRequest req;
     133                vmmdevInitRequest(&req.header, VMMDevReq_GetStatisticsChangeRequest);
     134                req.eventAck = VMMDEV_EVENT_STATISTICS_INTERVAL_CHANGE_REQUEST;
     135
     136                if (DeviceIoControl(gVBoxDriver, IOCTL_VBOXGUEST_VMMREQUEST, &req, req.header.size, &req, req.header.size, &cbReturned, NULL))
     137                {
     138                    dprintf(("VBoxGuestThread: new statistics interval %d seconds\n", req.u32StatInterval));
     139                    pCtx->uStatInterval = req.u32StatInterval * 1000;
     140                }
     141                else
     142                    dprintf(("VBoxGuestThread: DeviceIoControl failed with %d\n", GetLastError()));
     143
     144            }
    100145        }
    101146        else
     
    110155            }
    111156        }
     157        if (    gCtx.uStatInterval
     158            &&  gCtx.pfnNtQuerySystemInformation)
     159        {
     160            SYSTEM_INFO systemInfo;
     161
     162            /* Query and report guest statistics */
     163            GetSystemInfo(&systemInfo);
     164
     165            //gCtx.pfnNtQuerySystemInformation(
     166        }
    112167    }
    113168    while (!fTerminate);
    114169
    115170    maskInfo.u32OrMask = 0;
    116     maskInfo.u32NotMask = VMMDEV_EVENT_BALLOON_CHANGE_REQUEST;
     171    maskInfo.u32NotMask = VMMDEV_EVENT_BALLOON_CHANGE_REQUEST | VMMDEV_EVENT_STATISTICS_INTERVAL_CHANGE_REQUEST;
    117172    if (DeviceIoControl (gVBoxDriver, IOCTL_VBOXGUEST_CTL_FILTER_MASK, &maskInfo, sizeof (maskInfo), NULL, 0, &cbReturned, NULL))
    118173    {
  • trunk/src/VBox/Devices/VMMDev/VBoxDev.cpp

    r4492 r4524  
    11841184            if (requestHeader->size != sizeof(VMMDevGetMemBalloonChangeRequest))
    11851185            {
     1186                AssertFailed();
    11861187                requestHeader->rc = VERR_INVALID_PARAMETER;
    11871188            }
     
    11971198                    /* Remember which mode the client has queried. */
    11981199                    pData->u32LastMemoryBalloonSize = pData->u32MemoryBalloonSize;
     1200                }
     1201
     1202                requestHeader->rc = VINF_SUCCESS;
     1203            }
     1204            break;
     1205        }
     1206
     1207        case VMMDevReq_GetStatisticsChangeRequest:
     1208        {
     1209            Log(("VMMDevReq_GetStatisticsChangeRequest\n"));
     1210            if (requestHeader->size != sizeof(VMMDevGetStatisticsChangeRequest))
     1211            {
     1212                AssertFailed();
     1213                requestHeader->rc = VERR_INVALID_PARAMETER;
     1214            }
     1215            else
     1216            {
     1217                VMMDevGetStatisticsChangeRequest *statIntervalChangeRequest = (VMMDevGetStatisticsChangeRequest*)requestHeader;
     1218                /* just pass on the information */
     1219                Log(("VMMDev: returning statistics interval %d seconds\n", pData->u32StatIntervalSize));
     1220                statIntervalChangeRequest->u32StatInterval = pData->u32StatIntervalSize;
     1221
     1222                if (statIntervalChangeRequest->eventAck == VMMDEV_EVENT_STATISTICS_INTERVAL_CHANGE_REQUEST)
     1223                {
     1224                    /* Remember which mode the client has queried. */
     1225                    pData->u32LastStatIntervalSize= pData->u32StatIntervalSize;
    11991226                }
    12001227
     
    16961723    return VINF_SUCCESS;
    16971724}
     1725
     1726static DECLCALLBACK(int) vmmdevSetStatisticsInterval(PPDMIVMMDEVPORT pInterface, uint32_t ulStatInterval)
     1727{
     1728    VMMDevState *pData = IVMMDEVPORT_2_VMMDEVSTATE(pInterface);
     1729
     1730    /* Verify that the new resolution is different and that guest does not yet know about it. */
     1731    bool fSame = (pData->u32LastStatIntervalSize == ulStatInterval);
     1732
     1733    Log(("vmmdevSetStatisticsInterval: old=%d. new=%d\n", pData->u32LastStatIntervalSize, ulStatInterval));
     1734
     1735    if (!fSame)
     1736    {
     1737        /* we could validate the information here but hey, the guest can do that as well! */
     1738        pData->u32StatIntervalSize = ulStatInterval;
     1739
     1740        /* IRQ so the guest knows what's going on */
     1741        VMMDevNotifyGuest (pData, VMMDEV_EVENT_STATISTICS_INTERVAL_CHANGE_REQUEST);
     1742    }
     1743
     1744    return VINF_SUCCESS;
     1745}
     1746
    16981747
    16991748static DECLCALLBACK(int) vmmdevSetCredentials(PPDMIVMMDEVPORT pInterface, const char *pszUsername,
     
    19852034    pData->Port.pfnRequestSeamlessChange  = vmmdevRequestSeamlessChange;
    19862035    pData->Port.pfnSetMemoryBalloon       = vmmdevSetMemoryBalloon;
     2036    pData->Port.pfnSetStatisticsInterval  = vmmdevSetStatisticsInterval;
    19872037
    19882038    /* Shared folder LED */
     
    21162166    /* disabled memory ballooning */
    21172167    pData->u32LastMemoryBalloonSize = 0;
     2168
     2169    /* disabled statistics updating */
     2170    pData->u32LastStatIntervalSize = 0;
    21182171
    21192172    /* Clear the event variables.
  • trunk/src/VBox/Devices/VMMDev/VMMDevState.h

    r4492 r4524  
    135135    uint32_t    u32MemoryBalloonSize, u32LastMemoryBalloonSize;
    136136
     137    /* statistics interval change request */
     138    uint32_t    u32StatIntervalSize, u32LastStatIntervalSize;
     139
    137140    /* seamless mode change request */
    138141    bool fLastSeamlessEnabled, fSeamlessEnabled;
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