VirtualBox

Changeset 26201 in vbox


Ignore:
Timestamp:
Feb 3, 2010 3:18:26 PM (15 years ago)
Author:
vboxsync
Message:

Main: fix deleteSnapshot() which was broken for immutable and writethrough attachments

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

Legend:

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

    r26186 r26201  
    31703170/**
    31713171 * Checks that this hard disk may be discarded and performs necessary state
    3172  * changes.
     3172 * changes. Must not be called for writethrough disks because there is nothing
     3173 * to discard then.
    31733174 *
    31743175 * This method is to be called prior to calling the #discard() to perform
     
    31963197    Assert(m->pVirtualBox->getMediaTreeLockHandle().isWriteLockOnCurrentThread());
    31973198
    3198     AssertReturn(m->type == MediumType_Normal, E_FAIL);
     3199    // Medium must not be writethrough at this point
     3200    AssertReturn(   m->type == MediumType_Normal
     3201                 || m->type == MediumType_Immutable, E_FAIL);
    31993202
    32003203    if (getChildren().size() == 0)
  • trunk/src/VBox/Main/SnapshotImpl.cpp

    r26186 r26201  
    20142014            Assert(pHD);
    20152015            AutoReadLock mlock(pHD COMMA_LOCKVAL_SRC_POS);
    2016             if (pHD->getType() == MediumType_Normal)
     2016
     2017            MediumType_T type = pHD->getType();
     2018            if (type != MediumType_Writethrough) // writethrough images are unaffected by snapshots, so do nothing for them
    20172019            {
     2020                // normal or immutable: then this will need to be discarded
    20182021                ++ulOpCount;
    20192022                ulTotalWeight += (ULONG)(pHD->getSize() / _1M);
     
    21792182                Assert(pAttach->getMedium());
    21802183                ComObjPtr<Medium> pHD = pAttach->getMedium();
    2181                         // do not lock, prepareDiscared() has a write lock which will hang otherwise
     2184
     2185                {
     2186                    // writethrough images are unaffected by snapshots, so do nothing for them
     2187                    AutoReadLock medlock(pHD COMMA_LOCKVAL_SRC_POS);
     2188                    MediumType_T type = pHD->getType();
     2189                    if (type == MediumType_Writethrough)
     2190                        continue;
     2191                }
     2192
     2193                // image is normal or immutable: then this will need to be discarded
     2194
     2195                // do not lock medium now, prepareDiscard() has a write lock which will hang otherwise
    21822196
    21832197#ifdef DEBUG
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