VirtualBox

Changeset 42015 in vbox for trunk


Ignore:
Timestamp:
Jul 4, 2012 8:09:55 AM (13 years ago)
Author:
vboxsync
Message:

All attached devices will be detached automatically when a storage controller is removed from VM. Now this logic concentrated in the one place - function STDMETHODIMP Machine::RemoveStorageController.

File:
1 edited

Legend:

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

    r42000 r42015  
    58275827    if (FAILED(rc)) return rc;
    58285828
    5829     /* We can remove the controller only if there is no device attached. */
    5830     /* check if the device slot is already busy */
    5831     for (MediaData::AttachmentList::const_iterator it = mMediaData->mAttachments.begin();
    5832          it != mMediaData->mAttachments.end();
    5833          ++it)
    5834     {
    5835         if ((*it)->getControllerName() == aName)
    5836             return setError(VBOX_E_OBJECT_IN_USE,
    5837                             tr("Storage controller named '%ls' has still devices attached"),
    5838                             aName);
     5829    {/* find all attached devices to the appropriate storage controller and detach them all*/
     5830        MediaData::AttachmentList::const_iterator beginList = mMediaData->mAttachments.begin();
     5831        MediaData::AttachmentList::const_iterator endList = mMediaData->mAttachments.end();
     5832        LONG port = 0;
     5833        LONG device = 0;
     5834
     5835        for (MediaData::AttachmentList::const_iterator it = beginList;
     5836             it != endList;
     5837             it++)
     5838        {
     5839            if ((*it)->getControllerName() == aName)
     5840            {
     5841                port = (*it)->getPort();
     5842
     5843                device = (*it)->getDevice();
     5844
     5845                rc = DetachDevice(aName, port, device);
     5846                if (FAILED(rc)) return rc;
     5847            }
     5848        }
    58395849    }
    58405850
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