VirtualBox

Changeset 107229 in vbox


Ignore:
Timestamp:
Dec 4, 2024 9:01:51 PM (8 weeks ago)
Author:
vboxsync
Message:

Main/Medium: Address broken reference counting of medium back references
when snapshots are involved. Follow-up to r165743 to handle the
scenario of running a restored snapshot with attached removable media
since in this case there won't be a call to Medium::i_removeBackReference()
for the removable media associated with the machine since the snapshot
is running and as such the reference count remains at '1' for the
removable media device(s) even after all the back references in the
snapshots are removed.

File:
1 edited

Legend:

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

    r106976 r107229  
    48194819    }
    48204820
    4821     /* if the backref becomes empty, remove it */
    4822     if (it->fInCurState == false && it->iRefCnt == 0 && it->llSnapshotIds.size() == 0)
     4821    /* The common case is that the backref will become "empty" with the reference
     4822     * count dropping to zero (iRefCnt=0), fInCurState=false, and no more snapshot
     4823     * references (llSnapshotIds.size()=0) and thus the back reference is removed
     4824     * at that point.  However there is an exception and that is when a restored
     4825     * snapshot is running and in that case there will be no i_removeBackReference()
     4826     * call for any attached removable device referencing just the machine
     4827     * (aSnapshotId.isZero()) so in such cases iRefCnt will be '1' and won't ever
     4828     * drop to zero so remove such back references here as well. */
     4829    if (   it->fInCurState == false
     4830        && it->llSnapshotIds.size() == 0
     4831        && (it->iRefCnt == 0 || (fDvd && it->iRefCnt == 1)))
    48234832        m->backRefs.erase(it);
    48244833
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