Changeset 23023 in vbox
- Timestamp:
- Sep 15, 2009 8:03:49 AM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/VMM/VM.cpp
r23018 r23023 138 138 static bool vmR3ValidateStateTransition(VMSTATE enmStateOld, VMSTATE enmStateNew); 139 139 static void vmR3DoAtState(PVM pVM, PUVM pUVM, VMSTATE enmStateNew, VMSTATE enmStateOld); 140 static int vmR3TrySetState Ex(PVM pVM, const char *pszWho, unsigned cTransitions, ...);140 static int vmR3TrySetState(PVM pVM, const char *pszWho, unsigned cTransitions, ...); 141 141 static void vmR3SetStateLocked(PVM pVM, PUVM pUVM, VMSTATE enmStateNew, VMSTATE enmStateOld); 142 142 static void vmR3SetState(PVM pVM, VMSTATE enmStateNew, VMSTATE enmStateOld); 143 static unsigned vmR3SetState2(PVM pVM, VMSTATE enmStateNew1, VMSTATE enmStateOld1, VMSTATE enmStateNew2, VMSTATE enmStateOld2);144 143 static int vmR3SetErrorU(PUVM pUVM, int rc, RT_SRC_POS_DECL, const char *pszFormat, ...); 145 144 … … 1156 1155 * Try change the state. 1157 1156 */ 1158 int rc = vmR3TrySetState Ex(pVM, "VMR3PowerOff", 1, VMSTATE_POWERING_ON, VMSTATE_CREATED);1157 int rc = vmR3TrySetState(pVM, "VMR3PowerOff", 1, VMSTATE_POWERING_ON, VMSTATE_CREATED); 1159 1158 if (RT_FAILURE(rc)) 1160 1159 return rc; … … 1218 1217 if (pVCpu->idCpu == pVM->cCpus - 1) 1219 1218 { 1220 int rc = vmR3TrySetState Ex(pVM, "VMR3Suspend", 2,1221 1222 1219 int rc = vmR3TrySetState(pVM, "VMR3Suspend", 2, 1220 VMSTATE_SUSPENDING, VMSTATE_RUNNING, 1221 VMSTATE_SUSPENDING_LS, VMSTATE_RUNNING_LS); 1223 1222 if (RT_FAILURE(rc)) 1224 1223 return rc; … … 1321 1320 if (pVCpu->idCpu == 0) 1322 1321 { 1323 int rc = vmR3TrySetState Ex(pVM, "VMR3Resume", 1, VMSTATE_RESUMING, VMSTATE_SUSPENDED);1322 int rc = vmR3TrySetState(pVM, "VMR3Resume", 1, VMSTATE_RESUMING, VMSTATE_SUSPENDED); 1324 1323 if (RT_FAILURE(rc)) 1325 1324 return rc; … … 1402 1401 * Change the state and perform/start the saving. 1403 1402 */ 1404 int rc = vmR3TrySetState Ex(pVM, "VMR3Save", 2,1405 1406 1403 int rc = vmR3TrySetState(pVM, "VMR3Save", 2, 1404 VMSTATE_SAVING, VMSTATE_SUSPENDED, 1405 VMSTATE_RUNNING, VMSTATE_RUNNING_LS); 1407 1406 if (rc == 1) 1408 1407 { … … 1583 1582 * selectors and such are correct. 1584 1583 */ 1585 int rc = vmR3TrySetState Ex(pVM, "VMR3Load", 2,1586 1587 1584 int rc = vmR3TrySetState(pVM, "VMR3Load", 2, 1585 VMSTATE_LOADING, VMSTATE_CREATED, 1586 VMSTATE_LOADING, VMSTATE_SUSPENDED); 1588 1587 if (RT_FAILURE(rc)) 1589 1588 return rc; … … 1778 1777 */ 1779 1778 PDMR3PowerOff(pVM); 1780 vmR3SetState2(pVM, 1781 VMSTATE_OFF, VMSTATE_POWERING_OFF, 1782 VMSTATE_OFF_LS, VMSTATE_POWERING_OFF_LS); 1779 1780 PUVM pUVM = pVM->pUVM; 1781 RTCritSectEnter(&pUVM->vm.s.AtStateCritSect); 1782 VMSTATE enmVMState = pVM->enmVMState; 1783 if (enmVMState == VMSTATE_POWERING_OFF_LS) 1784 vmR3SetStateLocked(pVM, pUVM, VMSTATE_OFF_LS, VMSTATE_POWERING_OFF_LS); 1785 else 1786 vmR3SetStateLocked(pVM, pUVM, VMSTATE_OFF, VMSTATE_POWERING_OFF); 1787 RTCritSectLeave(&pUVM->vm.s.AtStateCritSect); 1783 1788 } 1784 1789 return VINF_EM_OFF; … … 1848 1853 * Change VM state to destroying and unlink the VM. 1849 1854 */ 1850 int rc = vmR3TrySetState Ex(pVM, "VMR3Destroy", 1, VMSTATE_DESTROYING, VMSTATE_OFF);1855 int rc = vmR3TrySetState(pVM, "VMR3Destroy", 1, VMSTATE_DESTROYING, VMSTATE_OFF); 1851 1856 if (RT_FAILURE(rc)) 1852 1857 return rc; … … 2761 2766 * @param ... Transition pairs; new, old. 2762 2767 */ 2763 static int vmR3TrySetState Ex(PVM pVM, const char *pszWho, unsigned cTransitions, ...)2768 static int vmR3TrySetState(PVM pVM, const char *pszWho, unsigned cTransitions, ...) 2764 2769 { 2765 2770 va_list va; … … 2859 2864 2860 2865 /** 2861 * Sets the current VM state to one of the two specified new states depending on2862 * the what the current (old) state is.2863 *2864 * @returns 1 if the first alternative, 2 if the second.2865 * @param pVM The VM handle.2866 * @param enmStateNew1 New state, alternative 1.2867 * @param enmStateOld1 Old state, alternative 1.2868 * @param enmStateNew2 New state, alternative 2.2869 * @param enmStateOld2 Old state, alternative 2.2870 */2871 static unsigned vmR3SetState2(PVM pVM, VMSTATE enmStateNew1, VMSTATE enmStateOld1, VMSTATE enmStateNew2, VMSTATE enmStateOld2)2872 {2873 vmR3ValidateStateTransition(enmStateOld1, enmStateNew1);2874 vmR3ValidateStateTransition(enmStateOld2, enmStateNew2);2875 2876 PUVM pUVM = pVM->pUVM;2877 RTCritSectEnter(&pUVM->vm.s.AtStateCritSect);2878 2879 unsigned rc;2880 VMSTATE enmStateOld = pVM->enmVMState;2881 if (enmStateOld == enmStateOld1)2882 {2883 vmR3SetStateLocked(pVM, pUVM, enmStateNew1, enmStateOld1);2884 rc = 1;2885 }2886 else2887 {2888 AssertLogRelMsg(enmStateOld == enmStateOld2,2889 ("%s, expected %s or %s (-> %s or %s)\n",2890 VMR3GetStateName(enmStateOld),2891 VMR3GetStateName(enmStateOld1),2892 VMR3GetStateName(enmStateOld2),2893 VMR3GetStateName(enmStateNew1),2894 VMR3GetStateName(enmStateNew2)));2895 vmR3SetStateLocked(pVM, pUVM, enmStateNew2, enmStateOld2);2896 rc = 2;2897 }2898 2899 RTCritSectLeave(&pUVM->vm.s.AtStateCritSect);2900 return rc;2901 }2902 2903 2904 /**2905 2866 * Flag a guru meditation ... a hack. 2906 2867 *
Note:
See TracChangeset
for help on using the changeset viewer.