third_party/virtualbox/src/VBox/Main/src-server/MachineImpl.cpp
/**
 * Perform deferred deletion of implicitly created diffs.
 *
 * Does nothing if the hard disk attachment data (mMediumAttachments) is not
 * changed (not backed up).
 *
 * @note Locks this object for writing!
 */
Perform deferred deletion of implicitly created diffs.
Does nothing if the hard disk attachment data (mMediumAttachments) is not
changed (not backed up).

@note Locks this object for writing!
Perform deferred deletion of implicitly created diffs . Does nothing if the hard disk attachment data ( mMediumAttachments ) is not changed ( not backed up ) . @note Locks this object for writing!
void Machine::i_rollbackMedia()
{
    AutoCaller autoCaller(this);
    AssertComRCReturnVoid(autoCaller.rc());
    LogFlowThisFunc(("Entering rollbackMedia\n"));
    HRESULT rc = S_OK;
    if (!mMediumAttachments.isBackedUp())
        return;
    for (MediumAttachmentList::const_iterator
         it = mMediumAttachments->begin();
         it != mMediumAttachments->end();
         ++it)
    {
        MediumAttachment *pAttach = *it;
        if (pAttach->i_getType() != DeviceType_HardDisk)
        {
            Medium *pMedium = pAttach->i_getMedium();
            if (pMedium)
            {
                rc = pMedium->i_removeBackReference(mData->mUuid);
                AssertComRC(rc);
            }
        }
        (*it)->i_rollback();
        pAttach = *it;
        if (pAttach->i_getType() != DeviceType_HardDisk)
        {
            Medium *pMedium = pAttach->i_getMedium();
            if (pMedium)
            {
                rc = pMedium->i_addBackReference(mData->mUuid);
                AssertComRC(rc);
            }
        }
    }
    i_deleteImplicitDiffs(Global::IsOnline(mData->mMachineState));
    return;
}
void Machine :: i_rollbackMedia ( ) { AutoCaller autoCaller ( this ) ; AssertComRCReturnVoid ( autoCaller . rc ( ) ) ; LogFlowThisFunc ( ( " \n " ) ) ; HRESULT rc = S_OK ; if ( ! mMediumAttachments . isBackedUp ( ) ) return ; for ( MediumAttachmentList :: const_iterator it = mMediumAttachments -> begin ( ) ; it != mMediumAttachments -> end ( ) ; ++ it ) { MediumAttachment * pAttach = * it ; if ( pAttach -> i_getType ( ) != DeviceType_HardDisk ) { Medium * pMedium = pAttach -> i_getMedium ( ) ; if ( pMedium ) { rc = pMedium -> i_removeBackReference ( mData -> mUuid ) ; AssertComRC ( rc ) ; } } ( * it ) -> i_rollback ( ) ; pAttach = * it ; if ( pAttach -> i_getType ( ) != DeviceType_HardDisk ) { Medium * pMedium = pAttach -> i_getMedium ( ) ; if ( pMedium ) { rc = pMedium -> i_addBackReference ( mData -> mUuid ) ; AssertComRC ( rc ) ; } } } i_deleteImplicitDiffs ( Global :: IsOnline ( mData -> mMachineState ) ) ; return ; }
Perform deferred deletion of implicitly created diffs.
Perform deferred deletion of implicitly created diffs .
// AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); /* no attach/detach operations -- nothing to do */ /* enumerate new attachments */ /* Fix up the backrefs for DVD/floppy media. */ /* Fix up the backrefs for DVD/floppy media. */ /** @todo convert all this Machine-based voodoo to MediumAttachment
     * based rollback logic. */