Changeset 66126 in vbox for trunk/src/VBox/Main/src-server/MachineImpl.cpp
- Timestamp:
- Mar 16, 2017 2:06:27 PM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/src-server/MachineImpl.cpp
r65390 r66126 5 5 6 6 /* 7 * Copyright (C) 2004-201 6Oracle Corporation7 * Copyright (C) 2004-2017 Oracle Corporation 8 8 * 9 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 225 225 226 226 Machine::HWData::~HWData() 227 {228 }229 230 /////////////////////////////////////////////////////////////////////////////231 // Machine::HDData structure232 /////////////////////////////////////////////////////////////////////////////233 234 Machine::MediaData::MediaData()235 {236 }237 238 Machine::MediaData::~MediaData()239 227 { 240 228 } … … 1057 1045 aGroups.resize(mUserData->s.llGroups.size()); 1058 1046 size_t i = 0; 1059 for (StringsList::const_iterator it = mUserData->s.llGroups.begin(); 1060 it != mUserData->s.llGroups.end(); ++it, ++i) 1047 for (StringsList::const_iterator 1048 it = mUserData->s.llGroups.begin(); 1049 it != mUserData->s.llGroups.end(); 1050 ++it, ++i) 1061 1051 aGroups[i] = (*it); 1062 1052 … … 2650 2640 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); 2651 2641 2652 aMediumAttachments.resize(mMedi aData->mAttachments.size());2642 aMediumAttachments.resize(mMediumAttachments->size()); 2653 2643 size_t i = 0; 2654 for (MediaData::AttachmentList::iterator it = mMediaData->mAttachments.begin(); 2655 it != mMediaData->mAttachments.end(); ++it, ++i) 2644 for (MediumAttachmentList::const_iterator 2645 it = mMediumAttachments->begin(); 2646 it != mMediumAttachments->end(); 2647 ++it, ++i) 2656 2648 aMediumAttachments[i] = *it; 2657 2649 … … 2692 2684 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); 2693 2685 2694 USBControllerList data = *mUSBControllers.data(); 2695 aUSBControllers.resize(data.size()); 2686 aUSBControllers.resize(mUSBControllers->size()); 2696 2687 size_t i = 0; 2697 for (USBControllerList::iterator it = data.begin(); it != data.end(); ++i, ++it) 2688 for (USBControllerList::const_iterator 2689 it = mUSBControllers->begin(); 2690 it != mUSBControllers->end(); 2691 ++it, ++i) 2698 2692 aUSBControllers[i] = *it; 2699 2693 … … 2868 2862 aSharedFolders.resize(mHWData->mSharedFolders.size()); 2869 2863 size_t i = 0; 2870 for (std::list<ComObjPtr<SharedFolder> >::iterator it = mHWData->mSharedFolders.begin(); 2871 it != mHWData->mSharedFolders.end(); ++i, ++it) 2864 for (std::list<ComObjPtr<SharedFolder> >::const_iterator 2865 it = mHWData->mSharedFolders.begin(); 2866 it != mHWData->mSharedFolders.end(); 2867 ++it, ++i) 2872 2868 aSharedFolders[i] = *it; 2873 2869 … … 2941 2937 { 2942 2938 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); 2943 StorageControllerList data = *mStorageControllers.data(); 2939 2940 aStorageControllers.resize(mStorageControllers->size()); 2944 2941 size_t i = 0; 2945 aStorageControllers.resize(data.size()); 2946 for (StorageControllerList::iterator it = data.begin(); it != data.end(); ++it, ++i) 2942 for (StorageControllerList::const_iterator 2943 it = mStorageControllers->begin(); 2944 it != mStorageControllers->end(); 2945 ++it, ++i) 2947 2946 aStorageControllers[i] = *it; 2947 2948 2948 return S_OK; 2949 2949 } … … 3858 3858 /* check if the device slot is already busy */ 3859 3859 MediumAttachment *pAttachTemp; 3860 if ((pAttachTemp = i_findAttachment( mMediaData->mAttachments,3860 if ((pAttachTemp = i_findAttachment(*mMediumAttachments.data(), 3861 3861 Bstr(aName).raw(), 3862 3862 aControllerPort, … … 3889 3889 AutoWriteLock mediumLock(medium COMMA_LOCKVAL_SRC_POS); 3890 3890 3891 if ( (pAttachTemp = i_findAttachment( mMediaData->mAttachments, medium))3891 if ( (pAttachTemp = i_findAttachment(*mMediumAttachments.data(), medium)) 3892 3892 && !medium.isNull() 3893 3893 ) … … 3934 3934 { 3935 3935 if ( aType == DeviceType_HardDisk 3936 && mMedi aData.isBackedUp())3937 { 3938 const Medi aData::AttachmentList &oldAtts = mMediaData.backedUpData()->mAttachments;3936 && mMediumAttachments.isBackedUp()) 3937 { 3938 const MediumAttachmentList &oldAtts = *mMediumAttachments.backedUpData(); 3939 3939 3940 3940 /* check if the medium was attached to the VM before we started … … 3950 3950 /* the simplest case: restore the whole attachment 3951 3951 * and return, nothing else to do */ 3952 mMedi aData->mAttachments.push_back(pAttachTemp);3952 mMediumAttachments->push_back(pAttachTemp); 3953 3953 3954 3954 /* Reattach the medium to the VM. */ … … 4015 4015 * attachments to make it possible to re-attach existing diffs to 4016 4016 * another device slot w/o losing their contents */ 4017 if (mMedi aData.isBackedUp())4017 if (mMediumAttachments.isBackedUp()) 4018 4018 { 4019 const Medi aData::AttachmentList &oldAtts = mMediaData.backedUpData()->mAttachments;4020 4021 Medi aData::AttachmentList::const_iterator foundIt = oldAtts.end();4019 const MediumAttachmentList &oldAtts = *mMediumAttachments.backedUpData(); 4020 4021 MediumAttachmentList::const_iterator foundIt = oldAtts.end(); 4022 4022 uint32_t foundLevel = 0; 4023 4023 4024 for (MediaData::AttachmentList::const_iterator it = oldAtts.begin(); it != oldAtts.end(); ++it) 4024 for (MediumAttachmentList::const_iterator 4025 it = oldAtts.begin(); 4026 it != oldAtts.end(); 4027 ++it) 4025 4028 { 4026 4029 uint32_t level = 0; … … 4035 4038 /* skip the hard disk if its currently attached (we 4036 4039 * cannot attach the same hard disk twice) */ 4037 if (i_findAttachment( mMediaData->mAttachments,4040 if (i_findAttachment(*mMediumAttachments.data(), 4038 4041 pMedium)) 4039 4042 continue; … … 4048 4051 /* the simplest case: restore the whole attachment 4049 4052 * and return, nothing else to do */ 4050 mMedi aData->mAttachments.push_back(*it);4053 mMediumAttachments->push_back(*it); 4051 4054 4052 4055 /* Reattach the medium to the VM. */ … … 4131 4134 AutoReadLock snapLock(snap COMMA_LOCKVAL_SRC_POS); 4132 4135 4133 const Medi aData::AttachmentList &snapAtts = snap->i_getSnapshotMachine()->mMediaData->mAttachments;4136 const MediumAttachmentList &snapAtts = *snap->i_getSnapshotMachine()->mMediumAttachments.data(); 4134 4137 4135 4138 MediumAttachment *pAttachFound = NULL; 4136 4139 uint32_t foundLevel = 0; 4137 4140 4138 for (MediaData::AttachmentList::const_iterator it = snapAtts.begin(); it != snapAtts.end(); ++it) 4141 for (MediumAttachmentList::const_iterator 4142 it = snapAtts.begin(); 4143 it != snapAtts.end(); 4144 ++it) 4139 4145 { 4140 4146 MediumAttachment *pAttach = *it; … … 4317 4323 /* success: finally remember the attachment */ 4318 4324 i_setModified(IsModified_Storage); 4319 mMedi aData.backup();4320 mMedi aData->mAttachments.push_back(attachment);4325 mMediumAttachments.backup(); 4326 mMediumAttachments->push_back(attachment); 4321 4327 4322 4328 mediumLock.release(); … … 4414 4420 aName.c_str()); 4415 4421 4416 MediumAttachment *pAttach = i_findAttachment( mMediaData->mAttachments,4422 MediumAttachment *pAttach = i_findAttachment(*mMediumAttachments.data(), 4417 4423 Bstr(aName).raw(), 4418 4424 aControllerPort, … … 4471 4477 Global::stringifyMachineState(mData->mMachineState)); 4472 4478 4473 MediumAttachment *pAttach = i_findAttachment( mMediaData->mAttachments,4479 MediumAttachment *pAttach = i_findAttachment(*mMediumAttachments.data(), 4474 4480 Bstr(aName).raw(), 4475 4481 aControllerPort, … … 4482 4488 4483 4489 i_setModified(IsModified_Storage); 4484 mMedi aData.backup();4490 mMediumAttachments.backup(); 4485 4491 4486 4492 AutoWriteLock attLock(pAttach COMMA_LOCKVAL_SRC_POS); … … 4507 4513 if (FAILED(rc)) return rc; 4508 4514 4509 MediumAttachment *pAttach = i_findAttachment( mMediaData->mAttachments,4515 MediumAttachment *pAttach = i_findAttachment(*mMediumAttachments.data(), 4510 4516 Bstr(aName).raw(), 4511 4517 aControllerPort, … … 4518 4524 4519 4525 i_setModified(IsModified_Storage); 4520 mMedi aData.backup();4526 mMediumAttachments.backup(); 4521 4527 4522 4528 AutoWriteLock attLock(pAttach COMMA_LOCKVAL_SRC_POS); … … 4550 4556 Global::stringifyMachineState(mData->mMachineState)); 4551 4557 4552 MediumAttachment *pAttach = i_findAttachment( mMediaData->mAttachments,4558 MediumAttachment *pAttach = i_findAttachment(*mMediumAttachments.data(), 4553 4559 Bstr(aName).raw(), 4554 4560 aControllerPort, … … 4561 4567 4562 4568 i_setModified(IsModified_Storage); 4563 mMedi aData.backup();4569 mMediumAttachments.backup(); 4564 4570 4565 4571 AutoWriteLock attLock(pAttach COMMA_LOCKVAL_SRC_POS); … … 4593 4599 Global::stringifyMachineState(mData->mMachineState)); 4594 4600 4595 MediumAttachment *pAttach = i_findAttachment( mMediaData->mAttachments,4601 MediumAttachment *pAttach = i_findAttachment(*mMediumAttachments.data(), 4596 4602 Bstr(aName).raw(), 4597 4603 aControllerPort, … … 4604 4610 4605 4611 i_setModified(IsModified_Storage); 4606 mMedi aData.backup();4612 mMediumAttachments.backup(); 4607 4613 4608 4614 AutoWriteLock attLock(pAttach COMMA_LOCKVAL_SRC_POS); … … 4635 4641 Global::stringifyMachineState(mData->mMachineState)); 4636 4642 4637 MediumAttachment *pAttach = i_findAttachment( mMediaData->mAttachments,4643 MediumAttachment *pAttach = i_findAttachment(*mMediumAttachments.data(), 4638 4644 Bstr(aName).raw(), 4639 4645 aControllerPort, … … 4662 4668 4663 4669 i_setModified(IsModified_Storage); 4664 mMedi aData.backup();4670 mMediumAttachments.backup(); 4665 4671 4666 4672 AutoWriteLock attLock(pAttach COMMA_LOCKVAL_SRC_POS); … … 4703 4709 Global::stringifyMachineState(mData->mMachineState)); 4704 4710 4705 MediumAttachment *pAttach = i_findAttachment( mMediaData->mAttachments,4711 MediumAttachment *pAttach = i_findAttachment(*mMediumAttachments.data(), 4706 4712 Bstr(aName).raw(), 4707 4713 aControllerPort, … … 4714 4720 4715 4721 i_setModified(IsModified_Storage); 4716 mMedi aData.backup();4722 mMediumAttachments.backup(); 4717 4723 4718 4724 IBandwidthGroup *iB = aBandwidthGroup; … … 4790 4796 &mParent->i_getMediaTreeLockHandle() COMMA_LOCKVAL_SRC_POS); 4791 4797 4792 ComObjPtr<MediumAttachment> pAttach = i_findAttachment( mMediaData->mAttachments,4798 ComObjPtr<MediumAttachment> pAttach = i_findAttachment(*mMediumAttachments.data(), 4793 4799 Bstr(aName).raw(), 4794 4800 aControllerPort, … … 4832 4838 4833 4839 i_setModified(IsModified_Storage); 4834 mMedi aData.backup();4840 mMediumAttachments.backup(); 4835 4841 4836 4842 { 4837 4843 // The backup operation makes the pAttach reference point to the 4838 4844 // old settings. Re-get the correct reference. 4839 pAttach = i_findAttachment( mMediaData->mAttachments,4845 pAttach = i_findAttachment(*mMediumAttachments.data(), 4840 4846 Bstr(aName).raw(), 4841 4847 aControllerPort, … … 4871 4877 if (!pMedium.isNull()) 4872 4878 pMedium->i_removeBackReference(mData->mUuid); 4873 pAttach = i_findAttachment( mMediaData->mAttachments,4879 pAttach = i_findAttachment(*mMediumAttachments.data(), 4874 4880 Bstr(aName).raw(), 4875 4881 aControllerPort, … … 4906 4912 aMedium = NULL; 4907 4913 4908 ComObjPtr<MediumAttachment> pAttach = i_findAttachment( mMediaData->mAttachments,4914 ComObjPtr<MediumAttachment> pAttach = i_findAttachment(*mMediumAttachments.data(), 4909 4915 Bstr(aName).raw(), 4910 4916 aControllerPort, … … 4961 4967 aKeys.resize(mData->pMachineConfigFile->mapExtraDataItems.size()); 4962 4968 size_t i = 0; 4963 for (settings::StringsMap::const_iterator it = mData->pMachineConfigFile->mapExtraDataItems.begin(); 4969 for (settings::StringsMap::const_iterator 4970 it = mData->pMachineConfigFile->mapExtraDataItems.begin(); 4964 4971 it != mData->pMachineConfigFile->mapExtraDataItems.end(); 4965 4972 ++it, ++i) … … 5196 5203 MediaList llMedia; 5197 5204 5198 if ( !mMedi aData.isNull()// can be NULL if machine is inaccessible5199 && mMedi aData->mAttachments.size()5205 if ( !mMediumAttachments.isNull() // can be NULL if machine is inaccessible 5206 && mMediumAttachments->size() 5200 5207 ) 5201 5208 { … … 5206 5213 return setError(VBOX_E_INVALID_OBJECT_STATE, 5207 5214 tr("Cannot unregister the machine '%s' because it has %d media attachments"), 5208 mUserData->s.strName.c_str(), mMedi aData->mAttachments.size());5215 mUserData->s.strName.c_str(), mMediumAttachments->size()); 5209 5216 } 5210 5217 … … 5246 5253 5247 5254 // return media to caller 5255 aMedia.resize(llMedia.size()); 5248 5256 size_t i = 0; 5249 aMedia.resize(llMedia.size()); 5250 for (MediaList::iterator it = llMedia.begin(); it != llMedia.end(); ++it, ++i) 5257 for (MediaList::const_iterator 5258 it = llMedia.begin(); 5259 it != llMedia.end(); 5260 ++it, ++i) 5251 5261 (*it).queryInterfaceTo(aMedia[i].asOutParam()); 5252 5262 … … 5281 5291 m_pMachine->i_deleteConfigHandler(*this); 5282 5292 } 5283 catch (...)5293 catch (...) 5284 5294 { 5285 5295 LogRel(("Some exception in the function Machine::i_deleteConfigHandler()\n")); … … 5383 5393 // medium storage files from the IMedium list passed in, and the 5384 5394 // machine XML file) 5385 StringsList::const_iterator it = task.m_llFilesToDelete.begin(); 5386 while (it != task.m_llFilesToDelete.end()) 5395 for (StringsList::const_iterator 5396 it = task.m_llFilesToDelete.begin(); 5397 it != task.m_llFilesToDelete.end(); 5398 ++it) 5387 5399 { 5388 5400 const Utf8Str &strFile = *it; 5389 5401 LogFunc(("Deleting file %s\n", strFile.c_str())); 5402 rc = task.m_pProgress->SetNextOperation(BstrFmt(tr("Deleting '%s'"), it->c_str()).raw(), 1); 5403 if (FAILED(rc)) throw rc; 5404 5390 5405 int vrc = RTFileDelete(strFile.c_str()); 5391 5406 if (RT_FAILURE(vrc)) 5392 5407 throw setError(VBOX_E_IPRT_ERROR, 5393 5408 tr("Could not delete file '%s' (%Rrc)"), strFile.c_str(), vrc); 5394 5395 ++it; 5396 if (it == task.m_llFilesToDelete.end()) 5397 { 5398 rc = task.m_pProgress->SetNextOperation(Bstr(tr("Cleaning up machine directory")).raw(), 1); 5399 if (FAILED(rc)) throw rc; 5400 break; 5401 } 5402 5403 rc = task.m_pProgress->SetNextOperation(BstrFmt(tr("Deleting '%s'"), it->c_str()).raw(), 1); 5404 if (FAILED(rc)) throw rc; 5405 } 5409 } 5410 5411 rc = task.m_pProgress->SetNextOperation(Bstr(tr("Cleaning up machine directory")).raw(), 1); 5412 if (FAILED(rc)) throw rc; 5406 5413 5407 5414 /* delete the settings only when the file actually exists */ … … 5937 5944 * Look for matching patterns and build up a list. 5938 5945 */ 5939 HWData::GuestPropertyMap::const_iterator it = mHWData->mGuestProperties.begin(); 5940 while (it != mHWData->mGuestProperties.end()) 5946 for (HWData::GuestPropertyMap::const_iterator 5947 it = mHWData->mGuestProperties.begin(); 5948 it != mHWData->mGuestProperties.end(); 5949 ++it) 5941 5950 { 5942 5951 if ( strPatterns.isEmpty() … … 5948 5957 ) 5949 5958 propMap.insert(*it); 5950 ++it;5951 5959 } 5952 5960 … … 5964 5972 5965 5973 char szFlags[MAX_FLAGS_LEN + 1]; 5966 size_t i= 0; 5967 for (it = propMap.begin(); it != propMap.end(); ++i, ++it) 5974 size_t i = 0; 5975 for (HWData::GuestPropertyMap::const_iterator 5976 it = propMap.begin(); 5977 it != propMap.end(); 5978 ++it, ++i) 5968 5979 { 5969 5980 aNames[i] = it->first; … … 6049 6060 std::vector<ComPtr<IMediumAttachment> > &aMediumAttachments) 6050 6061 { 6051 Medi aData::AttachmentList atts;6062 MediumAttachmentList atts; 6052 6063 6053 6064 HRESULT rc = i_getMediumAttachmentsOfController(aName, atts); 6054 6065 if (FAILED(rc)) return rc; 6055 6066 6067 aMediumAttachments.resize(atts.size()); 6056 6068 size_t i = 0; 6057 aMediumAttachments.resize(atts.size()); 6058 for (MediaData::AttachmentList::iterator it = atts.begin(); it != atts.end(); ++it, ++i) 6069 for (MediumAttachmentList::const_iterator 6070 it = atts.begin(); 6071 it != atts.end(); 6072 ++it, ++i) 6059 6073 (*it).queryInterfaceTo(aMediumAttachments[i].asOutParam()); 6060 6074 … … 6074 6088 aAttachment = NULL; 6075 6089 6076 ComObjPtr<MediumAttachment> pAttach = i_findAttachment( mMediaData->mAttachments,6090 ComObjPtr<MediumAttachment> pAttach = i_findAttachment(*mMediumAttachments.data(), 6077 6091 Bstr(aName).raw(), 6078 6092 aControllerPort, … … 6118 6132 ULONG ulInstance = 0; 6119 6133 bool fBootable = true; 6120 for (StorageControllerList::const_iterator it = mStorageControllers->begin(); 6134 for (StorageControllerList::const_iterator 6135 it = mStorageControllers->begin(); 6121 6136 it != mStorageControllers->end(); 6122 6137 ++it) … … 6171 6186 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); 6172 6187 6173 for (StorageControllerList::const_iterator it = mStorageControllers->begin(); 6188 for (StorageControllerList::const_iterator 6189 it = mStorageControllers->begin(); 6174 6190 it != mStorageControllers->end(); 6175 6191 ++it) … … 6203 6219 if (aBootable == TRUE) 6204 6220 { 6205 for (StorageControllerList::const_iterator it = mStorageControllers->begin(); 6221 for (StorageControllerList::const_iterator 6222 it = mStorageControllers->begin(); 6206 6223 it != mStorageControllers->end(); 6207 6224 ++it) … … 6251 6268 /* find all attached devices to the appropriate storage controller and detach them all */ 6252 6269 // make a temporary list because detachDevice invalidates iterators into 6253 // mMediaData->mAttachments 6254 MediaData::AttachmentList llAttachments2 = mMediaData->mAttachments; 6255 6256 for (MediaData::AttachmentList::iterator it = llAttachments2.begin(); 6270 // mMediumAttachments 6271 MediumAttachmentList llAttachments2 = *mMediumAttachments.data(); 6272 6273 for (MediumAttachmentList::const_iterator 6274 it = llAttachments2.begin(); 6257 6275 it != llAttachments2.end(); 6258 6276 ++it) … … 6770 6788 6771 6789 // check if device with this host PCI address already attached 6772 for (HWData::PCIDeviceAssignmentList::iterator it = mHWData->mPCIDeviceAssignments.begin(); 6773 it != mHWData->mPCIDeviceAssignments.end(); 6790 for (HWData::PCIDeviceAssignmentList::const_iterator 6791 it = mHWData->mPCIDeviceAssignments.begin(); 6792 it != mHWData->mPCIDeviceAssignments.end(); 6774 6793 ++it) 6775 6794 { … … 6816 6835 if (FAILED(rc)) return rc; 6817 6836 6818 for (HWData::PCIDeviceAssignmentList::iterator it = mHWData->mPCIDeviceAssignments.begin(); 6819 it != mHWData->mPCIDeviceAssignments.end(); 6837 for (HWData::PCIDeviceAssignmentList::const_iterator 6838 it = mHWData->mPCIDeviceAssignments.begin(); 6839 it != mHWData->mPCIDeviceAssignments.end(); 6820 6840 ++it) 6821 6841 { … … 6859 6879 6860 6880 aPCIDeviceAssignments.resize(mHWData->mPCIDeviceAssignments.size()); 6861 6862 6881 size_t i = 0; 6863 for (std::list<ComObjPtr<PCIDeviceAttachment> >::const_iterator it = mHWData->mPCIDeviceAssignments.begin(); 6882 for (std::list<ComObjPtr<PCIDeviceAttachment> >::const_iterator 6883 it = mHWData->mPCIDeviceAssignments.begin(); 6864 6884 it != mHWData->mPCIDeviceAssignments.end(); 6865 ++i , ++it)6885 ++it, ++i) 6866 6886 (*it).queryInterfaceTo(aPCIDeviceAssignments[i].asOutParam()); 6867 6887 … … 8357 8377 mUserData.allocate(); 8358 8378 mHWData.allocate(); 8359 mMedi aData.allocate();8379 mMediumAttachments.allocate(); 8360 8380 mStorageControllers.allocate(); 8361 8381 mUSBControllers.allocate(); … … 8505 8525 * attachments will already be uninitialized and deleted, so this 8506 8526 * code will not affect them. */ 8507 if ( ! !mMediaData8508 && (!i_isSessionMachine())8527 if ( !mMediumAttachments.isNull() 8528 && !i_isSessionMachine() 8509 8529 ) 8510 8530 { 8511 for (MediaData::AttachmentList::const_iterator it = mMediaData->mAttachments.begin(); 8512 it != mMediaData->mAttachments.end(); 8531 for (MediumAttachmentList::const_iterator 8532 it = mMediumAttachments->begin(); 8533 it != mMediumAttachments->end(); 8513 8534 ++it) 8514 8535 { … … 8539 8560 /* free data structures (the essential mData structure is not freed here 8540 8561 * since it may be still in use) */ 8541 mMedi aData.free();8562 mMediumAttachments.free(); 8542 8563 mStorageControllers.free(); 8543 8564 mUSBControllers.free(); … … 8555 8576 * (primary) machine pointer. 8556 8577 */ 8557 Machine *Machine::i_getMachine()8578 Machine *Machine::i_getMachine() 8558 8579 { 8559 8580 if (i_isSessionMachine()) … … 8664 8685 { 8665 8686 HRESULT rc = VBOX_E_OBJECT_NOT_FOUND; 8666 for (HWData::SharedFolderList::const_iterator it = mHWData->mSharedFolders.begin(); 8667 it != mHWData->mSharedFolders.end(); 8668 ++it) 8687 for (HWData::SharedFolderList::const_iterator 8688 it = mHWData->mSharedFolders.begin(); 8689 it != mHWData->mSharedFolders.end(); 8690 ++it) 8669 8691 { 8670 8692 SharedFolder *pSF = *it; … … 8879 8901 8880 8902 // now create the children 8881 for (settings::SnapshotsList::const_iterator it = data.llChildSnapshots.begin(); 8903 for (settings::SnapshotsList::const_iterator 8904 it = data.llChildSnapshots.begin(); 8882 8905 it != data.llChildSnapshots.end(); 8883 8906 ++it) … … 8939 8962 if (mHWData->mCPUHotPlugEnabled) 8940 8963 { 8941 for (settings::CpuList::const_iterator it = data.llCpus.begin(); 8942 it != data.llCpus.end(); 8943 ++it) 8964 for (settings::CpuList::const_iterator 8965 it = data.llCpus.begin(); 8966 it != data.llCpus.end(); 8967 ++it) 8944 8968 { 8945 8969 const settings::Cpu &cpu = *it; … … 8950 8974 8951 8975 // cpuid leafs 8952 for (settings::CpuIdLeafsList::const_iterator it = data.llCpuIdLeafs.begin(); 8953 it != data.llCpuIdLeafs.end(); 8954 ++it) 8976 for (settings::CpuIdLeafsList::const_iterator 8977 it = data.llCpuIdLeafs.begin(); 8978 it != data.llCpuIdLeafs.end(); 8979 ++it) 8955 8980 { 8956 8981 const settings::CpuIdLeaf &leaf = *it; … … 9044 9069 9045 9070 /* Shared folders */ 9046 for (settings::USBControllerList::const_iterator it = data.usbSettings.llUSBControllers.begin(); 9071 for (settings::USBControllerList::const_iterator 9072 it = data.usbSettings.llUSBControllers.begin(); 9047 9073 it != data.usbSettings.llUSBControllers.end(); 9048 9074 ++it) … … 9074 9100 else if (newCount < oldCount) 9075 9101 mNetworkAdapters.resize(newCount); 9076 for (settings::NetworkAdaptersList::const_iterator it = data.llNetworkAdapters.begin(); 9077 it != data.llNetworkAdapters.end(); 9078 ++it) 9102 for (settings::NetworkAdaptersList::const_iterator 9103 it = data.llNetworkAdapters.begin(); 9104 it != data.llNetworkAdapters.end(); 9105 ++it) 9079 9106 { 9080 9107 const settings::NetworkAdapter &nic = *it; … … 9087 9114 9088 9115 // serial ports 9089 for (settings::SerialPortsList::const_iterator it = data.llSerialPorts.begin(); 9090 it != data.llSerialPorts.end(); 9091 ++it) 9116 for (settings::SerialPortsList::const_iterator 9117 it = data.llSerialPorts.begin(); 9118 it != data.llSerialPorts.end(); 9119 ++it) 9092 9120 { 9093 9121 const settings::SerialPort &s = *it; … … 9099 9127 9100 9128 // parallel ports (optional) 9101 for (settings::ParallelPortsList::const_iterator it = data.llParallelPorts.begin(); 9102 it != data.llParallelPorts.end(); 9103 ++it) 9129 for (settings::ParallelPortsList::const_iterator 9130 it = data.llParallelPorts.begin(); 9131 it != data.llParallelPorts.end(); 9132 ++it) 9104 9133 { 9105 9134 const settings::ParallelPort &p = *it; … … 9121 9150 9122 9151 /* Shared folders */ 9123 for (settings::SharedFoldersList::const_iterator it = data.llSharedFolders.begin(); 9152 for (settings::SharedFoldersList::const_iterator 9153 it = data.llSharedFolders.begin(); 9124 9154 it != data.llSharedFolders.end(); 9125 9155 ++it) … … 9162 9192 9163 9193 // Host PCI devices 9164 for (settings::HostPCIDeviceAttachmentList::const_iterator it = data.pciAttachments.begin(); 9194 for (settings::HostPCIDeviceAttachmentList::const_iterator 9195 it = data.pciAttachments.begin(); 9165 9196 it != data.pciAttachments.end(); 9166 9197 ++it) … … 9194 9225 * as there are no config changes. */ 9195 9226 settings::GuestPropertiesList &llGuestProperties = unconst(data.llGuestProperties); 9196 for (settings::GuestPropertiesList::iterator it = llGuestProperties.begin(); 9197 it != llGuestProperties.end(); 9198 /*nothing*/) 9227 for (settings::GuestPropertiesList::iterator 9228 it = llGuestProperties.begin(); 9229 it != llGuestProperties.end(); 9230 /*nothing*/) 9199 9231 { 9200 9232 const settings::GuestProperty &prop = *it; … … 9223 9255 mHWData->mDefaultFrontend = data.strDefaultFrontend; 9224 9256 } 9225 catch (std::bad_alloc &)9257 catch (std::bad_alloc &) 9226 9258 { 9227 9259 return E_OUTOFMEMORY; … … 9262 9294 HRESULT rc = S_OK; 9263 9295 9264 for (settings::StorageControllersList::const_iterator it = data.llStorageControllers.begin(); 9296 for (settings::StorageControllersList::const_iterator 9297 it = data.llStorageControllers.begin(); 9265 9298 it != data.llStorageControllers.end(); 9266 9299 ++it) … … 9324 9357 9325 9358 /* paranoia: detect duplicate attachments */ 9326 for (settings::AttachedDevicesList::const_iterator it = data.llAttachedDevices.begin(); 9359 for (settings::AttachedDevicesList::const_iterator 9360 it = data.llAttachedDevices.begin(); 9327 9361 it != data.llAttachedDevices.end(); 9328 9362 ++it) … … 9352 9386 } 9353 9387 9354 for (settings::AttachedDevicesList::const_iterator it = data.llAttachedDevices.begin(); 9388 for (settings::AttachedDevicesList::const_iterator 9389 it = data.llAttachedDevices.begin(); 9355 9390 it != data.llAttachedDevices.end(); 9356 9391 ++it) … … 9452 9487 medium->i_getChildren().size()); 9453 9488 9454 if (i_findAttachment( mMediaData->mAttachments,9489 if (i_findAttachment(*mMediumAttachments.data(), 9455 9490 medium)) 9456 9491 return setError(E_FAIL, … … 9531 9566 break; 9532 9567 9533 /* back up mMedi aData to let registeredInit() properly rollback on failure9534 * (= limited accessibility) */9568 /* back up mMediumAttachments to let registeredInit() properly rollback 9569 * on failure (= limited accessibility) */ 9535 9570 i_setModified(IsModified_Storage); 9536 mMedi aData.backup();9537 mMedi aData->mAttachments.push_back(pAttachment);9571 mMediumAttachments.backup(); 9572 mMediumAttachments->push_back(pAttachment); 9538 9573 } 9539 9574 … … 9627 9662 AssertReturn(!aName.isEmpty(), E_INVALIDARG); 9628 9663 9629 for (StorageControllerList::const_iterator it = mStorageControllers->begin(); 9664 for (StorageControllerList::const_iterator 9665 it = mStorageControllers->begin(); 9630 9666 it != mStorageControllers->end(); 9631 9667 ++it) … … 9658 9694 AssertReturn(!aName.isEmpty(), E_INVALIDARG); 9659 9695 9660 for (USBControllerList::const_iterator it = mUSBControllers->begin(); 9696 for (USBControllerList::const_iterator 9697 it = mUSBControllers->begin(); 9661 9698 it != mUSBControllers->end(); 9662 9699 ++it) … … 9685 9722 ULONG cCtrls = 0; 9686 9723 9687 for (USBControllerList::const_iterator it = mUSBControllers->begin(); 9724 for (USBControllerList::const_iterator 9725 it = mUSBControllers->begin(); 9688 9726 it != mUSBControllers->end(); 9689 9727 ++it) … … 9697 9735 9698 9736 HRESULT Machine::i_getMediumAttachmentsOfController(const Utf8Str &aName, 9699 Medi aData::AttachmentList &atts)9737 MediumAttachmentList &atts) 9700 9738 { 9701 9739 AutoCaller autoCaller(this); … … 9704 9742 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); 9705 9743 9706 for (MediaData::AttachmentList::iterator it = mMediaData->mAttachments.begin(); 9707 it != mMediaData->mAttachments.end(); 9744 for (MediumAttachmentList::const_iterator 9745 it = mMediumAttachments->begin(); 9746 it != mMediumAttachments->end(); 9708 9747 ++it) 9709 9748 { … … 10342 10381 /* USB Controller (required) */ 10343 10382 data.usbSettings.llUSBControllers.clear(); 10344 for (USBControllerList::const_iterator it = mUSBControllers->begin(); it != mUSBControllers->end(); ++it) 10383 for (USBControllerList::const_iterator 10384 it = mUSBControllers->begin(); 10385 it != mUSBControllers->end(); 10386 ++it) 10345 10387 { 10346 10388 ComObjPtr<USBController> ctrl = *it; … … 10416 10458 /* Shared folders */ 10417 10459 data.llSharedFolders.clear(); 10418 for (HWData::SharedFolderList::const_iterator it = mHWData->mSharedFolders.begin(); 10419 it != mHWData->mSharedFolders.end(); 10420 ++it) 10460 for (HWData::SharedFolderList::const_iterator 10461 it = mHWData->mSharedFolders.begin(); 10462 it != mHWData->mSharedFolders.end(); 10463 ++it) 10421 10464 { 10422 10465 SharedFolder *pSF = *it; … … 10451 10494 /* Host PCI devices */ 10452 10495 data.pciAttachments.clear(); 10453 for (HWData::PCIDeviceAssignmentList::const_iterator it = mHWData->mPCIDeviceAssignments.begin(); 10496 for (HWData::PCIDeviceAssignmentList::const_iterator 10497 it = mHWData->mPCIDeviceAssignments.begin(); 10454 10498 it != mHWData->mPCIDeviceAssignments.end(); 10455 10499 ++it) … … 10467 10511 data.llGuestProperties.clear(); 10468 10512 #ifdef VBOX_WITH_GUEST_PROPS 10469 for (HWData::GuestPropertyMap::const_iterator it = mHWData->mGuestProperties.begin(); 10513 for (HWData::GuestPropertyMap::const_iterator 10514 it = mHWData->mGuestProperties.begin(); 10470 10515 it != mHWData->mGuestProperties.end(); 10471 10516 ++it) … … 10503 10548 data.strDefaultFrontend = mHWData->mDefaultFrontend; 10504 10549 } 10505 catch (std::bad_alloc &)10550 catch (std::bad_alloc &) 10506 10551 { 10507 10552 return E_OUTOFMEMORY; … … 10521 10566 data.llStorageControllers.clear(); 10522 10567 10523 for (StorageControllerList::const_iterator it = mStorageControllers->begin(); 10568 for (StorageControllerList::const_iterator 10569 it = mStorageControllers->begin(); 10524 10570 it != mStorageControllers->end(); 10525 10571 ++it) … … 10563 10609 settings::StorageController &data) 10564 10610 { 10565 Medi aData::AttachmentList atts;10611 MediumAttachmentList atts; 10566 10612 10567 10613 HRESULT rc = i_getMediumAttachmentsOfController(aStorageController->i_getName(), atts); … … 10569 10615 10570 10616 data.llAttachedDevices.clear(); 10571 for (MediaData::AttachmentList::const_iterator it = atts.begin(); 10617 for (MediumAttachmentList::const_iterator 10618 it = atts.begin(); 10572 10619 it != atts.end(); 10573 10620 ++it) … … 10718 10765 * from SessionMachine::BeginTakingSnapshot() and SessionMachine::restoreSnapshotHandler(). 10719 10766 * 10720 * This method assumes that mMediaData contains the original hard disk attachments 10721 * it needs to create diffs for. On success, these attachments will be replaced 10722 * with the created diffs. On failure, #deleteImplicitDiffs() is implicitly 10723 * called to delete created diffs which will also rollback mMediaData and restore 10724 * whatever was backed up before calling this method. 10767 * This method assumes that mMediumAttachments contains the original hard disk 10768 * attachments it needs to create diffs for. On success, these attachments will 10769 * be replaced with the created diffs. On failure, #deleteImplicitDiffs() is 10770 * implicitly called to delete created diffs which will also rollback 10771 * mMediumAttachments and restore whatever was backed up before calling this 10772 * method. 10725 10773 * 10726 10774 * Attachments with non-normal hard disks are left as is. … … 10779 10827 /* lock all attached hard disks early to detect "in use" 10780 10828 * situations before creating actual diffs */ 10781 for (MediaData::AttachmentList::const_iterator it = mMediaData->mAttachments.begin(); 10782 it != mMediaData->mAttachments.end(); 10829 for (MediumAttachmentList::const_iterator 10830 it = mMediumAttachments->begin(); 10831 it != mMediumAttachments->end(); 10783 10832 ++it) 10784 10833 { 10785 MediumAttachment *pAtt = *it;10834 MediumAttachment *pAtt = *it; 10786 10835 if (pAtt->i_getType() == DeviceType_HardDisk) 10787 10836 { 10788 Medium *pMedium = pAtt->i_getMedium();10837 Medium *pMedium = pAtt->i_getMedium(); 10789 10838 Assert(pMedium); 10790 10839 … … 10823 10872 10824 10873 /* remember the current list (note that we don't use backup() since 10825 * mMedi aDatamay be already backed up) */10826 Medi aData::AttachmentList atts = mMediaData->mAttachments;10874 * mMediumAttachments may be already backed up) */ 10875 MediumAttachmentList atts = *mMediumAttachments.data(); 10827 10876 10828 10877 /* start from scratch */ 10829 mMedi aData->mAttachments.clear();10878 mMediumAttachments->clear(); 10830 10879 10831 10880 /* go through remembered attachments and create diffs for normal hard 10832 10881 * disks and attach them */ 10833 for (MediaData::AttachmentList::const_iterator it = atts.begin(); 10882 for (MediumAttachmentList::const_iterator 10883 it = atts.begin(); 10834 10884 it != atts.end(); 10835 10885 ++it) 10836 10886 { 10837 MediumAttachment *pAtt = *it;10887 MediumAttachment *pAtt = *it; 10838 10888 10839 10889 DeviceType_T devType = pAtt->i_getType(); 10840 Medium *pMedium = pAtt->i_getMedium();10890 Medium *pMedium = pAtt->i_getMedium(); 10841 10891 10842 10892 if ( devType != DeviceType_HardDisk … … 10860 10910 } 10861 10911 10862 mMedi aData->mAttachments.push_back(pAtt);10912 mMediumAttachments->push_back(pAtt); 10863 10913 continue; 10864 10914 } … … 10941 10991 rc = lockedMediaMap->ReplaceKey(pAtt, attachment); 10942 10992 AssertComRCThrowRC(rc); 10943 mMedi aData->mAttachments.push_back(attachment);10993 mMediumAttachments->push_back(attachment); 10944 10994 } 10945 10995 } … … 10960 11010 /** 10961 11011 * Deletes implicit differencing hard disks created either by 10962 * #i_createImplicitDiffs() or by #attachDevice() and rolls back mMediaData. 11012 * #i_createImplicitDiffs() or by #attachDevice() and rolls back 11013 * mMediumAttachments. 10963 11014 * 10964 11015 * Note that to delete hard disks created by #attachDevice() this method is … … 10978 11029 10979 11030 /* We absolutely must have backed up state. */ 10980 AssertReturn(mMedi aData.isBackedUp(), E_FAIL);11031 AssertReturn(mMediumAttachments.isBackedUp(), E_FAIL); 10981 11032 10982 11033 /* Check if there are any implicitly created diff images. */ 10983 11034 bool fImplicitDiffs = false; 10984 for (MediaData::AttachmentList::const_iterator it = mMediaData->mAttachments.begin(); 10985 it != mMediaData->mAttachments.end(); 11035 for (MediumAttachmentList::const_iterator 11036 it = mMediumAttachments->begin(); 11037 it != mMediumAttachments->end(); 10986 11038 ++it) 10987 11039 { … … 11033 11085 /* lock all attached hard disks early to detect "in use" 11034 11086 * situations before deleting actual diffs */ 11035 for (MediaData::AttachmentList::const_iterator it = mMediaData->mAttachments.begin(); 11036 it != mMediaData->mAttachments.end(); 11037 ++it) 11087 for (MediumAttachmentList::const_iterator 11088 it = mMediumAttachments->begin(); 11089 it != mMediumAttachments->end(); 11090 ++it) 11038 11091 { 11039 MediumAttachment *pAtt = *it;11092 MediumAttachment *pAtt = *it; 11040 11093 if (pAtt->i_getType() == DeviceType_HardDisk) 11041 11094 { 11042 Medium *pMedium = pAtt->i_getMedium();11095 Medium *pMedium = pAtt->i_getMedium(); 11043 11096 Assert(pMedium); 11044 11097 … … 11072 11125 /* Go through remembered attachments and delete all implicitly created 11073 11126 * diffs and fix up the attachment information */ 11074 const MediaData::AttachmentList &oldAtts = mMediaData.backedUpData()->mAttachments; 11075 MediaData::AttachmentList implicitAtts; 11076 for (MediaData::AttachmentList::const_iterator it = mMediaData->mAttachments.begin(); 11077 it != mMediaData->mAttachments.end(); 11127 const MediumAttachmentList &oldAtts = *mMediumAttachments.backedUpData(); 11128 MediumAttachmentList implicitAtts; 11129 for (MediumAttachmentList::const_iterator 11130 it = mMediumAttachments->begin(); 11131 it != mMediumAttachments->end(); 11078 11132 ++it) 11079 11133 { … … 11123 11177 11124 11178 /* rollback hard disk changes */ 11125 mMedi aData.rollback();11179 mMediumAttachments.rollback(); 11126 11180 11127 11181 MultiResult mrc(S_OK); … … 11132 11186 alock.release(); 11133 11187 11134 for (MediaData::AttachmentList::const_iterator it = implicitAtts.begin(); it != implicitAtts.end(); ++it) 11188 for (MediumAttachmentList::const_iterator 11189 it = implicitAtts.begin(); 11190 it != implicitAtts.end(); 11191 ++it) 11135 11192 { 11136 11193 // Remove medium associated with this attachment. … … 11200 11257 * @return 11201 11258 */ 11202 MediumAttachment * Machine::i_findAttachment(const MediaData::AttachmentList &ll,11259 MediumAttachment *Machine::i_findAttachment(const MediumAttachmentList &ll, 11203 11260 const Utf8Str &aControllerName, 11204 11261 LONG aControllerPort, 11205 11262 LONG aDevice) 11206 11263 { 11207 for (MediaData::AttachmentList::const_iterator it = ll.begin(); it != ll.end(); ++it) 11264 for (MediumAttachmentList::const_iterator 11265 it = ll.begin(); 11266 it != ll.end(); 11267 ++it) 11208 11268 { 11209 11269 MediumAttachment *pAttach = *it; … … 11224 11284 * @return 11225 11285 */ 11226 MediumAttachment * Machine::i_findAttachment(const MediaData::AttachmentList &ll,11286 MediumAttachment *Machine::i_findAttachment(const MediumAttachmentList &ll, 11227 11287 ComObjPtr<Medium> pMedium) 11228 11288 { 11229 for (MediaData::AttachmentList::const_iterator it = ll.begin(); it != ll.end(); ++it) 11289 for (MediumAttachmentList::const_iterator 11290 it = ll.begin(); 11291 it != ll.end(); 11292 ++it) 11230 11293 { 11231 11294 MediumAttachment *pAttach = *it; … … 11247 11310 * @return 11248 11311 */ 11249 MediumAttachment * Machine::i_findAttachment(const MediaData::AttachmentList &ll,11312 MediumAttachment *Machine::i_findAttachment(const MediumAttachmentList &ll, 11250 11313 Guid &id) 11251 11314 { 11252 for (MediaData::AttachmentList::const_iterator it = ll.begin(); it != ll.end(); ++it) 11315 for (MediumAttachmentList::const_iterator 11316 it = ll.begin(); 11317 it != ll.end(); 11318 ++it) 11253 11319 { 11254 11320 MediumAttachment *pAttach = *it; … … 11290 11356 /// a special media state for it to make it even more simple. 11291 11357 11292 Assert(mMedi aData.isBackedUp());11358 Assert(mMediumAttachments.isBackedUp()); 11293 11359 11294 11360 /* will release the lock before the potentially lengthy operation, so … … 11310 11376 11311 11377 i_setModified(IsModified_Storage); 11312 mMedi aData.backup();11313 mMedi aData->mAttachments.remove(pAttach);11378 mMediumAttachments.backup(); 11379 mMediumAttachments->remove(pAttach); 11314 11380 11315 11381 if (!oldmedium.isNull()) … … 11364 11430 11365 11431 // make a temporary list because i_detachDevice invalidates iterators into 11366 // mMediaData->mAttachments 11367 MediaData::AttachmentList llAttachments2 = mMediaData->mAttachments; 11368 11369 for (MediaData::AttachmentList::iterator it = llAttachments2.begin(); it != llAttachments2.end(); ++it) 11432 // mMediumAttachments 11433 MediumAttachmentList llAttachments2 = *mMediumAttachments.data(); 11434 11435 for (MediumAttachmentList::iterator 11436 it = llAttachments2.begin(); 11437 it != llAttachments2.end(); 11438 ++it) 11370 11439 { 11371 11440 ComObjPtr<MediumAttachment> &pAttach = *it; … … 11428 11497 * Perform deferred hard disk detachments. 11429 11498 * 11430 * Does nothing if the hard disk attachment data (mMedi aData) is not changed (not11431 * backed up).11499 * Does nothing if the hard disk attachment data (mMediumAttachments) is not 11500 * changed (not backed up). 11432 11501 * 11433 * If @a aOnline is @c true then this method will also unlock the old hard disks11434 * for which the new implicit diffs were created and will lock these new diffs for11435 * writing.11502 * If @a aOnline is @c true then this method will also unlock the old hard 11503 * disks for which the new implicit diffs were created and will lock these new 11504 * diffs for writing. 11436 11505 * 11437 11506 * @param aOnline Whether the VM was online prior to this operation. … … 11451 11520 11452 11521 /* no attach/detach operations -- nothing to do */ 11453 if (!mMedi aData.isBackedUp())11522 if (!mMediumAttachments.isBackedUp()) 11454 11523 return; 11455 11524 11456 Medi aData::AttachmentList &oldAtts = mMediaData.backedUpData()->mAttachments;11525 MediumAttachmentList &oldAtts = *mMediumAttachments.backedUpData(); 11457 11526 bool fMediaNeedsLocking = false; 11458 11527 11459 11528 /* enumerate new attachments */ 11460 for (MediaData::AttachmentList::const_iterator it = mMediaData->mAttachments.begin(); 11461 it != mMediaData->mAttachments.end(); 11529 for (MediumAttachmentList::const_iterator 11530 it = mMediumAttachments->begin(); 11531 it != mMediumAttachments->end(); 11462 11532 ++it) 11463 11533 { … … 11466 11536 pAttach->i_commit(); 11467 11537 11468 Medium *pMedium = pAttach->i_getMedium();11538 Medium *pMedium = pAttach->i_getMedium(); 11469 11539 bool fImplicit = pAttach->i_isImplicit(); 11470 11540 … … 11511 11581 { 11512 11582 /* was this medium attached before? */ 11513 for (MediaData::AttachmentList::iterator oldIt = oldAtts.begin(); oldIt != oldAtts.end(); ++oldIt) 11583 for (MediumAttachmentList::iterator 11584 oldIt = oldAtts.begin(); 11585 oldIt != oldAtts.end(); 11586 ++oldIt) 11514 11587 { 11515 11588 MediumAttachment *pOldAttach = *oldIt; … … 11528 11601 /* enumerate remaining old attachments and de-associate from the 11529 11602 * current machine state */ 11530 for (MediaData::AttachmentList::const_iterator it = oldAtts.begin(); it != oldAtts.end(); ++it) 11603 for (MediumAttachmentList::const_iterator 11604 it = oldAtts.begin(); 11605 it != oldAtts.end(); 11606 ++it) 11531 11607 { 11532 11608 MediumAttachment *pAttach = *it; 11533 Medium *pMedium = pAttach->i_getMedium();11609 Medium *pMedium = pAttach->i_getMedium(); 11534 11610 11535 11611 /* Detach only hard disks, since DVD/floppy media is detached … … 11577 11653 11578 11654 /* commit the hard disk changes */ 11579 mMedi aData.commit();11655 mMediumAttachments.commit(); 11580 11656 11581 11657 if (i_isSessionMachine()) … … 11592 11668 * machine. 11593 11669 */ 11594 for (MediaData::AttachmentList::const_iterator it = mMediaData->mAttachments.begin(); 11595 it != mMediaData->mAttachments.end(); 11670 for (MediumAttachmentList::const_iterator 11671 it = mMediumAttachments->begin(); 11672 it != mMediumAttachments->end(); 11596 11673 ++it) 11597 11674 (*it)->i_updateParentMachine(mPeer); 11598 11675 11599 11676 /* attach new data to the primary machine and reshare it */ 11600 mPeer->mMedi aData.attach(mMediaData);11677 mPeer->mMediumAttachments.attach(mMediumAttachments); 11601 11678 } 11602 11679 … … 11607 11684 * Perform deferred deletion of implicitly created diffs. 11608 11685 * 11609 * Does nothing if the hard disk attachment data (mMedi aData) is not changed (not11610 * backed up).11686 * Does nothing if the hard disk attachment data (mMediumAttachments) is not 11687 * changed (not backed up). 11611 11688 * 11612 11689 * @note Locks this object for writing! … … 11623 11700 11624 11701 /* no attach/detach operations -- nothing to do */ 11625 if (!mMedi aData.isBackedUp())11702 if (!mMediumAttachments.isBackedUp()) 11626 11703 return; 11627 11704 11628 11705 /* enumerate new attachments */ 11629 for (MediaData::AttachmentList::const_iterator it = mMediaData->mAttachments.begin(); 11630 it != mMediaData->mAttachments.end(); 11706 for (MediumAttachmentList::const_iterator 11707 it = mMediumAttachments->begin(); 11708 it != mMediumAttachments->end(); 11631 11709 ++it) 11632 11710 { … … 11635 11713 if (pAttach->i_getType() != DeviceType_HardDisk) 11636 11714 { 11637 Medium *pMedium = pAttach->i_getMedium();11715 Medium *pMedium = pAttach->i_getMedium(); 11638 11716 if (pMedium) 11639 11717 { … … 11649 11727 if (pAttach->i_getType() != DeviceType_HardDisk) 11650 11728 { 11651 Medium *pMedium = pAttach->i_getMedium();11729 Medium *pMedium = pAttach->i_getMedium(); 11652 11730 if (pMedium) 11653 11731 { … … 11715 11793 { 11716 11794 /* unitialize all new devices (absent in the backed up list). */ 11717 StorageControllerList::const_iterator it = mStorageControllers->begin();11718 11795 StorageControllerList *backedList = mStorageControllers.backedUpData(); 11719 while (it != mStorageControllers->end()) 11796 for (StorageControllerList::const_iterator 11797 it = mStorageControllers->begin(); 11798 it != mStorageControllers->end(); 11799 ++it) 11720 11800 { 11721 11801 if ( std::find(backedList->begin(), backedList->end(), *it) … … 11725 11805 (*it)->uninit(); 11726 11806 } 11727 ++it;11728 11807 } 11729 11808 … … 11735 11814 if (mData->flModifications & IsModified_Storage) 11736 11815 { 11737 StorageControllerList::const_iterator it = mStorageControllers->begin(); 11738 while (it != mStorageControllers->end()) 11816 for (StorageControllerList::const_iterator 11817 it = mStorageControllers->begin(); 11818 it != mStorageControllers->end(); 11819 ++it) 11739 11820 { 11740 11821 (*it)->i_rollback(); 11741 ++it;11742 11822 } 11743 11823 } … … 11749 11829 { 11750 11830 /* unitialize all new devices (absent in the backed up list). */ 11751 USBControllerList::const_iterator it = mUSBControllers->begin();11752 11831 USBControllerList *backedList = mUSBControllers.backedUpData(); 11753 while (it != mUSBControllers->end()) 11832 for (USBControllerList::const_iterator 11833 it = mUSBControllers->begin(); 11834 it != mUSBControllers->end(); 11835 ++it) 11754 11836 { 11755 11837 if ( std::find(backedList->begin(), backedList->end(), *it) … … 11759 11841 (*it)->uninit(); 11760 11842 } 11761 ++it;11762 11843 } 11763 11844 … … 11769 11850 if (mData->flModifications & IsModified_USB) 11770 11851 { 11771 USBControllerList::const_iterator it = mUSBControllers->begin(); 11772 while (it != mUSBControllers->end()) 11852 for (USBControllerList::const_iterator 11853 it = mUSBControllers->begin(); 11854 it != mUSBControllers->end(); 11855 ++it) 11773 11856 { 11774 11857 (*it)->i_rollback(); 11775 ++it;11776 11858 } 11777 11859 } … … 11894 11976 mHWData.commit(); 11895 11977 11896 if (mMedi aData.isBackedUp())11978 if (mMediumAttachments.isBackedUp()) 11897 11979 i_commitMedia(Global::IsOnline(mData->mMachineState)); 11898 11980 … … 11968 12050 * peers for those who have peers) */ 11969 12051 StorageControllerList *newList = new StorageControllerList(); 11970 StorageControllerList::const_iterator it = mStorageControllers->begin(); 11971 while (it != mStorageControllers->end()) 12052 for (StorageControllerList::const_iterator 12053 it = mStorageControllers->begin(); 12054 it != mStorageControllers->end(); 12055 ++it) 11972 12056 { 11973 12057 (*it)->i_commit(); … … 11989 12073 /* and add it to the new list */ 11990 12074 newList->push_back(peer); 11991 11992 ++it;11993 12075 } 11994 12076 11995 12077 /* uninit old peer's controllers that are left */ 11996 it = mPeer->mStorageControllers->begin(); 11997 while (it != mPeer->mStorageControllers->end()) 12078 for (StorageControllerList::const_iterator 12079 it = mPeer->mStorageControllers->begin(); 12080 it != mPeer->mStorageControllers->end(); 12081 ++it) 11998 12082 { 11999 12083 (*it)->uninit(); 12000 ++it;12001 12084 } 12002 12085 … … 12020 12103 if (commitStorageControllers) 12021 12104 { 12022 StorageControllerList::const_iterator it = mStorageControllers->begin(); 12023 while (it != mStorageControllers->end()) 12105 for (StorageControllerList::const_iterator 12106 it = mStorageControllers->begin(); 12107 it != mStorageControllers->end(); 12108 ++it) 12024 12109 { 12025 12110 (*it)->i_commit(); 12026 ++it;12027 12111 } 12028 12112 } … … 12039 12123 * peers for those who have peers) */ 12040 12124 USBControllerList *newList = new USBControllerList(); 12041 USBControllerList::const_iterator it = mUSBControllers->begin(); 12042 while (it != mUSBControllers->end()) 12125 for (USBControllerList::const_iterator 12126 it = mUSBControllers->begin(); 12127 it != mUSBControllers->end(); 12128 ++it) 12043 12129 { 12044 12130 (*it)->i_commit(); … … 12060 12146 /* and add it to the new list */ 12061 12147 newList->push_back(peer); 12062 12063 ++it;12064 12148 } 12065 12149 12066 12150 /* uninit old peer's controllers that are left */ 12067 it = mPeer->mUSBControllers->begin(); 12068 while (it != mPeer->mUSBControllers->end()) 12151 for (USBControllerList::const_iterator 12152 it = mPeer->mUSBControllers->begin(); 12153 it != mPeer->mUSBControllers->end(); 12154 ++it) 12069 12155 { 12070 12156 (*it)->uninit(); 12071 ++it;12072 12157 } 12073 12158 … … 12091 12176 if (commitUSBControllers) 12092 12177 { 12093 USBControllerList::const_iterator it = mUSBControllers->begin(); 12094 while (it != mUSBControllers->end()) 12178 for (USBControllerList::const_iterator 12179 it = mUSBControllers->begin(); 12180 it != mUSBControllers->end(); 12181 ++it) 12095 12182 { 12096 12183 (*it)->i_commit(); 12097 ++it;12098 12184 } 12099 12185 } … … 12104 12190 mPeer->mUserData.attach(mUserData); 12105 12191 mPeer->mHWData.attach(mHWData); 12106 /* m MediaDatais reshared by fixupMedia */12107 // mPeer->mMedi aData.attach(mMediaData);12108 Assert(mPeer->mMedi aData.data() == mMediaData.data());12192 /* mmMediumAttachments is reshared by fixupMedia */ 12193 // mPeer->mMediumAttachments.attach(mMediumAttachments); 12194 Assert(mPeer->mMediumAttachments.data() == mMediumAttachments.data()); 12109 12195 } 12110 12196 } … … 12133 12219 // create copies of all shared folders (mHWData after attaching a copy 12134 12220 // contains just references to original objects) 12135 for (HWData::SharedFolderList::iterator it = mHWData->mSharedFolders.begin(); 12221 for (HWData::SharedFolderList::iterator 12222 it = mHWData->mSharedFolders.begin(); 12136 12223 it != mHWData->mSharedFolders.end(); 12137 12224 ++it) … … 12153 12240 mStorageControllers.backup(); 12154 12241 mStorageControllers->clear(); 12155 for (StorageControllerList::iterator it = aThat->mStorageControllers->begin(); 12242 for (StorageControllerList::const_iterator 12243 it = aThat->mStorageControllers->begin(); 12156 12244 it != aThat->mStorageControllers->end(); 12157 12245 ++it) … … 12166 12254 mUSBControllers.backup(); 12167 12255 mUSBControllers->clear(); 12168 for (USBControllerList::iterator it = aThat->mUSBControllers->begin(); 12256 for (USBControllerList::const_iterator 12257 it = aThat->mUSBControllers->begin(); 12169 12258 it != aThat->mUSBControllers->end(); 12170 12259 ++it) … … 12217 12306 void Machine::i_getDiskList(MediaList &list) 12218 12307 { 12219 for (MediaData::AttachmentList::const_iterator it = mMediaData->mAttachments.begin(); 12220 it != mMediaData->mAttachments.end(); 12308 for (MediumAttachmentList::const_iterator 12309 it = mMediumAttachments->begin(); 12310 it != mMediumAttachments->end(); 12221 12311 ++it) 12222 12312 { 12223 MediumAttachment *pAttach = *it;12313 MediumAttachment *pAttach = *it; 12224 12314 /* just in case */ 12225 12315 AssertContinue(pAttach); … … 12487 12577 mUserData.share(aMachine->mUserData); 12488 12578 mHWData.share(aMachine->mHWData); 12489 mMedi aData.share(aMachine->mMediaData);12579 mMediumAttachments.share(aMachine->mMediumAttachments); 12490 12580 12491 12581 mStorageControllers.allocate(); 12492 for (StorageControllerList::const_iterator it = aMachine->mStorageControllers->begin(); 12582 for (StorageControllerList::const_iterator 12583 it = aMachine->mStorageControllers->begin(); 12493 12584 it != aMachine->mStorageControllers->end(); 12494 12585 ++it) … … 12501 12592 12502 12593 mUSBControllers.allocate(); 12503 for (USBControllerList::const_iterator it = aMachine->mUSBControllers->begin(); 12594 for (USBControllerList::const_iterator 12595 it = aMachine->mUSBControllers->begin(); 12504 12596 it != aMachine->mUSBControllers->end(); 12505 12597 ++it) … … 12704 12796 mData->mSession.mRemoteControls.size())); 12705 12797 12706 Data::Session::RemoteControlList::iterator it = 12707 mData->mSession.mRemoteControls.begin(); 12708 while (it != mData->mSession.mRemoteControls.end()) 12798 /* Always restart a the beginning, since the iterator is invalidated 12799 * by using erase(). */ 12800 for (Data::Session::RemoteControlList::iterator 12801 it = mData->mSession.mRemoteControls.begin(); 12802 it != mData->mSession.mRemoteControls.end(); 12803 it = mData->mSession.mRemoteControls.begin()) 12709 12804 { 12710 12805 ComPtr<IInternalSessionControl> pControl = *it; … … 12717 12812 Log1WarningThisFunc(("Forgot to close the remote session?\n")); 12718 12813 multilock.acquire(); 12719 it = mData->mSession.mRemoteControls.begin();12720 12814 } 12721 12815 mData->mSession.mRemoteControls.clear(); … … 13128 13222 HRESULT SessionMachine::beginPowerUp(const ComPtr<IProgress> &aProgress) 13129 13223 { 13130 IProgress *pProgress(aProgress);13224 IProgress *pProgress(aProgress); 13131 13225 13132 13226 LogFlowThisFunc(("aProgress=%p\n", pProgress)); … … 13474 13568 { 13475 13569 /* the remote session is being normally closed */ 13476 Data::Session::RemoteControlList::iterator it = 13477 mData->mSession.mRemoteControls.begin(); 13478 while (it != mData->mSession.mRemoteControls.end()) 13570 bool found = false; 13571 for (Data::Session::RemoteControlList::iterator 13572 it = mData->mSession.mRemoteControls.begin(); 13573 it != mData->mSession.mRemoteControls.end(); 13574 ++it) 13479 13575 { 13480 13576 if (control == *it) 13577 { 13578 found = true; 13579 // This MUST be erase(it), not remove(*it) as the latter 13580 // triggers a very nasty use after free due to the place where 13581 // the value "lives". 13582 mData->mSession.mRemoteControls.erase(it); 13481 13583 break; 13482 ++it; 13483 } 13484 BOOL found = it != mData->mSession.mRemoteControls.end(); 13584 } 13585 } 13485 13586 ComAssertMsgRet(found, ("The session is not found in the session list!"), 13486 13587 E_INVALIDARG); 13487 // This MUST be erase(it), not remove(*it) as the latter triggers a13488 // very nasty use after free due to the place where the value "lives".13489 mData->mSession.mRemoteControls.erase(it);13490 13588 } 13491 13589 … … 13516 13614 13517 13615 size_t i = 0; 13518 for (HWData::GuestPropertyMap::iterator it = mHWData->mGuestProperties.begin(); 13616 for (HWData::GuestPropertyMap::const_iterator 13617 it = mHWData->mGuestProperties.begin(); 13519 13618 it != mHWData->mGuestProperties.end(); 13520 13619 ++it, ++i) … … 13676 13775 13677 13776 i_setModified(IsModified_Storage); 13678 mMedi aData.backup();13777 mMediumAttachments.backup(); 13679 13778 13680 13779 // The backup operation makes the pAttach reference point to the 13681 13780 // old settings. Re-get the correct reference. 13682 pAttach = i_findAttachment( mMediaData->mAttachments,13781 pAttach = i_findAttachment(*mMediumAttachments.data(), 13683 13782 ctrlName.raw(), 13684 13783 lPort, … … 14459 14558 14460 14559 /* Collect locking information for all medium objects attached to the VM. */ 14461 for (MediaData::AttachmentList::const_iterator it = mMediaData->mAttachments.begin(); 14462 it != mMediaData->mAttachments.end(); 14560 for (MediumAttachmentList::const_iterator 14561 it = mMediumAttachments->begin(); 14562 it != mMediumAttachments->end(); 14463 14563 ++it) 14464 14564 { 14465 MediumAttachment *pAtt = *it;14565 MediumAttachment *pAtt = *it; 14466 14566 DeviceType_T devType = pAtt->i_getType(); 14467 14567 Medium *pMedium = pAtt->i_getMedium(); … … 14730 14830 /* remove it from the settings representation */ 14731 14831 settings::GuestPropertiesList &llGuestProperties = mData->pMachineConfigFile->hardwareMachine.llGuestProperties; 14732 for (settings::GuestPropertiesList::iterator it = llGuestProperties.begin(); 14832 for (settings::GuestPropertiesList::iterator 14833 it = llGuestProperties.begin(); 14733 14834 it != llGuestProperties.end(); 14734 14835 /*nothing*/) … … 14750 14851 * keep everything in sync, as this is what the API keeps using. */ 14751 14852 HWData::GuestPropertyMap &llHWGuestProperties = mHWData->mGuestProperties; 14752 for (HWData::GuestPropertyMap::iterator it = llHWGuestProperties.begin(); 14853 for (HWData::GuestPropertyMap::iterator 14854 it = llHWGuestProperties.begin(); 14753 14855 it != llHWGuestProperties.end(); 14754 14856 /*nothing*/)
Note:
See TracChangeset
for help on using the changeset viewer.