- Timestamp:
- Sep 30, 2009 12:52:22 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/MachineImpl.cpp
r23395 r23441 2079 2079 { 2080 2080 return setError(VBOX_E_OBJECT_IN_USE, 2081 tr(" Hard disk'%ls' is already attached to this virtual machine"),2081 tr("Medium '%ls' is already attached to this virtual machine"), 2082 2082 medium->locationFull().raw()); 2083 2083 } … … 2308 2308 if (associate && !medium.isNull()) 2309 2309 { 2310 /* as the last step, associate the hard diskto the VM */2310 /* as the last step, associate the medium to the VM */ 2311 2311 rc = medium->attachTo(mData->mUuid); 2312 2312 /* here we can fail because of Deleting, or being in process of … … 5476 5476 } 5477 5477 5478 /* backup m HDData to let registeredInit() properly rollback on failure5478 /* backup mMediaData to let registeredInit() properly rollback on failure 5479 5479 * (= limited accessibility) */ 5480 5480 … … 6329 6329 * Used when taking a snapshot or when discarding the current state. 6330 6330 * 6331 * This method assumes that m HDData contains the original hard disk attachments6331 * This method assumes that mMediaData contains the original hard disk attachments 6332 6332 * it needs to create diffs for. On success, these attachments will be replaced 6333 6333 * with the created diffs. On failure, #deleteImplicitDiffs() is implicitly 6334 * called to delete created diffs which will also rollback m HDData and restore6334 * called to delete created diffs which will also rollback mMediaData and restore 6335 6335 * whatever was backed up before calling this method. 6336 6336 * … … 6369 6369 6370 6370 /* must be in a protective state because we leave the lock below */ 6371 AssertReturn( mData->mMachineState == MachineState_Saving ||6372 mData->mMachineState == MachineState_Discarding, E_FAIL);6371 AssertReturn( mData->mMachineState == MachineState_Saving 6372 || mData->mMachineState == MachineState_Discarding, E_FAIL); 6373 6373 6374 6374 HRESULT rc = S_OK; … … 6400 6400 6401 6401 /* remember the current list (note that we don't use backup() since 6402 * m HDData may be already backed up) */6402 * mMediaData may be already backed up) */ 6403 6403 MediaData::AttachmentList atts = mMediaData->mAttachments; 6404 6404 … … 6413 6413 { 6414 6414 MediumAttachment* pAtt = *it; 6415 if (pAtt->type() != DeviceType_HardDisk) 6416 continue;6417 6418 Medium* pHD = pAtt->medium(); 6419 Assert(pHD);6420 /* type cannot be changed while attached => no need to lock */6421 if (pHD->type() != MediumType_Normal)6415 6416 DeviceType_T devType = pAtt->type(); 6417 Medium* medium = pAtt->medium(); 6418 6419 if ( devType != DeviceType_HardDisk 6420 || medium == NULL 6421 || medium->type() != MediumType_Normal) 6422 6422 { 6423 6423 /* copy the attachment as is */ 6424 Assert(pHD->type() == MediumType_Writethrough); 6425 aProgress->SetNextOperation(BstrFmt(tr("Skipping medium '%s'"), 6426 pHD->base()->name().raw()), 6427 aWeight); // weight 6424 6425 /** @todo the progress object created in Console::TakeSnaphot 6426 * only expects operations for hard disks. Later other 6427 * device types need to show up in the progress as well. */ 6428 if (devType == DeviceType_HardDisk) 6429 { 6430 if (medium == NULL) 6431 aProgress->SetNextOperation(Bstr(tr("Skipping attachment without medium")), 6432 aWeight); // weight 6433 else 6434 aProgress->SetNextOperation(BstrFmt(tr("Skipping medium '%s'"), 6435 medium->base()->name().raw()), 6436 aWeight); // weight 6437 } 6428 6438 6429 6439 mMediaData->mAttachments.push_back(pAtt); … … 6433 6443 /* need a diff */ 6434 6444 aProgress->SetNextOperation(BstrFmt(tr("Creating differencing hard disk for '%s'"), 6435 pHD->base()->name().raw()),6445 medium->base()->name().raw()), 6436 6446 aWeight); // weight 6437 6447 … … 6439 6449 diff.createObject(); 6440 6450 rc = diff->init(mParent, 6441 pHD->preferredDiffFormat().raw(),6451 medium->preferredDiffFormat().raw(), 6442 6452 BstrFmt("%ls"RTPATH_SLASH_STR, 6443 6453 mUserData->mSnapshotFolderFull.raw()).raw()); … … 6447 6457 alock.leave(); 6448 6458 6449 rc = pHD->createDiffStorageAndWait(diff,6450 MediumVariant_Standard,6451 NULL);6459 rc = medium->createDiffStorageAndWait(diff, 6460 MediumVariant_Standard, 6461 NULL); 6452 6462 6453 6463 // at this point, the old image is still locked for writing, but instead … … 6458 6468 diff->LockWrite(NULL); 6459 6469 mData->mSession.mLockedMedia.push_back(Data::Session::LockedMedia::value_type(ComPtr<IMedium>(diff), true)); 6460 pHD->UnlockWrite(NULL);6461 pHD->LockRead(NULL);6462 mData->mSession.mLockedMedia.push_back(Data::Session::LockedMedia::value_type(ComPtr<IMedium>( pHD), false));6470 medium->UnlockWrite(NULL); 6471 medium->LockRead(NULL); 6472 mData->mSession.mLockedMedia.push_back(Data::Session::LockedMedia::value_type(ComPtr<IMedium>(medium), false)); 6463 6473 } 6464 6474 … … 6513 6523 /** 6514 6524 * Deletes implicit differencing hard disks created either by 6515 * #createImplicitDiffs() or by #AttachMedium() and rolls back m HDData.6525 * #createImplicitDiffs() or by #AttachMedium() and rolls back mMediaData. 6516 6526 * 6517 6527 * Note that to delete hard disks created by #AttachMedium() this method is … … 6688 6698 * created diffs on failure. 6689 6699 * 6690 * Does nothing if the hard disk attachment data (m HDData) is not changed (not6700 * Does nothing if the hard disk attachment data (mMediaData) is not changed (not 6691 6701 * backed up). 6692 6702 * 6693 * When the data is backed up, this method will commit m HDData if @a aCommit is6703 * When the data is backed up, this method will commit mMediaData if @a aCommit is 6694 6704 * @c true and rollback it otherwise before returning. 6695 6705 * … … 7257 7267 mPeer->mUserData.attach (mUserData); 7258 7268 mPeer->mHWData.attach (mHWData); 7259 /* m HDData is reshared by fixupMedia */7260 // mPeer->m HDData.attach (mHDData);7269 /* mMediaData is reshared by fixupMedia */ 7270 // mPeer->mMediaData.attach(mMediaData); 7261 7271 Assert(mPeer->mMediaData.data() == mMediaData.data()); 7262 7272 } … … 9340 9350 { 9341 9351 /* delete all differencing hard disks created (this will also attach 9342 * their parents back by rolling back m HDData) */9352 * their parents back by rolling back mMediaData) */ 9343 9353 fixupMedia(false /* aCommit */); 9344 9354 … … 10037 10047 HRESULT rc = S_OK; 10038 10048 10039 /* lock hard disks*/10049 /* lock all medium objects attached to the VM */ 10040 10050 for (MediaData::AttachmentList::const_iterator it = mMediaData->mAttachments.begin(); 10041 10051 it != mMediaData->mAttachments.end(); 10042 10052 ++it) 10043 10053 { 10054 DeviceType_T devType = (*it)->type(); 10044 10055 ComObjPtr<Medium> hd = (*it)->medium(); 10045 10056 … … 10052 10063 if (first) 10053 10064 { 10054 rc = hd->LockWrite (&mediaState); 10055 CheckComRCThrowRC(rc); 10065 if (devType != DeviceType_DVD) 10066 { 10067 /* HardDisk and Floppy medium must be locked for writing */ 10068 rc = hd->LockWrite(&mediaState); 10069 CheckComRCThrowRC(rc); 10070 } 10071 else 10072 { 10073 /* DVD medium must be locked for reading */ 10074 rc = hd->LockRead(&mediaState); 10075 CheckComRCThrowRC(rc); 10076 } 10056 10077 10057 10078 mData->mSession.mLockedMedia.push_back (
Note:
See TracChangeset
for help on using the changeset viewer.