Changeset 37779 in vbox for trunk/src/VBox/Main/src-server
- Timestamp:
- Jul 5, 2011 12:13:15 PM (14 years ago)
- svn:sync-xref-src-repo-rev:
- 72655
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/src-server/VirtualBoxImpl.cpp
r37525 r37779 1123 1123 1124 1124 return hrc; 1125 } 1126 1127 STDMETHODIMP 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 1193 STDMETHODIMP 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; 1125 1257 } 1126 1258
Note:
See TracChangeset
for help on using the changeset viewer.