VirtualBox

Changeset 35429 in vbox


Ignore:
Timestamp:
Jan 7, 2011 2:42:24 PM (14 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
69300
Message:

Main: fix bug that dvd/floppy host drives would not be restored from machine settings but always result in empty drives

Location:
trunk/src/VBox/Main
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/include/HostImpl.h

    r33540 r35429  
    109109
    110110    HRESULT getDrives(DeviceType_T mediumType, bool fRefresh, MediaList *&pll);
    111     HRESULT findHostDrive(DeviceType_T mediumType, const Guid &uuid, bool fRefresh, ComObjPtr<Medium> &pMedium);
     111    HRESULT findHostDriveById(DeviceType_T mediumType, const Guid &uuid, bool fRefresh, ComObjPtr<Medium> &pMedium);
     112    HRESULT findHostDriveByName(DeviceType_T mediumType, const Utf8Str &strLocationFull, bool fRefresh, ComObjPtr<Medium> &pMedium);
    112113
    113114#ifdef VBOX_WITH_USB
  • trunk/src/VBox/Main/src-server/HostImpl.cpp

    r35368 r35429  
    16841684 * @return VBOX_E_OBJECT_NOT_FOUND if not found, or S_OK if found, or errors from getDrives().
    16851685 */
    1686 HRESULT Host::findHostDrive(DeviceType_T mediumType,
    1687                             const Guid &uuid,
    1688                             bool fRefresh,
    1689                             ComObjPtr<Medium> &pMedium)
     1686HRESULT Host::findHostDriveById(DeviceType_T mediumType,
     1687                                const Guid &uuid,
     1688                                bool fRefresh,
     1689                                ComObjPtr<Medium> &pMedium)
    16901690{
    16911691    MediaList *pllMedia;
     
    17011701            Medium *pThis = *it;
    17021702            if (pThis->getId() == uuid)
     1703            {
     1704                pMedium = pThis;
     1705                return S_OK;
     1706            }
     1707        }
     1708    }
     1709
     1710    return VBOX_E_OBJECT_NOT_FOUND;
     1711}
     1712
     1713/**
     1714 * Goes through the list of host drives that would be returned by getDrives()
     1715 * and looks for a host drive with the given name. If found, it sets pMedium
     1716 * to that drive; otherwise returns VBOX_E_OBJECT_NOT_FOUND.
     1717 *
     1718 * @param mediumType Must be DeviceType_DVD or DeviceType_Floppy.
     1719 * @param strLocationFull Name (path) of host drive to look for.
     1720 * @param fRefresh Whether to refresh the host drives list (see getDrives())
     1721 * @param pMedium Medium object, if found…
     1722 * @return VBOX_E_OBJECT_NOT_FOUND if not found, or S_OK if found, or errors from getDrives().
     1723 */
     1724HRESULT Host::findHostDriveByName(DeviceType_T mediumType,
     1725                                  const Utf8Str &strLocationFull,
     1726                                  bool fRefresh,
     1727                                  ComObjPtr<Medium> &pMedium)
     1728{
     1729    MediaList *pllMedia;
     1730
     1731    AutoWriteLock wlock(m->drivesLock COMMA_LOCKVAL_SRC_POS);
     1732    HRESULT rc = getDrives(mediumType, fRefresh, pllMedia);
     1733    if (SUCCEEDED(rc))
     1734    {
     1735        for (MediaList::iterator it = pllMedia->begin();
     1736             it != pllMedia->end();
     1737             ++it)
     1738        {
     1739            Medium *pThis = *it;
     1740            if (pThis->getLocationFull() == strLocationFull)
    17031741            {
    17041742                pMedium = pThis;
  • trunk/src/VBox/Main/src-server/MachineImpl.cpp

    r35368 r35429  
    75297529            case DeviceType_Floppy:
    75307530            case DeviceType_DVD:
    7531                 rc = mParent->findRemoveableMedium(dev.deviceType, dev.uuid, false /* fRefresh */, medium);
     7531                if (dev.strHostDriveSrc.isNotEmpty())
     7532                    rc = mParent->host()->findHostDriveByName(dev.deviceType, dev.strHostDriveSrc, false /* fRefresh */, medium);
     7533                else
     7534                    rc = mParent->findRemoveableMedium(dev.deviceType, dev.uuid, false /* fRefresh */, medium);
    75327535                if (FAILED(rc))
    75337536                    return rc;
  • trunk/src/VBox/Main/src-server/VirtualBoxImpl.cpp

    r35368 r35429  
    28432843
    28442844    // first search for host drive with that UUID
    2845     HRESULT rc = m->pHost->findHostDrive(mediumType,
    2846                                          uuid,
    2847                                          fRefresh,
    2848                                          pMedium);
     2845    HRESULT rc = m->pHost->findHostDriveById(mediumType,
     2846                                             uuid,
     2847                                             fRefresh,
     2848                                             pMedium);
    28492849    if (rc == VBOX_E_OBJECT_NOT_FOUND)
    28502850                // then search for an image with that UUID
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette