VirtualBox

Changeset 37779 in vbox


Ignore:
Timestamp:
Jul 5, 2011 12:13:15 PM (13 years ago)
Author:
vboxsync
Message:

Main/VirtualBox: add two attributes for querying the list of internal networks and generic network drivers
Frontend/VirtualBox: use new methods to decrease time needed before the settings dialog opens

Location:
trunk/src/VBox
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsNetwork.cpp

    r37645 r37779  
    10661066{
    10671067    /* Load total internal network list of all VMs: */
    1068     QStringList otherInternalNetworks;
    10691068    CVirtualBox vbox = vboxGlobal().virtualBox();
    1070     ulong uCount = qMin((ULONG) 4, vbox.GetSystemProperties().GetMaxNetworkAdapters(KChipsetType_PIIX3));
    1071     const CMachineVector &machines = vbox.GetMachines();
    1072     for (int i = 0; i < machines.size(); ++i)
    1073     {
    1074         const CMachine &machine = machines[i];
    1075         if (machine.GetAccessible())
    1076         {
    1077             for (ulong uSlot = 0; uSlot < uCount; ++uSlot)
    1078             {
    1079                 QString strName = machine.GetNetworkAdapter(uSlot).GetInternalNetwork();
    1080                 if (!strName.isEmpty() && !otherInternalNetworks.contains(strName))
    1081                     otherInternalNetworks << strName;
    1082             }
    1083         }
    1084     }
     1069    QStringList otherInternalNetworks(QList<QString>::fromVector(vbox.GetInternalNetworks()));
    10851070    return otherInternalNetworks;
    10861071}
     
    10901075{
    10911076    /* Load total generic driver list of all VMs: */
    1092     QStringList otherGenericDrivers;
    10931077    CVirtualBox vbox = vboxGlobal().virtualBox();
    1094     ulong uCount = qMin((ULONG) 4, vbox.GetSystemProperties().GetMaxNetworkAdapters(KChipsetType_PIIX3));
    1095     const CMachineVector &machines = vbox.GetMachines();
    1096     for (int i = 0; i < machines.size(); ++i)
    1097     {
    1098         const CMachine &machine = machines[i];
    1099         if (machine.GetAccessible())
    1100         {
    1101             for (ulong uSlot = 0; uSlot < uCount; ++uSlot)
    1102             {
    1103                 QString strName = machine.GetNetworkAdapter(uSlot).GetGenericDriver();
    1104                 if (!strName.isEmpty() && !otherGenericDrivers.contains(strName))
    1105                     otherGenericDrivers << strName;
    1106             }
    1107         }
    1108     }
     1078    QStringList otherGenericDrivers(QList<QString>::fromVector(vbox.GetGenericNetworkDrivers()));
    11091079    return otherGenericDrivers;
    11101080}
  • trunk/src/VBox/Main/idl/VirtualBox.xidl

    r37709 r37779  
    13921392  <interface
    13931393    name="IVirtualBox" extends="$unknown"
    1394     uuid="d627bf11-2758-46be-9a4d-7d9ef794c247"
     1394    uuid="c28be65f-1a8f-43b4-81f1-eb60cb516e66"
    13951395    wsmap="managed"
    13961396    >
     
    15501550    </attribute>
    15511551
     1552
     1553    <attribute name="internalNetworks" type="wstring" safearray="yes" readonly="yes">
     1554      <desc>
     1555        Names of all internal networks.
     1556      </desc>
     1557    </attribute>
     1558
     1559    <attribute name="genericNetworkDrivers" type="wstring" safearray="yes" readonly="yes">
     1560      <desc>
     1561        Names of all generic network drivers.
     1562      </desc>
     1563    </attribute>
    15521564
    15531565    <method name="composeMachineFilename">
  • trunk/src/VBox/Main/include/MachineImpl.h

    r37777 r37779  
    574574
    575575    /**
     576     * Checks if this machine is accessible, without attempting to load the
     577     * config file.
     578     *
     579     * @note This method doesn't check this object's readiness. Intended to be
     580     * used by ready Machine children (whose readiness is bound to the parent's
     581     * one) or after doing addCaller() manually.
     582     */
     583    bool isAccessible() const { return mData->mAccessible; }
     584
     585    /**
    576586     * Returns this machine ID.
    577587     *
     
    625635        IsModified_BandwidthControl     = 0x1000
    626636    };
     637
     638    /**
     639     * Checks if this machine is accessible, without attempting to load the
     640     * config file.
     641     *
     642     * @note This method doesn't check this object's readiness. Intended to be
     643     * used by ready Machine children (whose readiness is bound to the parent's
     644     * one) or after doing addCaller() manually.
     645     */
     646    ChipsetType_T getChipsetType() const { return mHWData->mChipsetType; }
    627647
    628648    void setModified(uint32_t fl);
  • trunk/src/VBox/Main/include/VirtualBoxImpl.h

    r37525 r37779  
    120120    STDMETHOD(COMGETTER(EventSource))           (IEventSource ** aEventSource);
    121121    STDMETHOD(COMGETTER(ExtensionPackManager))  (IExtPackManager **aExtPackManager);
     122    STDMETHOD(COMGETTER(InternalNetworks))      (ComSafeArrayOut(BSTR, aInternalNetworks));
     123    STDMETHOD(COMGETTER(GenericNetworkDrivers)) (ComSafeArrayOut(BSTR, aGenericNetworkDrivers));
    122124
    123125    /* IVirtualBox methods */
  • trunk/src/VBox/Main/src-server/VirtualBoxImpl.cpp

    r37525 r37779  
    11231123
    11241124    return hrc;
     1125}
     1126
     1127STDMETHODIMP VirtualBox::COMGETTER(InternalNetworks)(ComSafeArrayOut(BSTR, aInternalNetworks))
     1128{
     1129    if (ComSafeArrayOutIsNull(aInternalNetworks))
     1130        return E_POINTER;
     1131
     1132    AutoCaller autoCaller(this);
     1133    if (FAILED(autoCaller.rc())) return autoCaller.rc();
     1134
     1135    std::list<Bstr> allInternalNetworks;
     1136
     1137    /* get copy of all machine references, to avoid holding the list lock */
     1138    MachinesOList::MyList allMachines;
     1139    {
     1140        AutoReadLock al(m->allMachines.getLockHandle() COMMA_LOCKVAL_SRC_POS);
     1141        allMachines = m->allMachines.getList();
     1142    }
     1143    for (MachinesOList::MyList::const_iterator it = allMachines.begin();
     1144         it != allMachines.end();
     1145         ++it)
     1146    {
     1147        const ComObjPtr<Machine> &pMachine = *it;
     1148        AutoCaller autoMachineCaller(pMachine);
     1149        if (FAILED(autoMachineCaller.rc()))
     1150            continue;
     1151        AutoReadLock mlock(pMachine COMMA_LOCKVAL_SRC_POS);
     1152
     1153        if (pMachine->isAccessible())
     1154        {
     1155            ULONG cNetworkAdapters = 0;
     1156            HRESULT rc = m->pSystemProperties->GetMaxNetworkAdapters(pMachine->getChipsetType(), &cNetworkAdapters);
     1157            if (FAILED(rc))
     1158                continue;
     1159            cNetworkAdapters = RT_MIN(4, cNetworkAdapters);
     1160            for (ULONG i = 0; i < cNetworkAdapters; i++)
     1161            {
     1162                ComPtr<INetworkAdapter> pNet;
     1163                rc = pMachine->GetNetworkAdapter(i, pNet.asOutParam());
     1164                if (FAILED(rc) || pNet.isNull())
     1165                    continue;
     1166                Bstr strInternalNetwork;
     1167                rc = pNet->COMGETTER(InternalNetwork)(strInternalNetwork.asOutParam());
     1168                if (FAILED(rc) || strInternalNetwork.isEmpty())
     1169                    continue;
     1170
     1171                allInternalNetworks.push_back(strInternalNetwork);
     1172            }
     1173        }
     1174    }
     1175
     1176    /* throw out any duplicates */
     1177    allInternalNetworks.sort();
     1178    allInternalNetworks.unique();
     1179    com::SafeArray<BSTR> internalNetworks(allInternalNetworks.size());
     1180    size_t i = 0;
     1181    for (std::list<Bstr>::const_iterator it = allInternalNetworks.begin();
     1182         it != allInternalNetworks.end();
     1183         ++it, i++)
     1184    {
     1185        const Bstr &tmp = *it;
     1186        tmp.cloneTo(&internalNetworks[i]);
     1187    }
     1188    internalNetworks.detachTo(ComSafeArrayOutArg(aInternalNetworks));
     1189
     1190    return S_OK;
     1191}
     1192
     1193STDMETHODIMP VirtualBox::COMGETTER(GenericNetworkDrivers)(ComSafeArrayOut(BSTR, aGenericNetworkDrivers))
     1194{
     1195    if (ComSafeArrayOutIsNull(aGenericNetworkDrivers))
     1196        return E_POINTER;
     1197
     1198    AutoCaller autoCaller(this);
     1199    if (FAILED(autoCaller.rc())) return autoCaller.rc();
     1200
     1201    std::list<Bstr> allGenericNetworkDrivers;
     1202
     1203    /* get copy of all machine references, to avoid holding the list lock */
     1204    MachinesOList::MyList allMachines;
     1205    {
     1206        AutoReadLock al(m->allMachines.getLockHandle() COMMA_LOCKVAL_SRC_POS);
     1207        allMachines = m->allMachines.getList();
     1208    }
     1209    for (MachinesOList::MyList::const_iterator it = allMachines.begin();
     1210         it != allMachines.end();
     1211         ++it)
     1212    {
     1213        const ComObjPtr<Machine> &pMachine = *it;
     1214        AutoCaller autoMachineCaller(pMachine);
     1215        if (FAILED(autoMachineCaller.rc()))
     1216            continue;
     1217        AutoReadLock mlock(pMachine COMMA_LOCKVAL_SRC_POS);
     1218
     1219        if (pMachine->isAccessible())
     1220        {
     1221            ULONG cNetworkAdapters = 0;
     1222            HRESULT rc = m->pSystemProperties->GetMaxNetworkAdapters(pMachine->getChipsetType(), &cNetworkAdapters);
     1223            if (FAILED(rc))
     1224                continue;
     1225            cNetworkAdapters = RT_MIN(4, cNetworkAdapters);
     1226            for (ULONG i = 0; i < cNetworkAdapters; i++)
     1227            {
     1228                ComPtr<INetworkAdapter> pNet;
     1229                rc = pMachine->GetNetworkAdapter(i, pNet.asOutParam());
     1230                if (FAILED(rc) || pNet.isNull())
     1231                    continue;
     1232                Bstr strGenericNetworkDriver;
     1233                rc = pNet->COMGETTER(GenericDriver)(strGenericNetworkDriver.asOutParam());
     1234                if (FAILED(rc) || strGenericNetworkDriver.isEmpty())
     1235                    continue;
     1236
     1237                allGenericNetworkDrivers.push_back(strGenericNetworkDriver);
     1238            }
     1239        }
     1240    }
     1241
     1242    /* throw out any duplicates */
     1243    allGenericNetworkDrivers.sort();
     1244    allGenericNetworkDrivers.unique();
     1245    com::SafeArray<BSTR> genericNetworks(allGenericNetworkDrivers.size());
     1246    size_t i = 0;
     1247    for (std::list<Bstr>::const_iterator it = allGenericNetworkDrivers.begin();
     1248         it != allGenericNetworkDrivers.end();
     1249         ++it, i++)
     1250    {
     1251        const Bstr &tmp = *it;
     1252        tmp.cloneTo(&genericNetworks[i]);
     1253    }
     1254    genericNetworks.detachTo(ComSafeArrayOutArg(aGenericNetworkDrivers));
     1255
     1256    return S_OK;
    11251257}
    11261258
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