Changeset 36275 in vbox
- Timestamp:
- Mar 14, 2011 6:01:34 PM (14 years ago)
- Location:
- trunk
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/VBox/settings.h
r36082 r36275 441 441 mode(NetworkAttachmentType_Null), 442 442 ulBootPriority(0), 443 fHasDisabledNAT(false), 444 ulBandwidthLimit(0) 443 fHasDisabledNAT(false) 445 444 {} 446 445 … … 466 465 uint32_t ulBootPriority; 467 466 bool fHasDisabledNAT; 468 uint32_t ulBandwidthLimit;467 com::Utf8Str strBandwidthGroup; // requires settings version 1.13 (VirtualBox 4.2) 469 468 }; 470 469 typedef std::list<NetworkAdapter> NetworkAdaptersList; -
trunk/src/VBox/Frontends/VBoxManage/VBoxManageHelp.cpp
r36082 r36275 208 208 " [--nicbootprio<1-N> <priority>]\n" 209 209 " [--nicpromisc<1-N> deny|allow-vms|allow-all]\n" 210 " [--nicbandwidthgroup<1-N> <name>\n" 210 211 " [--bridgeadapter<1-N> none|<devicename>]\n" 211 212 #if defined(VBOX_WITH_NETFLT) -
trunk/src/VBox/Frontends/VBoxManage/VBoxManageModifyVM.cpp
r36082 r36275 105 105 MODIFYVM_NICBOOTPRIO, 106 106 MODIFYVM_NICPROMISC, 107 MODIFYVM_NICBWGROUP, 107 108 MODIFYVM_NIC, 108 109 MODIFYVM_CABLECONNECTED, … … 232 233 { "--nicbootprio", MODIFYVM_NICBOOTPRIO, RTGETOPT_REQ_UINT32 | RTGETOPT_FLAG_INDEX }, 233 234 { "--nicpromisc", MODIFYVM_NICPROMISC, RTGETOPT_REQ_STRING | RTGETOPT_FLAG_INDEX }, 235 { "--nicbandwidthgroup", MODIFYVM_NICBWGROUP, RTGETOPT_REQ_STRING | RTGETOPT_FLAG_INDEX }, 234 236 { "--nic", MODIFYVM_NIC, RTGETOPT_REQ_STRING | RTGETOPT_FLAG_INDEX }, 235 237 { "--cableconnected", MODIFYVM_CABLECONNECTED, RTGETOPT_REQ_BOOL_ONOFF | RTGETOPT_FLAG_INDEX }, … … 1109 1111 } 1110 1112 1113 case MODIFYVM_NICBWGROUP: 1114 { 1115 ComPtr<INetworkAdapter> nic; 1116 CHECK_ERROR_BREAK(machine, GetNetworkAdapter(GetOptState.uIndex - 1, nic.asOutParam())); 1117 ASSERT(nic); 1118 1119 if (!RTStrICmp(ValueUnion.psz, "none")) 1120 { 1121 /* Just remove the bandwidth group. */ 1122 CHECK_ERROR(nic, COMSETTER(BandwidthGroup)(NULL)); 1123 //CHECK_ERROR(nic, COMSETTER(BandwidthGroup)(bwGroup)); 1124 //CHECK_ERROR(machine, SetBandwidthGroupForNetworkAdapter(GetOptState.uIndex - 1, NULL)); 1125 } 1126 else 1127 { 1128 ComPtr<IBandwidthControl> bwCtrl; 1129 ComPtr<IBandwidthGroup> bwGroup; 1130 1131 CHECK_ERROR(machine, COMGETTER(BandwidthControl)(bwCtrl.asOutParam())); 1132 1133 if (SUCCEEDED(rc)) 1134 { 1135 CHECK_ERROR(bwCtrl, GetBandwidthGroup(Bstr(ValueUnion.psz).raw(), bwGroup.asOutParam())); 1136 if (SUCCEEDED(rc)) 1137 { 1138 CHECK_ERROR(nic, COMSETTER(BandwidthGroup)(bwGroup)); 1139 } 1140 } 1141 } 1142 break; 1143 } 1144 1111 1145 case MODIFYVM_NIC: 1112 1146 { -
trunk/src/VBox/Main/idl/VirtualBox.xidl
r36224 r36275 488 488 </const> 489 489 490 <const name="v1_13" value="15"> 491 <desc>Settings version "1.13", written by VirtualBox 4.2.x.</desc> 492 <!-- 493 NetworkAdapter changes: bandwidth group. 494 --> 495 </const> 496 490 497 <const name="Future" value="99999"> 491 <desc>Settings version greater than "1.1 1", written by a future VirtualBox version.</desc>498 <desc>Settings version greater than "1.13", written by a future VirtualBox version.</desc> 492 499 </const> 493 500 </enum> … … 11827 11834 <interface 11828 11835 name="INetworkAdapter" extends="$unknown" 11829 uuid=" 2178cf4f-d961-42f4-ba76-59539234b337"11836 uuid="6aa240a1-dd58-478e-92e8-aac001ce5547" 11830 11837 wsmap="managed" 11831 11838 > … … 11949 11956 </attribute> 11950 11957 11951 <attribute name="bandwidthLimit" type="unsigned long"> 11952 <desc> 11953 Maximum throughput allowed for this network adapter, in units of 1 mbps. 11954 A zero value means uncapped/unlimited. 11955 </desc> 11958 <attribute name="bandwidthGroup" type="IBandwidthGroup"> 11959 <desc>The bandwidth group this network adapter is assigned to.</desc> 11956 11960 </attribute> 11957 11961 -
trunk/src/VBox/Main/include/NetworkAdapterImpl.h
r36082 r36275 23 23 #include "VirtualBoxBase.h" 24 24 #include "NATEngineImpl.h" 25 #include "BandwidthGroupImpl.h" 25 26 26 27 class GuestOSType; … … 71 72 Bstr mNATNetwork; 72 73 ULONG mBootPriority; 73 ULONG mBandwidthLimit;74 ComObjPtr<BandwidthGroup> mBandwidthGroup; 74 75 }; 75 76 … … 125 126 STDMETHOD(COMGETTER(BootPriority)) (ULONG *aBootPriority); 126 127 STDMETHOD(COMSETTER(BootPriority)) (ULONG aBootPriority); 127 STDMETHOD(COMGETTER(Bandwidth Limit)) (ULONG *aLimit);128 STDMETHOD(COMSETTER(Bandwidth Limit)) (ULONG aLimit);128 STDMETHOD(COMGETTER(BandwidthGroup)) (IBandwidthGroup **aBwGroup); 129 STDMETHOD(COMSETTER(BandwidthGroup)) (IBandwidthGroup *aBwGroup); 129 130 130 131 // INetworkAdapter methods … … 138 139 // public methods only for internal purposes 139 140 140 HRESULT loadSettings( const settings::NetworkAdapter &data);141 HRESULT loadSettings(BandwidthControl *bwctl, const settings::NetworkAdapter &data); 141 142 HRESULT saveSettings(settings::NetworkAdapter &data); 142 143 … … 151 152 void detach(); 152 153 void generateMACAddress(); 154 HRESULT updateMacAddress(Utf8Str aMacAddress); 155 void updateBandwidthGroup(BandwidthGroup *aBwGroup); 153 156 154 157 Machine * const mParent; -
trunk/src/VBox/Main/src-server/MachineImpl.cpp
r36219 r36275 7468 7468 if (FAILED(rc)) return rc; 7469 7469 7470 // Bandwidth control (must come before network adapters) 7471 rc = mBandwidthControl->loadSettings(data.ioSettings); 7472 if (FAILED(rc)) return rc; 7473 7470 7474 /* USB Controller */ 7471 7475 rc = mUSBController->loadSettings(data.usbController); … … 7481 7485 /* slot unicity is guaranteed by XML Schema */ 7482 7486 AssertBreak(nic.ulSlot < RT_ELEMENTS(mNetworkAdapters)); 7483 rc = mNetworkAdapters[nic.ulSlot]->loadSettings( nic);7487 rc = mNetworkAdapters[nic.ulSlot]->loadSettings(mBandwidthControl, nic); 7484 7488 if (FAILED(rc)) return rc; 7485 7489 } … … 7533 7537 mHWData->mIoCacheEnabled = data.ioSettings.fIoCacheEnabled; 7534 7538 mHWData->mIoCacheSize = data.ioSettings.ulIoCacheSize; 7535 7536 // Bandwidth control7537 rc = mBandwidthControl->loadSettings(data.ioSettings);7538 if (FAILED(rc)) return rc;7539 7539 7540 7540 // Host PCI devices -
trunk/src/VBox/Main/src-server/NetworkAdapterImpl.cpp
r36105 r36275 85 85 /* initialize data */ 86 86 mData->mSlot = aSlot; 87 88 /* Default limit is not capped/unlimited. */89 mData->mBandwidthLimit = 0;90 87 91 88 /* default to Am79C973 */ … … 340 337 } 341 338 342 STDMETHODIMP NetworkAdapter::COMSETTER(MACAddress)(IN_BSTR aMACAddress) 343 { 344 AutoCaller autoCaller(this); 345 if (FAILED(autoCaller.rc())) return autoCaller.rc(); 346 347 /* the machine needs to be mutable */ 348 AutoMutableStateDependency adep(mParent); 349 if (FAILED(adep.rc())) return adep.rc(); 350 339 HRESULT NetworkAdapter::updateMacAddress(Utf8Str aMACAddress) 340 { 351 341 HRESULT rc = S_OK; 352 bool emitChangeEvent = false;353 342 354 343 /* 355 344 * Are we supposed to generate a MAC? 356 345 */ 357 if (!aMACAddress || !*aMACAddress) 358 { 359 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); 360 mData.backup(); 361 346 if (aMACAddress.isEmpty()) 362 347 generateMACAddress(); 363 emitChangeEvent = true;364 365 m_fModified = true;366 // leave the lock before informing callbacks367 alock.release();368 369 AutoWriteLock mlock(mParent COMMA_LOCKVAL_SRC_POS); // mParent is const, no need to lock370 mParent->setModified(Machine::IsModified_NetworkAdapters);371 mlock.release();372 }373 348 else 374 349 { 375 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);376 350 if (mData->mMACAddress != aMACAddress) 377 351 { … … 379 353 * Verify given MAC address 380 354 */ 381 Utf8Str macAddressUtf = aMACAddress; 382 char *macAddressStr = macAddressUtf.mutableRaw(); 355 char *macAddressStr = aMACAddress.mutableRaw(); 383 356 int i = 0; 384 357 while ((i < 13) && macAddressStr && *macAddressStr && (rc == S_OK)) … … 408 381 409 382 if (SUCCEEDED(rc)) 410 { 411 mData.backup(); 412 413 mData->mMACAddress = macAddressUtf; 414 415 emitChangeEvent = true; 416 417 m_fModified = true; 418 // leave the lock before informing callbacks 419 alock.release(); 420 421 AutoWriteLock mlock(mParent COMMA_LOCKVAL_SRC_POS); // mParent is const, no need to lock 422 mParent->setModified(Machine::IsModified_NetworkAdapters); 423 mlock.release(); 424 } 383 mData->mMACAddress = aMACAddress; 425 384 } 426 385 } 427 386 428 // we have left the lock in any case at this point 429 430 if (emitChangeEvent) 431 { 387 return rc; 388 } 389 390 STDMETHODIMP NetworkAdapter::COMSETTER(MACAddress)(IN_BSTR aMACAddress) 391 { 392 AutoCaller autoCaller(this); 393 if (FAILED(autoCaller.rc())) return autoCaller.rc(); 394 395 /* the machine needs to be mutable */ 396 AutoMutableStateDependency adep(mParent); 397 if (FAILED(adep.rc())) return adep.rc(); 398 399 400 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); 401 mData.backup(); 402 403 HRESULT rc = updateMacAddress(aMACAddress); 404 if (SUCCEEDED(rc)) 405 { 406 m_fModified = true; 407 // leave the lock before informing callbacks 408 alock.release(); 409 410 AutoWriteLock mlock(mParent COMMA_LOCKVAL_SRC_POS); // mParent is const, no need to lock 411 mParent->setModified(Machine::IsModified_NetworkAdapters); 412 mlock.release(); 413 432 414 /* Changing the MAC via the Main API during runtime is not allowed, 433 415 * therefore no immediate change in CFGM logic => changeAdapter=FALSE. */ … … 799 781 800 782 return hrc; 801 }802 803 STDMETHODIMP NetworkAdapter::COMGETTER(BandwidthLimit) (ULONG *aLimit)804 {805 CheckComArgOutPointerValid(aLimit);806 807 AutoCaller autoCaller(this);808 if (FAILED(autoCaller.rc())) return autoCaller.rc();809 810 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);811 812 *aLimit = mData->mBandwidthLimit;813 return S_OK;814 }815 816 STDMETHODIMP NetworkAdapter::COMSETTER(BandwidthLimit) (ULONG aLimit)817 {818 AutoCaller autoCaller(this);819 if (FAILED(autoCaller.rc())) return autoCaller.rc();820 821 /* the machine doesn't need to be mutable */822 823 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);824 825 if (aLimit != mData->mBandwidthLimit)826 {827 mData.backup();828 mData->mBandwidthLimit = aLimit;829 830 m_fModified = true;831 // leave the lock before informing callbacks832 alock.release();833 834 AutoWriteLock mlock(mParent COMMA_LOCKVAL_SRC_POS); // mParent is const, no need to lock835 mParent->setModified(Machine::IsModified_NetworkAdapters);836 mlock.release();837 838 /* No change in CFGM logic => changeAdapter=FALSE. */839 mParent->onNetworkAdapterChange(this, FALSE);840 }841 return S_OK;842 783 } 843 784 … … 1279 1220 * @note Locks this object for writing. 1280 1221 */ 1281 HRESULT NetworkAdapter::loadSettings(const settings::NetworkAdapter &data) 1222 HRESULT NetworkAdapter::loadSettings(BandwidthControl *bwctl, 1223 const settings::NetworkAdapter &data) 1282 1224 { 1283 1225 AutoCaller autoCaller(this); 1284 1226 AssertComRCReturnRC(autoCaller.rc()); 1227 1228 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); 1285 1229 1286 1230 /* Note: we assume that the default values for attributes of optional … … 1300 1244 mData->mEnabled = data.fEnabled; 1301 1245 /* MAC address (can be null) */ 1302 rc = COMSETTER(MACAddress)(Bstr(data.strMACAddress).raw());1246 rc = updateMacAddress(data.strMACAddress); 1303 1247 if (FAILED(rc)) return rc; 1304 1248 /* cable (required) */ … … 1312 1256 /* boot priority (defaults to 0, i.e. lowest) */ 1313 1257 mData->mBootPriority = data.ulBootPriority; 1314 /* Bandwidth limit in Mbps. */ 1315 mData->mBandwidthLimit = data.ulBandwidthLimit; 1258 /* bandwidth group */ 1259 if (data.strBandwidthGroup.isEmpty()) 1260 updateBandwidthGroup(NULL); 1261 else 1262 { 1263 ComObjPtr<BandwidthGroup> group; 1264 rc = bwctl->getBandwidthGroupByName(data.strBandwidthGroup, group, true); // TODO: set error? 1265 if (FAILED(rc)) return rc; 1266 } 1267 1268 // leave the lock before attaching 1269 alock.release(); 1316 1270 1317 1271 switch (data.mode) … … 1398 1352 data.ulBootPriority = mData->mBootPriority; 1399 1353 1400 data.ulBandwidthLimit = mData->mBandwidthLimit; 1354 if (mData->mBandwidthGroup.isNull()) 1355 data.strBandwidthGroup = ""; 1356 else 1357 data.strBandwidthGroup = mData->mBandwidthGroup->getName(); 1401 1358 1402 1359 data.type = mData->mAdapterType; … … 1629 1586 mData->mMACAddress = strMAC; 1630 1587 } 1588 1589 STDMETHODIMP NetworkAdapter::COMGETTER(BandwidthGroup) (IBandwidthGroup **aBwGroup) 1590 { 1591 LogFlowThisFuncEnter(); 1592 CheckComArgOutPointerValid(aBwGroup); 1593 1594 AutoCaller autoCaller(this); 1595 if (FAILED(autoCaller.rc())) return autoCaller.rc(); 1596 1597 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); 1598 1599 mData->mBandwidthGroup.queryInterfaceTo(aBwGroup); 1600 1601 LogFlowThisFuncLeave(); 1602 return S_OK; 1603 } 1604 1605 STDMETHODIMP NetworkAdapter::COMSETTER(BandwidthGroup) (IBandwidthGroup *aBwGroup) 1606 { 1607 LogFlowThisFuncEnter(); 1608 CheckComArgOutPointerValid(aBwGroup); 1609 1610 AutoCaller autoCaller(this); 1611 if (FAILED(autoCaller.rc())) return autoCaller.rc(); 1612 1613 /* the machine needs to be mutable */ 1614 AutoMutableStateDependency adep(mParent); 1615 if (FAILED(adep.rc())) return adep.rc(); 1616 1617 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); 1618 1619 //HRESULT hrc = S_OK; 1620 1621 if (mData->mBandwidthGroup != aBwGroup) 1622 { 1623 mData.backup(); 1624 1625 updateBandwidthGroup(static_cast<BandwidthGroup*>(aBwGroup)); 1626 1627 m_fModified = true; 1628 // leave the lock before informing callbacks 1629 alock.release(); 1630 1631 AutoWriteLock mlock(mParent COMMA_LOCKVAL_SRC_POS); 1632 mParent->setModified(Machine::IsModified_NetworkAdapters); 1633 mlock.release(); 1634 1635 /* TODO: changeAdapter=???. */ 1636 mParent->onNetworkAdapterChange(this, FALSE); 1637 } 1638 1639 LogFlowThisFuncLeave(); 1640 return S_OK; 1641 } 1642 1643 void NetworkAdapter::updateBandwidthGroup(BandwidthGroup *aBwGroup) 1644 { 1645 LogFlowThisFuncEnter(); 1646 Assert(isWriteLockOnCurrentThread()); 1647 1648 mData.backup(); 1649 if (!mData->mBandwidthGroup.isNull()) 1650 { 1651 mData->mBandwidthGroup->release(); 1652 mData->mBandwidthGroup.setNull(); 1653 } 1654 1655 if (aBwGroup) 1656 { 1657 mData->mBandwidthGroup = aBwGroup; 1658 mData->mBandwidthGroup->reference(); 1659 } 1660 1661 LogFlowThisFuncLeave(); 1662 } 1631 1663 /* vi: set tabstop=4 shiftwidth=4 expandtab: */ -
trunk/src/VBox/Main/xml/Settings.cpp
r36168 r36275 1946 1946 pelmAdapter->getAttributeValue("tracefile", nic.strTraceFile); 1947 1947 pelmAdapter->getAttributeValue("bootPriority", nic.ulBootPriority); 1948 pelmAdapter->getAttributeValue("bandwidth Limit", nic.ulBandwidthLimit);1948 pelmAdapter->getAttributeValue("bandwidthGroup", nic.strBandwidthGroup); 1949 1949 1950 1950 xml::ElementNodesList llNetworkModes; … … 3695 3695 pelmAdapter->setAttribute("tracefile", nic.strTraceFile); 3696 3696 } 3697 if (nic. ulBandwidthLimit)3698 pelmAdapter->setAttribute("bandwidth Limit", nic.ulBandwidthLimit);3697 if (nic.strBandwidthGroup.isNotEmpty()) 3698 pelmAdapter->setAttribute("bandwidthGroup", nic.strBandwidthGroup); 3699 3699 3700 3700 const char *pszPolicy; … … 4729 4729 ++netit) 4730 4730 { 4731 if ( (m->sv < SettingsVersion_v1_1 1)4732 && (netit-> ulBandwidthLimit)4731 if ( (m->sv < SettingsVersion_v1_12) 4732 && (netit->strBandwidthGroup.isNotEmpty()) 4733 4733 ) 4734 4734 { 4735 /* New in VirtualBox 4. 0*/4736 m->sv = SettingsVersion_v1_1 1;4735 /* New in VirtualBox 4.1 */ 4736 m->sv = SettingsVersion_v1_12; 4737 4737 break; 4738 4738 }
Note:
See TracChangeset
for help on using the changeset viewer.