VirtualBox

Changeset 27885 in vbox


Ignore:
Timestamp:
Mar 31, 2010 12:16:27 PM (14 years ago)
Author:
vboxsync
Message:

Metrics: work in progress

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

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/GuestImpl.cpp

    r27852 r27885  
    218218}
    219219
    220 HRESULT Guest::GetStatisticsUpdateInterval (ULONG *aUpdateInterval)
     220STDMETHODIMP Guest::COMGETTER(StatisticsUpdateInterval)(ULONG *aUpdateInterval)
    221221{
    222222    CheckComArgOutPointerValid(aUpdateInterval);
     
    224224    AutoCaller autoCaller(this);
    225225    if (FAILED(autoCaller.rc())) return autoCaller.rc();
    226 
     226 
    227227    AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
    228228
    229229    *aUpdateInterval = mStatUpdateInterval;
    230 
    231     return S_OK;
    232 }
    233 
    234 HRESULT Guest::SetStatisticsUpdateInterval (ULONG aUpdateInterval)
     230    return S_OK;
     231}
     232
     233STDMETHODIMP Guest::COMSETTER(StatisticsUpdateInterval)(ULONG aUpdateInterval)
    235234{
    236235    AutoCaller autoCaller(this);
     
    247246    return S_OK;
    248247}
     248
     249STDMETHODIMP Guest::InternalGetStatistics(ULONG aCpuId, ULONG *aCpuUser, ULONG *aCpuKernel, ULONG *aCpuIdle,
     250                                          ULONG *aMemTotal, ULONG *aMemFree, ULONG *aMemBalloon, ULONG *aMemCache,
     251                                          ULONG *aPageTotal, ULONG *aPageFree)
     252{
     253    return S_OK;
     254}
     255
    249256
    250257STDMETHODIMP Guest::SetCredentials(IN_BSTR aUserName, IN_BSTR aPassword,
  • trunk/src/VBox/Main/MachineImpl.cpp

    r27874 r27885  
    89358935
    89368936    /* Guest metrics */
     8937    mGuestHAL = new pm::CollectorGuestHAL(this);
    89378938
    89388939    /* Create sub metrics */
     
    89518952
    89528953    pm::SubMetric *guestPagedTotal = new pm::SubMetric("Guest/Pagefile/Usage/Total",    "Total amount of space in the page file.");
    8953     pm::SubMetric *guestPagedFree = new pm::SubMetric("Guest/Pagefile/Usage/Free",      "Total amount of free space in the page file.");
    8954 
    8955     pm::SubMetric *guestSystemProc = new pm::SubMetric("Guest/System/Processes",      "Total number of guest processes.");
    8956     pm::SubMetric *guestSystemThread = new pm::SubMetric("Guest/System/Threads",      "Total number of guest threads.");
     8954    pm::SubMetric *guestPagedFree = new pm::SubMetric("Guest/Pagefile/Usage/Free",      "Free amount of free space in the page file.");
    89578955
    89588956    /* Create and register base metrics */
    8959     pm::BaseMetric *guestCpuLoad = new pm::GuestCpuLoad(&mGuestHAL, aMachine, guestLoadUser, guestLoadKernel, guestLoadIdle);
     8957    pm::BaseMetric *guestCpuLoad = new pm::GuestCpuLoad(mGuestHAL, aMachine, guestLoadUser, guestLoadKernel, guestLoadIdle);
    89608958    aCollector->registerBaseMetric(guestCpuLoad);
    89618959
    8962     pm::BaseMetric *guestCpuMem = new pm::GuestRamUsage(&mGuestHAL, aMachine, guestMemTotal, guestMemFree, guestMemBalloon,
     8960    pm::BaseMetric *guestCpuMem = new pm::GuestRamUsage(mGuestHAL, aMachine, guestMemTotal, guestMemFree, guestMemBalloon,
    89638961                                                        guestMemCache, guestPagedTotal, guestPagedFree);
    89648962    aCollector->registerBaseMetric(guestCpuMem);
    8965 
    8966     pm::BaseMetric *guestSystem = new pm::GuestSystemUsage(&mGuestHAL, aMachine, guestSystemProc, guestSystemThread);
    8967     aCollector->registerBaseMetric(guestSystem);
    8968 
    89698963
    89708964    aCollector->registerMetric(new pm::Metric(guestCpuLoad, guestLoadUser, 0));
     
    90129006    aCollector->registerMetric(new pm::Metric(guestCpuMem, guestPagedFree, new pm::AggregateMin()));
    90139007    aCollector->registerMetric(new pm::Metric(guestCpuMem, guestPagedFree, new pm::AggregateMax()));
    9014 
    9015     aCollector->registerMetric(new pm::Metric(guestSystem, guestSystemProc, 0));
    9016     aCollector->registerMetric(new pm::Metric(guestSystem, guestSystemProc, new pm::AggregateAvg()));
    9017     aCollector->registerMetric(new pm::Metric(guestSystem, guestSystemProc, new pm::AggregateMin()));
    9018     aCollector->registerMetric(new pm::Metric(guestSystem, guestSystemProc, new pm::AggregateMax()));
    9019 
    9020     aCollector->registerMetric(new pm::Metric(guestSystem, guestSystemThread, 0));
    9021     aCollector->registerMetric(new pm::Metric(guestSystem, guestSystemThread, new pm::AggregateAvg()));
    9022     aCollector->registerMetric(new pm::Metric(guestSystem, guestSystemThread, new pm::AggregateMin()));
    9023     aCollector->registerMetric(new pm::Metric(guestSystem, guestSystemThread, new pm::AggregateMax()));
    90249008};
    90259009
     
    90289012    aCollector->unregisterMetricsFor(aMachine);
    90299013    aCollector->unregisterBaseMetricsFor(aMachine);
     9014
     9015    if (mGuestHAL)
     9016        delete mGuestHAL;
    90309017};
    90319018#endif /* VBOX_WITH_RESOURCE_USAGE_API */
  • trunk/src/VBox/Main/Performance.cpp

    r27858 r27885  
    2828 */
    2929
     30#ifndef VBOX_COLLECTOR_TEST_CASE
     31#include "VirtualBoxImpl.h"
     32#include "MachineImpl.h"
     33#endif
    3034#include "Performance.h"
    3135
     
    119123}
    120124
     125#ifndef VBOX_COLLECTOR_TEST_CASE
    121126CollectorGuestHAL::~CollectorGuestHAL()
    122127{
    123 //    if (cEnabled)
    124 //
     128    Assert(!cEnabled);
    125129}
    126130
    127131int CollectorGuestHAL::enable()
    128132{
     133    HRESULT ret = S_OK;
     134
     135    if (ASMAtomicIncU32(&cEnabled) == 1)
     136    {
     137#if 0
     138        ComPtr<IInternalSessionControl> directControl;
     139
     140        ret = mMachine->getDirectControl(&directControl);
     141        if (ret != S_OK)
     142            return ret;
     143
     144        /* get the associated console */
     145        ComPtr<IConsole> console;
     146        ret = directControl->COMGETTER(Console)(console.asOutParam()));
     147        if (ret != S_OK)
     148            return ret;
     149
     150        ComPtr<IGuest> guest;
     151        ret = console->COMGETTER(Guest)(guest.asOutParam());
     152        if (ret == S_OK)
     153        {
     154        }
     155#endif
     156    }
     157    return ret;
     158}
     159
     160int CollectorGuestHAL::disable()
     161{
     162    if (ASMAtomicDecU32(&cEnabled) == 0)
     163    {
     164    }
    129165    return S_OK;
    130166}
    131 
    132 int CollectorGuestHAL::disable()
    133 {
    134     return S_OK;
    135 }
     167#endif /* VBOX_COLLECTOR_TEST_CASE */
    136168
    137169bool BaseMetric::collectorBeat(uint64_t nowAt)
     
    397429#endif
    398430}
    399 
    400 void GuestSystemUsage::init(ULONG period, ULONG length)
    401 {
    402     mPeriod = period;
    403     mLength = length;
    404 
    405     mThreads->init(mLength);
    406     mProcesses->init(mLength);
    407 }
    408 
    409 void GuestSystemUsage::preCollect(CollectorHints& /* hints */)
    410 {
    411 }
    412 
    413 void GuestSystemUsage::collect()
    414 {
    415 #if 0
    416     ULONG used;
    417     int rc = mHAL->getProcessMemoryUsage(mProcess, &used);
    418     if (RT_SUCCESS(rc))
    419         mUsed->put(used);
    420 #endif
    421 }
    422 
    423431
    424432void CircularBuffer::init(ULONG ulLength)
  • trunk/src/VBox/Main/PerformanceImpl.cpp

    r27822 r27885  
    9292    "Guest/Pagefile/Usage/Free:min",
    9393    "Guest/Pagefile/Usage/Free:max",
    94     "Guest/System/Processes",
    95     "Guest/System/Processes:avg",
    96     "Guest/System/Processes:min",
    97     "Guest/System/Processes:max",
    98     "Guest/System/Threads",
    99     "Guest/System/Threads:avg",
    100     "Guest/System/Threads:min",
    101     "Guest/System/Threads:max",
    10294};
    10395
  • trunk/src/VBox/Main/VMMDevInterface.cpp

    r27822 r27885  
    431431        return VERR_INVALID_PARAMETER; /** @todo wrong error */
    432432
    433     guest->GetStatisticsUpdateInterval(&val);
     433    guest->COMGETTER(StatisticsUpdateInterval)(&val);
    434434    *pulInterval = val;
    435435    return VINF_SUCCESS;
  • trunk/src/VBox/Main/idl/VirtualBox.xidl

    r27857 r27885  
    83538353  <interface
    83548354     name="IGuest" extends="$unknown"
    8355      uuid="2f6fba62-0d41-42fd-a891-51b7d87a9e84"
     8355     uuid="66dfe00b-f174-40d8-9d78-4e30d58137ed"
    83568356     wsmap="managed"
    83578357     >
     
    84178417      <desc>Guest system memory balloon size in megabytes.</desc>
    84188418    </attribute>
     8419
     8420    <attribute name="statisticsUpdateInterval" type="unsigned long">
     8421      <desc>Interval to update guest statistics in seconds.</desc>
     8422    </attribute>
     8423
     8424    <method name="internalGetStatistics">
     8425      <desc>
     8426         Internal method; do not use as it might change at any time
     8427      </desc>
     8428      <param name="cpuId" type="unsigned long" dir="in">
     8429         <desc>Virtual CPU id</desc>
     8430      </param>
     8431      <param name="cpuUser" type="unsigned long" dir="out">
     8432         <desc>Percentage of processor time spent in user mode as seen by the guest</desc>
     8433      </param>
     8434      <param name="cpuKernel" type="unsigned long" dir="out">
     8435         <desc>Percentage of processor time spent in kernel mode as seen by the guest</desc>
     8436      </param>
     8437      <param name="cpuIdle" type="unsigned long" dir="out">
     8438         <desc>Percentage of processor time spent idling as seen by the guest</desc>
     8439      </param>
     8440      <param name="memTotal" type="unsigned long" dir="out">
     8441         <desc>Total amount of physical guest RAM</desc>
     8442      </param>
     8443      <param name="memFree" type="unsigned long" dir="out">
     8444         <desc>Free amount of physical guest RAM</desc>
     8445      </param>
     8446      <param name="memBalloon" type="unsigned long" dir="out">
     8447         <desc>Amount of ballooned physical guest RAM</desc>
     8448      </param>
     8449      <param name="memCache" type="unsigned long" dir="out">
     8450         <desc>Total amount of guest (disk) cache memory</desc>
     8451      </param>
     8452      <param name="pagedTotal" type="unsigned long" dir="out">
     8453         <desc>Total amount of space in the page file</desc>
     8454      </param>
     8455      <param name="pagedFree" type="unsigned long" dir="out">
     8456         <desc>Free amount of space in the page file</desc>
     8457      </param>
     8458    </method>
    84198459
    84208460    <method name="setCredentials">
  • trunk/src/VBox/Main/include/GuestImpl.h

    r27822 r27885  
    2727
    2828class Console;
    29 
    30 #define GUEST_STAT_INVALID          (ULONG)-1
    3129
    3230class ATL_NO_VTABLE Guest :
     
    6563    STDMETHOD(COMGETTER(MemoryBalloonSize)) (ULONG *aMemoryBalloonSize);
    6664    STDMETHOD(COMSETTER(MemoryBalloonSize)) (ULONG aMemoryBalloonSize);
     65    STDMETHOD(COMGETTER(StatisticsUpdateInterval)) (ULONG *aUpdateInterval);
     66    STDMETHOD(COMSETTER(StatisticsUpdateInterval)) (ULONG aUpdateInterval);
    6767
    6868    // IGuest methods
     
    7474                              IN_BSTR aUserName, IN_BSTR aPassword,
    7575                              ULONG aTimeoutMS, ULONG* aPID);
     76    STDMETHOD(InternalGetStatistics)(ULONG aCpuId, ULONG *aCpuUser, ULONG *aCpuKernel, ULONG *aCpuIdle,
     77                                     ULONG *aMemTotal, ULONG *aMemFree, ULONG *aMemBalloon, ULONG *aMemCache,
     78                                     ULONG *aPageTotal, ULONG *aPageFree);
    7679
    7780    // public methods that are not in IDL
  • trunk/src/VBox/Main/include/MachineImpl.h

    r27849 r27885  
    624624    HRESULT openExistingSession(IInternalSessionControl *aControl);
    625625
     626    HRESULT getDirectControl(ComPtr<IInternalSessionControl> *directControl)
     627    {
     628        HRESULT rc;
     629        *directControl = mData->mSession.mDirectControl;
     630
     631        if (!*directControl)
     632            rc = E_ACCESSDENIED;
     633        else
     634            rc = S_OK;
     635
     636        return rc;
     637    }
     638
    626639#if defined(RT_OS_WINDOWS)
    627640
     
    796809    void unregisterMetrics(PerformanceCollector *aCollector, Machine *aMachine);
    797810
    798     pm::CollectorGuestHAL   mGuestHAL;
     811    pm::CollectorGuestHAL  *mGuestHAL;
    799812#endif /* VBOX_WITH_RESOURCE_USAGE_API */
    800813
  • trunk/src/VBox/Main/include/Performance.h

    r27849 r27885  
    3535#include <list>
    3636#include <vector>
     37
     38/* Forward decl. */
     39class Machine;
    3740
    3841namespace pm
     
    162165    {
    163166    public:
    164         CollectorGuestHAL() : cEnabled(0) {};
     167        CollectorGuestHAL(Machine *machine) : cEnabled(0), mMachine(machine) {};
    165168        ~CollectorGuestHAL();
    166169
     
    170173        virtual int disable();
    171174    protected:
    172         unsigned        cEnabled;
     175        uint32_t    cEnabled;
     176        Machine    *mMachine;
    173177    };
    174178
     
    383387    private:
    384388        SubMetric *mTotal, *mFree, *mBallooned, *mCache, *mPagedTotal, *mPagedFree;
    385     };
    386 
    387     class GuestSystemUsage : public BaseMetric
    388     {
    389     public:
    390         GuestSystemUsage(CollectorGuestHAL *hal, ComPtr<IUnknown> object, SubMetric *processes, SubMetric *threads)
    391         : BaseMetric(hal, "System/Usage", object), mProcesses(processes), mThreads(threads) {};
    392         ~GuestSystemUsage() { delete mProcesses; delete mThreads; };
    393 
    394         void init(ULONG period, ULONG length);
    395         void preCollect(CollectorHints& hints);
    396         void collect();
    397         const char *getUnit() { return "kB"; };
    398         ULONG getMinValue() { return 0; };
    399         ULONG getMaxValue() { return INT32_MAX; };
    400         ULONG getScale() { return 1; }
    401     private:
    402         SubMetric *mProcesses, *mThreads;
    403389    };
    404390
  • trunk/src/VBox/Main/testcase/Makefile.kmk

    r23848 r27885  
    113113        ../Performance.cpp
    114114tstCollector_INCS     = ../include
     115tstCollector_DEFS    += VBOX_COLLECTOR_TEST_CASE
    115116tstCollector_LDFLAGS.darwin  += -lproc
    116117tstCollector_LDFLAGS.solaris += -lkstat
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