VirtualBox

Ignore:
Timestamp:
Dec 5, 2013 6:53:18 PM (11 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
91125
Message:

6813 - stage 3 rev 1

File:
1 edited

Legend:

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

    r49687 r49795  
    10481048        if (pMedium) // can be NULL for non-harddisk
    10491049        {
    1050             rc = pMedium->addBackReference(mData->mUuid, mSnapshotId);
     1050            rc = pMedium->i_addBackReference(mData->mUuid, mSnapshotId);
    10511051            AssertComRC(rc);
    10521052        }
     
    17821782            ++ulTotalWeight;         // assume one MB weight for each differencing hard disk to manage
    17831783            Assert(pAttach->getMedium());
    1784             LogFlowThisFunc(("op %d: considering hard disk attachment %s\n", ulOpCount, pAttach->getMedium()->getName().c_str()));
     1784            LogFlowThisFunc(("op %d: considering hard disk attachment %s\n", ulOpCount, pAttach->getMedium()->i_getName().c_str()));
    17851785        }
    17861786    }
     
    19701970            if (    !pMedium.isNull()
    19711971                 && pAttach->getType() == DeviceType_HardDisk
    1972                  && !pMedium->getParent().isNull()
    1973                  && pMedium->getChildren().size() == 0
     1972                 && !pMedium->i_getParent().isNull()
     1973                 && pMedium->i_getChildren().size() == 0
    19741974               )
    19751975            {
    1976                 LogFlowThisFunc(("Picked differencing image '%s' for deletion\n", pMedium->getName().c_str()));
     1976                LogFlowThisFunc(("Picked differencing image '%s' for deletion\n", pMedium->i_getName().c_str()));
    19771977
    19781978                llDiffAttachmentsToDelete.push_back(pAttach);
     
    20122012            AutoWriteLock mlock(pMedium COMMA_LOCKVAL_SRC_POS);
    20132013
    2014             LogFlowThisFunc(("Detaching old current state in differencing image '%s'\n", pMedium->getName().c_str()));
     2014            LogFlowThisFunc(("Detaching old current state in differencing image '%s'\n", pMedium->i_getName().c_str()));
    20152015
    20162016            // Normally we "detach" the medium by removing the attachment object
     
    20282028                mMediaData.backedUpData()->mAttachments.remove(pAttach);
    20292029            // then clean up backrefs
    2030             pMedium->removeBackReference(mData->mUuid);
     2030            pMedium->i_removeBackReference(mData->mUuid);
    20312031
    20322032            llDiffsToDelete.push_back(pMedium);
     
    20542054        {
    20552055            ComObjPtr<Medium> &pMedium = *it;
    2056             LogFlowThisFunc(("Deleting old current state in differencing image '%s'\n", pMedium->getName().c_str()));
    2057 
    2058             HRESULT rc2 = pMedium->deleteStorage(NULL /* aProgress */,
    2059                                                  true /* aWait */);
     2056            LogFlowThisFunc(("Deleting old current state in differencing image '%s'\n", pMedium->i_getName().c_str()));
     2057
     2058            HRESULT rc2 = pMedium->i_deleteStorage(NULL /* aProgress */,
     2059                                                   true /* aWait */);
    20602060            // ignore errors here because we cannot roll back after saveSettings() above
    20612061            if (SUCCEEDED(rc2))
     
    21692169                        mUserData->s.strName.c_str(),
    21702170                        childrenCount);
     2171
    21712172    if (pSnapshot == mData->mCurrentSnapshot && childrenCount >= 1)
    21722173        return setError(VBOX_E_INVALID_OBJECT_STATE,
     
    21752176                        mUserData->s.strName.c_str());
    21762177
     2178
    21772179    /* If the snapshot being deleted is the current one, ensure current
    21782180     * settings are committed and saved.
     
    22182220            AutoReadLock mlock(pHD COMMA_LOCKVAL_SRC_POS);
    22192221
    2220             MediumType_T type = pHD->getType();
     2222            MediumType_T type = pHD->i_getType();
    22212223            // writethrough and shareable images are unaffected by snapshots,
    22222224            // so do nothing for them
     
    22272229                // normal or immutable media need attention
    22282230                ++ulOpCount;
    2229                 ulTotalWeight += (ULONG)(pHD->getSize() / _1M);
     2231                ulTotalWeight += (ULONG)(pHD->i_getSize() / _1M);
    22302232            }
    2231             LogFlowThisFunc(("op %d: considering hard disk attachment %s\n", ulOpCount, pHD->getName().c_str()));
     2233            LogFlowThisFunc(("op %d: considering hard disk attachment %s\n", ulOpCount, pHD->i_getName().c_str()));
    22322234        }
    22332235    }
     
    24452447                // unaffected by snapshots, skip them
    24462448                AutoReadLock medlock(pHD COMMA_LOCKVAL_SRC_POS);
    2447                 MediumType_T type = pHD->getType();
     2449                MediumType_T type = pHD->i_getType();
    24482450                if (   type == MediumType_Writethrough
    24492451                    || type == MediumType_Shareable
     
    24532455
    24542456#ifdef DEBUG
    2455             pHD->dumpBackRefs();
     2457            pHD->i_dumpBackRefs();
    24562458#endif
    24572459
     
    25252527                // base disk. Here we need then to update the attachment that
    25262528                // refers to the child and have it point to the parent instead
    2527                 Assert(pHD->getChildren().size() == 1);
    2528 
    2529                 ComObjPtr<Medium> pReplaceHD = pHD->getChildren().front();
     2529                Assert(pHD->i_getChildren().size() == 1);
     2530
     2531                ComObjPtr<Medium> pReplaceHD = pHD->i_getChildren().front();
    25302532
    25312533                ComAssertThrow(pReplaceHD == pSource, E_FAIL);
     
    25352537            Guid replaceSnapshotId;
    25362538
    2537             const Guid *pReplaceMachineId = pSource->getFirstMachineBackrefId();
     2539            const Guid *pReplaceMachineId = pSource->i_getFirstMachineBackrefId();
    25382540            // minimal sanity checking
    25392541            Assert(!pReplaceMachineId || *pReplaceMachineId == mData->mUuid);
     
    25412543                replaceMachineId = *pReplaceMachineId;
    25422544
    2543             const Guid *pSnapshotId = pSource->getFirstMachineBackrefSnapshotId();
     2545            const Guid *pSnapshotId = pSource->i_getFirstMachineBackrefSnapshotId();
    25442546            if (pSnapshotId)
    25452547                replaceSnapshotId = *pSnapshotId;
     
    25512553                // with the snapshot until the merge was successful.
    25522554                HRESULT rc2 = S_OK;
    2553                 rc2 = pSource->removeBackReference(replaceMachineId, replaceSnapshotId);
     2555                rc2 = pSource->i_removeBackReference(replaceMachineId, replaceSnapshotId);
    25542556                AssertComRC(rc2);
    25552557
     
    26082610                    throw rc;
    26092611
    2610                 if(pTarget_local->isMediumFormatFile())
     2612                if(pTarget_local->i_isMediumFormatFile())
    26112613                {
    2612                     int vrc = RTFsQuerySerial(pTarget_local->getLocationFull().c_str(), &pu32Serial);
     2614                    int vrc = RTFsQuerySerial(pTarget_local->i_getLocationFull().c_str(), &pu32Serial);
    26132615                    if (RT_FAILURE(vrc))
    26142616                    {
    26152617                        rc = setError(E_FAIL,
    26162618                                      tr(" Unable to merge storage '%s'. Can't get storage UID "),
    2617                                       pTarget_local->getLocationFull().c_str());
     2619                                      pTarget_local->i_getLocationFull().c_str());
    26182620                        throw rc;
    26192621                    }
     
    26242626                    neededStorageFreeSpace.insert(std::make_pair(pu32Serial,diskSize));
    26252627                    /* linking storage UID with snapshot path, it is a helper container (just for easy finding needed path) */
    2626                     serialMapToStoragePath.insert(std::make_pair(pu32Serial,pTarget_local->getLocationFull().c_str()));
     2628                    serialMapToStoragePath.insert(std::make_pair(pu32Serial,pTarget_local->i_getLocationFull().c_str()));
    26272629                }
    26282630
     
    27292731            {
    27302732                AutoReadLock alock(pMedium COMMA_LOCKVAL_SRC_POS);
    2731                 ulWeight = (ULONG)(pMedium->getSize() / _1M);
     2733                ulWeight = (ULONG)(pMedium->i_getSize() / _1M);
    27322734            }
    27332735
    27342736            aTask.pProgress->SetNextOperation(BstrFmt(tr("Merging differencing image '%s'"),
    2735                                               pMedium->getName().c_str()).raw(),
     2737                                              pMedium->i_getName().c_str()).raw(),
    27362738                                              ulWeight);
    27372739
     
    27452747
    27462748                Assert(   !it->mfMergeForward
    2747                        || pMedium->getChildren().size() == 0);
     2749                       || pMedium->i_getChildren().size() == 0);
    27482750
    27492751                /* Delete the differencing hard disk (has no children). Two
     
    27522754                 * In both cases leave the image in place. If it's the first
    27532755                 * exception the user can delete it later if he wants. */
    2754                 if (!pMedium->getParent().isNull())
     2756                if (!pMedium->i_getParent().isNull())
    27552757                {
    2756                     Assert(pMedium->getState() == MediumState_Deleting);
     2758                    Assert(pMedium->i_getState() == MediumState_Deleting);
    27572759                    /* No need to hold the lock any longer. */
    27582760                    mLock.release();
    2759                     rc = pMedium->deleteStorage(&aTask.pProgress,
    2760                                                 true /* aWait */);
     2761                    rc = pMedium->i_deleteStorage(&aTask.pProgress,
     2762                                                  true /* aWait */);
    27612763                    if (FAILED(rc))
    27622764                        throw rc;
     
    27912793                {
    27922794                    // normal medium merge, in the direction decided earlier
    2793                     rc = it->mpSource->mergeTo(it->mpTarget,
    2794                                                it->mfMergeForward,
    2795                                                it->mpParentForTarget,
    2796                                                it->mpChildrenToReparent,
    2797                                                it->mpMediumLockList,
    2798                                                &aTask.pProgress,
    2799                                                true /* aWait */);
     2795                    rc = it->mpSource->i_mergeTo(it->mpTarget,
     2796                                                 it->mfMergeForward,
     2797                                                 it->mpParentForTarget,
     2798                                                 it->mpChildrenToReparent,
     2799                                                 it->mpMediumLockList,
     2800                                                 &aTask.pProgress,
     2801                                                 true /* aWait */);
    28002802                }
    28012803
     
    28092811                {
    28102812                    AutoReadLock mlock(it->mpSource COMMA_LOCKVAL_SRC_POS);
    2811                     if (!it->mpSource->isMediumFormatFile())
     2813                    if (!it->mpSource->i_isMediumFormatFile())
    28122814                        // Diff medium not backed by a file - cannot get status so
    28132815                        // be pessimistic.
    28142816                        throw rc;
    2815                     const Utf8Str &loc = it->mpSource->getLocationFull();
     2817                    const Utf8Str &loc = it->mpSource->i_getLocationFull();
    28162818                    // Source medium is still there, so merge failed early.
    28172819                    if (RTFileExists(loc.c_str()))
     
    28482850                pAtt = findAttachment(pSnapMachine->mMediaData->mAttachments,
    28492851                                      it->mpTarget);
    2850                 it->mpTarget->removeBackReference(machineId, snapshotId);
     2852                it->mpTarget->i_removeBackReference(machineId, snapshotId);
    28512853            }
    28522854            else
     
    28722874                    AutoWriteLock attLock(pAtt COMMA_LOCKVAL_SRC_POS);
    28732875                    pAtt->updateMedium(it->mpTarget);
    2874                     it->mpTarget->addBackReference(pMachine->mData->mUuid, childSnapshotId);
     2876                    it->mpTarget->i_addBackReference(pMachine->mData->mUuid, childSnapshotId);
    28752877                }
    28762878                else
     
    28822884                    // Needs a bit of special treatment due to this difference.
    28832885                    if (it->mfNeedsOnlineMerge)
    2884                         it->mpTarget->addBackReference(pMachine->mData->mUuid, childSnapshotId);
     2886                        it->mpTarget->i_addBackReference(pMachine->mData->mUuid, childSnapshotId);
    28852887                }
    28862888            }
     
    30213023
    30223024    // Medium must not be writethrough/shareable/readonly at this point
    3023     MediumType_T type = aHD->getType();
     3025    MediumType_T type = aHD->i_getType();
    30243026    AssertReturn(   type != MediumType_Writethrough
    30253027                 && type != MediumType_Shareable
     
    30303032    fNeedsOnlineMerge = false;
    30313033
    3032     if (aHD->getChildren().size() == 0)
     3034    if (aHD->i_getChildren().size() == 0)
    30333035    {
    30343036        /* This technically is no merge, set those values nevertheless.
     
    30383040
    30393041        /* special treatment of the last hard disk in the chain: */
    3040         if (aHD->getParent().isNull())
     3042        if (aHD->i_getParent().isNull())
    30413043        {
    30423044            /* lock only, to prevent any usage until the snapshot deletion
     
    30483050        /* the differencing hard disk w/o children will be deleted, protect it
    30493051         * from attaching to other VMs (this is why Deleting) */
    3050         return aHD->markForDeletion();
     3052        return aHD->i_markForDeletion();
    30513053   }
    30523054
    30533055    /* not going multi-merge as it's too expensive */
    3054     if (aHD->getChildren().size() > 1)
     3056    if (aHD->i_getChildren().size() > 1)
    30553057        return setError(E_FAIL,
    30563058                        tr("Hard disk '%s' has more than one child hard disk (%d)"),
    3057                         aHD->getLocationFull().c_str(),
    3058                         aHD->getChildren().size());
    3059 
    3060     ComObjPtr<Medium> pChild = aHD->getChildren().front();
     3059                        aHD->i_getLocationFull().c_str(),
     3060                        aHD->i_getChildren().size());
     3061
     3062    ComObjPtr<Medium> pChild = aHD->i_getChildren().front();
    30613063
    30623064    AutoWriteLock childLock(pChild COMMA_LOCKVAL_SRC_POS);
    30633065
    30643066    /* the rest is a normal merge setup */
    3065     if (aHD->getParent().isNull())
     3067    if (aHD->i_getParent().isNull())
    30663068    {
    30673069        /* base hard disk, backward merge */
    3068         const Guid *pMachineId1 = pChild->getFirstMachineBackrefId();
    3069         const Guid *pMachineId2 = aHD->getFirstMachineBackrefId();
     3070        const Guid *pMachineId1 = pChild->i_getFirstMachineBackrefId();
     3071        const Guid *pMachineId2 = aHD->i_getFirstMachineBackrefId();
    30703072        if (pMachineId1 && pMachineId2 && *pMachineId1 != *pMachineId2)
    30713073        {
     
    30873089        childLock.release();
    30883090        alock.release();
    3089         HRESULT rc = aHD->queryPreferredMergeDirection(pChild, fMergeForward);
     3091        HRESULT rc = aHD->i_queryPreferredMergeDirection(pChild, fMergeForward);
    30903092        alock.acquire();
    30913093        childLock.acquire();
     
    31113113    childLock.release();
    31123114    alock.release();
    3113     rc = aSource->prepareMergeTo(aTarget, &aMachineId, &aSnapshotId,
     3115    rc = aSource->i_prepareMergeTo(aTarget, &aMachineId, &aSnapshotId,
    31143116                                 !fOnlineMergePossible /* fLockMedia */,
    31153117                                 aMergeForward, aParentForTarget,
     
    32213223                if (FAILED(rc))
    32223224                {
    3223                     aSource->cancelMergeTo(aChildrenToReparent, aMediumLockList);
     3225                    aSource->i_cancelMergeTo(aChildrenToReparent, aMediumLockList);
    32243226                    rc = setError(rc,
    32253227                                  tr("Cannot lock hard disk '%s' for a live merge"),
    3226                                   aHD->getLocationFull().c_str());
     3228                                  aHD->i_getLocationFull().c_str());
    32273229                }
    32283230                else
     
    32353237            else
    32363238            {
    3237                 aSource->cancelMergeTo(aChildrenToReparent, aMediumLockList);
     3239                aSource->i_cancelMergeTo(aChildrenToReparent, aMediumLockList);
    32383240                rc = setError(rc,
    32393241                              tr("Failed to construct lock list for a live merge of hard disk '%s'"),
    3240                               aHD->getLocationFull().c_str());
     3242                              aHD->i_getLocationFull().c_str());
    32413243            }
    32423244
     
    32613263                    // blindly apply this, only needed for medium objects which
    32623264                    // would be deleted as part of the merge
    3263                     pMedium->unmarkLockedForDeletion();
     3265                    pMedium->i_unmarkLockedForDeletion();
    32643266                }
    32653267            }
     
    32683270        else
    32693271        {
    3270             aSource->cancelMergeTo(aChildrenToReparent, aMediumLockList);
     3272            aSource->i_cancelMergeTo(aChildrenToReparent, aMediumLockList);
    32713273            rc = setError(rc,
    32723274                          tr("Cannot lock hard disk '%s' for an offline merge"),
    3273                           aHD->getLocationFull().c_str());
     3275                          aHD->i_getLocationFull().c_str());
    32743276        }
    32753277    }
     
    33073309        AutoMultiWriteLock2 mLock(&mParent->getMediaTreeLockHandle(), aHD->lockHandle() COMMA_LOCKVAL_SRC_POS);
    33083310
    3309         Assert(aHD->getChildren().size() == 0);
    3310 
    3311         if (aHD->getParent().isNull())
     3311        Assert(aHD->i_getChildren().size() == 0);
     3312
     3313        if (aHD->i_getParent().isNull())
    33123314        {
    33133315            Assert(!aHDLockToken.isNull());
     
    33203322        else
    33213323        {
    3322             HRESULT rc = aHD->unmarkForDeletion();
     3324            HRESULT rc = aHD->i_unmarkForDeletion();
    33233325            AssertComRC(rc);
    33243326        }
     
    33303332            // Online merge uses the medium lock list of the VM, so give
    33313333            // an empty list to cancelMergeTo so that it works as designed.
    3332             aSource->cancelMergeTo(aChildrenToReparent, new MediumLockList());
     3334            aSource->i_cancelMergeTo(aChildrenToReparent, new MediumLockList());
    33333335
    33343336            // clean up the VM medium lock list ourselves
     
    33453347                ComObjPtr<Medium> pMedium = it->GetMedium();
    33463348                AutoWriteLock mediumLock(pMedium COMMA_LOCKVAL_SRC_POS);
    3347                 if (pMedium->getState() == MediumState_Deleting)
    3348                     pMedium->unmarkForDeletion();
     3349                if (pMedium->i_getState() == MediumState_Deleting)
     3350                    pMedium->i_unmarkForDeletion();
    33493351                else
    33503352                {
    33513353                    // blindly apply this, only needed for medium objects which
    33523354                    // would be deleted as part of the merge
    3353                     pMedium->unmarkLockedForDeletion();
     3355                    pMedium->i_unmarkLockedForDeletion();
    33543356                }
    33553357                mediumLock.release();
     
    33603362        else
    33613363        {
    3362             aSource->cancelMergeTo(aChildrenToReparent, aMediumLockList);
     3364            aSource->i_cancelMergeTo(aChildrenToReparent, aMediumLockList);
    33633365        }
    33643366    }
     
    33673369    {
    33683370        // reattach the source media to the snapshot
    3369         HRESULT rc = aSource->addBackReference(aMachineId, aSnapshotId);
     3371        HRESULT rc = aSource->i_addBackReference(aMachineId, aSnapshotId);
    33703372        AssertComRC(rc);
    33713373    }
     
    35123514        // then, reparent it and disconnect the deleted branch at
    35133515        // both ends (chain->parent() is source's parent)
    3514         pDeleteRec->mpTarget->deparent();
    3515         pDeleteRec->mpTarget->setParent(pDeleteRec->mpParentForTarget);
     3516        pDeleteRec->mpTarget->i_deparent();
     3517        pDeleteRec->mpTarget->i_setParent(pDeleteRec->mpParentForTarget);
    35163518        if (pDeleteRec->mpParentForTarget)
    3517             pDeleteRec->mpSource->deparent();
     3519            pDeleteRec->mpSource->i_deparent();
    35183520
    35193521        // then, register again
     
    35233525    else
    35243526    {
    3525         Assert(pDeleteRec->mpTarget->getChildren().size() == 1);
    3526         targetChild = pDeleteRec->mpTarget->getChildren().front();
     3527        Assert(pDeleteRec->mpTarget->i_getChildren().size() == 1);
     3528        targetChild = pDeleteRec->mpTarget->i_getChildren().front();
    35273529
    35283530        // disconnect the deleted branch at the elder end
    3529         targetChild->deparent();
     3531        targetChild->i_deparent();
    35303532
    35313533        // Update parent UUIDs of the source's children, reparent them and
     
    35403542            // need manual fixing via VBoxManage to adjust the parent UUID.
    35413543            treeLock.release();
    3542             pDeleteRec->mpTarget->fixParentUuidOfChildren(pDeleteRec->mpChildrenToReparent);
     3544            pDeleteRec->mpTarget->i_fixParentUuidOfChildren(pDeleteRec->mpChildrenToReparent);
    35433545            // The childen are still write locked, unlock them now and don't
    35443546            // rely on the destructor doing it very late.
     
    35583560                AutoWriteLock childLock(pMedium COMMA_LOCKVAL_SRC_POS);
    35593561
    3560                 pMedium->deparent();  // removes pMedium from source
    3561                 pMedium->setParent(pDeleteRec->mpTarget);
     3562                pMedium->i_deparent();  // removes pMedium from source
     3563                pMedium->i_setParent(pDeleteRec->mpTarget);
    35623564            }
    35633565        }
     
    35843586        /* The target and all images not merged (readonly) are skipped */
    35853587        if (   pMedium == pDeleteRec->mpTarget
    3586             || pMedium->getState() == MediumState_LockedRead)
     3588            || pMedium->i_getState() == MediumState_LockedRead)
    35873589        {
    35883590            ++it;
     
    36073609            if (pMedium == pDeleteRec->mpSource)
    36083610            {
    3609                 Assert(pDeleteRec->mpSource->getChildren().size() == 0);
    3610                 Assert(pDeleteRec->mpSource->getFirstMachineBackrefId() == NULL);
     3611                Assert(pDeleteRec->mpSource->i_getChildren().size() == 0);
     3612                Assert(pDeleteRec->mpSource->i_getFirstMachineBackrefId() == NULL);
    36113613            }
    36123614
Note: See TracChangeset for help on using the changeset viewer.

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