Changeset 36981 in vbox for trunk/src/VBox
- Timestamp:
- May 6, 2011 1:07:10 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/src-server/MediumImpl.cpp
r36975 r36981 239 239 PVDINTERFACE mVDOperationIfaces; 240 240 241 // Whether the caller needs to call VirtualBox::save Settings() after241 // Whether the caller needs to call VirtualBox::saveRegistries() after 242 242 // the task function returns. Only used in synchronous (wait) mode; 243 243 // otherwise the task will save the settings itself. … … 1312 1312 m->strDescription = aDescription; 1313 1313 1314 /// @todo generate uuid (similarly to host network interface uuid) from location and device type1315 1316 1314 autoInitSpan.setSucceeded(); 1317 1315 return S_OK; … … 2257 2255 2258 2256 GuidList llRegistriesThatNeedSaving; 2259 HRESULTrc = close(&llRegistriesThatNeedSaving, autoCaller);2260 2261 pVirtualBox->saveRegistries(llRegistriesThatNeedSaving);2262 2263 return rc;2257 MultiResult mrc = close(&llRegistriesThatNeedSaving, autoCaller); 2258 /* Must save the registries, since an entry was most likely removed. */ 2259 mrc = pVirtualBox->saveRegistries(llRegistriesThatNeedSaving); 2260 2261 return mrc; 2264 2262 } 2265 2263 … … 2476 2474 2477 2475 GuidList llRegistriesThatNeedSaving; 2478 HRESULT rc = deleteStorage(&pProgress, 2479 false /* aWait */, 2480 &llRegistriesThatNeedSaving); 2481 m->pVirtualBox->saveRegistries(llRegistriesThatNeedSaving); 2482 2483 if (SUCCEEDED(rc)) 2476 MultiResult mrc = deleteStorage(&pProgress, 2477 false /* aWait */, 2478 &llRegistriesThatNeedSaving); 2479 /* Must save the registries in any case, since an entry was removed. */ 2480 mrc = m->pVirtualBox->saveRegistries(llRegistriesThatNeedSaving); 2481 2482 if (SUCCEEDED(mrc)) 2484 2483 pProgress.queryInterfaceTo(aProgress); 2485 2484 2486 return rc;2485 return mrc; 2487 2486 } 2488 2487 … … 3792 3791 * creating an asynchronous thread. 3793 3792 * @param pllRegistriesThatNeedSaving Optional pointer to a list of UUIDs that will receive the registry IDs that need saving. 3794 * This only works in "wait" mode; otherwise save Settings is called automatically by the thread that3793 * This only works in "wait" mode; otherwise saveRegistries is called automatically by the thread that 3795 3794 * was created, and this parameter is ignored. 3796 3795 * … … 3929 3928 /** 3930 3929 * Implementation for the public Medium::Close() with the exception of calling 3931 * VirtualBox::save Settings(), in case someone wants to call this for several3930 * VirtualBox::saveRegistries(), in case someone wants to call this for several 3932 3931 * media. 3933 3932 * … … 4013 4012 * an asynchronous thread. 4014 4013 * @param pfNeedsGlobalSaveSettings Optional pointer to a bool that must have been initialized to false and that will be set to true 4015 * by this function if the caller should invoke VirtualBox::save Settings() because the global settings have changed.4016 * This only works in "wait" mode; otherwise save Settings gets called automatically by the thread that was created,4014 * by this function if the caller should invoke VirtualBox::saveRegistries() because the global settings have changed. 4015 * This only works in "wait" mode; otherwise saveRegistries gets called automatically by the thread that was created, 4017 4016 * and this parameter is ignored. 4018 4017 * … … 4631 4630 * an asynchronous thread. 4632 4631 * @param pfNeedsGlobalSaveSettings Optional pointer to a bool that must have been initialized to false and that will be set to true 4633 * by this function if the caller should invoke VirtualBox::save Settings() because the global settings have changed.4634 * This only works in "wait" mode; otherwise save Settings gets called automatically by the thread that was created,4632 * by this function if the caller should invoke VirtualBox::saveRegistries() because the global settings have changed. 4633 * This only works in "wait" mode; otherwise saveRegistries gets called automatically by the thread that was created, 4635 4634 * and this parameter is ignored. 4636 4635 * … … 4845 4844 catch (int aVRC) 4846 4845 { 4847 throwsetError(E_FAIL,4848 4849 4850 4846 rc = setError(E_FAIL, 4847 tr("Could not update medium UUID references to parent '%s' (%s)"), 4848 m->strLocationFull.c_str(), 4849 vdError(aVRC).c_str()); 4851 4850 } 4852 4851 … … 6274 6273 HRESULT Medium::taskCreateDiffHandler(Medium::CreateDiffTask &task) 6275 6274 { 6276 HRESULT rc = S_OK;6275 HRESULT rcTmp = S_OK; 6277 6276 6278 6277 const ComObjPtr<Medium> &pTarget = task.mTarget; … … 6357 6356 if (capabilities & VD_CAP_FILE) 6358 6357 { 6359 rc = VirtualBox::ensureFilePathExists(targetLocation);6358 HRESULT rc = VirtualBox::ensureFilePathExists(targetLocation); 6360 6359 if (FAILED(rc)) 6361 6360 throw rc; … … 6384 6383 variant = (MediumVariant_T)uImageFlags; 6385 6384 } 6386 catch (HRESULT aRC) { rc = aRC; }6385 catch (HRESULT aRC) { rcTmp = aRC; } 6387 6386 6388 6387 VDDestroy(hdd); 6389 6388 } 6390 catch (HRESULT aRC) { rc = aRC; } 6391 6392 if (SUCCEEDED(rc)) 6389 catch (HRESULT aRC) { rcTmp = aRC; } 6390 6391 MultiResult mrc(rcTmp); 6392 6393 if (SUCCEEDED(mrc)) 6393 6394 { 6394 6395 AutoWriteLock treeLock(m->pVirtualBox->getMediaTreeLockHandle() COMMA_LOCKVAL_SRC_POS); … … 6408 6409 * Created state only on success (leaving an orphan file is 6409 6410 * better than breaking media registry consistency) */ 6410 rc = m->pVirtualBox->registerHardDisk(pTarget, &llRegistriesThatNeedSaving);6411 6412 if (FAILED( rc))6411 mrc = m->pVirtualBox->registerHardDisk(pTarget, &llRegistriesThatNeedSaving); 6412 6413 if (FAILED(mrc)) 6413 6414 /* break the parent association on failure to register */ 6414 6415 deparent(); … … 6417 6418 AutoMultiWriteLock2 mediaLock(this, pTarget COMMA_LOCKVAL_SRC_POS); 6418 6419 6419 if (SUCCEEDED( rc))6420 if (SUCCEEDED(mrc)) 6420 6421 { 6421 6422 pTarget->m->state = MediumState_Created; … … 6444 6445 { 6445 6446 mediaLock.release(); 6446 m ->pVirtualBox->saveRegistries(llRegistriesThatNeedSaving);6447 mrc = m->pVirtualBox->saveRegistries(llRegistriesThatNeedSaving); 6447 6448 } 6448 6449 else … … 6454 6455 * unlock the medium. */ 6455 6456 6456 return rc;6457 return mrc; 6457 6458 } 6458 6459 … … 6471 6472 HRESULT Medium::taskMergeHandler(Medium::MergeTask &task) 6472 6473 { 6473 HRESULT rc = S_OK;6474 HRESULT rcTmp = S_OK; 6474 6475 6475 6476 const ComObjPtr<Medium> &pTarget = task.mTarget; … … 6598 6599 } 6599 6600 } 6600 catch (HRESULT aRC) { rc = aRC; }6601 catch (HRESULT aRC) { rcTmp = aRC; } 6601 6602 catch (int aVRC) 6602 6603 { 6603 throwsetError(VBOX_E_FILE_ERROR,6604 tr("Could not merge the medium '%s' to '%s'%s"),6605 m->strLocationFull.c_str(),6606 pTarget->m->strLocationFull.c_str(),6607 vdError(aVRC).c_str());6604 rcTmp = setError(VBOX_E_FILE_ERROR, 6605 tr("Could not merge the medium '%s' to '%s'%s"), 6606 m->strLocationFull.c_str(), 6607 pTarget->m->strLocationFull.c_str(), 6608 vdError(aVRC).c_str()); 6608 6609 } 6609 6610 6610 6611 VDDestroy(hdd); 6611 6612 } 6612 catch (HRESULT aRC) { rc = aRC; } 6613 6613 catch (HRESULT aRC) { rcTmp = aRC; } 6614 6615 ErrorInfoKeeper eik; 6616 MultiResult mrc(rcTmp); 6614 6617 HRESULT rc2; 6615 6618 6616 if (SUCCEEDED( rc))6619 if (SUCCEEDED(mrc)) 6617 6620 { 6618 6621 /* all media but the target were successfully deleted by … … 6731 6734 GuidList llRegistriesThatNeedSaving; 6732 6735 addToRegistryIDList(llRegistriesThatNeedSaving); 6733 rc = m->pVirtualBox->saveRegistries(llRegistriesThatNeedSaving); 6736 /* collect multiple errors */ 6737 eik.restore(); 6738 mrc = m->pVirtualBox->saveRegistries(llRegistriesThatNeedSaving); 6739 eik.fetch(); 6734 6740 } 6735 6741 else … … 6738 6744 pTarget->addToRegistryIDList(*task.m_pllRegistriesThatNeedSaving); 6739 6745 6740 if (FAILED( rc))6746 if (FAILED(mrc)) 6741 6747 { 6742 6748 /* Here we come if either VDMerge() failed (in which case we 6743 6749 * assume that it tried to do everything to make a further 6744 6750 * retry possible -- e.g. not deleted intermediate media 6745 * and so on) or VirtualBox::save Settings() failed (where we6751 * and so on) or VirtualBox::saveRegistries() failed (where we 6746 6752 * should have the original tree but with intermediate storage 6747 6753 * units deleted by VDMerge()). We have to only restore states … … 6757 6763 } 6758 6764 6759 return rc;6765 return mrc; 6760 6766 } 6761 6767 … … 6771 6777 HRESULT Medium::taskCloneHandler(Medium::CloneTask &task) 6772 6778 { 6773 HRESULT rc = S_OK;6779 HRESULT rcTmp = S_OK; 6774 6780 6775 6781 const ComObjPtr<Medium> &pTarget = task.mTarget; … … 6853 6859 if (capabilities & VD_CAP_FILE) 6854 6860 { 6855 rc = VirtualBox::ensureFilePathExists(targetLocation);6861 HRESULT rc = VirtualBox::ensureFilePathExists(targetLocation); 6856 6862 if (FAILED(rc)) 6857 6863 throw rc; … … 6932 6938 variant = (MediumVariant_T)uImageFlags; 6933 6939 } 6934 catch (HRESULT aRC) { rc = aRC; }6940 catch (HRESULT aRC) { rcTmp = aRC; } 6935 6941 6936 6942 VDDestroy(targetHdd); 6937 6943 } 6938 catch (HRESULT aRC) { rc = aRC; }6944 catch (HRESULT aRC) { rcTmp = aRC; } 6939 6945 6940 6946 VDDestroy(hdd); 6941 6947 } 6942 catch (HRESULT aRC) { rc = aRC; } 6948 catch (HRESULT aRC) { rcTmp = aRC; } 6949 6950 ErrorInfoKeeper eik; 6951 MultiResult mrc(rcTmp); 6943 6952 6944 6953 /* Only do the parent changes for newly created media. */ 6945 if (SUCCEEDED( rc) && fCreatingTarget)6954 if (SUCCEEDED(mrc) && fCreatingTarget) 6946 6955 { 6947 6956 /* we set mParent & children() */ … … 6960 6969 * Created state only on success (leaving an orphan file is 6961 6970 * better than breaking media registry consistency) */ 6962 rc = pParent->m->pVirtualBox->registerHardDisk(pTarget, NULL /* pllRegistriesThatNeedSaving */); 6963 6964 if (FAILED(rc)) 6971 eik.restore(); 6972 mrc = pParent->m->pVirtualBox->registerHardDisk(pTarget, NULL /* pllRegistriesThatNeedSaving */); 6973 eik.fetch(); 6974 6975 if (FAILED(mrc)) 6965 6976 /* break parent association on failure to register */ 6966 6977 pTarget->deparent(); // removes target from parent … … 6969 6980 { 6970 6981 /* just register */ 6971 rc = m->pVirtualBox->registerHardDisk(pTarget, NULL /* pllRegistriesThatNeedSaving */); 6982 eik.restore(); 6983 mrc = m->pVirtualBox->registerHardDisk(pTarget, NULL /* pllRegistriesThatNeedSaving */); 6984 eik.fetch(); 6972 6985 } 6973 6986 } … … 6977 6990 AutoWriteLock mLock(pTarget COMMA_LOCKVAL_SRC_POS); 6978 6991 6979 if (SUCCEEDED( rc))6992 if (SUCCEEDED(mrc)) 6980 6993 { 6981 6994 pTarget->m->state = MediumState_Created; … … 7001 7014 GuidList llRegistriesThatNeedSaving; 7002 7015 addToRegistryIDList(llRegistriesThatNeedSaving); 7003 HRESULT rc1 = m->pVirtualBox->saveRegistries(llRegistriesThatNeedSaving); 7016 /* collect multiple errors */ 7017 eik.restore(); 7018 mrc = m->pVirtualBox->saveRegistries(llRegistriesThatNeedSaving); 7019 eik.fetch(); 7004 7020 } 7005 7021 … … 7012 7028 task.mpSourceMediumLockList->Clear(); 7013 7029 7014 return rc;7030 return mrc; 7015 7031 } 7016 7032 … … 7553 7569 HRESULT Medium::taskImportHandler(Medium::ImportTask &task) 7554 7570 { 7555 HRESULT rc = S_OK;7571 HRESULT rcTmp = S_OK; 7556 7572 7557 7573 const ComObjPtr<Medium> &pParent = task.mParent; … … 7617 7633 if (capabilities & VD_CAP_FILE) 7618 7634 { 7619 rc = VirtualBox::ensureFilePathExists(targetLocation);7635 HRESULT rc = VirtualBox::ensureFilePathExists(targetLocation); 7620 7636 if (FAILED(rc)) 7621 7637 throw rc; … … 7696 7712 variant = (MediumVariant_T)uImageFlags; 7697 7713 } 7698 catch (HRESULT aRC) { rc = aRC; }7714 catch (HRESULT aRC) { rcTmp = aRC; } 7699 7715 7700 7716 VDDestroy(targetHdd); 7701 7717 } 7702 catch (HRESULT aRC) { rc = aRC; }7718 catch (HRESULT aRC) { rcTmp = aRC; } 7703 7719 7704 7720 VDDestroy(hdd); 7705 7721 } 7706 catch (HRESULT aRC) { rc = aRC; } 7722 catch (HRESULT aRC) { rcTmp = aRC; } 7723 7724 ErrorInfoKeeper eik; 7725 MultiResult mrc(rcTmp); 7707 7726 7708 7727 /* Only do the parent changes for newly created media. */ 7709 if (SUCCEEDED( rc) && fCreatingTarget)7728 if (SUCCEEDED(mrc) && fCreatingTarget) 7710 7729 { 7711 7730 /* we set mParent & children() */ … … 7724 7743 * Created state only on success (leaving an orphan file is 7725 7744 * better than breaking media registry consistency) */ 7726 rc = pParent->m->pVirtualBox->registerHardDisk(this, NULL /* llRegistriesThatNeedSaving */); 7727 7728 if (FAILED(rc)) 7745 eik.restore(); 7746 mrc = pParent->m->pVirtualBox->registerHardDisk(this, NULL /* llRegistriesThatNeedSaving */); 7747 eik.fetch(); 7748 7749 if (FAILED(mrc)) 7729 7750 /* break parent association on failure to register */ 7730 7751 this->deparent(); // removes target from parent … … 7733 7754 { 7734 7755 /* just register */ 7735 rc = m->pVirtualBox->registerHardDisk(this, NULL /* pllRegistriesThatNeedSaving */); 7756 eik.restore(); 7757 mrc = m->pVirtualBox->registerHardDisk(this, NULL /* pllRegistriesThatNeedSaving */); 7758 eik.fetch(); 7736 7759 } 7737 7760 } … … 7741 7764 AutoWriteLock mLock(this COMMA_LOCKVAL_SRC_POS); 7742 7765 7743 if (SUCCEEDED( rc))7766 if (SUCCEEDED(mrc)) 7744 7767 { 7745 7768 m->state = MediumState_Created; … … 7765 7788 GuidList llRegistriesThatNeedSaving; 7766 7789 addToRegistryIDList(llRegistriesThatNeedSaving); 7767 HRESULT rc1 = m->pVirtualBox->saveRegistries(llRegistriesThatNeedSaving); 7790 /* collect multiple errors */ 7791 eik.restore(); 7792 mrc = m->pVirtualBox->saveRegistries(llRegistriesThatNeedSaving); 7793 eik.fetch(); 7768 7794 } 7769 7795 … … 7775 7801 task.mpTargetMediumLockList->Clear(); 7776 7802 7777 return rc;7803 return mrc; 7778 7804 } 7779 7805
Note:
See TracChangeset
for help on using the changeset viewer.