Changeset 37777 in vbox
- Timestamp:
- Jul 5, 2011 9:36:39 AM (13 years ago)
- Location:
- trunk/src/VBox/Main
- Files:
-
- 2 edited
-
include/MachineImpl.h (modified) (1 diff)
-
src-server/MachineImpl.cpp (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/include/MachineImpl.h
r37768 r37777 827 827 GuidList *pllRegistriesThatNeedSaving); 828 828 829 HRESULT searchAndAddImplicitParents(ComObjPtr<Medium> p, MediaList &llMedia) const;830 829 HRESULT detachAllMedia(AutoWriteLock &writeLock, 831 830 Snapshot *pSnapshot, -
trunk/src/VBox/Main/src-server/MachineImpl.cpp
r37768 r37777 9652 9652 9653 9653 /** 9654 * Search for medias which are not attached to any machine, but in the chain to9655 * an attached disk. Mediums are only consided if they are:9656 * - have only one child9657 * - no refereneces to any machines9658 * - are of normal medium type9659 *9660 * This is done recursive and the recursing is stopped if a medium has more the9661 * one child or there is no parent anymore.9662 *9663 * Used in detachAllMedia.9664 *9665 * @param pMedium Medium to investigate.9666 * @param llMedia Caller's list to add a corrosponding media to.9667 * @return9668 */9669 HRESULT Machine::searchAndAddImplicitParents(ComObjPtr<Medium> pMedium, MediaList &llMedia) const9670 {9671 if (!pMedium.isNull())9672 {9673 AutoCaller mac(pMedium);9674 if (FAILED(mac.rc())) return mac.rc();9675 AutoReadLock lock(pMedium COMMA_LOCKVAL_SRC_POS);9676 MediaList childs = pMedium->getChildren();9677 if (childs.size() == 1)9678 {9679 if ( pMedium->getMachineBackRefCount() == 09680 && pMedium->getType() == MediumType_Normal9681 && find(llMedia.begin(), llMedia.end(), pMedium) == llMedia.end())9682 llMedia.push_back(pMedium);9683 /* Recurse */9684 return searchAndAddImplicitParents(pMedium->getParent(), llMedia);9685 }9686 }9687 return S_OK;9688 }9689 9690 /**9691 9654 * Goes thru all media of the given list and 9692 9655 * … … 9734 9697 if (!pMedium.isNull()) 9735 9698 { 9699 AutoCaller mac(pMedium); 9700 if (FAILED(mac.rc())) return mac.rc(); 9701 AutoReadLock lock(pMedium COMMA_LOCKVAL_SRC_POS); 9736 9702 DeviceType_T devType = pMedium->getDeviceType(); 9737 9703 if ( ( cleanupMode == CleanupMode_DetachAllReturnHardDisksOnly … … 9741 9707 { 9742 9708 llMedia.push_back(pMedium); 9743 /* not enabled yet 9744 rc = searchAndAddImplicitParents(pMedium->getParent(), llMedia); 9745 if (FAILED(rc)) 9746 return rc; 9747 */ 9709 ComObjPtr<Medium> pParent = pMedium->getParent(); 9710 /* 9711 * Search for medias which are not attached to any machine, but 9712 * in the chain to an attached disk. Mediums are only consided 9713 * if they are: 9714 * - have only one child 9715 * - no references to any machines 9716 * - are of normal medium type 9717 */ 9718 while (!pParent.isNull()) 9719 { 9720 AutoCaller mac1(pParent); 9721 if (FAILED(mac1.rc())) return mac1.rc(); 9722 AutoReadLock lock1(pParent COMMA_LOCKVAL_SRC_POS); 9723 if (pParent->getChildren().size() == 1) 9724 { 9725 if ( pParent->getMachineBackRefCount() == 0 9726 && pParent->getType() == MediumType_Normal 9727 && find(llMedia.begin(), llMedia.end(), pParent) == llMedia.end()) 9728 llMedia.push_back(pParent); 9729 }else 9730 break; 9731 pParent = pParent->getParent(); 9732 } 9748 9733 } 9749 9734 }
Note:
See TracChangeset
for help on using the changeset viewer.

