- Timestamp:
- Oct 14, 2021 8:04:27 PM (3 years ago)
- Location:
- trunk/src/VBox/Main
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/include/MachineImpl.h
r91476 r91743 632 632 Machine *i_getMachine(); 633 633 634 void i_ensureNoStateDependencies( );634 void i_ensureNoStateDependencies(AutoWriteLock &alock); 635 635 636 636 virtual HRESULT i_setMachineState(MachineState_T aMachineState); … … 682 682 683 683 HRESULT i_prepareSaveSettings(bool *pfNeedsGlobalSaveSettings); 684 HRESULT i_saveSettings(bool *pfNeedsGlobalSaveSettings, int aFlags = 0);684 HRESULT i_saveSettings(bool *pfNeedsGlobalSaveSettings, AutoWriteLock &alock, int aFlags = 0); 685 685 686 686 void i_copyMachineDataToSettings(settings::MachineConfigFile &config); -
trunk/src/VBox/Main/src-server/MachineImpl.cpp
r91718 r91743 829 829 { 830 830 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); 831 i_saveSettings(NULL, Machine::SaveS_Force);831 i_saveSettings(NULL, alock, Machine::SaveS_Force); 832 832 } 833 833 } … … 1610 1610 /** Save settings if online - @todo why is this required? -- @bugref{6818} */ 1611 1611 if (Global::IsOnline(mData->mMachineState)) 1612 i_saveSettings(NULL );1612 i_saveSettings(NULL, alock); 1613 1613 1614 1614 return S_OK; … … 2664 2664 /** Save settings if online - @todo why is this required? -- @bugref{6818} */ 2665 2665 if (Global::IsOnline(mData->mMachineState)) 2666 i_saveSettings(NULL );2666 i_saveSettings(NULL, alock); 2667 2667 2668 2668 return S_OK; … … 2695 2695 /** Save settings if online - @todo why is this required? -- @bugref{6818} */ 2696 2696 if (Global::IsOnline(mData->mMachineState)) 2697 i_saveSettings(NULL );2697 i_saveSettings(NULL, alock); 2698 2698 2699 2699 return S_OK; … … 2727 2727 /** Save settings if online - @todo why is this required? -- @bugref{6818} */ 2728 2728 if (Global::IsOnline(mData->mMachineState)) 2729 i_saveSettings(NULL );2729 i_saveSettings(NULL, alock); 2730 2730 2731 2731 return S_OK; … … 4801 4801 // extradata items at all (unlike all other settings), so the old/new 4802 4802 // settings comparison would give a wrong result! 4803 i_saveSettings(&fNeedsGlobalSaveSettings, SaveS_Force);4803 i_saveSettings(&fNeedsGlobalSaveSettings, alock, SaveS_Force); 4804 4804 4805 4805 if (fNeedsGlobalSaveSettings) … … 4838 4838 /* save all VM data excluding snapshots */ 4839 4839 bool fNeedsGlobalSaveSettings = false; 4840 rc = i_saveSettings(&fNeedsGlobalSaveSettings );4840 rc = i_saveSettings(&fNeedsGlobalSaveSettings, mlock); 4841 4841 mlock.release(); 4842 4842 … … 4931 4931 4932 4932 // wait for state dependents to drop to zero 4933 i_ensureNoStateDependencies( );4933 i_ensureNoStateDependencies(alock); 4934 4934 4935 4935 if (!mData->mAccessible) … … 6411 6411 /** Save settings if online - @todo why is this required? -- @bugref{6818} */ 6412 6412 if (Global::IsOnline(mData->mMachineState)) 6413 i_saveSettings(NULL );6413 i_saveSettings(NULL, alock); 6414 6414 6415 6415 return S_OK; … … 6448 6448 /** Save settings if online - @todo why is this required? -- @bugref{6818} */ 6449 6449 if (Global::IsOnline(mData->mMachineState)) 6450 i_saveSettings(NULL );6450 i_saveSettings(NULL, alock); 6451 6451 6452 6452 return S_OK; … … 7883 7883 7884 7884 /* wait for state dependents to drop to zero */ 7885 i_ensureNoStateDependencies( );7885 i_ensureNoStateDependencies(alock); 7886 7886 7887 7887 if (!mData->mAccessible) … … 7907 7907 ) 7908 7908 { 7909 rc = i_saveSettings(NULL );7909 rc = i_saveSettings(NULL, alock); 7910 7910 // no need to check whether VirtualBox.xml needs saving too since 7911 7911 // we can't have a machine XML file rename pending … … 8420 8420 * control to the caller. 8421 8421 * 8422 * @note Locks this object for writing. The lock will be released while waiting8423 * (if necessary).8422 * @note Receives a lock to this object for writing. The lock will be released 8423 * while waiting (if necessary). 8424 8424 * 8425 8425 * @warning To be used only in methods that change the machine state! 8426 8426 */ 8427 void Machine::i_ensureNoStateDependencies( )8427 void Machine::i_ensureNoStateDependencies(AutoWriteLock &alock) 8428 8428 { 8429 8429 AssertReturnVoid(isWriteLockOnCurrentThread()); 8430 8431 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);8432 8430 8433 8431 /* Wait for all state dependents if necessary */ … … 8477 8475 8478 8476 /* wait for state dependents to drop to zero */ 8479 i_ensureNoStateDependencies( );8477 i_ensureNoStateDependencies(alock); 8480 8478 8481 8479 MachineState_T const enmOldState = mData->mMachineState; … … 9866 9864 */ 9867 9865 HRESULT Machine::i_saveSettings(bool *pfNeedsGlobalSaveSettings, 9866 AutoWriteLock &alock, 9868 9867 int aFlags /*= 0*/) 9869 9868 { … … 9874 9873 /* make sure child objects are unable to modify the settings while we are 9875 9874 * saving them */ 9876 i_ensureNoStateDependencies( );9875 i_ensureNoStateDependencies(alock); 9877 9876 9878 9877 AssertReturn(!i_isSnapshotMachine(), … … 12999 12998 13000 12999 /* save all VM settings */ 13001 rc = i_saveSettings(NULL );13000 rc = i_saveSettings(NULL, alock); 13002 13001 // no need to check whether VirtualBox.xml needs saving also since 13003 13002 // we can't have a name change pending at this point -
trunk/src/VBox/Main/src-server/MachineImplCloneVM.cpp
r91503 r91743 1600 1600 /* save all VM data */ 1601 1601 bool fNeedsGlobalSaveSettings = false; 1602 rc = d->pTrgMachine->i_saveSettings(&fNeedsGlobalSaveSettings, Machine::SaveS_Force);1602 rc = d->pTrgMachine->i_saveSettings(&fNeedsGlobalSaveSettings, trgLock, Machine::SaveS_Force); 1603 1603 if (FAILED(rc)) throw rc; 1604 1604 /* Release all locks */ -
trunk/src/VBox/Main/src-server/RecordingSettingsImpl.cpp
r82968 r91743 239 239 else 240 240 { 241 AutoWriteLock mlock(m->pMachine COMMA_LOCKVAL_SRC_POS); // mParentis const, needs no locking241 AutoWriteLock mlock(m->pMachine COMMA_LOCKVAL_SRC_POS); // pMachine is const, needs no locking 242 242 m->pMachine->i_setModified(Machine::IsModified_Recording); 243 243 … … 248 248 /** Save settings if online - @todo why is this required? -- @bugref{6818} */ 249 249 if (Global::IsOnline(m->pMachine->i_getMachineState())) 250 rc = m->pMachine->i_saveSettings(NULL );250 rc = m->pMachine->i_saveSettings(NULL, mlock); 251 251 } 252 252 } -
trunk/src/VBox/Main/src-server/SnapshotImpl.cpp
r91718 r91743 1395 1395 HRESULT SnapshotMachine::i_onSnapshotChange(Snapshot *aSnapshot) 1396 1396 { 1397 AutoMultiWriteLock2 mlock(this, aSnapshot COMMA_LOCKVAL_SRC_POS); 1397 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); 1398 AutoWriteLock slock(aSnapshot COMMA_LOCKVAL_SRC_POS); 1398 1399 Guid uuidMachine(mData->mUuid), 1399 1400 uuidSnapshot(aSnapshot->i_getId()); … … 1404 1405 * related to the current state. */ 1405 1406 mMachine->i_setModified(Machine::IsModified_Snapshots, false /* fAllowStateModification */); 1407 slock.release(); 1406 1408 HRESULT rc = mMachine->i_saveSettings(&fNeedsGlobalSaveSettings, 1409 alock, 1407 1410 SaveS_Force); // we know we need saving, no need to check 1408 mlock.release();1411 alock.release(); 1409 1412 1410 1413 if (SUCCEEDED(rc) && fNeedsGlobalSaveSettings) … … 1754 1757 /* save settings to ensure current changes are committed and 1755 1758 * hard disks are fixed up */ 1756 rc = i_saveSettings(NULL );1759 rc = i_saveSettings(NULL, alock); 1757 1760 // no need to check for whether VirtualBox.xml needs changing since 1758 1761 // we can't have a machine XML rename pending at this point … … 2109 2112 flSaveSettings |= SaveS_ResetCurStateModified; 2110 2113 2111 rc = i_saveSettings(NULL, flSaveSettings);2114 rc = i_saveSettings(NULL, alock, flSaveSettings); 2112 2115 } 2113 2116 … … 2508 2511 // save machine settings, reset the modified flag and commit; 2509 2512 bool fNeedsGlobalSaveSettings = false; 2510 rc = i_saveSettings(&fNeedsGlobalSaveSettings, 2513 rc = i_saveSettings(&fNeedsGlobalSaveSettings, alock, 2511 2514 SaveS_ResetCurStateModified); 2512 2515 if (FAILED(rc)) … … 2720 2723 if (mData->flModifications) 2721 2724 { 2722 rc = i_saveSettings(NULL); 2725 snapshotLock.release(); 2726 rc = i_saveSettings(NULL, alock); 2727 snapshotLock.acquire(); 2723 2728 // no need to change for whether VirtualBox.xml needs saving since 2724 2729 // we can't have a machine XML rename pending at this point -
trunk/src/VBox/Main/src-server/VirtualBoxImpl.cpp
r91503 r91743 5480 5480 continue; 5481 5481 AutoWriteLock mlock(pMachine COMMA_LOCKVAL_SRC_POS); 5482 rc = pMachine->i_saveSettings(&fNeedsGlobalSettings, 5482 rc = pMachine->i_saveSettings(&fNeedsGlobalSettings, mlock, 5483 5483 Machine::SaveS_Force); // caller said save, so stop arguing 5484 5484 }
Note:
See TracChangeset
for help on using the changeset viewer.