Changeset 24214 in vbox
- Timestamp:
- Oct 30, 2009 6:23:31 PM (15 years ago)
- svn:sync-xref-src-repo-rev:
- 54163
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/MachineImpl.cpp
r24209 r24214 10236 10236 10237 10237 typedef std::list <ComPtr<IMedium> > MediaList; 10238 MediaList mediaToCheck;10239 MediumState_T mediaState;10240 10238 10241 10239 try … … 10243 10241 HRESULT rc = S_OK; 10244 10242 10245 /* lock all medium objects attached to the VM */ 10243 ErrorInfoKeeper eik(true /* aIsNull */); 10244 MultiResult mrc(S_OK); 10245 10246 /* Lock all medium objects attached to the VM. 10247 * Get status for inaccessible media as well. */ 10246 10248 for (MediaData::AttachmentList::const_iterator it = mMediaData->mAttachments.begin(); 10247 10249 it != mMediaData->mAttachments.end(); … … 10249 10251 { 10250 10252 DeviceType_T devType = (*it)->type(); 10251 ComObjPtr<Medium> hd= (*it)->medium();10253 ComObjPtr<Medium> medium = (*it)->medium(); 10252 10254 10253 10255 bool first = true; … … 10255 10257 /** @todo split out the media locking, and put it into 10256 10258 * MediumImpl.cpp, as it needs this functionality too. */ 10257 while (! hd.isNull())10259 while (!medium.isNull()) 10258 10260 { 10261 MediumState_T mediumState = medium->state(); 10262 10263 /* accessibility check must be first, otherwise locking 10264 * interferes with getting the medium state. */ 10265 if (mediumState == MediumState_Inaccessible) 10266 { 10267 rc = medium->COMGETTER(State)(&mediumState); 10268 CheckComRCThrowRC(rc); 10269 10270 if (mediumState == MediumState_Inaccessible) 10271 { 10272 Bstr error; 10273 rc = medium->COMGETTER(LastAccessError)(error.asOutParam()); 10274 CheckComRCThrowRC(rc); 10275 10276 Bstr loc; 10277 rc = medium->COMGETTER(Location)(loc.asOutParam()); 10278 CheckComRCThrowRC(rc); 10279 10280 /* collect multiple errors */ 10281 eik.restore(); 10282 10283 /* be in sync with MediumBase::setStateError() */ 10284 Assert(!error.isEmpty()); 10285 mrc = setError(E_FAIL, 10286 tr("Medium '%ls' is not accessible. %ls"), 10287 loc.raw(), 10288 error.raw()); 10289 10290 eik.fetch(); 10291 } 10292 } 10293 10259 10294 if (first) 10260 10295 { … … 10262 10297 { 10263 10298 /* HardDisk and Floppy medium must be locked for writing */ 10264 rc = hd->LockWrite(&mediaState);10299 rc = medium->LockWrite(NULL); 10265 10300 CheckComRCThrowRC(rc); 10266 10301 } … … 10268 10303 { 10269 10304 /* DVD medium must be locked for reading */ 10270 rc = hd->LockRead(&mediaState);10305 rc = medium->LockRead(NULL); 10271 10306 CheckComRCThrowRC(rc); 10272 10307 } 10273 10308 10274 mData->mSession.mLockedMedia.push_back 10275 Data::Session::LockedMedia::value_type 10276 ComPtr<IMedium> (hd), true));10309 mData->mSession.mLockedMedia.push_back( 10310 Data::Session::LockedMedia::value_type( 10311 ComPtr<IMedium>(medium), true)); 10277 10312 10278 10313 first = false; … … 10280 10315 else 10281 10316 { 10282 rc = hd->LockRead (&mediaState);10317 rc = medium->LockRead(NULL); 10283 10318 CheckComRCThrowRC(rc); 10284 10319 10285 mData->mSession.mLockedMedia.push_back 10286 Data::Session::LockedMedia::value_type 10287 ComPtr<IMedium> (hd), false));10320 mData->mSession.mLockedMedia.push_back( 10321 Data::Session::LockedMedia::value_type( 10322 ComPtr<IMedium>(medium), false)); 10288 10323 } 10289 10324 10290 if (mediaState == MediumState_Inaccessible)10291 mediaToCheck.push_back (ComPtr<IMedium> (hd));10292 10325 10293 10326 /* no locks or callers here since there should be no way to 10294 10327 * change the hard disk parent at this point (as it is still 10295 10328 * attached to the machine) */ 10296 hd = hd->parent();10329 medium = medium->parent(); 10297 10330 } 10298 10331 } 10299 10332 10300 /* SUCCEEDED locking all media, now check accessibility */10301 10302 ErrorInfoKeeper eik (true /* aIsNull */);10303 MultiResult mrc (S_OK);10304 10305 /* perform a check of inaccessible media deferred above */10306 for (MediaList::const_iterator10307 it = mediaToCheck.begin();10308 it != mediaToCheck.end(); ++it)10309 {10310 MediumState_T mediaState;10311 rc = (*it)->COMGETTER(State) (&mediaState);10312 CheckComRCThrowRC(rc);10313 10314 Assert (mediaState == MediumState_LockedRead ||10315 mediaState == MediumState_LockedWrite);10316 10317 /* Note that we locked the medium already, so use the error10318 * value to see if there was an accessibility failure */10319 10320 Bstr error;10321 rc = (*it)->COMGETTER(LastAccessError) (error.asOutParam());10322 CheckComRCThrowRC(rc);10323 10324 if (!error.isEmpty())10325 {10326 Bstr loc;10327 rc = (*it)->COMGETTER(Location) (loc.asOutParam());10328 CheckComRCThrowRC(rc);10329 10330 /* collect multiple errors */10331 eik.restore();10332 10333 /* be in sync with MediumBase::setStateError() */10334 Assert (!error.isEmpty());10335 mrc = setError(E_FAIL,10336 tr("Medium '%ls' is not accessible. %ls"),10337 loc.raw(),10338 error.raw());10339 10340 eik.fetch();10341 }10342 }10343 10344 10333 eik.restore(); 10345 CheckComRCThrowRC((HRESULT) 10334 CheckComRCThrowRC((HRESULT)mrc); 10346 10335 } 10347 10336 catch (HRESULT aRC)
Note:
See TracChangeset
for help on using the changeset viewer.