Changeset 36058 in vbox for trunk/src/VBox/Main/src-server
- Timestamp:
- Feb 22, 2011 11:11:22 PM (14 years ago)
- Location:
- trunk/src/VBox/Main/src-server
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/src-server/MachineImpl.cpp
r36017 r36058 3709 3709 aType, 3710 3710 fIndirect, 3711 NULL);3711 Utf8Str::Empty); 3712 3712 if (FAILED(rc)) return rc; 3713 3713 … … 3871 3871 AutoWriteLock attLock(pAttach COMMA_LOCKVAL_SRC_POS); 3872 3872 3873 pAttach->updateBandwidthGroup(group); 3873 const Utf8Str strBandwidthGroupOld = pAttach->getBandwidthGroup(); 3874 if (strBandwidthGroupOld.isNotEmpty()) 3875 { 3876 /* Get the bandwidth group object and release it - this must not fail. */ 3877 ComObjPtr<BandwidthGroup> pBandwidthGroupOld; 3878 rc = getBandwidthGroup(strBandwidthGroupOld, pBandwidthGroupOld, false); 3879 Assert(SUCCEEDED(rc)); 3880 3881 pBandwidthGroupOld->release(); 3882 pAttach->updateBandwidthGroup(Utf8Str::Empty); 3883 } 3884 3885 if (!group.isNull()) 3886 { 3887 group->reference(); 3888 pAttach->updateBandwidthGroup(group->getName()); 3889 } 3874 3890 3875 3891 return S_OK; … … 7746 7762 mUserData->s.strName.c_str(), 7747 7763 mData->m_strConfigFileFull.c_str()); 7764 pBwGroup->reference(); 7748 7765 } 7749 7766 … … 7758 7775 dev.deviceType, 7759 7776 dev.fPassThrough, 7760 pBwGroup );7777 pBwGroup.isNull() ? Utf8Str::Empty : pBwGroup->getName()); 7761 7778 if (FAILED(rc)) break; 7762 7779 … … 8686 8703 MediumAttachment *pAttach = *it; 8687 8704 Medium *pMedium = pAttach->getMedium(); 8688 BandwidthGroup *pBwGroup = pAttach->getBandwidthGroup();8689 8705 8690 8706 dev.deviceType = pAttach->getType(); … … 8700 8716 } 8701 8717 8702 if (pBwGroup) 8703 { 8704 dev.strBwGroup = pBwGroup->getName(); 8705 } 8718 dev.strBwGroup = pAttach->getBandwidthGroup(); 8706 8719 8707 8720 data.llAttachedDevices.push_back(dev); -
trunk/src/VBox/Main/src-server/MediumAttachmentImpl.cpp
r35638 r36058 45 45 46 46 ComObjPtr<Medium> pMedium; 47 ComObjPtr<BandwidthGroup> pBwGroup;48 47 /* Since MediumAttachment is not a first class citizen when it 49 48 * comes to managing settings, having a reference to the storage … … 52 51 * substantial changes to MediumImpl.cpp. */ 53 52 const Bstr bstrControllerName; 53 /* Same counts for the assigned bandwidth group */ 54 Utf8Str strBandwidthGroup; 54 55 const LONG lPort; 55 56 const LONG lDevice; … … 110 111 DeviceType_T aType, 111 112 bool aPassthrough, 112 BandwidthGroup *aBandwidthGroup)113 const Utf8Str &strBandwidthGroup) 113 114 { 114 115 LogFlowThisFuncEnter(); … … 128 129 m->bd.allocate(); 129 130 m->bd->pMedium = aMedium; 130 if (aBandwidthGroup) 131 aBandwidthGroup->reference(); 132 m->bd->pBwGroup = aBandwidthGroup; 131 unconst(m->bd->strBandwidthGroup) = strBandwidthGroup; 133 132 unconst(m->bd->bstrControllerName) = aControllerName; 134 133 unconst(m->bd->lPort) = aPort; … … 290 289 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); 291 290 292 m->bd->pBwGroup.queryInterfaceTo(aBwGroup); 293 294 return S_OK; 291 HRESULT hrc = S_OK; 292 if (m->bd->strBandwidthGroup.isNotEmpty()) 293 { 294 ComObjPtr<BandwidthGroup> pBwGroup; 295 hrc = m->pMachine->getBandwidthGroup(m->bd->strBandwidthGroup, pBwGroup, true /* fSetError */); 296 297 Assert(SUCCEEDED(hrc)); /* This is not allowed to fail because the existence of the group was checked when it was attached. */ 298 299 if (SUCCEEDED(hrc)) 300 pBwGroup.queryInterfaceTo(aBwGroup); 301 } 302 303 return hrc; 295 304 } 296 305 … … 318 327 void MediumAttachment::commit() 319 328 { 320 LogFlowThisFunc Enter();329 LogFlowThisFunc(("ENTER - %s\n", getLogName())); 321 330 322 331 /* sanity */ … … 329 338 m->bd.commit(); 330 339 331 LogFlowThisFunc Leave();340 LogFlowThisFunc(("LEAVE - %s\n", getLogName())); 332 341 } 333 342 … … 373 382 } 374 383 375 const ComObjPtr<BandwidthGroup>& MediumAttachment::getBandwidthGroup() const376 { 377 return m->bd-> pBwGroup;384 const Utf8Str& MediumAttachment::getBandwidthGroup() const 385 { 386 return m->bd->strBandwidthGroup; 378 387 } 379 388 … … 407 416 } 408 417 409 void MediumAttachment::updateBandwidthGroup(const ComObjPtr<BandwidthGroup> &aBandwidthGroup) 410 { 418 void MediumAttachment::updateBandwidthGroup(const Utf8Str &aBandwidthGroup) 419 { 420 LogFlowThisFuncEnter(); 411 421 Assert(isWriteLockOnCurrentThread()); 412 422 413 423 m->bd.backup(); 414 if (!aBandwidthGroup.isNull()) 415 aBandwidthGroup->reference(); 416 417 if (!m->bd->pBwGroup.isNull()) 418 { 419 m->bd->pBwGroup->release(); 420 } 421 m->bd->pBwGroup = aBandwidthGroup; 422 } 423 424 m->bd->strBandwidthGroup = aBandwidthGroup; 425 426 LogFlowThisFuncLeave(); 427 } 428
Note:
See TracChangeset
for help on using the changeset viewer.