VirtualBox

Changeset 85263 in vbox


Ignore:
Timestamp:
Jul 12, 2020 12:24:26 AM (4 years ago)
Author:
vboxsync
Message:

Main/Performance.cpp/h: A whole bunch of int/HRESULT mixups. bugref:9790

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

Legend:

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

    r82968 r85263  
    280280                         ULONG aBalloonedVMM, ULONG aSharedVMM,
    281281                         ULONG aVmNetRx, ULONG aVmNetTx);
    282         int enable(ULONG mask);
    283         int disable(ULONG mask);
    284 
    285         int enqueueRequest(CollectorGuestRequest *aRequest);
     282        HRESULT enable(ULONG mask);
     283        HRESULT disable(ULONG mask);
     284
     285        HRESULT enqueueRequest(CollectorGuestRequest *aRequest);
    286286        HRESULT enableInternal(ULONG mask);
    287         int disableInternal(ULONG mask);
     287        HRESULT disableInternal(ULONG mask);
    288288
    289289        const com::Utf8Str& getVMName() const { return mMachineName; };
     
    307307
    308308    private:
    309         int enableVMMStats(bool mCollectVMMStats);
     309        HRESULT enableVMMStats(bool mCollectVMMStats);
    310310
    311311        CollectorGuestManager *mManager;
     
    347347        void preCollect(CollectorHints& hints, uint64_t iTick);
    348348        void destroyUnregistered();
    349         int enqueueRequest(CollectorGuestRequest *aRequest);
     349        HRESULT enqueueRequest(CollectorGuestRequest *aRequest);
    350350
    351351        CollectorGuest *getBlockedGuest() { return mGuestBeingCalled; };
     
    418418        bool collectorBeat(uint64_t nowAt);
    419419
    420         virtual int enable()  { mEnabled = true; return S_OK; };
    421         virtual int disable() { mEnabled = false; return S_OK; };
     420        virtual HRESULT enable()  { mEnabled = true; return S_OK; };
     421        virtual HRESULT disable() { mEnabled = false; return S_OK; };
    422422        void unregister() { mUnregistered = true; };
    423423
     
    649649        void preCollect(CollectorHints& hints, uint64_t iTick);
    650650        void collect();
    651         int enable();
    652         int disable();
     651        HRESULT enable();
     652        HRESULT disable();
    653653        const char *getUnit() { return "kB"; };
    654654        ULONG getMinValue() { return 0; };
     
    759759        void preCollect(CollectorHints& hints, uint64_t iTick);
    760760        void collect();
    761         int enable();
    762         int disable();
     761        HRESULT enable();
     762        HRESULT disable();
    763763        const char *getUnit() { return "B/s"; };
    764764        ULONG getMinValue() { return 0; };
     
    779779        void preCollect(CollectorHints& hints, uint64_t iTick);
    780780        void collect();
    781         int enable();
    782         int disable();
     781        HRESULT enable();
     782        HRESULT disable();
    783783        const char *getUnit() { return "%"; };
    784784        ULONG getMinValue() { return 0; };
     
    801801        void preCollect(CollectorHints& hints, uint64_t iTick);
    802802        void collect();
    803         int enable();
    804         int disable();
     803        HRESULT enable();
     804        HRESULT disable();
    805805        const char *getUnit() { return "kB"; };
    806806        ULONG getMinValue() { return 0; };
  • trunk/src/VBox/Main/src-server/Performance.cpp

    r82968 r85263  
    114114    RTCPUSET OnlineSet;
    115115    RTMpGetOnlineSet(&OnlineSet);
    116     for (RTCPUID iCpu = 0; iCpu < RTCPUSET_MAX_CPUS; iCpu++)
     116    for (int iCpu = 0; iCpu < RTCPUSET_MAX_CPUS; iCpu++)
    117117    {
    118118        Log7Func(("{%p}: Checking if CPU %d is member of online set...\n", this, (int)iCpu));
     
    159159CollectorGuestRequest* CollectorGuestQueue::pop()
    160160{
    161     int rc = VINF_SUCCESS;
    162     CollectorGuestRequest* rq = NULL;
     161    int vrc = VINF_SUCCESS;
     162    CollectorGuestRequest *rq = NULL;
    163163
    164164    do
     
    176176        if (rq)
    177177            return rq;
    178         else
    179             rc = RTSemEventWaitNoResume(mEvent, RT_INDEFINITE_WAIT);
    180     }
    181     while (RT_SUCCESS(rc));
     178        vrc = RTSemEventWaitNoResume(mEvent, RT_INDEFINITE_WAIT);
     179    } while (RT_SUCCESS(vrc));
    182180
    183181    return NULL;
     
    243241}
    244242
    245 int CollectorGuest::enableVMMStats(bool mCollectVMMStats)
    246 {
    247     HRESULT ret = S_OK;
     243HRESULT CollectorGuest::enableVMMStats(bool mCollectVMMStats)
     244{
     245    HRESULT hrc = S_OK;
    248246
    249247    if (mGuest)
     
    255253        ComPtr<IInternalSessionControl> directControl;
    256254
    257         ret = mMachine->i_getDirectControl(&directControl);
    258         if (ret != S_OK)
    259             return ret;
     255        hrc = mMachine->i_getDirectControl(&directControl);
     256        if (hrc != S_OK)
     257            return hrc;
    260258
    261259        /* enable statistics collection; this is a remote call (!) */
    262         ret = directControl->EnableVMMStatistics(mCollectVMMStats);
     260        hrc = directControl->EnableVMMStatistics(mCollectVMMStats);
    263261        Log7Func(("{%p}: %sable VMM stats (%s)\n",
    264               this, mCollectVMMStats ? "En" : "Dis", SUCCEEDED(ret) ? "success" : "failed"));
    265     }
    266 
    267     return ret;
    268 }
    269 
    270 int CollectorGuest::enable(ULONG mask)
     262                  this, mCollectVMMStats ? "En" : "Dis", SUCCEEDED(hrc) ? "success" : "failed"));
     263    }
     264
     265    return hrc;
     266}
     267
     268HRESULT CollectorGuest::enable(ULONG mask)
    271269{
    272270    return enqueueRequest(new CGRQEnable(mask));
    273271}
    274272
    275 int CollectorGuest::disable(ULONG mask)
     273HRESULT CollectorGuest::disable(ULONG mask)
    276274{
    277275    return enqueueRequest(new CGRQDisable(mask));
     
    324322}
    325323
    326 int CollectorGuest::disableInternal(ULONG mask)
     324HRESULT CollectorGuest::disableInternal(ULONG mask)
    327325{
    328326    if (!(mEnabled & mask))
     
    345343}
    346344
    347 int CollectorGuest::enqueueRequest(CollectorGuestRequest *aRequest)
     345HRESULT CollectorGuest::enqueueRequest(CollectorGuestRequest *aRequest)
    348346{
    349347    if (mManager)
     
    399397  : mVMMStatsProvider(NULL), mGuestBeingCalled(NULL)
    400398{
    401     int rc = RTThreadCreate(&mThread, CollectorGuestManager::requestProcessingThread,
     399    int vrc = RTThreadCreate(&mThread, CollectorGuestManager::requestProcessingThread,
    402400                            this, 0, RTTHREADTYPE_MAIN_WORKER, RTTHREADFLAGS_WAITABLE,
    403401                            "CGMgr");
    404     NOREF(rc);
    405     Log7Func(("{%p}: RTThreadCreate returned %Rrc (mThread=%p)\n", this, rc, mThread));
     402    NOREF(vrc);
     403    Log7Func(("{%p}: RTThreadCreate returned %Rrc (mThread=%p)\n", this, vrc, mThread));
    406404}
    407405
     
    410408    Assert(mGuests.size() == 0);
    411409    int rcThread = 0;
    412     int rc = enqueueRequest(new CGRQAbort());
    413     if (SUCCEEDED(rc))
     410    HRESULT hrc = enqueueRequest(new CGRQAbort());
     411    if (SUCCEEDED(hrc))
    414412    {
    415413        /* We wait only if we were able to put the abort request to a queue */
    416414        Log7Func(("{%p}: Waiting for CGM request processing thread to stop...\n", this));
    417         rc = RTThreadWait(mThread, 1000 /* 1 sec */, &rcThread);
    418         Log7Func(("{%p}: RTThreadWait returned %u (thread exit code: %u)\n", this, rc, rcThread));
     415        int vrc = RTThreadWait(mThread, 1000 /* 1 sec */, &rcThread);
     416        Log7Func(("{%p}: RTThreadWait returned %Rrc (thread exit code: %Rrc)\n", this, vrc, rcThread));
    419417    }
    420418}
     
    435433void CollectorGuestManager::unregisterGuest(CollectorGuest* pGuest)
    436434{
    437     int rc = S_OK;
    438 
    439435    Log7Func(("{%p}: About to unregister guest=%p provider=%p\n", this, pGuest, mVMMStatsProvider));
    440436    //mGuests.remove(pGuest); => destroyUnregistered()
     
    457453                /* Found the guest already collecting stats, elect it */
    458454                mVMMStatsProvider = *it;
    459                 rc = mVMMStatsProvider->enqueueRequest(new CGRQEnable(VMSTATS_VMM_RAM));
    460                 if (FAILED(rc))
     455                HRESULT hrc = mVMMStatsProvider->enqueueRequest(new CGRQEnable(VMSTATS_VMM_RAM));
     456                if (FAILED(hrc))
    461457                {
    462458                    /* This is not a good candidate -- try to find another */
     
    478474                mVMMStatsProvider = *it;
    479475                //mVMMStatsProvider->enable(VMSTATS_VMM_RAM);
    480                 rc = mVMMStatsProvider->enqueueRequest(new CGRQEnable(VMSTATS_VMM_RAM));
    481                 if (SUCCEEDED(rc))
     476                HRESULT hrc = mVMMStatsProvider->enqueueRequest(new CGRQEnable(VMSTATS_VMM_RAM));
     477                if (SUCCEEDED(hrc))
    482478                    break;
    483479                /* This was not a good candidate -- try to find another */
     
    505501}
    506502
    507 int CollectorGuestManager::enqueueRequest(CollectorGuestRequest *aRequest)
     503HRESULT CollectorGuestManager::enqueueRequest(CollectorGuestRequest *aRequest)
    508504{
    509505#ifdef DEBUG
     
    615611{
    616612    ULONG user, kernel, idle;
    617     int rc = mHAL->getHostCpuLoad(&user, &kernel, &idle);
    618     if (RT_SUCCESS(rc))
     613    int vrc = mHAL->getHostCpuLoad(&user, &kernel, &idle);
     614    if (RT_SUCCESS(vrc))
    619615    {
    620616        mUser->put(user);
     
    640636    uint64_t userDiff, kernelDiff, idleDiff, totalDiff;
    641637
    642     int rc = mHAL->getRawHostCpuLoad(&user, &kernel, &idle);
    643     if (RT_SUCCESS(rc))
     638    int vrc = mHAL->getRawHostCpuLoad(&user, &kernel, &idle);
     639    if (RT_SUCCESS(vrc))
    644640    {
    645641        userDiff   = user   - mUserPrev;
     
    674670{
    675671    NETIFSTATUS enmState = NETIF_S_UNKNOWN;
    676     int rc = NetIfGetState(szShortName, &enmState);
    677     if (RT_FAILURE(rc))
     672    int vrc = NetIfGetState(szShortName, &enmState);
     673    if (RT_FAILURE(vrc))
    678674        return false;
    679675    if (enmState != NETIF_S_UP)
     
    681677    else
    682678    {
    683         rc = NetIfGetLinkSpeed(szShortName, pSpeed);
    684         if (RT_FAILURE(rc))
     679        vrc = NetIfGetLinkSpeed(szShortName, pSpeed);
     680        if (RT_FAILURE(vrc))
    685681            return false;
    686682    }
     
    713709    if (getLinkSpeed(mShortName.c_str(), &uSpeedMbit))
    714710        mSpeed = (uint64_t)uSpeedMbit * (1000000/8); /* Convert to bytes/sec */
    715     /*int rc =*/ mHAL->getRawHostNetworkLoad(mShortName.c_str(), &mRxPrev, &mTxPrev);
    716     //AssertRC(rc);
     711    /*int vrc =*/ mHAL->getRawHostNetworkLoad(mShortName.c_str(), &mRxPrev, &mTxPrev);
     712    //AssertRC(vrc);
    717713}
    718714
     
    773769    mLength = length;
    774770    mUtil->init(mLength);
    775     int rc = mHAL->getRawHostDiskLoad(mDiskName.c_str(), &mDiskPrev, &mTotalPrev);
    776     AssertRC(rc);
     771    int vrc = mHAL->getRawHostDiskLoad(mDiskName.c_str(), &mDiskPrev, &mTotalPrev);
     772    AssertRC(vrc);
    777773}
    778774
     
    786782    uint64_t disk, total;
    787783
    788     int rc = mHAL->getRawHostDiskLoad(mDiskName.c_str(), &disk, &total);
    789     if (RT_SUCCESS(rc))
     784    int vrc = mHAL->getRawHostDiskLoad(mDiskName.c_str(), &disk, &total);
     785    if (RT_SUCCESS(vrc))
    790786    {
    791787        uint64_t diskDiff = disk - mDiskPrev;
     
    828824    }
    829825    else
    830         LogFlowThisFunc(("Failed to collect data: %Rrc (%d)\n", rc, rc));
     826        LogFlowThisFunc(("Failed to collect data: %Rrc (%d)\n", vrc, vrc));
    831827}
    832828
     
    841837{
    842838    ULONG mhz;
    843     int rc = mHAL->getHostCpuMHz(&mhz);
    844     if (RT_SUCCESS(rc))
     839    int vrc = mHAL->getHostCpuMHz(&mhz);
     840    if (RT_SUCCESS(vrc))
    845841        mMHz->put(mhz);
    846842}
     
    863859{
    864860    ULONG total, used, available;
    865     int rc = mHAL->getHostMemoryUsage(&total, &used, &available);
    866     if (RT_SUCCESS(rc))
     861    int vrc = mHAL->getHostMemoryUsage(&total, &used, &available);
     862    if (RT_SUCCESS(vrc))
    867863    {
    868864        mTotal->put(total);
     
    888884{
    889885    ULONG total, used, available;
    890     int rc = mHAL->getHostFilesystemUsage(mFsName.c_str(), &total, &used, &available);
    891     if (RT_SUCCESS(rc))
     886    int vrc = mHAL->getHostFilesystemUsage(mFsName.c_str(), &total, &used, &available);
     887    if (RT_SUCCESS(vrc))
    892888    {
    893889        mTotal->put(total);
     
    911907{
    912908    uint64_t total;
    913     int rc = mHAL->getHostDiskSize(mDiskName.c_str(), &total);
    914     if (RT_SUCCESS(rc))
     909    int vrc = mHAL->getHostDiskSize(mDiskName.c_str(), &total);
     910    if (RT_SUCCESS(vrc))
    915911        mTotal->put((ULONG)(total / _1M));
    916912}
    917913
    918914#ifndef VBOX_COLLECTOR_TEST_CASE
     915
    919916void HostRamVmm::init(ULONG period, ULONG length)
    920917{
     
    927924}
    928925
    929 int HostRamVmm::enable()
    930 {
    931     int rc = S_OK;
     926HRESULT HostRamVmm::enable()
     927{
     928    HRESULT hrc = S_OK;
    932929    CollectorGuest *provider = mCollectorGuestManager->getVMMStatsProvider();
    933930    if (provider)
    934         rc = provider->enable(VMSTATS_VMM_RAM);
     931        hrc = provider->enable(VMSTATS_VMM_RAM);
    935932    BaseMetric::enable();
    936     return rc;
    937 }
    938 
    939 int HostRamVmm::disable()
    940 {
    941     int rc = S_OK;
     933    return hrc;
     934}
     935
     936HRESULT HostRamVmm::disable()
     937{
     938    HRESULT rc = S_OK;
    942939    BaseMetric::disable();
    943940    CollectorGuest *provider = mCollectorGuestManager->getVMMStatsProvider();
     
    988985    mSharedVMM->put(mSharedCurrent);
    989986}
     987
    990988#endif /* !VBOX_COLLECTOR_TEST_CASE */
    991989
     
    10031001{
    10041002    ULONG user, kernel;
    1005     int rc = mHAL->getProcessCpuLoad(mProcess, &user, &kernel);
    1006     if (RT_SUCCESS(rc))
     1003    int vrc = mHAL->getProcessCpuLoad(mProcess, &user, &kernel);
     1004    if (RT_SUCCESS(vrc))
    10071005    {
    10081006        mUser->put(user);
     
    10201018    uint64_t processUser, processKernel, hostTotal;
    10211019
    1022     int rc = mHAL->getRawProcessCpuLoad(mProcess, &processUser, &processKernel, &hostTotal);
    1023     if (RT_SUCCESS(rc))
     1020    int vrc = mHAL->getRawProcessCpuLoad(mProcess, &processUser, &processKernel, &hostTotal);
     1021    if (RT_SUCCESS(vrc))
    10241022    {
    10251023        if (hostTotal == mHostTotalPrev)
     
    10561054{
    10571055    ULONG used;
    1058     int rc = mHAL->getProcessMemoryUsage(mProcess, &used);
    1059     if (RT_SUCCESS(rc))
     1056    int vrc = mHAL->getProcessMemoryUsage(mProcess, &used);
     1057    if (RT_SUCCESS(vrc))
    10601058        mUsed->put(used);
    10611059}
     
    10631061
    10641062#ifndef VBOX_COLLECTOR_TEST_CASE
     1063
    10651064void MachineDiskUsage::init(ULONG period, ULONG length)
    10661065{
     
    11151114}
    11161115
    1117 int MachineNetRate::enable()
    1118 {
    1119     int rc = mCGuest->enable(VMSTATS_NET_RATE);
     1116HRESULT MachineNetRate::enable()
     1117{
     1118    HRESULT rc = mCGuest->enable(VMSTATS_NET_RATE);
    11201119    BaseMetric::enable();
    11211120    return rc;
    11221121}
    11231122
    1124 int MachineNetRate::disable()
     1123HRESULT MachineNetRate::disable()
    11251124{
    11261125    BaseMetric::disable();
     
    11591158}
    11601159
    1161 int GuestCpuLoad::enable()
    1162 {
    1163     int rc = mCGuest->enable(VMSTATS_GUEST_CPULOAD);
     1160HRESULT GuestCpuLoad::enable()
     1161{
     1162    HRESULT rc = mCGuest->enable(VMSTATS_GUEST_CPULOAD);
    11641163    BaseMetric::enable();
    11651164    return rc;
    11661165}
    11671166
    1168 int GuestCpuLoad::disable()
     1167HRESULT GuestCpuLoad::disable()
    11691168{
    11701169    BaseMetric::disable();
     
    11991198}
    12001199
    1201 int GuestRamUsage::enable()
    1202 {
    1203     int rc = mCGuest->enable(VMSTATS_GUEST_RAMUSAGE);
     1200HRESULT GuestRamUsage::enable()
     1201{
     1202    HRESULT rc = mCGuest->enable(VMSTATS_GUEST_RAMUSAGE);
    12041203    BaseMetric::enable();
    12051204    return rc;
    12061205}
    12071206
    1208 int GuestRamUsage::disable()
     1207HRESULT GuestRamUsage::disable()
    12091208{
    12101209    BaseMetric::disable();
     
    12161215    hints.collectGuestStats(mCGuest->getProcess());
    12171216}
     1217
    12181218#endif /* !VBOX_COLLECTOR_TEST_CASE */
    12191219
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