VirtualBox

Changeset 27256 in vbox


Ignore:
Timestamp:
Mar 10, 2010 4:50:08 PM (15 years ago)
Author:
vboxsync
Message:

Main: fix regressions with renaming VMs; as a welcome side effect, Machine::saveSettings() no longer implicitly calls VirtualBox::saveSettings() and therefore no longer requires the global VirtualBox lock

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

Legend:

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

    r27179 r27256  
    17191719    if (FAILED(rc)) return rc;
    17201720
    1721     BOOL *pb;
    1722 
    17231721    switch(property)
    17241722    {
     
    29282926    if (fNeedsSaveSettings)
    29292927    {
    2930         alock.release();
    2931         AutoWriteLock vboxlock(this COMMA_LOCKVAL_SRC_POS);
    2932         saveSettings();
     2928        bool fNeedsGlobalSaveSettings = false;
     2929        saveSettings(&fNeedsGlobalSaveSettings);
     2930
     2931        if (fNeedsGlobalSaveSettings)
     2932        {
     2933            alock.release();
     2934            AutoWriteLock vboxlock(this COMMA_LOCKVAL_SRC_POS);
     2935            mParent->saveSettings();
     2936        }
    29332937    }
    29342938
     
    33063310        }
    33073311
    3308         // data is changing and change not vetoed: then write it out under the locks
    3309 
    3310         // saveSettings() needs VirtualBox write lock
    3311         AutoMultiWriteLock2 alock(mParent, this COMMA_LOCKVAL_SRC_POS);
     3312        // data is changing and change not vetoed: then write it out under the lock
     3313        AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
    33123314
    33133315        if (getClassID() == clsidSnapshotMachine)
     
    33233325                // creates a new key if needed
    33243326
    3325         /* save settings on success */
    3326         HRESULT rc = saveSettings();
    3327         if (FAILED(rc)) return rc;
     3327        bool fNeedsGlobalSaveSettings = false;
     3328        saveSettings(&fNeedsGlobalSaveSettings);
     3329
     3330        if (fNeedsGlobalSaveSettings)
     3331        {
     3332            alock.release();
     3333            AutoWriteLock vboxlock(mParent COMMA_LOCKVAL_SRC_POS);
     3334            mParent->saveSettings();
     3335        }
    33283336    }
    33293337
     
    33403348    if (FAILED(autoCaller.rc())) return autoCaller.rc();
    33413349
    3342     /* saveSettings() needs mParent lock */
    3343     AutoMultiWriteLock2 alock(mParent, this COMMA_LOCKVAL_SRC_POS);
     3350    AutoWriteLock mlock(this COMMA_LOCKVAL_SRC_POS);
    33443351
    33453352    /* when there was auto-conversion, we want to save the file even if
     
    33523359
    33533360    /* save all VM data excluding snapshots */
    3354     return saveSettings();
     3361    bool fNeedsGlobalSaveSettings = false;
     3362    rc = saveSettings(&fNeedsGlobalSaveSettings);
     3363    mlock.release();
     3364
     3365    if (SUCCEEDED(rc) && fNeedsGlobalSaveSettings)
     3366    {
     3367        AutoWriteLock vlock(mParent COMMA_LOCKVAL_SRC_POS);
     3368        rc = mParent->saveSettings();
     3369    }
     3370
     3371    return rc;
    33553372}
    33563373
     
    54765493       )
    54775494    {
    5478         rc = saveSettings();
     5495        rc = saveSettings(NULL);
     5496                // no need to check whether VirtualBox.xml needs saving too since
     5497                // we can't have a machine XML file rename pending
    54795498        if (FAILED(rc)) return rc;
    54805499    }
     
    68406859 *  @param aNew     receives |true| if a virgin settings file was created.
    68416860 */
    6842 HRESULT Machine::prepareSaveSettings(bool &aRenamed,
    6843                                      bool &aNew)
    6844 {
    6845     /* Note: tecnhically, mParent needs to be locked only when the machine is
    6846      * registered (see prepareSaveSettings() for details) but we don't
    6847      * currently differentiate it in callers of saveSettings() so we don't
    6848      * make difference here too.  */
    6849     AssertReturn(mParent->isWriteLockOnCurrentThread(), E_FAIL);
     6861HRESULT Machine::prepareSaveSettings(bool *pfNeedsGlobalSaveSettings)
     6862{
    68506863    AssertReturn(isWriteLockOnCurrentThread(), E_FAIL);
    68516864
    68526865    HRESULT rc = S_OK;
    68536866
    6854     aRenamed = false;
    6855 
    6856     /* if we're ready and isConfigLocked() is FALSE then it means
    6857      * that no config file exists yet (we will create a virgin one) */
    6858     aNew = !mData->m_pMachineConfigFile->fileExists();
     6867    bool fSettingsFileIsNew = !mData->m_pMachineConfigFile->fileExists();
    68596868
    68606869    /* attempt to rename the settings file if machine name is changed */
     
    68646873       )
    68656874    {
    6866         aRenamed = true;
    6867 
    68686875        bool dirRenamed = false;
    68696876        bool fileRenamed = false;
     
    68936900                 * above and because name != newName */
    68946901                Assert(configDir != newConfigDir);
    6895                 if (!aNew)
     6902                if (!fSettingsFileIsNew)
    68966903                {
    68976904                    /* perform real rename only if the machine is not new */
     
    69216928                                        RTPATH_DELIMITER,
    69226929                                        RTPathFilename(configFile.c_str()));
    6923                 if (!aNew)
     6930                if (!fSettingsFileIsNew)
    69246931                {
    69256932                    /* perform real rename only if the machine is not new */
     
    69396946
    69406947            /* update m_strConfigFileFull amd mConfigFile */
    6941             Utf8Str oldConfigFileFull = mData->m_strConfigFileFull;
    6942             Utf8Str oldConfigFile = mData->m_strConfigFile;
    69436948            mData->m_strConfigFileFull = newConfigFile;
    6944             /* try to get the relative path for mConfigFile */
     6949
     6950            // compute the relative path too
    69456951            Utf8Str path = newConfigFile;
    69466952            mParent->calculateRelativePath(path, path);
    69476953            mData->m_strConfigFile = path;
    69486954
    6949             /* last, try to update the global settings with the new path */
    6950             if (mData->mRegistered)
     6955            // store the old and new so that VirtualBox::saveSettings() can update
     6956            // the media registry
     6957            if (    mData->mRegistered
     6958                 && configDir != newConfigDir)
    69516959            {
    6952                 rc = mParent->updatePathInMediaRegistry(configDir.c_str(), newConfigDir.c_str());
    6953                 if (FAILED(rc))
    6954                 {
    6955                     /* revert to old values */
    6956                     mData->m_strConfigFileFull = oldConfigFileFull;
    6957                     mData->m_strConfigFile = oldConfigFile;
    6958                     break;
    6959                 }
     6960                mParent->rememberMachineNameChangeForMedia(configDir, newConfigDir);
     6961
     6962                if (pfNeedsGlobalSaveSettings)
     6963                    *pfNeedsGlobalSaveSettings = true;
    69606964            }
    69616965
     
    70017005    }
    70027006
    7003     if (aNew)
     7007    if (fSettingsFileIsNew)
    70047008    {
    70057009        /* create a virgin config file */
     
    70537057 *    change machine data directly, not through the backup()/commit() mechanism.
    70547058 *
    7055  * @note Must be called from under mParent write lock (sometimes needed by
    7056  * #prepareSaveSettings()) and this object's write lock. Locks children for
    7057  * writing. There is one exception when mParent is unused and therefore may be
    7058  * left unlocked: if this machine is an unregistered one.
     7059 * @note Must be called from under this object's write lock. Locks children for
     7060 * writing.
     7061 *
     7062 * @param pfNeedsGlobalSaveSettings Optional pointer to a bool that must have been
     7063 *          initialized to false and that will be set to true by this function if
     7064 *          the caller must invoke VirtualBox::saveSettings() because the global
     7065 *          settings have changed. This will happen if a machine rename has been
     7066 *          saved and the global machine and media registries will therefore need
     7067 *          updating.
    70597068 */
    7060 HRESULT Machine::saveSettings(int aFlags /*= 0*/)
     7069HRESULT Machine::saveSettings(bool *pfNeedsGlobalSaveSettings,
     7070                              int aFlags /*= 0*/)
    70617071{
    70627072    LogFlowThisFuncEnter();
    70637073
    7064     /* Note: tecnhically, mParent needs to be locked only when the machine is
    7065      * registered (see prepareSaveSettings() for details) but we don't
    7066      * currently differentiate it in callers of saveSettings() so we don't
    7067      * make difference here too.  */
    7068     AssertReturn(mParent->isWriteLockOnCurrentThread(), E_FAIL);
    70697074    AssertReturn(isWriteLockOnCurrentThread(), E_FAIL);
    70707075
     
    70837088     * settings directory and file if the machine name was changed and about
    70847089     * creating a new settings file if this is a new machine. */
    7085     bool fIsRenamed = false;
    7086     bool fIsNew = false;
    7087     rc = prepareSaveSettings(fIsRenamed, fIsNew);
     7090    rc = prepareSaveSettings(pfNeedsGlobalSaveSettings);
    70887091    if (FAILED(rc)) return rc;
    70897092
     
    1020110204
    1020210205        /* save all VM settings */
    10203         rc = saveSettings();
     10206        rc = saveSettings(NULL);
     10207                // no need to check whether VirtualBox.xml needs saving also since
     10208                // we can't have a name change pending at this point
    1020410209    }
    1020510210    else
  • trunk/src/VBox/Main/MediumImpl.cpp

    r27232 r27256  
    28942894    LogFlowThisFunc(("locationFull.before='%s'\n", m->strLocationFull.raw()));
    28952895
    2896     Utf8Str path = m->strLocationFull;
    2897 
    2898     if (RTPathStartsWith(path.c_str(), aOldPath))
    2899     {
    2900         Utf8Str newPath = Utf8StrFmt("%s%s", aNewPath,
    2901                                      path.raw() + strlen(aOldPath));
    2902         path = newPath;
    2903 
     2896    const char *pcszMediumPath = m->strLocationFull.c_str();
     2897
     2898    if (RTPathStartsWith(pcszMediumPath, aOldPath))
     2899    {
     2900        Utf8Str newPath = Utf8StrFmt("%s%s",
     2901                                     aNewPath,
     2902                                     pcszMediumPath + strlen(aOldPath));
     2903        Utf8Str path = newPath;
    29042904        m->pVirtualBox->calculateRelativePath(path, path);
    2905 
    29062905        unconst(m->strLocationFull) = newPath;
    29072906        unconst(m->strLocation) = path;
  • trunk/src/VBox/Main/SnapshotImpl.cpp

    r26753 r27256  
    12601260        /* save all current settings to ensure current changes are committed and
    12611261         * hard disks are fixed up */
    1262 
    1263         // VirtualBox lock before machine lock
    1264         alock.release();
    1265         AutoWriteLock vboxLock(mParent COMMA_LOCKVAL_SRC_POS);
    1266         alock.acquire();
    1267         HRESULT rc = saveSettings();
     1262        HRESULT rc = saveSettings(NULL);
     1263                // no need to check for whether VirtualBox.xml needs changing since
     1264                // we can't have a machine XML rename pending at this point
    12681265        if (FAILED(rc)) return rc;
    12691266    }
     
    14631460            mData->mCurrentStateModified = FALSE;
    14641461
    1465         rc = saveSettings();
     1462        rc = saveSettings(NULL);
     1463                // no need to change for whether VirtualBox.xml needs saving since
     1464                // we can't have a machine XML rename pending at this point
    14661465    }
    14671466
     
    18501849        }
    18511850
    1852         alock.leave();
    1853 
    1854         AutoWriteLock vboxLock(mParent COMMA_LOCKVAL_SRC_POS);
    1855         alock.enter();
    1856 
    18571851        // save machine settings, reset the modified flag and commit;
    1858         rc = saveSettings(SaveS_ResetCurStateModified | saveFlags);
     1852        rc = saveSettings(&fNeedsSaveSettings, SaveS_ResetCurStateModified | saveFlags);
    18591853        if (FAILED(rc)) throw rc;
    18601854
    18611855        // let go of the locks while we're deleting image files below
    18621856        alock.leave();
    1863         vboxLock.release();
    1864 
    18651857        // from here on we cannot roll back on failure any more
    18661858
     
    18811873        {
    18821874            // finally, VirtualBox.xml needs saving too
    1883             vboxLock.acquire();
     1875            AutoWriteLock vboxLock(mParent COMMA_LOCKVAL_SRC_POS);
    18841876            mParent->saveSettings();
    18851877        }
     
    19521944    AssertComRCReturn(autoCaller.rc(), autoCaller.rc());
    19531945
    1954     /* saveSettings() needs mParent lock */
    1955     AutoMultiWriteLock2 alock(mParent, this COMMA_LOCKVAL_SRC_POS);
     1946    AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
    19561947
    19571948    // machine must not be running
     
    19791970        if (m_flModifications)
    19801971        {
    1981             rc = saveSettings();
     1972            rc = saveSettings(NULL);
     1973                // no need to change for whether VirtualBox.xml needs saving since
     1974                // we can't have a machine XML rename pending at this point
    19821975            if (FAILED(rc)) return rc;
    19831976        }
     
    24042397        if (fMachineSettingsChanged || fNeedsSaveSettings)
    24052398        {
    2406             // saveSettings needs VirtualBox write lock in addition to our own
    2407             // (parent -> child locking order!)
    2408             AutoWriteLock vboxLock(mParent COMMA_LOCKVAL_SRC_POS);
    2409 
    24102399            if (fMachineSettingsChanged)
    24112400            {
    24122401                AutoWriteLock machineLock(this COMMA_LOCKVAL_SRC_POS);
    2413                 saveSettings(SaveS_InformCallbacksAnyway);
     2402                saveSettings(&fNeedsSaveSettings, SaveS_InformCallbacksAnyway);
    24142403            }
    24152404
    24162405            if (fNeedsSaveSettings)
     2406            {
     2407                AutoWriteLock vboxLock(mParent COMMA_LOCKVAL_SRC_POS);
    24172408                mParent->saveSettings();
     2409            }
    24182410        }
    24192411    }
  • trunk/src/VBox/Main/VirtualBoxImpl.cpp

    r27179 r27256  
    223223    // All the media lists are protected by the following locking handle:
    224224    RWLockHandle                        lockMedia;
    225     MediaOList                          ollHardDisks,
     225    MediaOList                          ollHardDisks,           // base images only!
    226226                                        ollDVDImages,
    227227                                        ollFloppyImages;
     
    231231    HardDiskMap                         mapHardDisks;
    232232
     233    // list of pending machine renames (also protected by media tree lock;
     234    // see VirtualBox::rememberMachineNameChangeForMedia())
     235    struct PendingMachineRename
     236    {
     237        Utf8Str     strConfigDirOld;
     238        Utf8Str     strConfigDirNew;
     239    };
     240    typedef std::list<PendingMachineRename> PendingMachineRenamesList;
     241    PendingMachineRenamesList           llPendingMachineRenames;
     242
    233243    RWLockHandle                        lockSharedFolders;
    234244    SharedFoldersOList                  ollSharedFolders;
     
    240250    ProgressMap                         mapProgressOperations;
    241251    CallbackList                        llCallbacks;
    242 
    243252
    244253    // the following are data for the client watcher thread
     
    32453254
    32463255/**
     3256 * Called from Machine::prepareSaveSettings() when it has detected
     3257 * that a machine has been renamed. Such renames will require
     3258 * updating the global media registry during the
     3259 * VirtualBox::saveSettings() that follows later.
     3260*
     3261 * When a machine is renamed, there may well be media (in particular,
     3262 * diff images for snapshots) in the global registry that will need
     3263 * to have their paths updated. Before 3.2, Machine::saveSettings
     3264 * used to call VirtualBox::saveSettings implicitly, which was both
     3265 * unintuitive and caused locking order problems. Now, we remeber
     3266 * such pending name changes with this method so that
     3267 * VirtualBox::saveSettings() can process them properly.
     3268 */
     3269void VirtualBox::rememberMachineNameChangeForMedia(const Utf8Str &strOldConfigDir,
     3270                                                   const Utf8Str &strNewConfigDir)
     3271{
     3272    AutoWriteLock mediaLock(getMediaTreeLockHandle() COMMA_LOCKVAL_SRC_POS);
     3273
     3274    Data::PendingMachineRename pmr;
     3275    pmr.strConfigDirOld = strOldConfigDir;
     3276    pmr.strConfigDirNew = strNewConfigDir;
     3277    m->llPendingMachineRenames.push_back(pmr);
     3278}
     3279
     3280/**
    32473281 *  Helper function to write out the configuration tree.
    32483282 *
    3249  *  @note Locks this object for writing and child objects for reading/writing!
     3283 *  @note Caller must have locked the VirtualBox object for writing!
    32503284 */
    32513285HRESULT VirtualBox::saveSettings()
     
    32543288    AssertComRCReturn(autoCaller.rc(), autoCaller.rc());
    32553289
     3290    AssertReturn(isWriteLockOnCurrentThread(), E_FAIL);
    32563291    AssertReturn(!m->strSettingsFilePath.isEmpty(), E_FAIL);
    32573292
     
    32603295    try
    32613296    {
     3297        // lock the lists while we're here
     3298        AutoReadLock machinesLock(m->ollMachines.getLockHandle() COMMA_LOCKVAL_SRC_POS);
     3299
    32623300        // machines
    32633301        settings::MachinesRegistry machinesTemp;
    32643302        {
    3265             AutoReadLock al(m->ollMachines.getLockHandle() COMMA_LOCKVAL_SRC_POS);
    32663303            for (MachinesOList::iterator it = m->ollMachines.begin();
    32673304                 it != m->ollMachines.end();
    32683305                 ++it)
    32693306            {
     3307                Machine *pMachine = *it;
     3308                // save actual machine registry entry
    32703309                settings::MachineRegistryEntry mre;
    3271                 rc = (*it)->saveRegistryEntry(mre);
     3310                rc = pMachine->saveRegistryEntry(mre);
    32723311                machinesTemp.push_back(mre);
    32733312            }
    32743313        }
    32753314
     3315        // lock all media for the following; use a write lock because we're
     3316        // modifying the PendingMachineRenamesList, which is protected by this
     3317        AutoWriteLock mediaLock(getMediaTreeLockHandle() COMMA_LOCKVAL_SRC_POS);
     3318
     3319        // if a machine was renamed, then we'll need to refresh media paths
     3320        if (m->llPendingMachineRenames.size())
     3321        {
     3322            // make a single list from the three media lists so we don't need three loops
     3323            MediaList llAllMedia;
     3324            // with hard disks, we must use the map, not the list, because the list only has base images
     3325            for (HardDiskMap::iterator it = m->mapHardDisks.begin(); it != m->mapHardDisks.end(); ++it)
     3326                llAllMedia.push_back(it->second);
     3327            for (MediaList::iterator it = m->ollDVDImages.begin(); it != m->ollDVDImages.end(); ++it)
     3328                llAllMedia.push_back(*it);
     3329            for (MediaList::iterator it = m->ollFloppyImages.begin(); it != m->ollFloppyImages.end(); ++it)
     3330                llAllMedia.push_back(*it);
     3331
     3332            for (MediaList::iterator it = llAllMedia.begin();
     3333                 it != llAllMedia.end();
     3334                 ++it)
     3335            {
     3336                Medium *pMedium = *it;
     3337                for (Data::PendingMachineRenamesList::iterator it2 = m->llPendingMachineRenames.begin();
     3338                     it2 != m->llPendingMachineRenames.end();
     3339                     ++it2)
     3340                {
     3341                    const Data::PendingMachineRename &pmr = *it2;
     3342                    const char *pcszOld = pmr.strConfigDirOld.c_str();
     3343                    const char *pcszNew = pmr.strConfigDirNew.c_str();
     3344                    pMedium->updatePath(pcszOld, pcszNew);
     3345                }
     3346            }
     3347            // done, don't do it again until we have more machine renames
     3348            m->llPendingMachineRenames.clear();
     3349        }
     3350
    32763351        // hard disks
    32773352        settings::MediaList hardDisksTemp;
    3278         {
    3279             AutoReadLock al(m->ollHardDisks.getLockHandle() COMMA_LOCKVAL_SRC_POS);
    3280             for (MediaList::const_iterator it = m->ollHardDisks.begin();
    3281                  it != m->ollHardDisks.end();
    3282                  ++it)
    3283             {
    3284                 settings::Medium med;
    3285                 rc = (*it)->saveSettings(med);
    3286                 if (FAILED(rc)) throw rc;
    3287                 hardDisksTemp.push_back(med);
    3288             }
     3353        for (MediaList::const_iterator it = m->ollHardDisks.begin();
     3354                it != m->ollHardDisks.end();
     3355                ++it)
     3356        {
     3357            settings::Medium med;
     3358            rc = (*it)->saveSettings(med);     // this recurses into its children
     3359            if (FAILED(rc)) throw rc;
     3360            hardDisksTemp.push_back(med);
    32893361        }
    32903362
    32913363        /* CD/DVD images */
    32923364        settings::MediaList dvdsTemp;
    3293         {
    3294             AutoReadLock al(m->ollDVDImages.getLockHandle() COMMA_LOCKVAL_SRC_POS);
    3295             for (MediaList::const_iterator it = m->ollDVDImages.begin();
    3296                  it != m->ollDVDImages.end();
    3297                  ++it)
    3298             {
    3299                 settings::Medium med;
    3300                 rc = (*it)->saveSettings(med);
    3301                 if (FAILED(rc)) throw rc;
    3302                 dvdsTemp.push_back(med);
    3303             }
     3365        for (MediaList::const_iterator it = m->ollDVDImages.begin();
     3366                it != m->ollDVDImages.end();
     3367                ++it)
     3368        {
     3369            settings::Medium med;
     3370            rc = (*it)->saveSettings(med);
     3371            if (FAILED(rc)) throw rc;
     3372            dvdsTemp.push_back(med);
    33043373        }
    33053374
    33063375        /* floppy images */
    33073376        settings::MediaList floppiesTemp;
    3308         {
    3309             AutoReadLock al(m->ollFloppyImages.getLockHandle() COMMA_LOCKVAL_SRC_POS);
    3310             for (MediaList::const_iterator it = m->ollFloppyImages.begin();
    3311                  it != m->ollFloppyImages.end();
    3312                  ++it)
    3313             {
    3314                 settings::Medium med;
    3315                 rc = (*it)->saveSettings(med);
    3316                 if (FAILED(rc)) throw rc;
    3317                 floppiesTemp.push_back(med);
    3318             }
     3377        for (MediaList::const_iterator it = m->ollFloppyImages.begin();
     3378                it != m->ollFloppyImages.end();
     3379                ++it)
     3380        {
     3381            settings::Medium med;
     3382            rc = (*it)->saveSettings(med);
     3383            if (FAILED(rc)) throw rc;
     3384            floppiesTemp.push_back(med);
    33193385        }
    33203386
    33213387        settings::DHCPServersList dhcpServersTemp;
    33223388        {
    3323             AutoReadLock al(m->ollDHCPServers.getLockHandle() COMMA_LOCKVAL_SRC_POS);
     3389            AutoReadLock dhcpLock(m->ollDHCPServers.getLockHandle() COMMA_LOCKVAL_SRC_POS);
    33243390            for (DHCPServersOList::const_iterator it = m->ollDHCPServers.begin();
    33253391                 it != m->ollDHCPServers.end();
     
    33333399        }
    33343400
    3335         /* finally, lock VirtualBox object for writing */
    3336         AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
    3337 
    33383401        /* now copy the temp data to the config file under the VirtualBox lock */
    33393402        m->pMainConfigFile->llMachines = machinesTemp;
     
    36483711    if (pfNeedsSaveSettings)
    36493712        *pfNeedsSaveSettings = true;
    3650 
    3651     return rc;
    3652 }
    3653 
    3654 /**
    3655  * Helper to update the global settings file when the name of some machine
    3656  * changes so that file and directory renaming occurs. This method ensures that
    3657  * all affected paths in the disk registry are properly updated.
    3658  *
    3659  * @param aOldPath  Old path (full).
    3660  * @param aNewPath  New path (full).
    3661  *
    3662  * @note Locks this object + DVD, Floppy and HardDisk children for writing.
    3663  */
    3664 HRESULT VirtualBox::updatePathInMediaRegistry(const char *aOldPath, const char *aNewPath)
    3665 {
    3666     LogFlowThisFunc(("aOldPath={%s} aNewPath={%s}\n", aOldPath, aNewPath));
    3667 
    3668     AssertReturn(aOldPath, E_INVALIDARG);
    3669     AssertReturn(aNewPath, E_INVALIDARG);
    3670 
    3671     AutoCaller autoCaller(this);
    3672     AssertComRCReturn(autoCaller.rc(), autoCaller.rc());
    3673 
    3674     RWLockHandle tmpLock(LOCKCLASS_LISTOFMEDIA);        // not really necessary but the ObjectsList<> constructor wants one
    3675     ObjectsList<Medium> ollAll(tmpLock);
    3676     ollAll.appendOtherList(m->ollDVDImages);
    3677     ollAll.appendOtherList(m->ollFloppyImages);
    3678     ollAll.appendOtherList(m->ollHardDisks);
    3679 
    3680     for (MediaList::iterator it = ollAll.begin();
    3681          it != ollAll.end();
    3682          ++ it)
    3683     {
    3684         (*it)->updatePath(aOldPath, aNewPath);
    3685     }
    3686 
    3687     HRESULT rc = saveSettings();
    36883713
    36893714    return rc;
  • trunk/src/VBox/Main/include/MachineImpl.h

    r27166 r27256  
    718718    };
    719719
    720     HRESULT prepareSaveSettings(bool &aRenamed, bool &aNew);
    721     HRESULT saveSettings(int aFlags = 0);
     720    HRESULT prepareSaveSettings(bool *pfNeedsGlobalSaveSettings);
     721    HRESULT saveSettings(bool *pfNeedsGlobalSaveSettings, int aFlags = 0);
    722722
    723723    HRESULT saveAllSnapshots();
  • trunk/src/VBox/Main/include/VirtualBoxImpl.h

    r27179 r27256  
    278278    HRESULT unregisterImage(Medium *aImage, DeviceType_T argType, bool *pfNeedsSaveSettings);
    279279
     280    void rememberMachineNameChangeForMedia(const Utf8Str &strOldConfigDir,
     281                                           const Utf8Str &strNewConfigDir);
     282
    280283    HRESULT saveSettings();
    281     HRESULT updatePathInMediaRegistry(const char *aOldPath, const char *aNewPath);
    282284
    283285    static HRESULT ensureFilePathExists(const Utf8Str &strFileName);
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