Changeset 33905 in vbox
- Timestamp:
- Nov 9, 2010 3:10:12 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/VirtualBoxImpl.cpp
r33806 r33905 3100 3100 * ID match the given UUID. 3101 3101 * 3102 * Before actually writing to the structures, all media paths (not just the 3103 * ones for the given registry) are updated if machines have been renamed 3104 * since the last call. 3105 * 3102 3106 * This gets called from two contexts: 3103 3107 * … … 3114 3118 * get saved. 3115 3119 * 3116 * This throws HRESULT on errors!3120 * This locks the media tree. Throws HRESULT on errors! 3117 3121 * 3118 3122 * @param mediaRegistry Settings structure to fill. … … 3124 3128 const Utf8Str &strMachineFolder) 3125 3129 { 3130 // lock all media for the following; use a write lock because we're 3131 // modifying the PendingMachineRenamesList, which is protected by this 3132 AutoWriteLock mediaLock(getMediaTreeLockHandle() COMMA_LOCKVAL_SRC_POS); 3133 3134 // if a machine was renamed, then we'll need to refresh media paths 3135 if (m->llPendingMachineRenames.size()) 3136 { 3137 // make a single list from the three media lists so we don't need three loops 3138 MediaList llAllMedia; 3139 // with hard disks, we must use the map, not the list, because the list only has base images 3140 for (HardDiskMap::iterator it = m->mapHardDisks.begin(); it != m->mapHardDisks.end(); ++it) 3141 llAllMedia.push_back(it->second); 3142 for (MediaList::iterator it = m->allDVDImages.begin(); it != m->allDVDImages.end(); ++it) 3143 llAllMedia.push_back(*it); 3144 for (MediaList::iterator it = m->allFloppyImages.begin(); it != m->allFloppyImages.end(); ++it) 3145 llAllMedia.push_back(*it); 3146 3147 for (MediaList::iterator it = llAllMedia.begin(); 3148 it != llAllMedia.end(); 3149 ++it) 3150 { 3151 Medium *pMedium = *it; 3152 for (Data::PendingMachineRenamesList::iterator it2 = m->llPendingMachineRenames.begin(); 3153 it2 != m->llPendingMachineRenames.end(); 3154 ++it2) 3155 { 3156 const Data::PendingMachineRename &pmr = *it2; 3157 pMedium->updatePath(pmr.strConfigDirOld, 3158 pmr.strConfigDirNew); 3159 } 3160 } 3161 // done, don't do it again until we have more machine renames 3162 m->llPendingMachineRenames.clear(); 3163 } 3164 3126 3165 HRESULT rc; 3127 3166 // hard disks … … 3211 3250 } 3212 3251 3213 // lock all media for the following; use a write lock because we're3214 // modifying the PendingMachineRenamesList, which is protected by this3215 AutoWriteLock mediaLock(getMediaTreeLockHandle() COMMA_LOCKVAL_SRC_POS);3216 3217 // if a machine was renamed, then we'll need to refresh media paths3218 if (m->llPendingMachineRenames.size())3219 {3220 // make a single list from the three media lists so we don't need three loops3221 MediaList llAllMedia;3222 // with hard disks, we must use the map, not the list, because the list only has base images3223 for (HardDiskMap::iterator it = m->mapHardDisks.begin(); it != m->mapHardDisks.end(); ++it)3224 llAllMedia.push_back(it->second);3225 for (MediaList::iterator it = m->allDVDImages.begin(); it != m->allDVDImages.end(); ++it)3226 llAllMedia.push_back(*it);3227 for (MediaList::iterator it = m->allFloppyImages.begin(); it != m->allFloppyImages.end(); ++it)3228 llAllMedia.push_back(*it);3229 3230 for (MediaList::iterator it = llAllMedia.begin();3231 it != llAllMedia.end();3232 ++it)3233 {3234 Medium *pMedium = *it;3235 for (Data::PendingMachineRenamesList::iterator it2 = m->llPendingMachineRenames.begin();3236 it2 != m->llPendingMachineRenames.end();3237 ++it2)3238 {3239 // is medium in global registry:?3240 if (pMedium->isInRegistry(m->uuidMediaRegistry))3241 {3242 const Data::PendingMachineRename &pmr = *it2;3243 pMedium->updatePath(pmr.strConfigDirOld,3244 pmr.strConfigDirNew);3245 }3246 }3247 }3248 // done, don't do it again until we have more machine renames3249 m->llPendingMachineRenames.clear();3250 }3251 3252 3252 saveMediaRegistry(m->pMainConfigFile->mediaRegistry, 3253 3253 m->uuidMediaRegistry, // global media registry ID 3254 3254 Utf8Str::Empty); // strMachineFolder 3255 3256 mediaLock.release();3257 3255 3258 3256 m->pMainConfigFile->llDhcpServers.clear();
Note:
See TracChangeset
for help on using the changeset viewer.