VirtualBox

Changeset 44347 in vbox for trunk/src/VBox/Main


Ignore:
Timestamp:
Jan 24, 2013 12:27:56 AM (12 years ago)
Author:
vboxsync
Message:

PGM,SSM,STAM: Changed APIs used by Main to take PUVM instead of PVM as the VM handle.

Location:
trunk/src/VBox/Main
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/include/DisplayImpl.h

    r42878 r44347  
    122122    HRESULT init (Console *aParent);
    123123    void uninit();
    124     int  registerSSM(PVM pVM);
     124    int  registerSSM(PUVM pUVM);
    125125
    126126    // public methods only for internal purposes
  • trunk/src/VBox/Main/src-client/ConsoleImpl.cpp

    r44340 r44347  
    89008900                 * Register our load/save state file handlers
    89018901                 */
    8902                 vrc = SSMR3RegisterExternal(pVM, sSSMConsoleUnit, 0 /*iInstance*/, sSSMConsoleVer, 0 /* cbGuess */,
     8902                vrc = SSMR3RegisterExternal(pConsole->mpUVM, sSSMConsoleUnit, 0 /*iInstance*/, sSSMConsoleVer, 0 /* cbGuess */,
    89038903                                            NULL, NULL, NULL,
    89048904                                            NULL, saveStateFileExec, NULL,
     
    89078907                AssertRCBreak(vrc);
    89088908
    8909                 vrc = static_cast<Console *>(pConsole)->getDisplay()->registerSSM(pVM);
     8909                vrc = static_cast<Console *>(pConsole)->getDisplay()->registerSSM(pConsole->mpUVM);
    89108910                AssertRC(vrc);
    89118911                if (RT_FAILURE(vrc))
     
    92829282{
    92839283    PUVM pUVM = (PUVM)pvUser;
    9284     SSMR3Cancel(VMR3GetVM(pUVM));
     9284    SSMR3Cancel(pUVM);
    92859285}
    92869286
  • trunk/src/VBox/Main/src-client/ConsoleImplTeleporter.cpp

    r44340 r44347  
    574574{
    575575    TeleporterState *pState = (TeleporterState *)pvUser;
    576     SSMR3Cancel(VMR3GetVM(pState->mpUVM));
     576    SSMR3Cancel(pState->mpUVM);
    577577    if (!pState->mfIsSource)
    578578    {
     
    598598            if (SUCCEEDED(hrc) && fCanceled)
    599599            {
    600                 SSMR3Cancel(VMR3GetVM(pState->mpUVM));
     600                SSMR3Cancel(pState->mpUVM);
    601601                return VERR_SSM_CANCELLED;
    602602            }
  • trunk/src/VBox/Main/src-client/DisplayImpl.cpp

    r44340 r44347  
    569569 * pass pVM
    570570 */
    571 int Display::registerSSM(PVM pVM)
     571int Display::registerSSM(PUVM pUVM)
    572572{
    573573    /* Version 2 adds width and height of the framebuffer; version 3 adds
    574574     * the framebuffer offset in the virtual desktop and the framebuffer flags.
    575575     */
    576     int rc = SSMR3RegisterExternal(pVM, "DisplayData", 0, sSSMDisplayVer3,
     576    int rc = SSMR3RegisterExternal(pUVM, "DisplayData", 0, sSSMDisplayVer3,
    577577                                   mcMonitors * sizeof(uint32_t) * 8 + sizeof(uint32_t),
    578578                                   NULL, NULL, NULL,
     
    585585     * 3 * sizeof(uint32_t *) due to a code mistake.
    586586     */
    587     rc = SSMR3RegisterExternal(pVM, "DisplayData", 12 /*uInstance*/, sSSMDisplayVer, 0 /*cbGuess*/,
     587    rc = SSMR3RegisterExternal(pUVM, "DisplayData", 12 /*uInstance*/, sSSMDisplayVer, 0 /*cbGuess*/,
    588588                               NULL, NULL, NULL,
    589589                               NULL, NULL, NULL,
     
    591591    AssertRCReturn(rc, rc);
    592592
    593     rc = SSMR3RegisterExternal(pVM, "DisplayData", 24 /*uInstance*/, sSSMDisplayVer, 0 /*cbGuess*/,
     593    rc = SSMR3RegisterExternal(pUVM, "DisplayData", 24 /*uInstance*/, sSSMDisplayVer, 0 /*cbGuess*/,
    594594                               NULL, NULL, NULL,
    595595                               NULL, NULL, NULL,
     
    598598
    599599    /* uInstance is an arbitrary value greater than 1024. Such a value will ensure a quick seek in saved state file. */
    600     rc = SSMR3RegisterExternal(pVM, "DisplayScreenshot", 1100 /*uInstance*/, sSSMDisplayScreenshotVer, 0 /*cbGuess*/,
     600    rc = SSMR3RegisterExternal(pUVM, "DisplayScreenshot", 1100 /*uInstance*/, sSSMDisplayScreenshotVer, 0 /*cbGuess*/,
    601601                               NULL, NULL, NULL,
    602602                               NULL, displaySSMSaveScreenshot, NULL,
  • trunk/src/VBox/Main/src-client/GuestImpl.cpp

    r43908 r44347  
    231231void Guest::updateStats(uint64_t iTick)
    232232{
    233     uint64_t uFreeTotal, uAllocTotal, uBalloonedTotal, uSharedTotal;
    234     uint64_t uTotalMem, uPrivateMem, uSharedMem, uZeroMem;
     233    uint64_t cbFreeTotal      = 0;
     234    uint64_t cbAllocTotal     = 0;
     235    uint64_t cbBalloonedTotal = 0;
     236    uint64_t cbSharedTotal    = 0;
     237    uint64_t cbSharedMem      = 0;
     238    ULONG    uNetStatRx       = 0;
     239    ULONG    uNetStatTx       = 0;
     240    ULONG    aGuestStats[GUESTSTATTYPE_MAX];
     241    RT_ZERO(aGuestStats);
    235242
    236243    AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
    237244
    238     ULONG uNetStatRx = 0;
    239     ULONG uNetStatTx = 0;
    240     ULONG aGuestStats[GUESTSTATTYPE_MAX];
    241     RT_ZERO(aGuestStats);
    242245    ULONG validStats = mVmValidStats;
    243246    /* Check if we have anything to report */
     
    248251    }
    249252    alock.release();
     253
    250254    /*
    251255     * Calling SessionMachine may take time as the object resides in VBoxSVC
     
    253257     * and released the lock.
    254258     */
    255     uFreeTotal      = 0;
    256     uAllocTotal     = 0;
    257     uBalloonedTotal = 0;
    258     uSharedTotal    = 0;
    259     uTotalMem       = 0;
    260     uPrivateMem     = 0;
    261     uSharedMem      = 0;
    262     uZeroMem        = 0;
    263 
    264     Console::SafeVMPtr pVM(mParent);
    265     if (pVM.isOk())
     259    Console::SafeVMPtr ptrVM(mParent);
     260    if (ptrVM.isOk())
    266261    {
    267262        int rc;
     
    274269        {
    275270            /* Query the missing per-VM memory statistics. */
    276             rc = PGMR3QueryMemoryStats(pVM.raw(), &uTotalMem, &uPrivateMem, &uSharedMem, &uZeroMem);
     271            uint64_t cbTotalMemIgn, cbPrivateMemIgn, cbZeroMemIgn;
     272            rc = PGMR3QueryMemoryStats(ptrVM.rawUVM(), &cbTotalMemIgn, &cbPrivateMemIgn, &cbSharedMem, &cbZeroMemIgn);
    277273            if (rc == VINF_SUCCESS)
    278274            {
     
    283279        if (mCollectVMMStats)
    284280        {
    285             rc = PGMR3QueryGlobalMemoryStats(pVM.raw(), &uAllocTotal, &uFreeTotal, &uBalloonedTotal, &uSharedTotal);
     281            rc = PGMR3QueryGlobalMemoryStats(ptrVM.rawUVM(), &cbAllocTotal, &cbFreeTotal, &cbBalloonedTotal, &cbSharedTotal);
    286282            AssertRC(rc);
    287283            if (rc == VINF_SUCCESS)
     
    296292        uint64_t uTxPrev = mNetStatTx;
    297293        mNetStatRx = mNetStatTx = 0;
    298         rc = STAMR3Enum(pVM, "*/ReceiveBytes|*/TransmitBytes", staticEnumStatsCallback, this);
     294        rc = STAMR3Enum(ptrVM.rawUVM(), "*/ReceiveBytes|*/TransmitBytes", staticEnumStatsCallback, this);
    299295        uint64_t uTsNow = RTTimeNanoTS();
    300296        uint64_t uTimePassed = uTsNow - mNetStatLastTs;
     
    315311                                mCurrentGuestStat[GUESTSTATTYPE_MEMFREE] * (_4K/_1K),
    316312                                mCurrentGuestStat[GUESTSTATTYPE_MEMBALLOON] * (_4K/_1K),
    317                                 (ULONG)(uSharedMem / _1K), /* bytes -> KB */
     313                                (ULONG)(cbSharedMem / _1K), /* bytes -> KB */
    318314                                mCurrentGuestStat[GUESTSTATTYPE_MEMCACHE] * (_4K/_1K),
    319315                                mCurrentGuestStat[GUESTSTATTYPE_PAGETOTAL] * (_4K/_1K),
    320                                 (ULONG)(uAllocTotal / _1K), /* bytes -> KB */
    321                                 (ULONG)(uFreeTotal / _1K),
    322                                 (ULONG)(uBalloonedTotal / _1K),
    323                                 (ULONG)(uSharedTotal / _1K),
     316                                (ULONG)(cbAllocTotal / _1K), /* bytes -> KB */
     317                                (ULONG)(cbFreeTotal / _1K),
     318                                (ULONG)(cbBalloonedTotal / _1K),
     319                                (ULONG)(cbSharedTotal / _1K),
    324320                                uNetStatRx,
    325321                                uNetStatTx);
     
    637633    *aPageTotal  = mCurrentGuestStat[GUESTSTATTYPE_PAGETOTAL] * (_4K/_1K);   /* page (4K) -> 1KB units */
    638634
     635    /* Play safe or smth? */
     636    *aMemAllocTotal   = 0;
     637    *aMemFreeTotal    = 0;
     638    *aMemBalloonTotal = 0;
     639    *aMemSharedTotal  = 0;
     640    *aMemShared       = 0;
     641
    639642    /* MUST release all locks before calling any PGM statistics queries,
    640643     * as they are executed by EMT and that might deadlock us by VMM device
    641644     * activity which waits for the Guest object lock. */
    642645    alock.release();
    643     Console::SafeVMPtr pVM (mParent);
    644     if (pVM.isOk())
    645     {
    646         uint64_t uFreeTotal, uAllocTotal, uBalloonedTotal, uSharedTotal;
    647         *aMemFreeTotal = 0;
    648         int rc = PGMR3QueryGlobalMemoryStats(pVM.raw(), &uAllocTotal, &uFreeTotal, &uBalloonedTotal, &uSharedTotal);
    649         AssertRC(rc);
    650         if (rc == VINF_SUCCESS)
    651         {
    652             *aMemAllocTotal   = (ULONG)(uAllocTotal / _1K);  /* bytes -> KB */
    653             *aMemFreeTotal    = (ULONG)(uFreeTotal / _1K);
    654             *aMemBalloonTotal = (ULONG)(uBalloonedTotal / _1K);
    655             *aMemSharedTotal  = (ULONG)(uSharedTotal / _1K);
    656         }
    657         else
    658             return E_FAIL;
    659 
    660         /* Query the missing per-VM memory statistics. */
    661         *aMemShared  = 0;
    662         uint64_t uTotalMem, uPrivateMem, uSharedMem, uZeroMem;
    663         rc = PGMR3QueryMemoryStats(pVM.raw(), &uTotalMem, &uPrivateMem, &uSharedMem, &uZeroMem);
    664         if (rc == VINF_SUCCESS)
    665         {
    666             *aMemShared = (ULONG)(uSharedMem / _1K);
    667         }
    668         else
    669             return E_FAIL;
    670     }
    671     else
    672     {
    673         *aMemAllocTotal   = 0;
    674         *aMemFreeTotal    = 0;
    675         *aMemBalloonTotal = 0;
    676         *aMemSharedTotal  = 0;
    677         *aMemShared       = 0;
     646    Console::SafeVMPtr ptrVM(mParent);
     647    if (!ptrVM.isOk())
    678648        return E_FAIL;
    679     }
     649
     650    uint64_t cbFreeTotal, cbAllocTotal, cbBalloonedTotal, cbSharedTotal;
     651    int rc = PGMR3QueryGlobalMemoryStats(ptrVM.rawUVM(), &cbAllocTotal, &cbFreeTotal, &cbBalloonedTotal, &cbSharedTotal);
     652    AssertRCReturn(rc, E_FAIL);
     653
     654    *aMemAllocTotal   = (ULONG)(cbAllocTotal / _1K);  /* bytes -> KB */
     655    *aMemFreeTotal    = (ULONG)(cbFreeTotal / _1K);
     656    *aMemBalloonTotal = (ULONG)(cbBalloonedTotal / _1K);
     657    *aMemSharedTotal  = (ULONG)(cbSharedTotal / _1K);
     658
     659    /* Query the missing per-VM memory statistics. */
     660    uint64_t cbTotalMemIgn, cbPrivateMemIgn, cbSharedMem, cbZeroMemIgn;
     661    rc = PGMR3QueryMemoryStats(ptrVM.rawUVM(), &cbTotalMemIgn, &cbPrivateMemIgn, &cbSharedMem, &cbZeroMemIgn);
     662    AssertRCReturn(rc, E_FAIL);
     663    *aMemShared = (ULONG)(cbSharedMem / _1K);
    680664
    681665    return S_OK;
  • trunk/src/VBox/Main/src-client/MachineDebuggerImpl.cpp

    r44346 r44347  
    754754    AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
    755755
    756     Console::SafeVMPtrQuiet pVM (mParent);
    757 
    758     if (pVM.isOk())
    759     {
    760         uint64_t cr4 = CPUMGetGuestCR4 (VMMGetCpu0(pVM.raw()));
    761         *aEnabled = !!(cr4 & X86_CR4_PAE);
     756    Console::SafeVMPtrQuiet ptrVM(mParent);
     757
     758    if (ptrVM.isOk())
     759    {
     760        uint32_t cr4;
     761        int rc = DBGFR3RegCpuQueryU32(ptrVM.raw(), 0 /*idCpu*/,  DBGFREG_CR4, &cr4); AssertRC(rc);
     762        *aEnabled = RT_BOOL(cr4 & X86_CR4_PAE);
    762763    }
    763764    else
     
    14091410STDMETHODIMP MachineDebugger::ResetStats(IN_BSTR aPattern)
    14101411{
    1411     Console::SafeVMPtrQuiet pVM (mParent);
    1412 
    1413     if (!pVM.isOk())
     1412    Console::SafeVMPtrQuiet ptrVM(mParent);
     1413
     1414    if (!ptrVM.isOk())
    14141415        return setError(VBOX_E_INVALID_VM_STATE, "Machine is not running");
    14151416
    1416     STAMR3Reset(pVM, Utf8Str(aPattern).c_str());
     1417    STAMR3Reset(ptrVM.rawUVM(), Utf8Str(aPattern).c_str());
    14171418
    14181419    return S_OK;
     
    14251426 * @param   aPattern            The selection pattern. A bit similar to filename globbing.
    14261427 */
    1427 STDMETHODIMP MachineDebugger::DumpStats (IN_BSTR aPattern)
    1428 {
    1429     Console::SafeVMPtrQuiet pVM (mParent);
    1430 
    1431     if (!pVM.isOk())
     1428STDMETHODIMP MachineDebugger::DumpStats(IN_BSTR aPattern)
     1429{
     1430    Console::SafeVMPtrQuiet ptrVM(mParent);
     1431
     1432    if (!ptrVM.isOk())
    14321433        return setError(VBOX_E_INVALID_VM_STATE, "Machine is not running");
    14331434
    1434     STAMR3Dump(pVM, Utf8Str(aPattern).c_str());
     1435    STAMR3Dump(ptrVM.rawUVM(), Utf8Str(aPattern).c_str());
    14351436
    14361437    return S_OK;
     
    14471448STDMETHODIMP MachineDebugger::GetStats (IN_BSTR aPattern, BOOL aWithDescriptions, BSTR *aStats)
    14481449{
    1449     Console::SafeVMPtrQuiet pVM (mParent);
    1450 
    1451     if (!pVM.isOk())
     1450    Console::SafeVMPtrQuiet ptrVM (mParent);
     1451
     1452    if (!ptrVM.isOk())
    14521453        return setError(VBOX_E_INVALID_VM_STATE, "Machine is not running");
    14531454
    14541455    char *pszSnapshot;
    1455     int vrc = STAMR3Snapshot(pVM, Utf8Str(aPattern).c_str(), &pszSnapshot, NULL,
     1456    int vrc = STAMR3Snapshot(ptrVM.rawUVM(), Utf8Str(aPattern).c_str(), &pszSnapshot, NULL,
    14561457                             !!aWithDescriptions);
    14571458    if (RT_FAILURE(vrc))
     
    14631464     * of the amount statistics in a debug build. */
    14641465    Bstr(pszSnapshot).detachTo(aStats);
     1466    STAMR3SnapshotFree(ptrVM.rawUVM(), pszSnapshot);
    14651467
    14661468    return S_OK;
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