VirtualBox

Changeset 55728 in vbox for trunk/src/VBox/Main/src-server


Ignore:
Timestamp:
May 7, 2015 1:58:38 PM (10 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
100140
Message:

Main/Machine+Snapshot+Medium: Remove bogus assertion when locking a machine for shared access. Fix a race between querying medium information and deleting the medium, which was triggered by the GUI medium thread querying the same medium which restoring a snapshot wanted to delete (timing sensitive, happened most with poweroff/restore snapshot). Additionally move the machine state update for restoring a snapshot to the end, when the operation is pretty much done. For taking a snapshot, make sure that the corresponding event is signalled after the operation completed.

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

Legend:

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

    r55674 r55728  
    32083208HRESULT Machine::lockMachine(const ComPtr<ISession> &aSession,
    32093209                             LockType_T aLockType)
    3210 
    32113210{
    32123211    /* check the session state */
     
    32603259
    32613260        // copy pointers to W (the write-locking session) before leaving lock (these must not be NULL)
    3262         ComAssertRet(mData->mSession.mLockType == LockType_Write || mData->mSession.mLockType == LockType_VM, E_FAIL);
    32633261        ComPtr<IInternalSessionControl> pSessionW = mData->mSession.mDirectControl;
    32643262        ComAssertRet(!pSessionW.isNull(), E_FAIL);
     
    1000810006            // a saved state in the current state, so keep everything as is
    1000910007         || (    (   mData->mMachineState == MachineState_Snapshotting
    10010                   || mData->mMachineState == MachineState_DeletingSnapshot)
     10008                  || mData->mMachineState == MachineState_DeletingSnapshot
     10009                  || mData->mMachineState == MachineState_RestoringSnapshot)
    1001110010              && (!mSSData->strStateFilePath.isEmpty())
    1001210011            )
  • trunk/src/VBox/Main/src-server/MediumImpl.cpp

    r55285 r55728  
    46474647                           tr("Medium format '%s' does not support storage deletion"),
    46484648                           m->strFormat.c_str());
     4649
     4650        /* Wait for a concurrently running Medium::i_queryInfo to complete. */
     4651        /** @todo r=klaus would be great if this could be moved to the async
     4652         * part of the operation as it can take quite a while */
     4653        if (m->queryInfoRunning)
     4654        {
     4655            while (m->queryInfoRunning)
     4656            {
     4657                multilock.release();
     4658                /* Must not hold the media tree lock or the object lock, as
     4659                 * Medium::i_queryInfo needs this lock and thus we would run
     4660                 * into a deadlock here. */
     4661                Assert(!m->pVirtualBox->i_getMediaTreeLockHandle().isWriteLockOnCurrentThread());
     4662                Assert(!isWriteLockOnCurrentThread());
     4663                {
     4664                    AutoReadLock qlock(m->queryInfoSem COMMA_LOCKVAL_SRC_POS);
     4665                }
     4666                multilock.acquire();
     4667            }
     4668        }
    46494669
    46504670        /* Note that we are fine with Inaccessible state too: a) for symmetry
  • trunk/src/VBox/Main/src-server/SnapshotImpl.cpp

    r55698 r55728  
    17961796    task.m_pProgress->i_notifyComplete(rc);
    17971797
     1798    if (SUCCEEDED(rc))
     1799        mParent->i_onSnapshotTaken(mData->mUuid,
     1800                                   task.m_pSnapshot->i_getId());
    17981801    LogFlowThisFuncLeave();
    17991802}
     
    18641867        /* associate old hard disks with the snapshot and do locking/unlocking*/
    18651868        i_commitMedia(task.m_fTakingSnapshotOnline);
    1866 
    1867         /* inform callbacks */
    1868         mParent->i_onSnapshotTaken(mData->mUuid,
    1869                                    task.m_pSnapshot->i_getId());
    18701869        alock.release();
    18711870    }
     
    20392038
    20402039    HRESULT rc = S_OK;
    2041 
    2042     bool stateRestored = false;
    20432040
    20442041    try
     
    21612158         * state accordingly no matter of the delete snapshot result */
    21622159        if (mSSData->strStateFilePath.isNotEmpty())
    2163             i_setMachineState(MachineState_Saved);
     2160            task.modifyBackedUpState(MachineState_Saved);
    21642161        else
    2165             i_setMachineState(MachineState_PoweredOff);
    2166 
    2167         stateRestored = true;
     2162            task.modifyBackedUpState(MachineState_PoweredOff);
    21682163
    21692164        /* Paranoia: no one must have saved the settings in the mean time. If
     
    22522247        i_rollback(false /* aNotify */);
    22532248
    2254         if (!stateRestored)
    2255         {
    2256             /* restore the machine state */
    2257             i_setMachineState(task.m_machineStateBackup);
    2258         }
    22592249    }
    22602250
    22612251    mParent->i_saveModifiedRegistries();
     2252
     2253    /* restore the machine state */
     2254    i_setMachineState(task.m_machineStateBackup);
    22622255
    22632256    /* set the result (this will try to fetch current error info on failure) */
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