Changeset 80670 in vbox for trunk/src/VBox/Main
- Timestamp:
- Sep 9, 2019 11:59:30 AM (6 years ago)
- svn:sync-xref-src-repo-rev:
- 133202
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/src-client/GuestImpl.cpp
r80654 r80670 108 108 109 109 mMagic = GUEST_MAGIC; 110 int vrc = RTTimerLRCreateEx(&mStatTimer, RT_NS_1SEC, 0 /*fFlags*/, &Guest::i_staticUpdateStats, this); 111 AssertMsgRC(vrc, ("Failed to create guest statistics update timer (%Rrc) - ignored\n", vrc)); 110 mStatTimer = NIL_RTTIMERLR; 112 111 113 112 hr = unconst(mEventSource).createObject(); … … 168 167 int vrc = RTTimerLRDestroy(mStatTimer); 169 168 AssertMsgRC(vrc, ("Failed to create guest statistics update timer(%Rra)\n", vrc)); 170 mStatTimer = N ULL;169 mStatTimer = NIL_RTTIMERLR; 171 170 mMagic = 0; 172 171 … … 626 625 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); 627 626 628 if (mStatUpdateInterval) 629 { 630 if (aStatisticsUpdateInterval == 0) 631 RTTimerLRStop(mStatTimer); 632 else 633 RTTimerLRChangeInterval(mStatTimer, aStatisticsUpdateInterval * RT_NS_1SEC_64); 634 } 635 else if (aStatisticsUpdateInterval != 0) 636 { 637 RTTimerLRChangeInterval(mStatTimer, aStatisticsUpdateInterval * RT_NS_1SEC_64); 638 RTTimerLRStart(mStatTimer, 0); 639 } 627 /* Update the timer, creating it the first time we're called with a non-zero value. */ 628 int vrc; 629 HRESULT hrc = S_OK; 630 if (aStatisticsUpdateInterval > 0) 631 { 632 if (mStatTimer == NIL_RTTIMERLR) 633 { 634 vrc = RTTimerLRCreate(&mStatTimer, aStatisticsUpdateInterval * RT_MS_1SEC, &Guest::i_staticUpdateStats, this); 635 AssertRCStmt(vrc, hrc = setErrorVrc(vrc, "Failed to create guest statistics update timer (%Rrc)", vrc)); 636 } 637 else if (aStatisticsUpdateInterval != mStatUpdateInterval) 638 { 639 vrc = RTTimerLRChangeInterval(mStatTimer, aStatisticsUpdateInterval * RT_NS_1SEC_64); 640 AssertRCStmt(vrc, hrc = setErrorVrc(vrc, "Failed to change guest statistics update timer interval from %u to %u failed (%Rrc)", 641 mStatUpdateInterval, aStatisticsUpdateInterval, vrc)); 642 if (mStatUpdateInterval == 0) 643 { 644 vrc = RTTimerLRStart(mStatTimer, 0); 645 AssertRCStmt(vrc, hrc = setErrorVrc(vrc, "Failed to start the guest statistics update timer (%Rrc)", vrc)); 646 } 647 } 648 } 649 /* Setting interval to zero - stop the update timer if needed: */ 650 else if (mStatUpdateInterval > 0 && mStatTimer != NIL_RTTIMERLR) 651 { 652 vrc = RTTimerLRStop(mStatTimer); 653 AssertRCStmt(vrc, hrc = setErrorVrc(vrc, "Failed to stop the guest statistics update timer (%Rrc)", vrc)); 654 } 655 656 /* Update the interval now that the timer is in sync. */ 640 657 mStatUpdateInterval = aStatisticsUpdateInterval; 641 658 … … 652 669 } 653 670 654 return S_OK;671 return hrc; 655 672 } 656 673 … … 667 684 *aCpuKernel = mCurrentGuestStat[GUESTSTATTYPE_CPUKERNEL]; 668 685 *aCpuIdle = mCurrentGuestStat[GUESTSTATTYPE_CPUIDLE]; 669 *aMemTotal = mCurrentGuestStat[GUESTSTATTYPE_MEMTOTAL] * (_4K/_1K);/* page (4K) -> 1KB units */670 *aMemFree = mCurrentGuestStat[GUESTSTATTYPE_MEMFREE] * (_4K/_1K);/* page (4K) -> 1KB units */686 *aMemTotal = mCurrentGuestStat[GUESTSTATTYPE_MEMTOTAL] * (_4K/_1K); /* page (4K) -> 1KB units */ 687 *aMemFree = mCurrentGuestStat[GUESTSTATTYPE_MEMFREE] * (_4K/_1K); /* page (4K) -> 1KB units */ 671 688 *aMemBalloon = mCurrentGuestStat[GUESTSTATTYPE_MEMBALLOON] * (_4K/_1K); /* page (4K) -> 1KB units */ 672 *aMemCache = mCurrentGuestStat[GUESTSTATTYPE_MEMCACHE] * (_4K/_1K);/* page (4K) -> 1KB units */673 *aPageTotal = mCurrentGuestStat[GUESTSTATTYPE_PAGETOTAL] * (_4K/_1K);/* page (4K) -> 1KB units */689 *aMemCache = mCurrentGuestStat[GUESTSTATTYPE_MEMCACHE] * (_4K/_1K); /* page (4K) -> 1KB units */ 690 *aPageTotal = mCurrentGuestStat[GUESTSTATTYPE_PAGETOTAL] * (_4K/_1K); /* page (4K) -> 1KB units */ 674 691 675 692 /* Play safe or smth? */
Note:
See TracChangeset
for help on using the changeset viewer.