VirtualBox

Changeset 32190 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Sep 2, 2010 12:20:06 PM (14 years ago)
Author:
vboxsync
Message:

PDMDevHlpVMSuspendSaveAndPowerOff: More code.

Location:
trunk/src/VBox
Files:
1 deleted
13 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Debugger/testcase/tstVBoxDbg.cpp

    r31530 r32190  
    4646     */
    4747    PVM pVM;
    48     int rc = VMR3Create(1, NULL, NULL, NULL, NULL, &pVM);
     48    int rc = VMR3Create(1, NULL, NULL, NULL, NULL, NULL, &pVM);
    4949    if (RT_SUCCESS(rc))
    5050    {
  • trunk/src/VBox/Devices/PC/DevACPI.cpp

    r32189 r32190  
    10641064    {
    10651065        rc = PDMDevHlpVMSuspendSaveAndPowerOff(pThis->pDevIns);
    1066         AssertRC(rc);
     1066        if (rc != VERR_NOT_SUPPORTED)
     1067            AssertRC(rc);
     1068        else
     1069        {
     1070            LogRel(("ACPI: PDMDevHlpVMSuspendSaveAndPowerOff is not supported, falling back to suspend-only\n"));
     1071            rc = PDMDevHlpVMSuspend(pThis->pDevIns);
     1072            AssertRC(rc);
     1073        }
    10671074    }
    10681075    else
  • trunk/src/VBox/Main/ConsoleImpl.cpp

    r32169 r32190  
    73627362        alock.leave();
    73637363
    7364         vrc = VMR3Create(cCpus, Console::genericVMSetErrorCallback, &task->mErrorMsg,
     7364        vrc = VMR3Create(cCpus, NULL,
     7365                         Console::genericVMSetErrorCallback, &task->mErrorMsg,
    73657366                         task->mConfigConstructor, static_cast<Console *>(console),
    73667367                         &pVM);
  • trunk/src/VBox/VMM/PDMDevHlp.cpp

    r32189 r32190  
    2828#include <VBox/rem.h>
    2929#include <VBox/dbgf.h>
     30#include <VBox/vmapi.h>
    3031#include <VBox/vm.h>
     32#include <VBox/uvm.h>
    3133#include <VBox/vmm.h>
    3234
     
    28142816             pDevIns->pReg->szName, pDevIns->iInstance));
    28152817
     2818    /** @todo Always take the SMP path - fewer code paths. */
    28162819    if (pVM->cCpus > 1)
    28172820    {
     
    28292832
    28302833
     2834/**
     2835 * Worker for pdmR3DevHlp_VMSuspendSaveAndPowerOff that is invoked via a queued
     2836 * EMT request to avoid deadlocks.
     2837 *
     2838 * @returns VBox status code fit for scheduling.
     2839 * @param   pVM                 The VM handle.
     2840 * @param   pDevIns             The device that triggered this action.
     2841 */
     2842static DECLCALLBACK(int) pdmR3DevHlp_VMSuspendSaveAndPowerOffWorker(PVM pVM, PPDMDEVINS pDevIns)
     2843{
     2844    /*
     2845     * Suspend the VM first then do the saving.
     2846     */
     2847    int rc = VMR3Suspend(pVM);
     2848    if (RT_SUCCESS(rc))
     2849    {
     2850        rc = pVM->pUVM->pVmm2UserMethods->pfnSaveState(pVM->pUVM->pVmm2UserMethods, pVM);
     2851
     2852        /*
     2853         * On success, power off the VM, on failure we'll leave it suspended.
     2854         */
     2855        if (RT_SUCCESS(rc))
     2856        {
     2857            rc = VMR3PowerOff(pVM);
     2858            if (RT_FAILURE(rc))
     2859                LogRel(("%s/SSP: VMR3PowerOff failed: %Rrc\n", pDevIns->pReg->szName, rc));
     2860        }
     2861        else
     2862            LogRel(("%s/SSP: pfnSaveState failed: %Rrc\n", pDevIns->pReg->szName, rc));
     2863    }
     2864    else
     2865        LogRel(("%s/SSP: Suspend failed: %Rrc\n", pDevIns->pReg->szName, rc));
     2866    return rc;
     2867}
     2868
     2869
    28312870/** @interface_method_impl{PDMDEVHLPR3,pfnVMSuspendSaveAndPowerOff} */
    28322871static DECLCALLBACK(int) pdmR3DevHlp_VMSuspendSaveAndPowerOff(PPDMDEVINS pDevIns)
    28332872{
    2834     int rc;
    28352873    PDMDEV_ASSERT_DEVINS(pDevIns);
    28362874    PVM pVM = pDevIns->Internal.s.pVMR3;
     
    28392877             pDevIns->pReg->szName, pDevIns->iInstance));
    28402878
    2841     /** @todo We'll have to queue a request to avoid deadlock issues. */
    2842     rc = VERR_NOT_IMPLEMENTED;
     2879    int rc;
     2880    if (   pVM->pUVM->pVmm2UserMethods
     2881        && pVM->pUVM->pVmm2UserMethods->pfnSaveState)
     2882    {
     2883        rc = VMR3ReqCallNoWaitU(pVM->pUVM, VMCPUID_ANY_QUEUE, (PFNRT)pdmR3DevHlp_VMSuspendSaveAndPowerOffWorker, 2, pVM, pDevIns);
     2884        if (RT_SUCCESS(rc))
     2885        {
     2886            LogRel(("%s: Suspending, Saving and Powering Off the VM\n", pDevIns->pReg->szName));
     2887            rc = VINF_EM_SUSPEND;
     2888        }
     2889    }
     2890    else
     2891        rc = VERR_NOT_SUPPORTED;
    28432892
    28442893    LogFlow(("pdmR3DevHlp_VMSuspendSaveAndPowerOff: caller='%s'/%d: returns %Rrc\n", pDevIns->pReg->szName, pDevIns->iInstance, rc));
     
    28572906             pDevIns->pReg->szName, pDevIns->iInstance));
    28582907
     2908    /** @todo Always take the SMP path - fewer code paths. */
    28592909    if (pVM->cCpus > 1)
    28602910    {
  • trunk/src/VBox/VMM/VM.cpp

    r32171 r32190  
    119119*   Internal Functions                                                         *
    120120*******************************************************************************/
    121 static int               vmR3CreateUVM(uint32_t cCpus, PUVM *ppUVM);
    122 static int               vmR3CreateU(PUVM pUVM, uint32_t cCpus, PFNCFGMCONSTRUCTOR pfnCFGMConstructor, void *pvUserCFGM);
    123 static int               vmR3InitRing3(PVM pVM, PUVM pUVM);
    124 static int               vmR3InitVMCpu(PVM pVM);
    125 static int               vmR3InitRing0(PVM pVM);
    126 static int               vmR3InitGC(PVM pVM);
    127 static int               vmR3InitDoCompleted(PVM pVM, VMINITCOMPLETED enmWhat);
     121static int                  vmR3CreateUVM(uint32_t cCpus, PCVMM2USERMETHODS pVmm2UserMethods, PUVM *ppUVM);
     122static int                  vmR3CreateU(PUVM pUVM, uint32_t cCpus, PFNCFGMCONSTRUCTOR pfnCFGMConstructor, void *pvUserCFGM);
     123static int                  vmR3InitRing3(PVM pVM, PUVM pUVM);
     124static int                  vmR3InitVMCpu(PVM pVM);
     125static int                  vmR3InitRing0(PVM pVM);
     126static int                  vmR3InitGC(PVM pVM);
     127static int                  vmR3InitDoCompleted(PVM pVM, VMINITCOMPLETED enmWhat);
    128128static DECLCALLBACK(size_t) vmR3LogPrefixCallback(PRTLOGGER pLogger, char *pchBuf, size_t cchBuf, void *pvUser);
    129 static void              vmR3DestroyUVM(PUVM pUVM, uint32_t cMilliesEMTWait);
    130 static void              vmR3AtDtor(PVM pVM);
    131 static bool              vmR3ValidateStateTransition(VMSTATE enmStateOld, VMSTATE enmStateNew);
    132 static void              vmR3DoAtState(PVM pVM, PUVM pUVM, VMSTATE enmStateNew, VMSTATE enmStateOld);
    133 static int               vmR3TrySetState(PVM pVM, const char *pszWho, unsigned cTransitions, ...);
    134 static void              vmR3SetStateLocked(PVM pVM, PUVM pUVM, VMSTATE enmStateNew, VMSTATE enmStateOld);
    135 static void              vmR3SetState(PVM pVM, VMSTATE enmStateNew, VMSTATE enmStateOld);
    136 static int               vmR3SetErrorU(PUVM pUVM, int rc, RT_SRC_POS_DECL, const char *pszFormat, ...);
     129static void                 vmR3DestroyUVM(PUVM pUVM, uint32_t cMilliesEMTWait);
     130static void                 vmR3AtDtor(PVM pVM);
     131static bool                 vmR3ValidateStateTransition(VMSTATE enmStateOld, VMSTATE enmStateNew);
     132static void                 vmR3DoAtState(PVM pVM, PUVM pUVM, VMSTATE enmStateNew, VMSTATE enmStateOld);
     133static int                  vmR3TrySetState(PVM pVM, const char *pszWho, unsigned cTransitions, ...);
     134static void                 vmR3SetStateLocked(PVM pVM, PUVM pUVM, VMSTATE enmStateNew, VMSTATE enmStateOld);
     135static void                 vmR3SetState(PVM pVM, VMSTATE enmStateNew, VMSTATE enmStateOld);
     136static int                  vmR3SetErrorU(PUVM pUVM, int rc, RT_SRC_POS_DECL, const char *pszFormat, ...);
    137137
    138138
     
    169169 * @returns VBox error code on failure.
    170170 * @param   cCpus               Number of virtual CPUs for the new VM.
     171 * @param   pVmm2UserMethods    An optional method table that the VMM can use to
     172 *                              make the user perform various action, like for
     173 *                              instance state saving.
    171174 * @param   pfnVMAtError        Pointer to callback function for setting VM
    172175 *                              errors. This was added as an implicit call to
     
    181184 * @param   ppVM                Where to store the 'handle' of the created VM.
    182185 */
    183 VMMR3DECL(int)   VMR3Create(uint32_t cCpus, PFNVMATERROR pfnVMAtError, void *pvUserVM, PFNCFGMCONSTRUCTOR pfnCFGMConstructor, void *pvUserCFGM, PVM *ppVM)
    184 {
    185     LogFlow(("VMR3Create: cCpus=%RU32 pfnVMAtError=%p pvUserVM=%p  pfnCFGMConstructor=%p pvUserCFGM=%p ppVM=%p\n",
    186              cCpus, pfnVMAtError, pvUserVM, pfnCFGMConstructor, pvUserCFGM, ppVM));
     186VMMR3DECL(int)   VMR3Create(uint32_t cCpus, PCVMM2USERMETHODS pVmm2UserMethods,
     187                            PFNVMATERROR pfnVMAtError, void *pvUserVM,
     188                            PFNCFGMCONSTRUCTOR pfnCFGMConstructor, void *pvUserCFGM,
     189                            PVM *ppVM)
     190{
     191    LogFlow(("VMR3Create: cCpus=%RU32 pVmm2UserMethods=%p pfnVMAtError=%p pvUserVM=%p  pfnCFGMConstructor=%p pvUserCFGM=%p ppVM=%p\n",
     192             cCpus, pVmm2UserMethods, pfnVMAtError, pvUserVM, pfnCFGMConstructor, pvUserCFGM, ppVM));
     193
     194    if (pVmm2UserMethods)
     195    {
     196        AssertPtrReturn(pVmm2UserMethods, VERR_INVALID_POINTER);
     197        AssertReturn(pVmm2UserMethods->u32Magic    == VMM2USERMETHODS_MAGIC,   VERR_INVALID_PARAMETER);
     198        AssertReturn(pVmm2UserMethods->u32Version  == VMM2USERMETHODS_VERSION, VERR_INVALID_PARAMETER);
     199        AssertPtrReturn(pVmm2UserMethods->pfnSaveState, VERR_INVALID_POINTER);
     200        AssertReturn(pVmm2UserMethods->u32EndMagic == VMM2USERMETHODS_MAGIC,   VERR_INVALID_PARAMETER);
     201    }
     202    AssertPtrNullReturn(pfnVMAtError, VERR_INVALID_POINTER);
     203    AssertPtrNullReturn(pfnCFGMConstructor, VERR_INVALID_POINTER);
     204    AssertPtrReturn(ppVM, VERR_INVALID_POINTER);
    187205
    188206    /*
     
    210228     */
    211229    PUVM pUVM = NULL;                   /* shuts up gcc */
    212     int rc = vmR3CreateUVM(cCpus, &pUVM);
     230    int rc = vmR3CreateUVM(cCpus, pVmm2UserMethods, &pUVM);
    213231    if (RT_FAILURE(rc))
    214232        return rc;
     
    417435 *
    418436 * @returns VBox status code.
    419  * @param   cCpus   Number of virtual CPUs
    420  * @param   ppUVM   Where to store the UVM pointer.
    421  */
    422 static int vmR3CreateUVM(uint32_t cCpus, PUVM *ppUVM)
     437 * @param   cCpus               Number of virtual CPUs
     438 * @param   pVmm2UserMethods    Pointer to the optional VMM -> User method
     439 *                              table.
     440 * @param   ppUVM               Where to store the UVM pointer.
     441 */
     442static int vmR3CreateUVM(uint32_t cCpus, PCVMM2USERMETHODS pVmm2UserMethods, PUVM *ppUVM)
    423443{
    424444    uint32_t i;
     
    429449    PUVM pUVM = (PUVM)RTMemPageAllocZ(RT_OFFSETOF(UVM, aCpus[cCpus]));
    430450    AssertReturn(pUVM, VERR_NO_MEMORY);
    431     pUVM->u32Magic = UVM_MAGIC;
    432     pUVM->cCpus = cCpus;
     451    pUVM->u32Magic          = UVM_MAGIC;
     452    pUVM->cCpus             = cCpus;
     453    pUVM->pVmm2UserMethods  = pVmm2UserMethods;
    433454
    434455    AssertCompile(sizeof(pUVM->vm.s) <= sizeof(pUVM->vm.padding));
  • trunk/src/VBox/VMM/testcase/tstAnimate.cpp

    r28800 r32190  
    824824     */
    825825    PVM pVM;
    826     rc = VMR3Create(1, NULL, NULL, cfgmR3CreateDefault, &cbMem, &pVM);
     826    rc = VMR3Create(1, NULL, NULL, NULL, cfgmR3CreateDefault, &cbMem, &pVM);
    827827    if (RT_SUCCESS(rc))
    828828    {
  • trunk/src/VBox/VMM/testcase/tstMicro.cpp

    r31989 r32190  
    345345     */
    346346    PVM pVM;
    347     int rc = VMR3Create(1, NULL, NULL, NULL, NULL, &pVM);
     347    int rc = VMR3Create(1, NULL, NULL, NULL, NULL, NULL, &pVM);
    348348    if (RT_SUCCESS(rc))
    349349    {
  • trunk/src/VBox/VMM/testcase/tstPDMAsyncCompletion.cpp

    r28800 r32190  
    8787
    8888    PVM pVM;
    89     rc = VMR3Create(1, NULL, NULL, NULL, NULL, &pVM);
     89    rc = VMR3Create(1, NULL, NULL, NULL, NULL, NULL, &pVM);
    9090    if (RT_SUCCESS(rc))
    9191    {
  • trunk/src/VBox/VMM/testcase/tstPDMAsyncCompletionStress.cpp

    r28800 r32190  
    575575
    576576    PVM pVM;
    577     rc = VMR3Create(1, NULL, NULL, NULL, NULL, &pVM);
     577    rc = VMR3Create(1, NULL, NULL, NULL, NULL, NULL, &pVM);
    578578    if (RT_SUCCESS(rc))
    579579    {
  • trunk/src/VBox/VMM/testcase/tstVMM-HwAccm.cpp

    r28800 r32190  
    8282    RTPrintf(TESTCASE ": Initializing...\n");
    8383    PVM pVM;
    84     int rc = VMR3Create(1, NULL, NULL, CFGMConstructor, NULL, &pVM);
     84    int rc = VMR3Create(1, NULL, NULL, NULL, CFGMConstructor, NULL, &pVM);
    8585    if (RT_SUCCESS(rc))
    8686    {
  • trunk/src/VBox/VMM/testcase/tstVMM.cpp

    r28800 r32190  
    250250    RTPrintf(TESTCASE ": Initializing...\n");
    251251    PVM pVM;
    252     rc = VMR3Create(g_cCpus, NULL, NULL, tstVMMConfigConstructor, NULL, &pVM);
     252    rc = VMR3Create(g_cCpus, NULL, NULL, NULL, tstVMMConfigConstructor, NULL, &pVM);
    253253    if (RT_SUCCESS(rc))
    254254    {
  • trunk/src/VBox/VMM/testcase/tstVMMFork.cpp

    r28800 r32190  
    6767    RTPrintf(TESTCASE ": Initializing...\n");
    6868    PVM pVM;
    69     int rc = VMR3Create(1, NULL, NULL, NULL, NULL, &pVM);
     69    int rc = VMR3Create(1, NULL, NULL, NULL, NULL, NULL, &pVM);
    7070    if (RT_SUCCESS(rc))
    7171    {
  • trunk/src/VBox/VMM/testcase/tstVMREQ.cpp

    r28800 r32190  
    215215     */
    216216    PVM pVM;
    217     int rc = VMR3Create(1, NULL, NULL, NULL, NULL, &pVM);
     217    int rc = VMR3Create(1, NULL, NULL, NULL, NULL, NULL, &pVM);
    218218    if (RT_SUCCESS(rc))
    219219    {
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