VirtualBox

Changeset 55511 in vbox for trunk/src


Ignore:
Timestamp:
Apr 29, 2015 10:16:01 AM (10 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
99867
Message:

Main/Snapshot: fix handling of saved state with offline snapshots (looked at wrong machine state variable, regression in previous big code structure change), streamline the code path and fix a crash for early failures to take a snapshot. Eliminate a local variable which should always have the same value as the same flag in the task struct, avoiding inconsistent behavior.
Main/Machine: fix sanity check regarding saved state presence when saving the config (resulted in loss of saved state)

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

Legend:

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

    r55437 r55511  
    99959995    if (    mData->mMachineState == MachineState_Saved
    99969996         || mData->mMachineState == MachineState_Restoring
    9997             // when deleting a snapshot we may or may not have a saved state in the current state,
    9998             // so let's not assert here please
    9999          || (    (   mData->mMachineState == MachineState_DeletingSnapshot
    10000                   || mData->mMachineState == MachineState_DeletingSnapshotOnline
    10001                   || mData->mMachineState == MachineState_DeletingSnapshotPaused)
     9997            // when doing certain snapshot operations we may or may not have
     9998            // a saved state in the current state, so keep everything as is
     9999         || (    (   mData->mMachineState == MachineState_Snapshotting
     10000                  || mData->mMachineState == MachineState_DeletingSnapshot)
    1000210001              && (!mSSData->strStateFilePath.isEmpty())
    1000310002            )
  • trunk/src/VBox/Main/src-server/SnapshotImpl.cpp

    r55255 r55511  
    15551555    {
    15561556        // @todo: at this point we have to be in the right state!!!!
    1557         AssertStmt(   !Global::IsOnlineOrTransient(mData->mMachineState)
    1558                    || mData->mMachineState == MachineState_Snapshotting
     1557        AssertStmt(   mData->mMachineState == MachineState_Snapshotting
    15591558                   || mData->mMachineState == MachineState_OnlineSnapshotting
    15601559                   || mData->mMachineState == MachineState_LiveSnapshotting, throw E_FAIL);
     
    15701569        }
    15711570
    1572         if (    !task.m_fTakingSnapshotOnline
    1573              && mData->mMachineState != MachineState_Saved)
    1574         {
    1575             /* save settings to ensure current changes are committed and
    1576              * hard disks are fixed up */
    1577             rc = i_saveSettings(NULL);
    1578                 // no need to check for whether VirtualBox.xml needs changing since
    1579                 // we can't have a machine XML rename pending at this point
    1580             if (FAILED(rc))
    1581                 throw rc;
    1582         }
     1571        /* save settings to ensure current changes are committed and
     1572         * hard disks are fixed up */
     1573        rc = i_saveSettings(NULL);
     1574            // no need to check for whether VirtualBox.xml needs changing since
     1575            // we can't have a machine XML rename pending at this point
     1576        if (FAILED(rc))
     1577            throw rc;
    15831578
    15841579        /* task.m_strStateFilePath is "" when the machine is offline or saved */
     
    15921587                i_composeSavedStateFilename(task.m_strStateFilePath);
    15931588        }
    1594         else if (mData->mMachineState == MachineState_Saved)
     1589        else if (task.m_machineStateBackup == MachineState_Saved)
    15951590            // taking an offline snapshot from machine in "saved" state: use existing state file
    15961591            task.m_strStateFilePath = mSSData->strStateFilePath;
     
    16521647
    16531648        fBeganTakingSnapshot = true;
    1654 
    1655         /* Check sanity: for offline snapshots there must not be a saved state
    1656          * file name. All other combinations are valid (though online snapshots
    1657          * without saved state file seems inconsistent - there are exotic use
    1658          * cases, which need to be explicitly enabled, see the code above. */
    1659         if (   !task.m_fTakingSnapshotOnline
    1660             && !task.m_strStateFilePath.isEmpty())
    1661             throw setError(E_FAIL, "Invalid state of saved state file");
    16621649
    16631650        // STEP 3: save the VM state (if online)
     
    17291716        // have to postpone this to the end as i_finishTakingSnapshot() needs
    17301717        // it for various cleanup steps
    1731         task.m_pSnapshot->uninit();
    1732         task.m_pSnapshot.setNull();
     1718        if (task.m_pSnapshot)
     1719        {
     1720            task.m_pSnapshot->uninit();
     1721            task.m_pSnapshot.setNull();
     1722        }
    17331723    }
    17341724    Assert(alock.isWriteLockOnCurrentThread());
     
    18451835    ComObjPtr<Snapshot> pOldCurrentSnap = mData->mCurrentSnapshot;
    18461836
    1847     bool fOnline = Global::IsOnline(task.m_machineStateBackup);
    1848 
    18491837    HRESULT rc = S_OK;
    18501838
     
    18601848        int flSaveSettings = SaveS_Force;       // do not do a deep compare in machine settings,
    18611849                                                // snapshots change, so we know we need to save
    1862         if (!fOnline)
     1850        if (!task.m_fTakingSnapshotOnline)
    18631851            /* the machine was powered off or saved when taking a snapshot, so
    18641852             * reset the mCurrentStateModified flag */
     
    18711859    {
    18721860        /* associate old hard disks with the snapshot and do locking/unlocking*/
    1873         i_commitMedia(fOnline);
     1861        i_commitMedia(task.m_fTakingSnapshotOnline);
    18741862
    18751863        /* inform callbacks */
     
    18901878
    18911879        // delete the saved state file (it might have been already created)
    1892         if (fOnline)
     1880        if (task.m_fTakingSnapshotOnline)
    18931881            // no need to test for whether the saved state file is shared: an online
    18941882            // snapshot means that a new saved state file was created, which we must
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette