VirtualBox

Changeset 24509 in vbox


Ignore:
Timestamp:
Nov 9, 2009 2:59:05 PM (15 years ago)
Author:
vboxsync
Message:

Main: fix deleteSnapshot failure: medium backreferences were not updated correctly after attachment of a new disk so that detachFrom() failed if the disk had been attached in the same session (e.g. through takeSnapshot())

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

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/MediumImpl.cpp

    r24462 r24509  
    7171            const Guid &aSnapshotId = Guid::Empty)
    7272        : machineId(aMachineId),
    73           inCurState(aSnapshotId.isEmpty())
     73          fInCurState(aSnapshotId.isEmpty())
    7474    {
    7575        if (!aSnapshotId.isEmpty())
     
    7878
    7979    Guid machineId;
    80     bool inCurState : 1;
     80    bool fInCurState : 1;
    8181    GuidList llSnapshotIds;
    8282};
     
    17931793            /* if the medium is attached to the machine in the current state, we
    17941794             * return its ID as the first element of the array */
    1795             if (it->inCurState)
    1796                 ++ size;
     1795            if (it->fInCurState)
     1796                ++size;
    17971797
    17981798            if (size > 0)
     
    18011801
    18021802                size_t j = 0;
    1803                 if (it->inCurState)
    1804                     it->machineId.toUtf16().detachTo(&snapshotIds [j ++]);
     1803                if (it->fInCurState)
     1804                    it->machineId.toUtf16().detachTo(&snapshotIds[j++]);
    18051805
    18061806                for (BackRef::GuidList::const_iterator jt = it->llSnapshotIds.begin();
     
    18081808                     ++jt, ++j)
    18091809                {
    1810                      (*jt).toUtf16().detachTo(&snapshotIds [j]);
     1810                     (*jt).toUtf16().detachTo(&snapshotIds[j]);
    18111811                }
    18121812            }
     
    26892689    }
    26902690
     2691    // if the caller has not supplied a snapshot ID, then we're attaching
     2692    // to a machine a medium which represents the machine's current state,
     2693    // so set the flag
    26912694    if (aSnapshotId.isEmpty())
    26922695    {
    26932696        /* sanity: no duplicate attachments */
    2694         AssertReturn(!it->inCurState, E_FAIL);
    2695         it->inCurState = true;
     2697        AssertReturn(!it->fInCurState, E_FAIL);
     2698        it->fInCurState = true;
    26962699
    26972700        return S_OK;
    26982701    }
     2702
     2703    // otherwise: a snapshot medium is being attached
    26992704
    27002705    /* sanity: no duplicate attachments */
     
    27152720
    27162721    it->llSnapshotIds.push_back(aSnapshotId);
     2722    it->fInCurState = false;
    27172723
    27182724    LogFlowThisFuncLeave();
     
    27472753    {
    27482754        /* remove the current state attachment */
    2749         it->inCurState = false;
     2755        it->fInCurState = false;
    27502756    }
    27512757    else
     
    27602766
    27612767    /* if the backref becomes empty, remove it */
    2762     if (it->inCurState == false && it->llSnapshotIds.size() == 0)
     2768    if (it->fInCurState == false && it->llSnapshotIds.size() == 0)
    27632769        m->backRefs.erase(it);
    27642770
     
    27832789    {
    27842790        const BackRef &ref = *it2;
    2785         LogFlowThisFunc(("  Backref from machine {%RTuuid}\n", ref.machineId.raw()));
     2791        LogFlowThisFunc(("  Backref from machine {%RTuuid} (fInCurState: %d)\n", ref.machineId.raw(), ref.fInCurState));
    27862792
    27872793        for (BackRef::GuidList::const_iterator jt2 = it2->llSnapshotIds.begin();
     
    28742880        std::find_if(m->backRefs.begin(), m->backRefs.end(),
    28752881                        BackRef::EqualsTo(aMachineId));
    2876     return it != m->backRefs.end() && it->inCurState;
     2882    return it != m->backRefs.end() && it->fInCurState;
    28772883}
    28782884
     
    31903196     * (the code calling prepareDiscard() should detach). */
    31913197    AssertReturn(m->backRefs.size() == 1, E_FAIL);
    3192     AssertReturn(!m->backRefs.front().inCurState, E_FAIL);
     3198    AssertReturn(!m->backRefs.front().fInCurState, E_FAIL);
    31933199    AssertReturn(m->backRefs.front().llSnapshotIds.size() == 1, E_FAIL);
    31943200
     
    42344240         it != m->backRefs.end(); ++ it)
    42354241    {
    4236         if (it->inCurState)
     4242        if (it->fInCurState)
    42374243        {
    42384244            /* Note: when a VM snapshot is being taken, all normal hard disks
  • trunk/src/VBox/Main/SnapshotImpl.cpp

    r24458 r24509  
    21282128                        // do not lock, prepareDiscared() has a write lock which will hang otherwise
    21292129
     2130#ifdef DEBUG
     2131                pHD->dumpBackRefs();
     2132#endif
     2133
    21302134                Medium::MergeChain *chain = NULL;
    21312135
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