VirtualBox

Changeset 24458 in vbox


Ignore:
Timestamp:
Nov 6, 2009 4:02:24 PM (15 years ago)
Author:
vboxsync
Message:

Main: fix medium detachments when restoring snapshot, second try

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

Legend:

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

    r24345 r24458  
    31893189     * time when discard() is called, there must be no any attachments at all
    31903190     * (the code calling prepareDiscard() should detach). */
    3191     AssertReturn(    m->backRefs.size() == 1
    3192                   && !m->backRefs.front().inCurState
    3193                   && m->backRefs.front().llSnapshotIds.size() == 1,
    3194                  E_FAIL);
     3191    AssertReturn(m->backRefs.size() == 1, E_FAIL);
     3192    AssertReturn(!m->backRefs.front().inCurState, E_FAIL);
     3193    AssertReturn(m->backRefs.front().llSnapshotIds.size() == 1, E_FAIL);
    31953194
    31963195    ComObjPtr<Medium> child = children().front();
     
    40714070
    40724071    if (m->backRefs.size() != 0)
     4072    {
     4073        Utf8Str strMachines;
     4074        for (BackRefList::const_iterator it = m->backRefs.begin();
     4075            it != m->backRefs.end();
     4076            ++it)
     4077        {
     4078            const BackRef &b = *it;
     4079            if (strMachines.length())
     4080                strMachines.append(", ");
     4081            strMachines.append(b.machineId.toString().c_str());
     4082        }
     4083#ifdef DEBUG
     4084        dumpBackRefs();
     4085#endif
    40734086        return setError(VBOX_E_OBJECT_IN_USE,
    4074                         tr("Hard disk '%s' is attached to %d virtual machines"),
    4075                         m->strLocationFull.raw(), m->backRefs.size());
     4087                        tr("Cannot delete storage: hard disk '%s' is still attached to the following %d virtual machine(s): %s"),
     4088                        m->strLocationFull.c_str(),
     4089                        m->backRefs.size(),
     4090                        strMachines.c_str());
     4091    }
    40764092
    40774093    HRESULT rc = canClose();
  • trunk/src/VBox/Main/SnapshotImpl.cpp

    r24447 r24458  
    18101810            LogFlowThisFunc(("Detaching old current state in differencing image '%s'\n", pMedium->name().raw()));
    18111811
    1812             // we "detach" the medium by removing the attachment object
    1813             // from the current machine data; saveSettings() below will then
     1812            // Normally we "detach" the medium by removing the attachment object
     1813            // from the current machine data; saveSettings() below would then
    18141814            // compare the current machine data with the one in the backup
    1815             // and actually call Medium::detachFrom()
     1815            // and actually call Medium::detachFrom(). But that works only half
     1816            // the time in our case so instead we force a detachment here:
     1817            // remove from machine data
    18161818            mMediaData->mAttachments.remove(pAttach);
     1819            // remove it from the backup or else saveSettings will try to detach
     1820            // it again and assert
     1821            mMediaData.backedUpData()->mAttachments.remove(pAttach);
     1822            // then clean up backrefs
     1823            pMedium->detachFrom(mData->mUuid);
    18171824
    18181825            llDiffsToDelete.push_back(pMedium);
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