VirtualBox

vbox的更動 44548 路徑 trunk/src/VBox/Main/src-server


忽略:
時間撮記:
2013-2-5 下午03:52:49 (12 年 以前)
作者:
vboxsync
訊息:

Main/Metrics: Update link status on metrics setup, do not collect metrics for interfaces brought down (#6613)

檔案:
修改 1 筆資料

圖例:

未更動
新增
刪除
  • trunk/src/VBox/Main/src-server/Performance.cpp

    r44529 r44548  
    2929#endif
    3030#include "Performance.h"
     31#include "HostNetworkInterfaceImpl.h"
     32#include "netif.h"
    3133
    3234#include <VBox/com/array.h>
     
    684686}
    685687
     688#ifndef VBOX_COLLECTOR_TEST_CASE
     689static bool getLinkSpeed(const char *szShortName, uint32_t *pSpeed)
     690{
     691    /*
     692     * Note that we do not need the full name in the info, so we do not
     693     * allocate the space for it and we rely on the fact that
     694     * NetIfGetConfigByName() never fills it.
     695     */
     696    NETIFINFO Info;
     697    memset(&Info, 0, sizeof(Info));
     698    strcpy(Info.szShortName, szShortName);
     699    int rc = NetIfGetConfigByName(&Info);
     700    if (RT_FAILURE(rc))
     701        return false;
     702    *pSpeed =  Info.enmStatus == NETIF_S_UP ? Info.uSpeedMbits : 0;
     703    return true;
     704}
     705
     706void HostNetworkSpeed::init(ULONG period, ULONG length)
     707{
     708    mPeriod = period;
     709    mLength = length;
     710    mLinkSpeed->init(length);
     711    /*
     712     * Retrieve the link speed now as it may be wrong if the metric was
     713     * registered at boot (see @bugref{6613}).
     714     */
     715    getLinkSpeed(mShortName.c_str(), &mSpeed);
     716}
     717
    686718void HostNetworkLoadRaw::init(ULONG period, ULONG length)
    687719{
     
    690722    mRx->init(mLength);
    691723    mTx->init(mLength);
     724    /*
     725     * Retrieve the link speed now as it may be wrong if the metric was
     726     * registered at boot (see @bugref{6613}).
     727     */
     728    uint32_t uSpeedMbit = 65535;
     729    if (getLinkSpeed(mShortName.c_str(), &uSpeedMbit))
     730        mSpeed = (uint64_t)uSpeedMbit * (1000000/8); /* Convert to bytes/sec */
    692731    /*int rc =*/ mHAL->getRawHostNetworkLoad(mShortName.c_str(), &mRxPrev, &mTxPrev);
    693732    //AssertRC(rc);
     
    736775                         " Will update the list of interfaces...\n", mRc,mRc));
    737776}
     777#endif /* !VBOX_COLLECTOR_TEST_CASE */
    738778
    739779void HostDiskLoadRaw::init(ULONG period, ULONG length)
注意: 瀏覽 TracChangeset 來幫助您使用更動檢視器

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette