VirtualBox

Changeset 23023 in vbox


Ignore:
Timestamp:
Sep 15, 2009 8:03:49 AM (15 years ago)
Author:
vboxsync
Message:

VM.cpp: Retire vmR3SetState2. s/vmR3TrySetStateEx/vmR3TrySetState/

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/VMM/VM.cpp

    r23018 r23023  
    138138static bool              vmR3ValidateStateTransition(VMSTATE enmStateOld, VMSTATE enmStateNew);
    139139static void              vmR3DoAtState(PVM pVM, PUVM pUVM, VMSTATE enmStateNew, VMSTATE enmStateOld);
    140 static int               vmR3TrySetStateEx(PVM pVM, const char *pszWho, unsigned cTransitions, ...);
     140static int               vmR3TrySetState(PVM pVM, const char *pszWho, unsigned cTransitions, ...);
    141141static void              vmR3SetStateLocked(PVM pVM, PUVM pUVM, VMSTATE enmStateNew, VMSTATE enmStateOld);
    142142static void              vmR3SetState(PVM pVM, VMSTATE enmStateNew, VMSTATE enmStateOld);
    143 static unsigned          vmR3SetState2(PVM pVM, VMSTATE enmStateNew1, VMSTATE enmStateOld1, VMSTATE enmStateNew2, VMSTATE enmStateOld2);
    144143static int               vmR3SetErrorU(PUVM pUVM, int rc, RT_SRC_POS_DECL, const char *pszFormat, ...);
    145144
     
    11561155     * Try change the state.
    11571156     */
    1158     int rc = vmR3TrySetStateEx(pVM, "VMR3PowerOff", 1, VMSTATE_POWERING_ON, VMSTATE_CREATED);
     1157    int rc = vmR3TrySetState(pVM, "VMR3PowerOff", 1, VMSTATE_POWERING_ON, VMSTATE_CREATED);
    11591158    if (RT_FAILURE(rc))
    11601159        return rc;
     
    12181217    if (pVCpu->idCpu == pVM->cCpus - 1)
    12191218    {
    1220         int rc = vmR3TrySetStateEx(pVM, "VMR3Suspend", 2,
    1221                                    VMSTATE_SUSPENDING, VMSTATE_RUNNING,
    1222                                    VMSTATE_SUSPENDING_LS, VMSTATE_RUNNING_LS);
     1219        int rc = vmR3TrySetState(pVM, "VMR3Suspend", 2,
     1220                                 VMSTATE_SUSPENDING, VMSTATE_RUNNING,
     1221                                 VMSTATE_SUSPENDING_LS, VMSTATE_RUNNING_LS);
    12231222        if (RT_FAILURE(rc))
    12241223            return rc;
     
    13211320    if (pVCpu->idCpu == 0)
    13221321    {
    1323         int rc = vmR3TrySetStateEx(pVM, "VMR3Resume", 1, VMSTATE_RESUMING, VMSTATE_SUSPENDED);
     1322        int rc = vmR3TrySetState(pVM, "VMR3Resume", 1, VMSTATE_RESUMING, VMSTATE_SUSPENDED);
    13241323        if (RT_FAILURE(rc))
    13251324            return rc;
     
    14021401     * Change the state and perform/start the saving.
    14031402     */
    1404     int rc = vmR3TrySetStateEx(pVM, "VMR3Save", 2,
    1405                                VMSTATE_SAVING, VMSTATE_SUSPENDED,
    1406                                VMSTATE_RUNNING, VMSTATE_RUNNING_LS);
     1403    int rc = vmR3TrySetState(pVM, "VMR3Save", 2,
     1404                             VMSTATE_SAVING, VMSTATE_SUSPENDED,
     1405                             VMSTATE_RUNNING, VMSTATE_RUNNING_LS);
    14071406    if (rc == 1)
    14081407    {
     
    15831582     * selectors and such are correct.
    15841583     */
    1585     int rc = vmR3TrySetStateEx(pVM, "VMR3Load", 2,
    1586                                VMSTATE_LOADING, VMSTATE_CREATED,
    1587                                VMSTATE_LOADING, VMSTATE_SUSPENDED);
     1584    int rc = vmR3TrySetState(pVM, "VMR3Load", 2,
     1585                             VMSTATE_LOADING, VMSTATE_CREATED,
     1586                             VMSTATE_LOADING, VMSTATE_SUSPENDED);
    15881587    if (RT_FAILURE(rc))
    15891588        return rc;
     
    17781777         */
    17791778        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);
    17831788    }
    17841789    return VINF_EM_OFF;
     
    18481853     * Change VM state to destroying and unlink the VM.
    18491854     */
    1850     int rc = vmR3TrySetStateEx(pVM, "VMR3Destroy", 1, VMSTATE_DESTROYING, VMSTATE_OFF);
     1855    int rc = vmR3TrySetState(pVM, "VMR3Destroy", 1, VMSTATE_DESTROYING, VMSTATE_OFF);
    18511856    if (RT_FAILURE(rc))
    18521857        return rc;
     
    27612766 * @param   ...                 Transition pairs; new, old.
    27622767 */
    2763 static int vmR3TrySetStateEx(PVM pVM, const char *pszWho, unsigned cTransitions, ...)
     2768static int vmR3TrySetState(PVM pVM, const char *pszWho, unsigned cTransitions, ...)
    27642769{
    27652770    va_list va;
     
    28592864
    28602865/**
    2861  * Sets the current VM state to one of the two specified new states depending on
    2862  * 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     else
    2887     {
    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 /**
    29052866 * Flag a guru meditation ... a hack.
    29062867 *
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