VirtualBox

Changeset 23331 in vbox


Ignore:
Timestamp:
Sep 25, 2009 1:24:26 PM (15 years ago)
Author:
vboxsync
Message:

Main/MachineImpl: add paranoia to check for duplicate attachments

File:
1 edited

Legend:

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

    r23328 r23331  
    52805280 * @param aNode        <HardDiskAttachments> node.
    52815281 * @param aRegistered  true when the machine is being loaded on VirtualBox
    5282  *                      startup, or when a snapshot is being loaded (wchich
    5283  *                      currently can happen on startup only)
     5282 *                     startup, or when a snapshot is being loaded (wchich
     5283 *                     currently can happen on startup only)
    52845284 * @param aSnapshotId  pointer to the snapshot ID if this is a snapshot machine
    52855285 *
    5286  * @note Lock mParent for reading and hard disks for writing before calling.
     5286 * @note Lock mParent  for reading and hard disks for writing before calling.
    52875287 */
    52885288HRESULT Machine::loadStorageDevices(StorageController *aStorageController,
     
    53055305                        mUserData->mName.raw(),
    53065306                        data.llAttachedDevices.size());
     5307
     5308    /* paranoia: detect duplicate attachments */
     5309    for (settings::AttachedDevicesList::const_iterator it = data.llAttachedDevices.begin();
     5310         it != data.llAttachedDevices.end();
     5311         ++it)
     5312    {
     5313        for (settings::AttachedDevicesList::const_iterator it2 = it;
     5314             it2 != data.llAttachedDevices.end();
     5315             ++it2)
     5316        {
     5317            if (it == it2)
     5318                continue;
     5319
     5320            if (   (*it).lPort == (*it2).lPort
     5321                && (*it).lDevice == (*it2).lDevice)
     5322            {
     5323                return setError(E_FAIL,
     5324                                tr("Duplicate attachments for storage controller '%s', port %d, device %d of the virtual machine '%ls'"),
     5325                                aStorageController->name().raw(), (*it).lPort, (*it).lDevice, mUserData->mName.raw());
     5326            }
     5327        }
     5328    }
    53075329
    53085330    for (settings::AttachedDevicesList::const_iterator it = data.llAttachedDevices.begin();
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