Changeset 28872 in vbox
- Timestamp:
- Apr 28, 2010 2:54:03 PM (15 years ago)
- svn:sync-xref-src-repo-rev:
- 60802
- Location:
- trunk/src/VBox/Main
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/MediumImpl.cpp
r28835 r28872 4949 4949 4950 4950 /** 4951 * Fix the parent UUID of all children to point to this medium as their 4952 * parent. 4953 */ 4954 HRESULT Medium::fixParentUuidOfChildren(const MediaList &childrenToReparent) 4955 { 4956 MediumLockList mediumLockList; 4957 HRESULT rc = createMediumLockList(false, this, mediumLockList); 4958 AssertComRCReturnRC(rc); 4959 4960 try 4961 { 4962 PVBOXHDD hdd; 4963 int vrc = VDCreate(m->vdDiskIfaces, &hdd); 4964 ComAssertRCThrow(vrc, E_FAIL); 4965 4966 try 4967 { 4968 MediumLockList::Base::iterator lockListBegin = 4969 mediumLockList.GetBegin(); 4970 MediumLockList::Base::iterator lockListEnd = 4971 mediumLockList.GetEnd(); 4972 for (MediumLockList::Base::iterator it = lockListBegin; 4973 it != lockListEnd; 4974 ++it) 4975 { 4976 MediumLock &mediumLock = *it; 4977 const ComObjPtr<Medium> &pMedium = mediumLock.GetMedium(); 4978 AutoReadLock(pMedium COMMA_LOCKVAL_SRC_POS); 4979 4980 // open the image 4981 vrc = VDOpen(hdd, 4982 pMedium->m->strFormat.c_str(), 4983 pMedium->m->strLocationFull.c_str(), 4984 VD_OPEN_FLAGS_READONLY, 4985 pMedium->m->vdDiskIfaces); 4986 if (RT_FAILURE(vrc)) 4987 throw vrc; 4988 } 4989 4990 for (MediaList::const_iterator it = childrenToReparent.begin(); 4991 it != childrenToReparent.end(); 4992 ++it) 4993 { 4994 /* VD_OPEN_FLAGS_INFO since UUID is wrong yet */ 4995 vrc = VDOpen(hdd, 4996 (*it)->m->strFormat.c_str(), 4997 (*it)->m->strLocationFull.c_str(), 4998 VD_OPEN_FLAGS_INFO, 4999 (*it)->m->vdDiskIfaces); 5000 if (RT_FAILURE(vrc)) 5001 throw vrc; 5002 5003 vrc = VDSetParentUuid(hdd, VD_LAST_IMAGE, m->id); 5004 if (RT_FAILURE(vrc)) 5005 throw vrc; 5006 5007 vrc = VDClose(hdd, false /* fDelete */); 5008 if (RT_FAILURE(vrc)) 5009 throw vrc; 5010 5011 (*it)->UnlockWrite(NULL); 5012 } 5013 } 5014 catch (HRESULT aRC) { rc = aRC; } 5015 catch (int aVRC) 5016 { 5017 throw setError(E_FAIL, 5018 tr("Could not update medium UUID references to parent '%s' (%s)"), 5019 m->strLocationFull.raw(), 5020 vdError(aVRC).raw()); 5021 } 5022 5023 VDDestroy(hdd); 5024 } 5025 catch (HRESULT aRC) { rc = aRC; } 5026 5027 return rc; 5028 } 5029 5030 /** 4951 5031 * Runs Medium::Task::handler() on the current thread instead of creating 4952 5032 * a new one. … … 5217 5297 targetLocation.raw(), vdError(vrc).raw()); 5218 5298 5219 size = VDGetFileSize(hdd, 1);5220 logicalSize = VDGetSize(hdd, 1) / _1M;5299 size = VDGetFileSize(hdd, VD_LAST_IMAGE); 5300 logicalSize = VDGetSize(hdd, VD_LAST_IMAGE) / _1M; 5221 5301 } 5222 5302 catch (HRESULT aRC) { rc = aRC; } … … 5421 5501 throw vrc; 5422 5502 5423 vrc = VDSetParentUuid(hdd, 1,5503 vrc = VDSetParentUuid(hdd, VD_LAST_IMAGE, 5424 5504 pTarget->m->id); 5425 5505 if (RT_FAILURE(vrc)) … … 5440 5520 throw setError(E_FAIL, 5441 5521 tr("Could not merge the hard disk '%s' to '%s'%s"), 5442 m->strLocationFull.raw(), m->strLocationFull.raw(), 5522 m->strLocationFull.raw(), 5523 pTarget->m->strLocationFull.raw(), 5443 5524 vdError(aVRC).raw()); 5444 5525 } … … 5501 5582 5502 5583 pMedium->deparent(); // removes pMedium from source 5503 pTarget->m->llChildren.push_back(pMedium); 5504 pMedium->m->pParent = pTarget; 5584 pMedium->setParent(pTarget); 5505 5585 } 5506 5586 } … … 5748 5828 targetLocation.raw(), vdError(vrc).raw()); 5749 5829 5750 size = VDGetFileSize(targetHdd, 0);5751 logicalSize = VDGetSize(targetHdd, 0) / _1M;5830 size = VDGetFileSize(targetHdd, VD_LAST_IMAGE); 5831 logicalSize = VDGetSize(targetHdd, VD_LAST_IMAGE) / _1M; 5752 5832 } 5753 5833 catch (HRESULT aRC) { rc = aRC; } … … 5943 6023 try 5944 6024 { 6025 /* Open all hard disk images in the target chain but the last. */ 6026 MediumLockList::Base::const_iterator targetListBegin = 6027 task.mpMediumLockList->GetBegin(); 6028 MediumLockList::Base::const_iterator targetListEnd = 6029 task.mpMediumLockList->GetEnd(); 6030 for (MediumLockList::Base::const_iterator it = targetListBegin; 6031 it != targetListEnd; 6032 ++it) 6033 { 6034 const MediumLock &mediumLock = *it; 6035 const ComObjPtr<Medium> &pMedium = mediumLock.GetMedium(); 6036 6037 AutoReadLock alock(pMedium COMMA_LOCKVAL_SRC_POS); 6038 6039 /* sanity check */ 6040 Assert(pMedium->m->state == MediumState_LockedRead); 6041 6042 /* Open all images in appropriate mode. */ 6043 vrc = VDOpen(hdd, 6044 pMedium->m->strFormat.c_str(), 6045 pMedium->m->strLocationFull.c_str(), 6046 VD_OPEN_FLAGS_READONLY, 6047 pMedium->m->vdDiskIfaces); 6048 if (RT_FAILURE(vrc)) 6049 throw setError(E_FAIL, 6050 tr("Could not open the hard disk storage unit '%s'%s"), 6051 pMedium->m->strLocationFull.raw(), 6052 vdError(vrc).raw()); 6053 6054 /* Done when we hit the image which should be reset */ 6055 if (pMedium == this) 6056 break; 6057 } 6058 5945 6059 /* first, delete the storage unit */ 5946 vrc = VDOpen(hdd, 5947 format.c_str(), 5948 location.c_str(), 5949 VD_OPEN_FLAGS_READONLY | VD_OPEN_FLAGS_INFO, 5950 m->vdDiskIfaces); 5951 if (RT_SUCCESS(vrc)) 5952 vrc = VDClose(hdd, true /* fDelete */); 5953 6060 vrc = VDClose(hdd, true /* fDelete */); 5954 6061 if (RT_FAILURE(vrc)) 5955 6062 throw setError(E_FAIL, … … 5984 6091 location.raw(), vdError(vrc).raw()); 5985 6092 5986 size = VDGetFileSize(hdd, 1);5987 logicalSize = VDGetSize(hdd, 1) / _1M;6093 size = VDGetFileSize(hdd, VD_LAST_IMAGE); 6094 logicalSize = VDGetSize(hdd, VD_LAST_IMAGE) / _1M; 5988 6095 } 5989 6096 catch (HRESULT aRC) { rc = aRC; } -
trunk/src/VBox/Main/include/MediumImpl.h
r28835 r28872 219 219 MediumLockList *aMediumLockList); 220 220 221 HRESULT fixParentUuidOfChildren(const MediaList &childrenToReparent); 222 221 223 /** Returns a preferred format for a differencing hard disk. */ 222 224 Bstr preferredDiffFormat();
Note:
See TracChangeset
for help on using the changeset viewer.