VirtualBox

Ignore:
Timestamp:
Mar 16, 2017 2:06:27 PM (8 years ago)
Author:
vboxsync
Message:

Main/Machine+Snapshot+Appliance+StorageController: eliminate the one-member struct MediaData, as a preparation for later eliminating the Backupable<> template use in combination with anything containing a ComObjPtr (since these are not handled in a sensible way when creating a session or a snapshot anyway, needing more effort to fix than do right from the beginning). Additionally a lot of iterator loop cleanups, making proper use of scoping and const_iterator whenever possible. Also take the opportunity to improve the readability of some quite long lines. No behavior change intended.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/src-server/MachineImpl.cpp

    r65390 r66126  
    55
    66/*
    7  * Copyright (C) 2004-2016 Oracle Corporation
     7 * Copyright (C) 2004-2017 Oracle Corporation
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    225225
    226226Machine::HWData::~HWData()
    227 {
    228 }
    229 
    230 /////////////////////////////////////////////////////////////////////////////
    231 // Machine::HDData structure
    232 /////////////////////////////////////////////////////////////////////////////
    233 
    234 Machine::MediaData::MediaData()
    235 {
    236 }
    237 
    238 Machine::MediaData::~MediaData()
    239227{
    240228}
     
    10571045    aGroups.resize(mUserData->s.llGroups.size());
    10581046    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)
    10611051        aGroups[i] = (*it);
    10621052
     
    26502640    AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
    26512641
    2652     aMediumAttachments.resize(mMediaData->mAttachments.size());
     2642    aMediumAttachments.resize(mMediumAttachments->size());
    26532643    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)
    26562648        aMediumAttachments[i] = *it;
    26572649
     
    26922684    AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
    26932685
    2694     USBControllerList data = *mUSBControllers.data();
    2695     aUSBControllers.resize(data.size());
     2686    aUSBControllers.resize(mUSBControllers->size());
    26962687    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)
    26982692        aUSBControllers[i] = *it;
    26992693
     
    28682862    aSharedFolders.resize(mHWData->mSharedFolders.size());
    28692863    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)
    28722868        aSharedFolders[i] = *it;
    28732869
     
    29412937{
    29422938    AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
    2943     StorageControllerList data = *mStorageControllers.data();
     2939
     2940    aStorageControllers.resize(mStorageControllers->size());
    29442941    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)
    29472946        aStorageControllers[i] = *it;
     2947
    29482948    return S_OK;
    29492949}
     
    38583858    /* check if the device slot is already busy */
    38593859    MediumAttachment *pAttachTemp;
    3860     if ((pAttachTemp = i_findAttachment(mMediaData->mAttachments,
     3860    if ((pAttachTemp = i_findAttachment(*mMediumAttachments.data(),
    38613861                                        Bstr(aName).raw(),
    38623862                                        aControllerPort,
     
    38893889    AutoWriteLock mediumLock(medium COMMA_LOCKVAL_SRC_POS);
    38903890
    3891     if (    (pAttachTemp = i_findAttachment(mMediaData->mAttachments, medium))
     3891    if (    (pAttachTemp = i_findAttachment(*mMediumAttachments.data(), medium))
    38923892         && !medium.isNull()
    38933893       )
     
    39343934    {
    39353935        if (    aType == DeviceType_HardDisk
    3936              && mMediaData.isBackedUp())
    3937         {
    3938             const MediaData::AttachmentList &oldAtts = mMediaData.backedUpData()->mAttachments;
     3936             && mMediumAttachments.isBackedUp())
     3937        {
     3938            const MediumAttachmentList &oldAtts = *mMediumAttachments.backedUpData();
    39393939
    39403940            /* check if the medium was attached to the VM before we started
     
    39503950                    /* the simplest case: restore the whole attachment
    39513951                     * and return, nothing else to do */
    3952                     mMediaData->mAttachments.push_back(pAttachTemp);
     3952                    mMediumAttachments->push_back(pAttachTemp);
    39533953
    39543954                    /* Reattach the medium to the VM. */
     
    40154015             * attachments to make it possible to re-attach existing diffs to
    40164016             * another device slot w/o losing their contents */
    4017             if (mMediaData.isBackedUp())
     4017            if (mMediumAttachments.isBackedUp())
    40184018            {
    4019                 const MediaData::AttachmentList &oldAtts = mMediaData.backedUpData()->mAttachments;
    4020 
    4021                 MediaData::AttachmentList::const_iterator foundIt = oldAtts.end();
     4019                const MediumAttachmentList &oldAtts = *mMediumAttachments.backedUpData();
     4020
     4021                MediumAttachmentList::const_iterator foundIt = oldAtts.end();
    40224022                uint32_t foundLevel = 0;
    40234023
    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)
    40254028                {
    40264029                    uint32_t level = 0;
     
    40354038                        /* skip the hard disk if its currently attached (we
    40364039                         * cannot attach the same hard disk twice) */
    4037                         if (i_findAttachment(mMediaData->mAttachments,
     4040                        if (i_findAttachment(*mMediumAttachments.data(),
    40384041                                             pMedium))
    40394042                            continue;
     
    40484051                            /* the simplest case: restore the whole attachment
    40494052                             * and return, nothing else to do */
    4050                             mMediaData->mAttachments.push_back(*it);
     4053                            mMediumAttachments->push_back(*it);
    40514054
    40524055                            /* Reattach the medium to the VM. */
     
    41314134                AutoReadLock snapLock(snap COMMA_LOCKVAL_SRC_POS);
    41324135
    4133                 const MediaData::AttachmentList &snapAtts = snap->i_getSnapshotMachine()->mMediaData->mAttachments;
     4136                const MediumAttachmentList &snapAtts = *snap->i_getSnapshotMachine()->mMediumAttachments.data();
    41344137
    41354138                MediumAttachment *pAttachFound = NULL;
    41364139                uint32_t foundLevel = 0;
    41374140
    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)
    41394145                {
    41404146                    MediumAttachment *pAttach = *it;
     
    43174323    /* success: finally remember the attachment */
    43184324    i_setModified(IsModified_Storage);
    4319     mMediaData.backup();
    4320     mMediaData->mAttachments.push_back(attachment);
     4325    mMediumAttachments.backup();
     4326    mMediumAttachments->push_back(attachment);
    43214327
    43224328    mediumLock.release();
     
    44144420                        aName.c_str());
    44154421
    4416     MediumAttachment *pAttach = i_findAttachment(mMediaData->mAttachments,
     4422    MediumAttachment *pAttach = i_findAttachment(*mMediumAttachments.data(),
    44174423                                                 Bstr(aName).raw(),
    44184424                                                 aControllerPort,
     
    44714477                        Global::stringifyMachineState(mData->mMachineState));
    44724478
    4473     MediumAttachment *pAttach = i_findAttachment(mMediaData->mAttachments,
     4479    MediumAttachment *pAttach = i_findAttachment(*mMediumAttachments.data(),
    44744480                                                 Bstr(aName).raw(),
    44754481                                                 aControllerPort,
     
    44824488
    44834489    i_setModified(IsModified_Storage);
    4484     mMediaData.backup();
     4490    mMediumAttachments.backup();
    44854491
    44864492    AutoWriteLock attLock(pAttach COMMA_LOCKVAL_SRC_POS);
     
    45074513    if (FAILED(rc)) return rc;
    45084514
    4509     MediumAttachment *pAttach = i_findAttachment(mMediaData->mAttachments,
     4515    MediumAttachment *pAttach = i_findAttachment(*mMediumAttachments.data(),
    45104516                                                 Bstr(aName).raw(),
    45114517                                                 aControllerPort,
     
    45184524
    45194525    i_setModified(IsModified_Storage);
    4520     mMediaData.backup();
     4526    mMediumAttachments.backup();
    45214527
    45224528    AutoWriteLock attLock(pAttach COMMA_LOCKVAL_SRC_POS);
     
    45504556                        Global::stringifyMachineState(mData->mMachineState));
    45514557
    4552     MediumAttachment *pAttach = i_findAttachment(mMediaData->mAttachments,
     4558    MediumAttachment *pAttach = i_findAttachment(*mMediumAttachments.data(),
    45534559                                                 Bstr(aName).raw(),
    45544560                                                 aControllerPort,
     
    45614567
    45624568    i_setModified(IsModified_Storage);
    4563     mMediaData.backup();
     4569    mMediumAttachments.backup();
    45644570
    45654571    AutoWriteLock attLock(pAttach COMMA_LOCKVAL_SRC_POS);
     
    45934599                        Global::stringifyMachineState(mData->mMachineState));
    45944600
    4595     MediumAttachment *pAttach = i_findAttachment(mMediaData->mAttachments,
     4601    MediumAttachment *pAttach = i_findAttachment(*mMediumAttachments.data(),
    45964602                                                 Bstr(aName).raw(),
    45974603                                                 aControllerPort,
     
    46044610
    46054611    i_setModified(IsModified_Storage);
    4606     mMediaData.backup();
     4612    mMediumAttachments.backup();
    46074613
    46084614    AutoWriteLock attLock(pAttach COMMA_LOCKVAL_SRC_POS);
     
    46354641                        Global::stringifyMachineState(mData->mMachineState));
    46364642
    4637     MediumAttachment *pAttach = i_findAttachment(mMediaData->mAttachments,
     4643    MediumAttachment *pAttach = i_findAttachment(*mMediumAttachments.data(),
    46384644                                                 Bstr(aName).raw(),
    46394645                                                 aControllerPort,
     
    46624668
    46634669    i_setModified(IsModified_Storage);
    4664     mMediaData.backup();
     4670    mMediumAttachments.backup();
    46654671
    46664672    AutoWriteLock attLock(pAttach COMMA_LOCKVAL_SRC_POS);
     
    47034709                        Global::stringifyMachineState(mData->mMachineState));
    47044710
    4705     MediumAttachment *pAttach = i_findAttachment(mMediaData->mAttachments,
     4711    MediumAttachment *pAttach = i_findAttachment(*mMediumAttachments.data(),
    47064712                                                 Bstr(aName).raw(),
    47074713                                                 aControllerPort,
     
    47144720
    47154721    i_setModified(IsModified_Storage);
    4716     mMediaData.backup();
     4722    mMediumAttachments.backup();
    47174723
    47184724    IBandwidthGroup *iB = aBandwidthGroup;
     
    47904796                                  &mParent->i_getMediaTreeLockHandle() COMMA_LOCKVAL_SRC_POS);
    47914797
    4792     ComObjPtr<MediumAttachment> pAttach = i_findAttachment(mMediaData->mAttachments,
     4798    ComObjPtr<MediumAttachment> pAttach = i_findAttachment(*mMediumAttachments.data(),
    47934799                                                           Bstr(aName).raw(),
    47944800                                                           aControllerPort,
     
    48324838
    48334839    i_setModified(IsModified_Storage);
    4834     mMediaData.backup();
     4840    mMediumAttachments.backup();
    48354841
    48364842    {
    48374843        // The backup operation makes the pAttach reference point to the
    48384844        // old settings. Re-get the correct reference.
    4839         pAttach = i_findAttachment(mMediaData->mAttachments,
     4845        pAttach = i_findAttachment(*mMediumAttachments.data(),
    48404846                                   Bstr(aName).raw(),
    48414847                                   aControllerPort,
     
    48714877        if (!pMedium.isNull())
    48724878            pMedium->i_removeBackReference(mData->mUuid);
    4873         pAttach = i_findAttachment(mMediaData->mAttachments,
     4879        pAttach = i_findAttachment(*mMediumAttachments.data(),
    48744880                                   Bstr(aName).raw(),
    48754881                                   aControllerPort,
     
    49064912    aMedium = NULL;
    49074913
    4908     ComObjPtr<MediumAttachment> pAttach = i_findAttachment(mMediaData->mAttachments,
     4914    ComObjPtr<MediumAttachment> pAttach = i_findAttachment(*mMediumAttachments.data(),
    49094915                                                           Bstr(aName).raw(),
    49104916                                                           aControllerPort,
     
    49614967    aKeys.resize(mData->pMachineConfigFile->mapExtraDataItems.size());
    49624968    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();
    49644971         it != mData->pMachineConfigFile->mapExtraDataItems.end();
    49654972         ++it, ++i)
     
    51965203    MediaList llMedia;
    51975204
    5198     if (    !mMediaData.isNull()      // can be NULL if machine is inaccessible
    5199          && mMediaData->mAttachments.size()
     5205    if (    !mMediumAttachments.isNull()    // can be NULL if machine is inaccessible
     5206         && mMediumAttachments->size()
    52005207       )
    52015208    {
     
    52065213            return setError(VBOX_E_INVALID_OBJECT_STATE,
    52075214                            tr("Cannot unregister the machine '%s' because it has %d media attachments"),
    5208                             mUserData->s.strName.c_str(), mMediaData->mAttachments.size());
     5215                            mUserData->s.strName.c_str(), mMediumAttachments->size());
    52095216    }
    52105217
     
    52465253
    52475254    // return media to caller
     5255    aMedia.resize(llMedia.size());
    52485256    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)
    52515261        (*it).queryInterfaceTo(aMedia[i].asOutParam());
    52525262
     
    52815291            m_pMachine->i_deleteConfigHandler(*this);
    52825292        }
    5283         catch(...)
     5293        catch (...)
    52845294        {
    52855295            LogRel(("Some exception in the function Machine::i_deleteConfigHandler()\n"));
     
    53835393        // medium storage files from the IMedium list passed in, and the
    53845394        // 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)
    53875399        {
    53885400            const Utf8Str &strFile = *it;
    53895401            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
    53905405            int vrc = RTFileDelete(strFile.c_str());
    53915406            if (RT_FAILURE(vrc))
    53925407                throw setError(VBOX_E_IPRT_ERROR,
    53935408                               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;
    54065413
    54075414        /* delete the settings only when the file actually exists */
     
    59375944     * Look for matching patterns and build up a list.
    59385945     */
    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)
    59415950    {
    59425951        if (   strPatterns.isEmpty()
     
    59485957           )
    59495958            propMap.insert(*it);
    5950         ++it;
    59515959    }
    59525960
     
    59645972
    59655973    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)
    59685979    {
    59695980        aNames[i] = it->first;
     
    60496060                                                  std::vector<ComPtr<IMediumAttachment> > &aMediumAttachments)
    60506061{
    6051     MediaData::AttachmentList atts;
     6062    MediumAttachmentList atts;
    60526063
    60536064    HRESULT rc = i_getMediumAttachmentsOfController(aName, atts);
    60546065    if (FAILED(rc)) return rc;
    60556066
     6067    aMediumAttachments.resize(atts.size());
    60566068    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)
    60596073        (*it).queryInterfaceTo(aMediumAttachments[i].asOutParam());
    60606074
     
    60746088    aAttachment = NULL;
    60756089
    6076     ComObjPtr<MediumAttachment> pAttach = i_findAttachment(mMediaData->mAttachments,
     6090    ComObjPtr<MediumAttachment> pAttach = i_findAttachment(*mMediumAttachments.data(),
    60776091                                                           Bstr(aName).raw(),
    60786092                                                           aControllerPort,
     
    61186132    ULONG ulInstance = 0;
    61196133    bool fBootable = true;
    6120     for (StorageControllerList::const_iterator it = mStorageControllers->begin();
     6134    for (StorageControllerList::const_iterator
     6135         it = mStorageControllers->begin();
    61216136         it != mStorageControllers->end();
    61226137         ++it)
     
    61716186    AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
    61726187
    6173     for (StorageControllerList::const_iterator it = mStorageControllers->begin();
     6188    for (StorageControllerList::const_iterator
     6189         it = mStorageControllers->begin();
    61746190         it != mStorageControllers->end();
    61756191         ++it)
     
    62036219        if (aBootable == TRUE)
    62046220        {
    6205             for (StorageControllerList::const_iterator it = mStorageControllers->begin();
     6221            for (StorageControllerList::const_iterator
     6222                 it = mStorageControllers->begin();
    62066223                 it != mStorageControllers->end();
    62076224                 ++it)
     
    62516268        /* find all attached devices to the appropriate storage controller and detach them all */
    62526269        // 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();
    62576275             it != llAttachments2.end();
    62586276             ++it)
     
    67706788
    67716789        // 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();
    67746793             ++it)
    67756794        {
     
    68166835        if (FAILED(rc)) return rc;
    68176836
    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();
    68206840             ++it)
    68216841        {
     
    68596879
    68606880    aPCIDeviceAssignments.resize(mHWData->mPCIDeviceAssignments.size());
    6861 
    68626881    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();
    68646884         it != mHWData->mPCIDeviceAssignments.end();
    6865          ++i, ++it)
     6885         ++it, ++i)
    68666886        (*it).queryInterfaceTo(aPCIDeviceAssignments[i].asOutParam());
    68676887
     
    83578377    mUserData.allocate();
    83588378    mHWData.allocate();
    8359     mMediaData.allocate();
     8379    mMediumAttachments.allocate();
    83608380    mStorageControllers.allocate();
    83618381    mUSBControllers.allocate();
     
    85058525     * attachments will already be uninitialized and deleted, so this
    85068526     * code will not affect them. */
    8507     if (    !!mMediaData
    8508          && (!i_isSessionMachine())
     8527    if (    !mMediumAttachments.isNull()
     8528         && !i_isSessionMachine()
    85098529       )
    85108530    {
    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();
    85138534             ++it)
    85148535        {
     
    85398560    /* free data structures (the essential mData structure is not freed here
    85408561     * since it may be still in use) */
    8541     mMediaData.free();
     8562    mMediumAttachments.free();
    85428563    mStorageControllers.free();
    85438564    mUSBControllers.free();
     
    85558576 *  (primary) machine pointer.
    85568577 */
    8557 Machine* Machine::i_getMachine()
     8578Machine *Machine::i_getMachine()
    85588579{
    85598580    if (i_isSessionMachine())
     
    86648685{
    86658686    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)
    86698691    {
    86708692        SharedFolder *pSF = *it;
     
    88798901
    88808902    // 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();
    88828905         it != data.llChildSnapshots.end();
    88838906         ++it)
     
    89398962        if (mHWData->mCPUHotPlugEnabled)
    89408963        {
    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)
    89448968            {
    89458969                const settings::Cpu &cpu = *it;
     
    89508974
    89518975        // 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)
    89558980        {
    89568981            const settings::CpuIdLeaf &leaf = *it;
     
    90449069
    90459070        /* 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();
    90479073             it != data.usbSettings.llUSBControllers.end();
    90489074             ++it)
     
    90749100        else if (newCount < oldCount)
    90759101            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)
    90799106        {
    90809107            const settings::NetworkAdapter &nic = *it;
     
    90879114
    90889115        // 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)
    90929120        {
    90939121            const settings::SerialPort &s = *it;
     
    90999127
    91009128        // 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)
    91049133        {
    91059134            const settings::ParallelPort &p = *it;
     
    91219150
    91229151        /* Shared folders */
    9123         for (settings::SharedFoldersList::const_iterator it = data.llSharedFolders.begin();
     9152        for (settings::SharedFoldersList::const_iterator
     9153             it = data.llSharedFolders.begin();
    91249154             it != data.llSharedFolders.end();
    91259155             ++it)
     
    91629192
    91639193        // Host PCI devices
    9164         for (settings::HostPCIDeviceAttachmentList::const_iterator it = data.pciAttachments.begin();
     9194        for (settings::HostPCIDeviceAttachmentList::const_iterator
     9195             it = data.pciAttachments.begin();
    91659196             it != data.pciAttachments.end();
    91669197             ++it)
     
    91949225         * as there are no config changes. */
    91959226        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*/)
    91999231        {
    92009232            const settings::GuestProperty &prop = *it;
     
    92239255        mHWData->mDefaultFrontend = data.strDefaultFrontend;
    92249256    }
    9225     catch(std::bad_alloc &)
     9257    catch (std::bad_alloc &)
    92269258    {
    92279259        return E_OUTOFMEMORY;
     
    92629294    HRESULT rc = S_OK;
    92639295
    9264     for (settings::StorageControllersList::const_iterator it = data.llStorageControllers.begin();
     9296    for (settings::StorageControllersList::const_iterator
     9297         it = data.llStorageControllers.begin();
    92659298         it != data.llStorageControllers.end();
    92669299         ++it)
     
    93249357
    93259358    /* 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();
    93279361         it != data.llAttachedDevices.end();
    93289362         ++it)
     
    93529386    }
    93539387
    9354     for (settings::AttachedDevicesList::const_iterator it = data.llAttachedDevices.begin();
     9388    for (settings::AttachedDevicesList::const_iterator
     9389         it = data.llAttachedDevices.begin();
    93559390         it != data.llAttachedDevices.end();
    93569391         ++it)
     
    94529487                                    medium->i_getChildren().size());
    94539488
    9454                 if (i_findAttachment(mMediaData->mAttachments,
     9489                if (i_findAttachment(*mMediumAttachments.data(),
    94559490                                     medium))
    94569491                    return setError(E_FAIL,
     
    95319566            break;
    95329567
    9533         /* back up mMediaData to let registeredInit() properly rollback on failure
    9534          * (= limited accessibility) */
     9568        /* back up mMediumAttachments to let registeredInit() properly rollback
     9569         * on failure (= limited accessibility) */
    95359570        i_setModified(IsModified_Storage);
    9536         mMediaData.backup();
    9537         mMediaData->mAttachments.push_back(pAttachment);
     9571        mMediumAttachments.backup();
     9572        mMediumAttachments->push_back(pAttachment);
    95389573    }
    95399574
     
    96279662    AssertReturn(!aName.isEmpty(), E_INVALIDARG);
    96289663
    9629     for (StorageControllerList::const_iterator it = mStorageControllers->begin();
     9664    for (StorageControllerList::const_iterator
     9665         it = mStorageControllers->begin();
    96309666         it != mStorageControllers->end();
    96319667         ++it)
     
    96589694    AssertReturn(!aName.isEmpty(), E_INVALIDARG);
    96599695
    9660     for (USBControllerList::const_iterator it = mUSBControllers->begin();
     9696    for (USBControllerList::const_iterator
     9697         it = mUSBControllers->begin();
    96619698         it != mUSBControllers->end();
    96629699         ++it)
     
    96859722    ULONG cCtrls = 0;
    96869723
    9687     for (USBControllerList::const_iterator it = mUSBControllers->begin();
     9724    for (USBControllerList::const_iterator
     9725         it = mUSBControllers->begin();
    96889726         it != mUSBControllers->end();
    96899727         ++it)
     
    96979735
    96989736HRESULT Machine::i_getMediumAttachmentsOfController(const Utf8Str &aName,
    9699                                                     MediaData::AttachmentList &atts)
     9737                                                    MediumAttachmentList &atts)
    97009738{
    97019739    AutoCaller autoCaller(this);
     
    97049742    AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
    97059743
    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();
    97089747         ++it)
    97099748    {
     
    1034210381        /* USB Controller (required) */
    1034310382        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)
    1034510387        {
    1034610388            ComObjPtr<USBController> ctrl = *it;
     
    1041610458        /* Shared folders */
    1041710459        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)
    1042110464        {
    1042210465            SharedFolder *pSF = *it;
     
    1045110494        /* Host PCI devices */
    1045210495        data.pciAttachments.clear();
    10453         for (HWData::PCIDeviceAssignmentList::const_iterator it = mHWData->mPCIDeviceAssignments.begin();
     10496        for (HWData::PCIDeviceAssignmentList::const_iterator
     10497             it = mHWData->mPCIDeviceAssignments.begin();
    1045410498             it != mHWData->mPCIDeviceAssignments.end();
    1045510499             ++it)
     
    1046710511        data.llGuestProperties.clear();
    1046810512#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();
    1047010515             it != mHWData->mGuestProperties.end();
    1047110516             ++it)
     
    1050310548        data.strDefaultFrontend = mHWData->mDefaultFrontend;
    1050410549    }
    10505     catch(std::bad_alloc &)
     10550    catch (std::bad_alloc &)
    1050610551    {
    1050710552        return E_OUTOFMEMORY;
     
    1052110566    data.llStorageControllers.clear();
    1052210567
    10523     for (StorageControllerList::const_iterator it = mStorageControllers->begin();
     10568    for (StorageControllerList::const_iterator
     10569         it = mStorageControllers->begin();
    1052410570         it != mStorageControllers->end();
    1052510571         ++it)
     
    1056310609                                      settings::StorageController &data)
    1056410610{
    10565     MediaData::AttachmentList atts;
     10611    MediumAttachmentList atts;
    1056610612
    1056710613    HRESULT rc = i_getMediumAttachmentsOfController(aStorageController->i_getName(), atts);
     
    1056910615
    1057010616    data.llAttachedDevices.clear();
    10571     for (MediaData::AttachmentList::const_iterator it = atts.begin();
     10617    for (MediumAttachmentList::const_iterator
     10618         it = atts.begin();
    1057210619         it != atts.end();
    1057310620         ++it)
     
    1071810765 * from SessionMachine::BeginTakingSnapshot() and SessionMachine::restoreSnapshotHandler().
    1071910766 *
    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.
    1072510773 *
    1072610774 * Attachments with non-normal hard disks are left as is.
     
    1077910827            /* lock all attached hard disks early to detect "in use"
    1078010828             * 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();
    1078310832                 ++it)
    1078410833            {
    10785                 MediumAttachment* pAtt = *it;
     10834                MediumAttachment *pAtt = *it;
    1078610835                if (pAtt->i_getType() == DeviceType_HardDisk)
    1078710836                {
    10788                     Medium* pMedium = pAtt->i_getMedium();
     10837                    Medium *pMedium = pAtt->i_getMedium();
    1078910838                    Assert(pMedium);
    1079010839
     
    1082310872
    1082410873        /* remember the current list (note that we don't use backup() since
    10825          * mMediaData may be already backed up) */
    10826         MediaData::AttachmentList atts = mMediaData->mAttachments;
     10874         * mMediumAttachments may be already backed up) */
     10875        MediumAttachmentList atts = *mMediumAttachments.data();
    1082710876
    1082810877        /* start from scratch */
    10829         mMediaData->mAttachments.clear();
     10878        mMediumAttachments->clear();
    1083010879
    1083110880        /* go through remembered attachments and create diffs for normal hard
    1083210881         * disks and attach them */
    10833         for (MediaData::AttachmentList::const_iterator it = atts.begin();
     10882        for (MediumAttachmentList::const_iterator
     10883             it = atts.begin();
    1083410884             it != atts.end();
    1083510885             ++it)
    1083610886        {
    10837             MediumAttachment* pAtt = *it;
     10887            MediumAttachment *pAtt = *it;
    1083810888
    1083910889            DeviceType_T devType = pAtt->i_getType();
    10840             Medium* pMedium = pAtt->i_getMedium();
     10890            Medium *pMedium = pAtt->i_getMedium();
    1084110891
    1084210892            if (   devType != DeviceType_HardDisk
     
    1086010910                }
    1086110911
    10862                 mMediaData->mAttachments.push_back(pAtt);
     10912                mMediumAttachments->push_back(pAtt);
    1086310913                continue;
    1086410914            }
     
    1094110991            rc = lockedMediaMap->ReplaceKey(pAtt, attachment);
    1094210992            AssertComRCThrowRC(rc);
    10943             mMediaData->mAttachments.push_back(attachment);
     10993            mMediumAttachments->push_back(attachment);
    1094410994        }
    1094510995    }
     
    1096011010/**
    1096111011 * 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.
    1096311014 *
    1096411015 * Note that to delete hard disks created by #attachDevice() this method is
     
    1097811029
    1097911030    /* We absolutely must have backed up state. */
    10980     AssertReturn(mMediaData.isBackedUp(), E_FAIL);
     11031    AssertReturn(mMediumAttachments.isBackedUp(), E_FAIL);
    1098111032
    1098211033    /* Check if there are any implicitly created diff images. */
    1098311034    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();
    1098611038         ++it)
    1098711039    {
     
    1103311085            /* lock all attached hard disks early to detect "in use"
    1103411086             * 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)
    1103811091            {
    11039                 MediumAttachment* pAtt = *it;
     11092                MediumAttachment *pAtt = *it;
    1104011093                if (pAtt->i_getType() == DeviceType_HardDisk)
    1104111094                {
    11042                     Medium* pMedium = pAtt->i_getMedium();
     11095                    Medium *pMedium = pAtt->i_getMedium();
    1104311096                    Assert(pMedium);
    1104411097
     
    1107211125        /* Go through remembered attachments and delete all implicitly created
    1107311126         * 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();
    1107811132             ++it)
    1107911133        {
     
    1112311177
    1112411178        /* rollback hard disk changes */
    11125         mMediaData.rollback();
     11179        mMediumAttachments.rollback();
    1112611180
    1112711181        MultiResult mrc(S_OK);
     
    1113211186            alock.release();
    1113311187
    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)
    1113511192            {
    1113611193                // Remove medium associated with this attachment.
     
    1120011257 * @return
    1120111258 */
    11202 MediumAttachment* Machine::i_findAttachment(const MediaData::AttachmentList &ll,
     11259MediumAttachment *Machine::i_findAttachment(const MediumAttachmentList &ll,
    1120311260                                            const Utf8Str &aControllerName,
    1120411261                                            LONG aControllerPort,
    1120511262                                            LONG aDevice)
    1120611263{
    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)
    1120811268    {
    1120911269        MediumAttachment *pAttach = *it;
     
    1122411284 * @return
    1122511285 */
    11226 MediumAttachment* Machine::i_findAttachment(const MediaData::AttachmentList &ll,
     11286MediumAttachment *Machine::i_findAttachment(const MediumAttachmentList &ll,
    1122711287                                            ComObjPtr<Medium> pMedium)
    1122811288{
    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)
    1123011293    {
    1123111294        MediumAttachment *pAttach = *it;
     
    1124711310 * @return
    1124811311 */
    11249 MediumAttachment* Machine::i_findAttachment(const MediaData::AttachmentList &ll,
     11312MediumAttachment *Machine::i_findAttachment(const MediumAttachmentList &ll,
    1125011313                                            Guid &id)
    1125111314{
    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)
    1125311319    {
    1125411320        MediumAttachment *pAttach = *it;
     
    1129011356        /// a special media state for it to make it even more simple.
    1129111357
    11292         Assert(mMediaData.isBackedUp());
     11358        Assert(mMediumAttachments.isBackedUp());
    1129311359
    1129411360        /* will release the lock before the potentially lengthy operation, so
     
    1131011376
    1131111377    i_setModified(IsModified_Storage);
    11312     mMediaData.backup();
    11313     mMediaData->mAttachments.remove(pAttach);
     11378    mMediumAttachments.backup();
     11379    mMediumAttachments->remove(pAttach);
    1131411380
    1131511381    if (!oldmedium.isNull())
     
    1136411430
    1136511431    // 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)
    1137011439    {
    1137111440        ComObjPtr<MediumAttachment> &pAttach = *it;
     
    1142811497 * Perform deferred hard disk detachments.
    1142911498 *
    11430  * Does nothing if the hard disk attachment data (mMediaData) is not changed (not
    11431  * backed up).
     11499 * Does nothing if the hard disk attachment data (mMediumAttachments) is not
     11500 * changed (not backed up).
    1143211501 *
    11433  * If @a aOnline is @c true then this method will also unlock the old hard disks
    11434  * for which the new implicit diffs were created and will lock these new diffs for
    11435  * 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.
    1143611505 *
    1143711506 * @param aOnline       Whether the VM was online prior to this operation.
     
    1145111520
    1145211521    /* no attach/detach operations -- nothing to do */
    11453     if (!mMediaData.isBackedUp())
     11522    if (!mMediumAttachments.isBackedUp())
    1145411523        return;
    1145511524
    11456     MediaData::AttachmentList &oldAtts = mMediaData.backedUpData()->mAttachments;
     11525    MediumAttachmentList &oldAtts = *mMediumAttachments.backedUpData();
    1145711526    bool fMediaNeedsLocking = false;
    1145811527
    1145911528    /* 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();
    1146211532         ++it)
    1146311533    {
     
    1146611536        pAttach->i_commit();
    1146711537
    11468         Medium* pMedium = pAttach->i_getMedium();
     11538        Medium *pMedium = pAttach->i_getMedium();
    1146911539        bool fImplicit = pAttach->i_isImplicit();
    1147011540
     
    1151111581        {
    1151211582            /* 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)
    1151411587            {
    1151511588                MediumAttachment *pOldAttach = *oldIt;
     
    1152811601    /* enumerate remaining old attachments and de-associate from the
    1152911602     * 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)
    1153111607    {
    1153211608        MediumAttachment *pAttach = *it;
    11533         Medium* pMedium = pAttach->i_getMedium();
     11609        Medium *pMedium = pAttach->i_getMedium();
    1153411610
    1153511611        /* Detach only hard disks, since DVD/floppy media is detached
     
    1157711653
    1157811654    /* commit the hard disk changes */
    11579     mMediaData.commit();
     11655    mMediumAttachments.commit();
    1158011656
    1158111657    if (i_isSessionMachine())
     
    1159211668         *        machine.
    1159311669         */
    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();
    1159611673             ++it)
    1159711674            (*it)->i_updateParentMachine(mPeer);
    1159811675
    1159911676        /* attach new data to the primary machine and reshare it */
    11600         mPeer->mMediaData.attach(mMediaData);
     11677        mPeer->mMediumAttachments.attach(mMediumAttachments);
    1160111678    }
    1160211679
     
    1160711684 * Perform deferred deletion of implicitly created diffs.
    1160811685 *
    11609  * Does nothing if the hard disk attachment data (mMediaData) is not changed (not
    11610  * backed up).
     11686 * Does nothing if the hard disk attachment data (mMediumAttachments) is not
     11687 * changed (not backed up).
    1161111688 *
    1161211689 * @note Locks this object for writing!
     
    1162311700
    1162411701    /* no attach/detach operations -- nothing to do */
    11625     if (!mMediaData.isBackedUp())
     11702    if (!mMediumAttachments.isBackedUp())
    1162611703        return;
    1162711704
    1162811705    /* 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();
    1163111709         ++it)
    1163211710    {
     
    1163511713        if (pAttach->i_getType() != DeviceType_HardDisk)
    1163611714        {
    11637             Medium* pMedium = pAttach->i_getMedium();
     11715            Medium *pMedium = pAttach->i_getMedium();
    1163811716            if (pMedium)
    1163911717            {
     
    1164911727        if (pAttach->i_getType() != DeviceType_HardDisk)
    1165011728        {
    11651             Medium* pMedium = pAttach->i_getMedium();
     11729            Medium *pMedium = pAttach->i_getMedium();
    1165211730            if (pMedium)
    1165311731            {
     
    1171511793        {
    1171611794            /* unitialize all new devices (absent in the backed up list). */
    11717             StorageControllerList::const_iterator it = mStorageControllers->begin();
    1171811795            StorageControllerList *backedList = mStorageControllers.backedUpData();
    11719             while (it != mStorageControllers->end())
     11796            for (StorageControllerList::const_iterator
     11797                 it = mStorageControllers->begin();
     11798                 it != mStorageControllers->end();
     11799                 ++it)
    1172011800            {
    1172111801                if (   std::find(backedList->begin(), backedList->end(), *it)
     
    1172511805                    (*it)->uninit();
    1172611806                }
    11727                 ++it;
    1172811807            }
    1172911808
     
    1173511814        if (mData->flModifications & IsModified_Storage)
    1173611815        {
    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)
    1173911820            {
    1174011821                (*it)->i_rollback();
    11741                 ++it;
    1174211822            }
    1174311823        }
     
    1174911829        {
    1175011830            /* unitialize all new devices (absent in the backed up list). */
    11751             USBControllerList::const_iterator it = mUSBControllers->begin();
    1175211831            USBControllerList *backedList = mUSBControllers.backedUpData();
    11753             while (it != mUSBControllers->end())
     11832            for (USBControllerList::const_iterator
     11833                 it = mUSBControllers->begin();
     11834                 it != mUSBControllers->end();
     11835                 ++it)
    1175411836            {
    1175511837                if (   std::find(backedList->begin(), backedList->end(), *it)
     
    1175911841                    (*it)->uninit();
    1176011842                }
    11761                 ++it;
    1176211843            }
    1176311844
     
    1176911850        if (mData->flModifications & IsModified_USB)
    1177011851        {
    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)
    1177311856            {
    1177411857                (*it)->i_rollback();
    11775                 ++it;
    1177611858            }
    1177711859        }
     
    1189411976    mHWData.commit();
    1189511977
    11896     if (mMediaData.isBackedUp())
     11978    if (mMediumAttachments.isBackedUp())
    1189711979        i_commitMedia(Global::IsOnline(mData->mMachineState));
    1189811980
     
    1196812050             * peers for those who have peers) */
    1196912051            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)
    1197212056            {
    1197312057                (*it)->i_commit();
     
    1198912073                /* and add it to the new list */
    1199012074                newList->push_back(peer);
    11991 
    11992                 ++it;
    1199312075            }
    1199412076
    1199512077            /* 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)
    1199812082            {
    1199912083                (*it)->uninit();
    12000                 ++it;
    1200112084            }
    1200212085
     
    1202012103    if (commitStorageControllers)
    1202112104    {
    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)
    1202412109        {
    1202512110            (*it)->i_commit();
    12026             ++it;
    1202712111        }
    1202812112    }
     
    1203912123             * peers for those who have peers) */
    1204012124            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)
    1204312129            {
    1204412130                (*it)->i_commit();
     
    1206012146                /* and add it to the new list */
    1206112147                newList->push_back(peer);
    12062 
    12063                 ++it;
    1206412148            }
    1206512149
    1206612150            /* 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)
    1206912155            {
    1207012156                (*it)->uninit();
    12071                 ++it;
    1207212157            }
    1207312158
     
    1209112176    if (commitUSBControllers)
    1209212177    {
    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)
    1209512182        {
    1209612183            (*it)->i_commit();
    12097             ++it;
    1209812184        }
    1209912185    }
     
    1210412190        mPeer->mUserData.attach(mUserData);
    1210512191        mPeer->mHWData.attach(mHWData);
    12106         /* mMediaData is reshared by fixupMedia */
    12107         // mPeer->mMediaData.attach(mMediaData);
    12108         Assert(mPeer->mMediaData.data() == mMediaData.data());
     12192        /* mmMediumAttachments is reshared by fixupMedia */
     12193        // mPeer->mMediumAttachments.attach(mMediumAttachments);
     12194        Assert(mPeer->mMediumAttachments.data() == mMediumAttachments.data());
    1210912195    }
    1211012196}
     
    1213312219    // create copies of all shared folders (mHWData after attaching a copy
    1213412220    // 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();
    1213612223         it != mHWData->mSharedFolders.end();
    1213712224         ++it)
     
    1215312240    mStorageControllers.backup();
    1215412241    mStorageControllers->clear();
    12155     for (StorageControllerList::iterator it = aThat->mStorageControllers->begin();
     12242    for (StorageControllerList::const_iterator
     12243         it = aThat->mStorageControllers->begin();
    1215612244         it != aThat->mStorageControllers->end();
    1215712245         ++it)
     
    1216612254    mUSBControllers.backup();
    1216712255    mUSBControllers->clear();
    12168     for (USBControllerList::iterator it = aThat->mUSBControllers->begin();
     12256    for (USBControllerList::const_iterator
     12257         it = aThat->mUSBControllers->begin();
    1216912258         it != aThat->mUSBControllers->end();
    1217012259         ++it)
     
    1221712306void Machine::i_getDiskList(MediaList &list)
    1221812307{
    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();
    1222112311         ++it)
    1222212312    {
    12223         MediumAttachment* pAttach = *it;
     12313        MediumAttachment *pAttach = *it;
    1222412314        /* just in case */
    1222512315        AssertContinue(pAttach);
     
    1248712577    mUserData.share(aMachine->mUserData);
    1248812578    mHWData.share(aMachine->mHWData);
    12489     mMediaData.share(aMachine->mMediaData);
     12579    mMediumAttachments.share(aMachine->mMediumAttachments);
    1249012580
    1249112581    mStorageControllers.allocate();
    12492     for (StorageControllerList::const_iterator it = aMachine->mStorageControllers->begin();
     12582    for (StorageControllerList::const_iterator
     12583         it = aMachine->mStorageControllers->begin();
    1249312584         it != aMachine->mStorageControllers->end();
    1249412585         ++it)
     
    1250112592
    1250212593    mUSBControllers.allocate();
    12503     for (USBControllerList::const_iterator it = aMachine->mUSBControllers->begin();
     12594    for (USBControllerList::const_iterator
     12595         it = aMachine->mUSBControllers->begin();
    1250412596         it != aMachine->mUSBControllers->end();
    1250512597         ++it)
     
    1270412796                          mData->mSession.mRemoteControls.size()));
    1270512797
    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())
    1270912804        {
    1271012805            ComPtr<IInternalSessionControl> pControl = *it;
     
    1271712812                Log1WarningThisFunc(("Forgot to close the remote session?\n"));
    1271812813            multilock.acquire();
    12719             it = mData->mSession.mRemoteControls.begin();
    1272012814        }
    1272112815        mData->mSession.mRemoteControls.clear();
     
    1312813222HRESULT SessionMachine::beginPowerUp(const ComPtr<IProgress> &aProgress)
    1312913223{
    13130     IProgress* pProgress(aProgress);
     13224    IProgress *pProgress(aProgress);
    1313113225
    1313213226    LogFlowThisFunc(("aProgress=%p\n", pProgress));
     
    1347413568    {
    1347513569        /* 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)
    1347913575        {
    1348013576            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);
    1348113583                break;
    13482             ++it;
    13483         }
    13484         BOOL found = it != mData->mSession.mRemoteControls.end();
     13584            }
     13585        }
    1348513586        ComAssertMsgRet(found, ("The session is not found in the session list!"),
    1348613587                         E_INVALIDARG);
    13487         // This MUST be erase(it), not remove(*it) as the latter triggers a
    13488         // very nasty use after free due to the place where the value "lives".
    13489         mData->mSession.mRemoteControls.erase(it);
    1349013588    }
    1349113589
     
    1351613614
    1351713615    size_t  i = 0;
    13518     for (HWData::GuestPropertyMap::iterator it = mHWData->mGuestProperties.begin();
     13616    for (HWData::GuestPropertyMap::const_iterator
     13617         it = mHWData->mGuestProperties.begin();
    1351913618         it != mHWData->mGuestProperties.end();
    1352013619         ++it, ++i)
     
    1367613775
    1367713776        i_setModified(IsModified_Storage);
    13678         mMediaData.backup();
     13777        mMediumAttachments.backup();
    1367913778
    1368013779        // The backup operation makes the pAttach reference point to the
    1368113780        // old settings. Re-get the correct reference.
    13682         pAttach = i_findAttachment(mMediaData->mAttachments,
     13781        pAttach = i_findAttachment(*mMediumAttachments.data(),
    1368313782                                   ctrlName.raw(),
    1368413783                                   lPort,
     
    1445914558
    1446014559    /* 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();
    1446314563         ++it)
    1446414564    {
    14465         MediumAttachment* pAtt = *it;
     14565        MediumAttachment *pAtt = *it;
    1446614566        DeviceType_T devType = pAtt->i_getType();
    1446714567        Medium *pMedium = pAtt->i_getMedium();
     
    1473014830        /* remove it from the settings representation */
    1473114831        settings::GuestPropertiesList &llGuestProperties = mData->pMachineConfigFile->hardwareMachine.llGuestProperties;
    14732         for (settings::GuestPropertiesList::iterator it = llGuestProperties.begin();
     14832        for (settings::GuestPropertiesList::iterator
     14833             it = llGuestProperties.begin();
    1473314834             it != llGuestProperties.end();
    1473414835             /*nothing*/)
     
    1475014851         * keep everything in sync, as this is what the API keeps using. */
    1475114852        HWData::GuestPropertyMap &llHWGuestProperties = mHWData->mGuestProperties;
    14752         for (HWData::GuestPropertyMap::iterator it = llHWGuestProperties.begin();
     14853        for (HWData::GuestPropertyMap::iterator
     14854             it = llHWGuestProperties.begin();
    1475314855             it != llHWGuestProperties.end();
    1475414856             /*nothing*/)
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