VirtualBox

Changeset 37777 in vbox


Ignore:
Timestamp:
Jul 5, 2011 9:36:39 AM (13 years ago)
Author:
vboxsync
Message:

Main: simply iterate over all parents

Location:
trunk/src/VBox/Main
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/include/MachineImpl.h

    r37768 r37777  
    827827                         GuidList *pllRegistriesThatNeedSaving);
    828828
    829     HRESULT searchAndAddImplicitParents(ComObjPtr<Medium> p, MediaList &llMedia) const;
    830829    HRESULT detachAllMedia(AutoWriteLock &writeLock,
    831830                           Snapshot *pSnapshot,
  • trunk/src/VBox/Main/src-server/MachineImpl.cpp

    r37768 r37777  
    96529652
    96539653/**
    9654  * Search for medias which are not attached to any machine, but in the chain to
    9655  * an attached disk. Mediums are only consided if they are:
    9656  * - have only one child
    9657  * - no refereneces to any machines
    9658  * - are of normal medium type
    9659  *
    9660  * This is done recursive and the recursing is stopped if a medium has more the
    9661  * 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  * @return
    9668  */
    9669 HRESULT Machine::searchAndAddImplicitParents(ComObjPtr<Medium> pMedium, MediaList &llMedia) const
    9670 {
    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() == 0
    9680                 && pMedium->getType() == MediumType_Normal
    9681                 && 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 /**
    96919654 * Goes thru all media of the given list and
    96929655 *
     
    97349697        if (!pMedium.isNull())
    97359698        {
     9699            AutoCaller mac(pMedium);
     9700            if (FAILED(mac.rc())) return mac.rc();
     9701            AutoReadLock lock(pMedium COMMA_LOCKVAL_SRC_POS);
    97369702            DeviceType_T devType = pMedium->getDeviceType();
    97379703            if (    (    cleanupMode == CleanupMode_DetachAllReturnHardDisksOnly
     
    97419707            {
    97429708                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                }
    97489733            }
    97499734        }
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette