VirtualBox

Changeset 37768 in vbox for trunk/src/VBox/Main/src-server


Ignore:
Timestamp:
Jul 4, 2011 2:49:46 PM (14 years ago)
Author:
vboxsync
Message:

Main: add implicit parents which are not attached to other machines to the deletion list on unregister (code still disabled)

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

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/src-server/MachineImpl.cpp

    r37709 r37768  
    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 */
     9669HRESULT 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/**
    96549691 * Goes thru all media of the given list and
    96559692 *
     
    97029739                 || (cleanupMode == CleanupMode_Full)
    97039740               )
     9741            {
    97049742                llMedia.push_back(pMedium);
     9743                /* not enabled yet
     9744                rc = searchAndAddImplicitParents(pMedium->getParent(), llMedia);
     9745                if (FAILED(rc))
     9746                    return rc;
     9747                */
     9748            }
    97059749        }
    97069750
  • trunk/src/VBox/Main/src-server/MediumImpl.cpp

    r37625 r37768  
    34633463
    34643464    return &ref.llSnapshotIds.front();
     3465}
     3466
     3467size_t Medium::getMachineBackRefCount() const
     3468{
     3469    return m->backRefs.size();
    34653470}
    34663471
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