VirtualBox

Changeset 63581 in vbox


Ignore:
Timestamp:
Aug 18, 2016 10:58:11 AM (8 years ago)
Author:
vboxsync
Message:

bugref:4323. First implementation of Medium::setDescription().

File:
1 edited

Legend:

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

    r63563 r63581  
    17061706HRESULT Medium::setDescription(const com::Utf8Str &aDescription)
    17071707{
    1708 //     AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
    1709 
    1710     /// @todo update m->description and save the global registry (and local
     1708    /// @todo update m->strDescription and save the global registry (and local
    17111709    /// registries of portable VMs referring to this medium), this will also
    17121710    /// require to add the mRegistered flag to data
    1713     NOREF(aDescription);
    1714     ReturnComNotImplemented();
     1711
     1712    HRESULT rc = S_OK;
     1713
     1714    MediumLockList *pMediumLockList(new MediumLockList());
     1715
     1716    try
     1717    {
     1718        // locking: we need the tree lock first because we access parent pointers
     1719        // and we need to write-lock the media involved
     1720        uint32_t    cHandles    = 2;
     1721        LockHandle* pHandles[2] = { &m->pVirtualBox->i_getMediaTreeLockHandle(),
     1722                                    this->lockHandle() };
     1723
     1724        AutoWriteLock alock(cHandles,
     1725                            pHandles
     1726                            COMMA_LOCKVAL_SRC_POS);
     1727
     1728        /* Build the lock list. */
     1729        alock.release();
     1730        rc = i_createMediumLockList(true /* fFailIfInaccessible */,
     1731                                    this /* pToLockWrite */,
     1732                                    true /* fMediumLockWriteAll */,
     1733                                    NULL,
     1734                                    *pMediumLockList);
     1735        alock.acquire();
     1736
     1737        if (FAILED(rc))
     1738        {
     1739            throw setError(rc,
     1740                           tr("Failed to create medium lock list for '%s'"),
     1741                           i_getLocationFull().c_str());
     1742        }
     1743
     1744        alock.release();
     1745        rc = pMediumLockList->Lock();
     1746        alock.acquire();
     1747
     1748        if (FAILED(rc))
     1749        {
     1750            throw setError(rc,
     1751                           tr("Failed to lock media '%s'"),
     1752                           i_getLocationFull().c_str());
     1753        }
     1754
     1755        /* Set a new description */
     1756        if (SUCCEEDED(rc))
     1757        {
     1758            m->strDescription = aDescription;
     1759        }
     1760
     1761        // save the settings
     1762        i_markRegistriesModified();
     1763        m->pVirtualBox->i_saveModifiedRegistries();
     1764    }
     1765    catch (HRESULT aRC) { rc = aRC; }
     1766
     1767    delete pMediumLockList;
     1768
     1769    return rc;
    17151770}
    17161771
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