VirtualBox

Changeset 49687 in vbox


Ignore:
Timestamp:
Nov 27, 2013 6:00:49 PM (11 years ago)
Author:
vboxsync
Message:

Main/Snapshot: block deleting of current snapshot if it has child snapshots, as this would lead to VM config corruption, plus safety belts in the GUI and settings reader

Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/doc/manual/user_ChangeLogImpl.xml

    r49682 r49687  
    1818
    1919    <itemizedlist>
     20
     21      <listitem>
     22        <para>API: block the removal of the current snapshot if it has child
     23           snapshots (only relevant for VMs without snapshottable hard disks,
     24           their presence always prevented removal), which resulted in VM
     25           config corruption</para>
     26      </listitem>
     27
     28      <listitem>
     29        <para>API: mark VM configs with snapshots but without current snapshot
     30           as inaccessible, as this combination is nonsense</para>
     31      </listitem>
    2032
    2133      <listitem>
  • trunk/include/VBox/settings.h

    r49587 r49687  
    12761276    void readAutostart(const xml::ElementNode *pElmAutostart, Autostart *pAutostart);
    12771277    void readGroups(const xml::ElementNode *elmGroups, StringsList *pllGroups);
    1278     void readSnapshot(uint32_t depth, const xml::ElementNode &elmSnapshot, Snapshot &snap);
     1278    bool readSnapshot(const com::Guid &curSnapshotUuid, uint32_t depth, const xml::ElementNode &elmSnapshot, Snapshot &snap);
    12791279    void convertOldOSType_pre1_5(com::Utf8Str &str);
    12801280    void readMachine(const xml::ElementNode &elmMachine);
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/VBoxSnapshotsWgt.cpp

    r48534 r49687  
    10181018    item->recache();
    10191019
    1020     if (mMachine.GetCurrentSnapshot().GetId() == aSnapshot.GetId())
     1020    CSnapshot curSnapshot = mMachine.GetCurrentSnapshot();
     1021    if (!curSnapshot.isNull() && curSnapshot.GetId() == aSnapshot.GetId())
    10211022    {
    10221023        item->setBold (true);
  • trunk/src/VBox/Main/src-server/SnapshotImpl.cpp

    r48311 r49687  
    21692169                        mUserData->s.strName.c_str(),
    21702170                        childrenCount);
     2171    if (pSnapshot == mData->mCurrentSnapshot && childrenCount >= 1)
     2172        return setError(VBOX_E_INVALID_OBJECT_STATE,
     2173                        tr("Snapshot '%s' of the machine '%s' cannot be deleted, because it is the current snapshot and has one child snapshot"),
     2174                        pSnapshot->getName().c_str(),
     2175                        mUserData->s.strName.c_str());
    21712176
    21722177    /* If the snapshot being deleted is the current one, ensure current
  • trunk/src/VBox/Main/xml/Settings.cpp

    r49296 r49687  
    36983698 * Snapshot structure.
    36993699 *
     3700 * @param curSnapshotUuid
    37003701 * @param depth
    37013702 * @param elmSnapshot
    37023703 * @param snap
    3703  */
    3704 void MachineConfigFile::readSnapshot(uint32_t depth,
     3704 * @returns true if curSnapshotUuid is in this snapshot subtree, otherwise false
     3705 */
     3706bool MachineConfigFile::readSnapshot(const Guid &curSnapshotUuid,
     3707                                     uint32_t depth,
    37053708                                     const xml::ElementNode &elmSnapshot,
    37063709                                     Snapshot &snap)
     
    37143717        throw ConfigFileError(this, &elmSnapshot, N_("Required Snapshot/@uuid attribute is missing"));
    37153718    parseUUID(snap.uuid, strTemp);
     3719    bool foundCurrentSnapshot = (snap.uuid == curSnapshotUuid);
    37163720
    37173721    if (!elmSnapshot.getAttributeValue("name", snap.strName))
     
    37583762                    // small, especially with XPCOM.
    37593763                    Snapshot *child = new Snapshot();
    3760                     readSnapshot(depth + 1, *pelmChildSnapshot, *child);
     3764                    bool found = readSnapshot(curSnapshotUuid, depth + 1, *pelmChildSnapshot, *child);
     3765                    foundCurrentSnapshot = foundCurrentSnapshot || found;
    37613766                    snap.llChildSnapshots.push_back(*child);
    37623767                    delete child;
     
    37743779    readAutostart(elmSnapshot.findChildElement("Autostart"), &snap.autostart);
    37753780    // note: Groups exist only for Machine, not for Snapshot
     3781
     3782    return foundCurrentSnapshot;
    37763783}
    37773784
     
    38943901            else if (pelmMachineChild->nameEquals("Snapshot"))
    38953902            {
     3903                if (uuidCurrentSnapshot.isZero())
     3904                    throw ConfigFileError(this, &elmMachine, N_("Snapshots present but required Machine/@currentSnapshot attribute is missing"));
     3905                bool foundCurrentSnapshot = false;
    38963906                Snapshot snap;
    38973907                // this will recurse into child snapshots, if necessary
    3898                 readSnapshot(1, *pelmMachineChild, snap);
     3908                foundCurrentSnapshot = readSnapshot(uuidCurrentSnapshot, 1, *pelmMachineChild, snap);
     3909                if (!foundCurrentSnapshot)
     3910                    throw ConfigFileError(this, &elmMachine, N_("Snapshots present but none matches the UUID in the Machine/@currentSnapshot attribute"));
    38993911                llFirstSnapshot.push_back(snap);
    39003912            }
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