VirtualBox

Changeset 46788 in vbox


Ignore:
Timestamp:
Jun 25, 2013 5:39:02 PM (12 years ago)
Author:
vboxsync
Message:

VMM: Suspend and resume reasons.

Location:
trunk
Files:
13 edited

Legend:

Unmodified
Added
Removed
  • trunk/Config.kmk

    r46772 r46788  
    16431643 LIB_DDU         = $(PATH_STAGE_LIB)/VBoxDDU.lib
    16441644endif
    1645 if1of ($(KBUILD_TARGET).$(KBUILD_TARGET_ARCH), win.amd64)
     1645if1of ($(KBUILD_TARGET).$(KBUILD_TARGET_ARCH), win.amd64 linux.amd64)
    16461646 VBOX_LIB_VMM_LAZY      = $(PATH_STAGE_LIB)/VMMR3LazyImp$(VBOX_SUFF_LIB)
    16471647else
  • trunk/include/VBox/vmm/pdmdev.h

    r45965 r46788  
    34413441    DECLR3CALLBACKMEMBER(int, pfnCallR0,(PPDMDEVINS pDevIns, uint32_t uOperation, uint64_t u64Arg));
    34423442
     3443    /**
     3444     * Gets the reason for the most recent VM suspend.
     3445     *
     3446     * @returns The suspend reason. VMSUSPENDREASON_INVALID is returned if no
     3447     *          suspend has been made or if the pDevIns is invalid.
     3448     * @param   pDevIns             The device instance.
     3449     */
     3450    DECLR3CALLBACKMEMBER(VMSUSPENDREASON, pfnVMGetSuspendReason,(PPDMDEVINS pDevIns));
     3451
     3452    /**
     3453     * Gets the reason for the most recent VM resume.
     3454     *
     3455     * @returns The resume reason. VMRESUMEREASON_INVALID is returned if no
     3456     *          resume has been made or if the pDevIns is invalid.
     3457     * @param   pDevIns             The device instance.
     3458     */
     3459    DECLR3CALLBACKMEMBER(VMRESUMEREASON, pfnVMGetResumeReason,(PPDMDEVINS pDevIns));
     3460
     3461
    34433462    /** Space reserved for future members.
    34443463     * @{ */
     
    34503469    DECLR3CALLBACKMEMBER(void, pfnReserved6,(void));
    34513470    DECLR3CALLBACKMEMBER(void, pfnReserved7,(void));
    3452     DECLR3CALLBACKMEMBER(void, pfnReserved8,(void));
    3453     DECLR3CALLBACKMEMBER(void, pfnReserved9,(void));
     3471    /*DECLR3CALLBACKMEMBER(void, pfnReserved8,(void));
     3472    DECLR3CALLBACKMEMBER(void, pfnReserved9,(void));*/
    34543473    /*DECLR3CALLBACKMEMBER(void, pfnReserved10,(void));*/
    34553474    /** @} */
     
    36273646
    36283647/** Current PDMDEVHLPR3 version number. */
    3629 #define PDM_DEVHLPR3_VERSION                    PDM_VERSION_MAKE(0xffe7, 12, 0)
     3648#define PDM_DEVHLPR3_VERSION                    PDM_VERSION_MAKE(0xffe7, 12, 1)
    36303649
    36313650
     
    50845103
    50855104/**
     5105 * @copydoc PDMDEVHLP::pfnVMGetSuspendReason
     5106 */
     5107DECLINLINE(VMSUSPENDREASON) PDMDevHlpVMGetSuspendReason(PPDMDEVINS pDevIns)
     5108{
     5109    return pDevIns->pHlpR3->pfnVMGetSuspendReason(pDevIns);
     5110}
     5111
     5112/**
     5113 * @copydoc PDMDEVHLP::pfnVMGetResumeReason
     5114 */
     5115DECLINLINE(VMRESUMEREASON) PDMDevHlpVMGetResumeReason(PPDMDEVINS pDevIns)
     5116{
     5117    return pDevIns->pHlpR3->pfnVMGetResumeReason(pDevIns);
     5118}
     5119
     5120/**
    50865121 * @copydoc PDMDEVHLPR3::pfnGetUVM
    50875122 */
  • trunk/include/VBox/vmm/pdmdrv.h

    r44528 r46788  
    12981298                                                  PFNPDMBLKCACHEXFERENQUEUEDISCARDDRV pfnXferEnqueueDiscard,
    12991299                                                  const char *pcszId));
     1300    /**
     1301     * Gets the reason for the most recent VM suspend.
     1302     *
     1303     * @returns The suspend reason. VMSUSPENDREASON_INVALID is returned if no
     1304     *          suspend has been made or if the pDrvIns is invalid.
     1305     * @param   pDrvIns             The driver instance.
     1306     */
     1307    DECLR3CALLBACKMEMBER(VMSUSPENDREASON, pfnVMGetSuspendReason,(PPDMDRVINS pDrvIns));
     1308
     1309    /**
     1310     * Gets the reason for the most recent VM resume.
     1311     *
     1312     * @returns The resume reason. VMRESUMEREASON_INVALID is returned if no
     1313     *          resume has been made or if the pDrvIns is invalid.
     1314     * @param   pDrvIns             The driver instance.
     1315     */
     1316    DECLR3CALLBACKMEMBER(VMRESUMEREASON, pfnVMGetResumeReason,(PPDMDRVINS pDrvIns));
     1317
     1318    /** @name Space reserved for minor interface changes.
     1319     * @{ */
     1320    DECLR3CALLBACKMEMBER(void, pfnReserved0,(PPDMDRVINS pDrvIns));
     1321    DECLR3CALLBACKMEMBER(void, pfnReserved1,(PPDMDRVINS pDrvIns));
     1322    DECLR3CALLBACKMEMBER(void, pfnReserved2,(PPDMDRVINS pDrvIns));
     1323    DECLR3CALLBACKMEMBER(void, pfnReserved3,(PPDMDRVINS pDrvIns));
     1324    DECLR3CALLBACKMEMBER(void, pfnReserved4,(PPDMDRVINS pDrvIns));
     1325    DECLR3CALLBACKMEMBER(void, pfnReserved5,(PPDMDRVINS pDrvIns));
     1326    DECLR3CALLBACKMEMBER(void, pfnReserved6,(PPDMDRVINS pDrvIns));
     1327    DECLR3CALLBACKMEMBER(void, pfnReserved7,(PPDMDRVINS pDrvIns));
     1328    DECLR3CALLBACKMEMBER(void, pfnReserved8,(PPDMDRVINS pDrvIns));
     1329    DECLR3CALLBACKMEMBER(void, pfnReserved9,(PPDMDRVINS pDrvIns));
     1330    /** @}  */
    13001331
    13011332    /** Just a safety precaution. */
     
    13031334} PDMDRVHLPR3;
    13041335/** Current DRVHLP version number. */
    1305 #define PDM_DRVHLPR3_VERSION                    PDM_VERSION_MAKE(0xf0fb, 2, 0)
     1336#define PDM_DRVHLPR3_VERSION                    PDM_VERSION_MAKE(0xf0fb, 3, 0)
    13061337
    13071338#endif /* IN_RING3 */
     
    17781809}
    17791810
     1811/**
     1812 * @copydoc PDMDRVHLP::pfnVMGetSuspendReason
     1813 */
     1814DECLINLINE(VMSUSPENDREASON) PDMDrvHlpVMGetSuspendReason(PPDMDRVINS pDrvIns)
     1815{
     1816    return pDrvIns->pHlpR3->pfnVMGetSuspendReason(pDrvIns);
     1817}
     1818
     1819/**
     1820 * @copydoc PDMDRVHLP::pfnVMGetResumeReason
     1821 */
     1822DECLINLINE(VMRESUMEREASON) PDMDrvHlpVMGetResumeReason(PPDMDRVINS pDrvIns)
     1823{
     1824    return pDrvIns->pHlpR3->pfnVMGetResumeReason(pDrvIns);
     1825}
     1826
     1827
    17801828/** Pointer to callbacks provided to the VBoxDriverRegister() call. */
    17811829typedef struct PDMDRVREGCB *PPDMDRVREGCB;
  • trunk/include/VBox/vmm/pdmusb.h

    r44528 r46788  
    678678    DECLR3CALLBACKMEMBER(void, pfnAsyncNotificationCompleted, (PPDMUSBINS pUsbIns));
    679679
     680    /**
     681     * Gets the reason for the most recent VM suspend.
     682     *
     683     * @returns The suspend reason. VMSUSPENDREASON_INVALID is returned if no
     684     *          suspend has been made or if the pUsbIns is invalid.
     685     * @param   pUsbIns             The driver instance.
     686     */
     687    DECLR3CALLBACKMEMBER(VMSUSPENDREASON, pfnVMGetSuspendReason,(PPDMUSBINS pUsbIns));
     688
     689    /**
     690     * Gets the reason for the most recent VM resume.
     691     *
     692     * @returns The resume reason. VMRESUMEREASON_INVALID is returned if no
     693     *          resume has been made or if the pUsbIns is invalid.
     694     * @param   pUsbIns             The driver instance.
     695     */
     696    DECLR3CALLBACKMEMBER(VMRESUMEREASON, pfnVMGetResumeReason,(PPDMUSBINS pUsbIns));
     697
     698    /** @name Space reserved for minor interface changes.
     699     * @{ */
     700    DECLR3CALLBACKMEMBER(void, pfnReserved0,(PPDMUSBINS pUsbIns));
     701    DECLR3CALLBACKMEMBER(void, pfnReserved1,(PPDMUSBINS pUsbIns));
     702    DECLR3CALLBACKMEMBER(void, pfnReserved2,(PPDMUSBINS pUsbIns));
     703    DECLR3CALLBACKMEMBER(void, pfnReserved3,(PPDMUSBINS pUsbIns));
     704    DECLR3CALLBACKMEMBER(void, pfnReserved4,(PPDMUSBINS pUsbIns));
     705    DECLR3CALLBACKMEMBER(void, pfnReserved5,(PPDMUSBINS pUsbIns));
     706    DECLR3CALLBACKMEMBER(void, pfnReserved6,(PPDMUSBINS pUsbIns));
     707    DECLR3CALLBACKMEMBER(void, pfnReserved7,(PPDMUSBINS pUsbIns));
     708    DECLR3CALLBACKMEMBER(void, pfnReserved8,(PPDMUSBINS pUsbIns));
     709    DECLR3CALLBACKMEMBER(void, pfnReserved9,(PPDMUSBINS pUsbIns));
     710    /** @}  */
     711
    680712    /** Just a safety precaution. */
    681713    uint32_t                        u32TheEnd;
     
    687719
    688720/** Current USBHLP version number. */
    689 #define PDM_USBHLP_VERSION                      PDM_VERSION_MAKE(0xeefe, 2, 0)
     721#define PDM_USBHLP_VERSION                      PDM_VERSION_MAKE(0xeefe, 3, 0)
    690722
    691723#endif /* IN_RING3 */
  • trunk/include/VBox/vmm/vmapi.h

    r45618 r46788  
    332332} VMINITCOMPLETED;
    333333
     334
     335/** Reason for VM resume. */
     336typedef enum VMRESUMEREASON
     337{
     338    VMRESUMEREASON_INVALID = 0,
     339    /** User decided to do so. */
     340    VMRESUMEREASON_USER,
     341    /** VM reconfiguration (like changing DVD). */
     342    VMRESUMEREASON_RECONFIG,
     343    /** The host resumed. */
     344    VMRESUMEREASON_HOST_RESUME,
     345    /** Restored state. */
     346    VMRESUMEREASON_STATE_RESTORED,
     347    /** Snapshot / saved state. */
     348    VMRESUMEREASON_STATE_SAVED,
     349    /** Teleported to a new box / instance. */
     350    VMRESUMEREASON_TELEPORTED,
     351    /** Teleportation failed. */
     352    VMRESUMEREASON_TELEPORT_FAILED,
     353    /** FTM temporarily suspended the VM. */
     354    VMRESUMEREASON_FTM_SYNC,
     355    /** End of valid reasons. */
     356    VMRESUMEREASON_END,
     357    /** Blow the type up to 32-bits. */
     358    VMRESUMEREASON_32BIT_HACK = 0x7fffffff
     359} VMRESUMEREASON;
     360
     361/** Reason for VM suspend. */
     362typedef enum VMSUSPENDREASON
     363{
     364    VMSUSPENDREASON_INVALID = 0,
     365    /** User decided to do so. */
     366    VMSUSPENDREASON_USER,
     367    /** VM reconfiguration (like changing DVD). */
     368    VMSUSPENDREASON_RECONFIG,
     369    /** The VM is suspending itself. */
     370    VMSUSPENDREASON_VM,
     371    /** The Vm is suspending because of a runtime error. */
     372    VMSUSPENDREASON_RUNTIME_ERROR,
     373    /** The host was suspended. */
     374    VMSUSPENDREASON_HOST_SUSPEND,
     375    /** The host is running low on battery power. */
     376    VMSUSPENDREASON_HOST_BATTERY_LOW,
     377    /** FTM is temporarily suspending the VM. */
     378    VMSUSPENDREASON_FTM_SYNC,
     379    /** End of valid reasons. */
     380    VMSUSPENDREASON_END,
     381    /** Blow the type up to 32-bits. */
     382    VMSUSPENDREASON_32BIT_HACK = 0x7fffffff
     383} VMSUSPENDREASON;
     384
     385
    334386/**
    335387 * Progress callback.
     
    353405                                   PVM *ppVM, PUVM *ppUVM);
    354406VMMR3DECL(int)          VMR3PowerOn(PUVM pUVM);
    355 VMMR3DECL(int)          VMR3Suspend(PUVM pUVM);
    356 VMMR3DECL(int)          VMR3Resume(PUVM pUVM);
     407VMMR3DECL(int)          VMR3Suspend(PUVM pUVM, VMSUSPENDREASON enmReason);
     408VMMR3DECL(VMSUSPENDREASON) VMR3GetSuspendReason(PUVM);
     409VMMR3DECL(int)          VMR3Resume(PUVM pUVM, VMRESUMEREASON enmReason);
     410VMMR3DECL(VMRESUMEREASON) VMR3GetResumeReason(PUVM);
    357411VMMR3DECL(int)          VMR3Reset(PUVM pUVM);
    358412VMMR3DECL(int)          VMR3Save(PUVM pUVM, const char *pszFilename, bool fContinueAfterwards, PFNVMPROGRESS pfnProgress, void *pvUser, bool *pfSuspended);
  • trunk/src/VBox/Main/src-client/ConsoleImpl.cpp

    r46775 r46788  
    36173617            /* disable the callback to prevent Console-level state change */
    36183618            pConsole->mVMStateChangeCallbackDisabled = true;
    3619             int rc = VMR3Suspend(pUVM);
     3619            int rc = VMR3Suspend(pUVM, VMSUSPENDREASON_RECONFIG);
    36203620            pConsole->mVMStateChangeCallbackDisabled = false;
    36213621            AssertRCReturn(rc, rc);
     
    36803680        /* disable the callback to prevent Console-level state change */
    36813681        pConsole->mVMStateChangeCallbackDisabled = true;
    3682         rc = VMR3Resume(pUVM);
     3682        rc = VMR3Resume(pUVM, VMRESUMEREASON_RECONFIG);
    36833683        pConsole->mVMStateChangeCallbackDisabled = false;
    36843684        AssertRC(rc);
     
    38663866            /* disable the callback to prevent Console-level state change */
    38673867            pConsole->mVMStateChangeCallbackDisabled = true;
    3868             int rc = VMR3Suspend(pUVM);
     3868            int rc = VMR3Suspend(pUVM, VMSUSPENDREASON_RECONFIG);
    38693869            pConsole->mVMStateChangeCallbackDisabled = false;
    38703870            AssertRCReturn(rc, rc);
     
    39293929        /* disable the callback to prevent Console-level state change */
    39303930        pConsole->mVMStateChangeCallbackDisabled = true;
    3931         rc = VMR3Resume(pUVM);
     3931        rc = VMR3Resume(pUVM, VMRESUMEREASON_RECONFIG);
    39323932        pConsole->mVMStateChangeCallbackDisabled = false;
    39333933        AssertRC(rc);
     
    41094109            /* disable the callback to prevent Console-level state change */
    41104110            pConsole->mVMStateChangeCallbackDisabled = true;
    4111             int rc = VMR3Suspend(pUVM);
     4111            int rc = VMR3Suspend(pUVM, VMSUSPENDREASON_RECONFIG);
    41124112            pConsole->mVMStateChangeCallbackDisabled = false;
    41134113            AssertRCReturn(rc, rc);
     
    41914191        /* disable the callback to prevent Console-level state change */
    41924192        pConsole->mVMStateChangeCallbackDisabled = true;
    4193         rc = VMR3Resume(pUVM);
     4193        rc = VMR3Resume(pUVM, VMRESUMEREASON_RECONFIG);
    41944194        pConsole->mVMStateChangeCallbackDisabled = false;
    41954195        AssertRC(rc);
     
    45334533            /* disable the callback to prevent Console-level state change */
    45344534            pThis->mVMStateChangeCallbackDisabled = true;
    4535             int rc = VMR3Suspend(pUVM);
     4535            int rc = VMR3Suspend(pUVM, VMSUSPENDREASON_RECONFIG);
    45364536            pThis->mVMStateChangeCallbackDisabled = false;
    45374537            AssertRCReturn(rc, rc);
     
    45694569        /* disable the callback to prevent Console-level state change */
    45704570        pThis->mVMStateChangeCallbackDisabled = true;
    4571         rc = VMR3Resume(pUVM);
     4571        rc = VMR3Resume(pUVM, VMRESUMEREASON_RECONFIG);
    45724572        pThis->mVMStateChangeCallbackDisabled = false;
    45734573        AssertRC(rc);
     
    55785578        /* disable the callback to prevent Console-level state change */
    55795579        mVMStateChangeCallbackDisabled = true;
    5580         int vrc2 = VMR3Suspend(ptrVM.rawUVM());
     5580        int vrc2 = VMR3Suspend(ptrVM.rawUVM(), VMSUSPENDREASON_RECONFIG);
    55815581        mVMStateChangeCallbackDisabled = false;
    55825582        AssertRCReturn(vrc2, E_FAIL);
     
    56075607        /* disable the callback to prevent Console-level state change */
    56085608        mVMStateChangeCallbackDisabled = true;
    5609         int vrc2 = VMR3Resume(ptrVM.rawUVM());
     5609        int vrc2 = VMR3Resume(ptrVM.rawUVM(), VMRESUMEREASON_RECONFIG);
    56105610        mVMStateChangeCallbackDisabled = false;
    56115611        if (RT_FAILURE(vrc2))
     
    56495649        /* disable the callback to prevent Console-level state change */
    56505650        mVMStateChangeCallbackDisabled = true;
    5651         int vrc2 = VMR3Suspend(ptrVM.rawUVM());
     5651        int vrc2 = VMR3Suspend(ptrVM.rawUVM(), VMSUSPENDREASON_RECONFIG);
    56525652        mVMStateChangeCallbackDisabled = false;
    56535653        AssertRCReturn(vrc2, E_FAIL);
     
    56835683        /* disable the callback to prevent Console-level state change */
    56845684        mVMStateChangeCallbackDisabled = true;
    5685         int vrc2 = VMR3Resume(ptrVM.rawUVM());
     5685        int vrc2 = VMR3Resume(ptrVM.rawUVM(), VMRESUMEREASON_RECONFIG);
    56865686        mVMStateChangeCallbackDisabled = false;
    56875687        AssertRC(vrc2);
     
    57535753
    57545754    /** @todo r=klaus make use of aReason */
    5755     int vrc = VMR3Suspend(ptrVM.rawUVM());
     5755    VMSUSPENDREASON enmReason = VMSUSPENDREASON_USER;
     5756    if (aReason == Reason_HostSuspend)
     5757        enmReason = VMSUSPENDREASON_HOST_SUSPEND;
     5758    else if (aReason == Reason_HostBatteryLow)
     5759        enmReason = VMSUSPENDREASON_HOST_BATTERY_LOW;
     5760    int vrc = VMR3Suspend(ptrVM.rawUVM(), enmReason);
    57565761
    57575762    HRESULT hrc = S_OK;
     
    57945799        LogRel(("Resuming VM execution, reason \"%s\"\n", Global::stringifyReason(aReason)));
    57955800
    5796     /** @todo r=klaus make use of aReason */
    57975801    int vrc;
    57985802    if (VMR3GetStateU(ptrVM.rawUVM()) == VMSTATE_CREATED)
     
    58075811    }
    58085812    else
    5809         vrc = VMR3Resume(ptrVM.rawUVM());
     5813    {
     5814        VMRESUMEREASON enmReason = VMRESUMEREASON_USER;
     5815        if (aReason == Reason_HostResume)
     5816            enmReason = VMRESUMEREASON_HOST_RESUME;
     5817        vrc = VMR3Resume(ptrVM.rawUVM(), enmReason);
     5818    }
    58105819
    58115820    HRESULT rc = RT_SUCCESS(vrc) ? S_OK :
     
    58585867        /* release the lock before a VMR3* call (EMT will call us back)! */
    58595868        alock.release();
    5860         int vrc = VMR3Suspend(ptrVM.rawUVM());
     5869        VMSUSPENDREASON enmReason = VMSUSPENDREASON_USER;
     5870        if (aReason == Reason_HostSuspend)
     5871            enmReason = VMSUSPENDREASON_HOST_SUSPEND;
     5872        else if (aReason == Reason_HostBatteryLow)
     5873            enmReason = VMSUSPENDREASON_HOST_BATTERY_LOW;
     5874        int vrc = VMR3Suspend(ptrVM.rawUVM(), enmReason);
    58615875        alock.acquire();
    58625876
     
    59675981            {
    59685982                alock.release();
    5969                 VMR3Resume(ptrVM.rawUVM());
     5983                VMR3Resume(ptrVM.rawUVM(), VMRESUMEREASON_STATE_RESTORED);
    59705984                alock.acquire();
    59715985            }
     
    90909104#endif
    90919105                            if (RT_SUCCESS(vrc))
    9092                                 vrc = VMR3Resume(pConsole->mpUVM);
     9106                                vrc = VMR3Resume(pConsole->mpUVM, VMRESUMEREASON_STATE_RESTORED);
    90939107                            AssertLogRelRC(vrc);
    90949108                        }
     
    96309644                SafeVMPtr ptrVM(that);
    96319645                alock.release();
    9632                 int vrc = VMR3Resume(ptrVM.rawUVM());
     9646                int vrc = VMR3Resume(ptrVM.rawUVM(), VMRESUMEREASON_STATE_SAVED);
    96339647                alock.acquire();
    96349648                if (RT_FAILURE(vrc))
     
    96889702                        SafeVMPtr ptrVM(that);
    96899703                        alock.release();
    9690                         int vrc = VMR3Resume(ptrVM.rawUVM()); AssertLogRelRC(vrc);
     9704                        int vrc = VMR3Resume(ptrVM.rawUVM(), VMRESUMEREASON_STATE_SAVED); AssertLogRelRC(vrc);
    96919705                        alock.acquire();
    96929706                        if (RT_FAILURE(vrc))
     
    97479761    LogFlowFunc(("Saving the state to '%s'...\n", task->mSavedStateFile.c_str()));
    97489762
    9749     /** @todo r=klaus make use of task->mReason */
    97509763    bool fSuspenededBySave;
    97519764    int vrc = VMR3Save(task->mpUVM,
  • trunk/src/VBox/Main/src-client/ConsoleImplTeleporter.cpp

    r46326 r46788  
    888888                        {
    889889                            autoLock.release();
    890                             int rc = VMR3Resume(pState->mpUVM);
     890                            int rc = VMR3Resume(pState->mpUVM, VMRESUMEREASON_TELEPORT_FAILED);
    891891                            AssertLogRelMsgRC(rc, ("VMR3Resume -> %Rrc\n", rc));
    892892                            autoLock.acquire();
     
    14131413                {
    14141414                    if (!strcmp(szCmd, "hand-over-resume"))
    1415                         vrc = VMR3Resume(pState->mpUVM);
     1415                        vrc = VMR3Resume(pState->mpUVM, VMRESUMEREASON_TELEPORTED);
    14161416                    else
    14171417                        pState->mptrConsole->setMachineState(MachineState_Paused);
  • trunk/src/VBox/VMM/VMMR3/FTM.cpp

    r46420 r46788  
    638638    bool fSuspended = false;
    639639
    640     int rc = VMR3Suspend(pVM->pUVM);
     640    int rc = VMR3Suspend(pVM->pUVM, VMSUSPENDREASON_FTM_SYNC);
    641641    AssertRCReturn(rc, rc);
    642642
     
    668668    AssertRCReturn(rc, rc);
    669669
    670     rc = VMR3Resume(pVM->pUVM);
     670    rc = VMR3Resume(pVM->pUVM, VMRESUMEREASON_FTM_SYNC);
    671671    AssertRC(rc);
    672672
  • trunk/src/VBox/VMM/VMMR3/PDMDevHlp.cpp

    r46420 r46788  
    22152215    PDMDEV_ASSERT_DEVINS(pDevIns);
    22162216    PVM pVM = pDevIns->Internal.s.pVMR3;
    2217     VM_ASSERT_EMT(pDevIns->Internal.s.pVMR3);
     2217    VM_ASSERT_EMT(pVM);
    22182218    LogFlow(("pdmR3DevHlp_CallR0: caller='%s'/%d: uOperation=%#x u64Arg=%#RX64\n",
    22192219             pDevIns->pReg->szName, pDevIns->iInstance, uOperation, u64Arg));
     
    22562256             pDevIns->iInstance, rc));
    22572257    return rc;
     2258}
     2259
     2260
     2261/** @interface_method_impl{PDMDEVHLP,pfnVMGetSuspendReason} */
     2262static DECLCALLBACK(VMSUSPENDREASON) pdmR3DevHlp_VMGetSuspendReason(PPDMDEVINS pDevIns)
     2263{
     2264    PDMDEV_ASSERT_DEVINS(pDevIns);
     2265    PVM pVM = pDevIns->Internal.s.pVMR3;
     2266    VM_ASSERT_EMT(pVM);
     2267    VMSUSPENDREASON enmReason = VMR3GetSuspendReason(pVM->pUVM);
     2268    LogFlow(("pdmR3DevHlp_VMGetSuspendReason: caller='%s'/%d: returns %d\n",
     2269             pDevIns->pReg->szName, pDevIns->iInstance, enmReason));
     2270    return enmReason;
     2271}
     2272
     2273
     2274/** @interface_method_impl{PDMDEVHLP,pfnVMGetResumeReason} */
     2275static DECLCALLBACK(VMRESUMEREASON) pdmR3DevHlp_VMGetResumeReason(PPDMDEVINS pDevIns)
     2276{
     2277    PDMDEV_ASSERT_DEVINS(pDevIns);
     2278    PVM pVM = pDevIns->Internal.s.pVMR3;
     2279    VM_ASSERT_EMT(pVM);
     2280    VMRESUMEREASON enmReason = VMR3GetResumeReason(pVM->pUVM);
     2281    LogFlow(("pdmR3DevHlp_VMGetResumeReason: caller='%s'/%d: returns %d\n",
     2282             pDevIns->pReg->szName, pDevIns->iInstance, enmReason));
     2283    return enmReason;
    22582284}
    22592285
     
    32563282    {
    32573283        /* We own the IOM lock here and could cause a deadlock by waiting for a VCPU that is blocking on the IOM lock. */
    3258         rc = VMR3ReqCallNoWait(pVM, VMCPUID_ANY_QUEUE, (PFNRT)VMR3Suspend, 1, pVM->pUVM);
     3284        rc = VMR3ReqCallNoWait(pVM, VMCPUID_ANY_QUEUE, (PFNRT)VMR3Suspend, 2, pVM->pUVM, VMSUSPENDREASON_VM);
    32593285        AssertRC(rc);
    32603286        rc = VINF_EM_SUSPEND;
    32613287    }
    32623288    else
    3263         rc = VMR3Suspend(pVM->pUVM);
     3289        rc = VMR3Suspend(pVM->pUVM, VMSUSPENDREASON_VM);
    32643290
    32653291    LogFlow(("pdmR3DevHlp_VMSuspend: caller='%s'/%d: returns %Rrc\n", pDevIns->pReg->szName, pDevIns->iInstance, rc));
     
    32813307     * Suspend the VM first then do the saving.
    32823308     */
    3283     int rc = VMR3Suspend(pVM->pUVM);
     3309    int rc = VMR3Suspend(pVM->pUVM, VMSUSPENDREASON_VM);
    32843310    if (RT_SUCCESS(rc))
    32853311    {
     
    34943520    pdmR3DevHlp_LdrGetR0InterfaceSymbols,
    34953521    pdmR3DevHlp_CallR0,
    3496     0,
    3497     0,
     3522    pdmR3DevHlp_VMGetSuspendReason,
     3523    pdmR3DevHlp_VMGetResumeReason,
    34983524    0,
    34993525    0,
     
    37353761    pdmR3DevHlp_LdrGetR0InterfaceSymbols,
    37363762    pdmR3DevHlp_CallR0,
    3737     0,
    3738     0,
     3763    pdmR3DevHlp_VMGetSuspendReason,
     3764    pdmR3DevHlp_VMGetResumeReason,
    37393765    0,
    37403766    0,
  • trunk/src/VBox/VMM/VMMR3/PDMDriver.cpp

    r46493 r46788  
    17581758
    17591759
     1760
     1761/** @interface_method_impl{PDMDRVHLP,pfnVMGetSuspendReason} */
     1762static DECLCALLBACK(VMSUSPENDREASON) pdmR3DrvHlp_VMGetSuspendReason(PPDMDRVINS pDrvIns)
     1763{
     1764    PDMDRV_ASSERT_DRVINS(pDrvIns);
     1765    PVM pVM = pDrvIns->Internal.s.pVMR3;
     1766    VM_ASSERT_EMT(pVM);
     1767    VMSUSPENDREASON enmReason = VMR3GetSuspendReason(pVM->pUVM);
     1768    LogFlow(("pdmR3DrvHlp_VMGetSuspendReason: caller='%s'/%d: returns %d\n",
     1769             pDrvIns->pReg->szName, pDrvIns->iInstance, enmReason));
     1770    return enmReason;
     1771}
     1772
     1773
     1774/** @interface_method_impl{PDMDRVHLP,pfnVMGetResumeReason} */
     1775static DECLCALLBACK(VMRESUMEREASON) pdmR3DrvHlp_VMGetResumeReason(PPDMDRVINS pDrvIns)
     1776{
     1777    PDMDRV_ASSERT_DRVINS(pDrvIns);
     1778    PVM pVM = pDrvIns->Internal.s.pVMR3;
     1779    VM_ASSERT_EMT(pVM);
     1780    VMRESUMEREASON enmReason = VMR3GetResumeReason(pVM->pUVM);
     1781    LogFlow(("pdmR3DrvHlp_VMGetResumeReason: caller='%s'/%d: returns %d\n",
     1782             pDrvIns->pReg->szName, pDrvIns->iInstance, enmReason));
     1783    return enmReason;
     1784}
     1785
     1786
    17601787/**
    17611788 * The driver helper structure.
     
    18051832    pdmR3DrvHlp_FTSetCheckpoint,
    18061833    pdmR3DrvHlp_BlkCacheRetain,
     1834    pdmR3DrvHlp_VMGetSuspendReason,
     1835    pdmR3DrvHlp_VMGetResumeReason,
     1836    NULL,
     1837    NULL,
     1838    NULL,
     1839    NULL,
     1840    NULL,
     1841    NULL,
     1842    NULL,
     1843    NULL,
     1844    NULL,
     1845    NULL,
    18071846    PDM_DRVHLPR3_VERSION /* u32TheEnd */
    18081847};
  • trunk/src/VBox/VMM/VMMR3/PDMUsb.cpp

    r44386 r46788  
    14651465
    14661466
     1467/** @interface_method_impl{PDMUSBHLP,pfnVMGetSuspendReason} */
     1468static DECLCALLBACK(VMSUSPENDREASON) pdmR3UsbHlp_VMGetSuspendReason(PPDMUSBINS pUsbIns)
     1469{
     1470    PDMUSB_ASSERT_USBINS(pUsbIns);
     1471    PVM pVM = pUsbIns->Internal.s.pVM;
     1472    VM_ASSERT_EMT(pVM);
     1473    VMSUSPENDREASON enmReason = VMR3GetSuspendReason(pVM->pUVM);
     1474    LogFlow(("pdmR3UsbHlp_VMGetSuspendReason: caller='%s'/%d: returns %d\n",
     1475             pUsbIns->pReg->szName, pUsbIns->iInstance, enmReason));
     1476    return enmReason;
     1477}
     1478
     1479
     1480/** @interface_method_impl{PDMUSBHLP,pfnVMGetResumeReason} */
     1481static DECLCALLBACK(VMRESUMEREASON) pdmR3UsbHlp_VMGetResumeReason(PPDMUSBINS pUsbIns)
     1482{
     1483    PDMUSB_ASSERT_USBINS(pUsbIns);
     1484    PVM pVM = pUsbIns->Internal.s.pVM;
     1485    VM_ASSERT_EMT(pVM);
     1486    VMRESUMEREASON enmReason = VMR3GetResumeReason(pVM->pUVM);
     1487    LogFlow(("pdmR3UsbHlp_VMGetResumeReason: caller='%s'/%d: returns %d\n",
     1488             pUsbIns->pReg->szName, pUsbIns->iInstance, enmReason));
     1489    return enmReason;
     1490}
     1491
     1492
    14671493/**
    14681494 * The USB device helper structure.
     
    14881514    pdmR3UsbHlp_SetAsyncNotification,
    14891515    pdmR3UsbHlp_AsyncNotificationCompleted,
     1516    pdmR3UsbHlp_VMGetSuspendReason,
     1517    pdmR3UsbHlp_VMGetResumeReason,
     1518    NULL,
     1519    NULL,
     1520    NULL,
     1521    NULL,
     1522    NULL,
     1523    NULL,
     1524    NULL,
     1525    NULL,
     1526    NULL,
     1527    NULL,
    14901528    PDM_USBHLP_VERSION
    14911529};
  • trunk/src/VBox/VMM/VMMR3/VM.cpp

    r45786 r46788  
    13431343static DECLCALLBACK(VBOXSTRICTRC) vmR3Suspend(PVM pVM, PVMCPU pVCpu, void *pvUser)
    13441344{
    1345     LogFlow(("vmR3Suspend: pVM=%p pVCpu=%p/#%u\n", pVM, pVCpu, pVCpu->idCpu));
    1346     Assert(!pvUser); NOREF(pvUser);
     1345    VMSUSPENDREASON enmReason = (VMSUSPENDREASON)(uintptr_t)pvUser;
     1346    LogFlow(("vmR3Suspend: pVM=%p pVCpu=%p/#%u enmReason=%d\n", pVM, pVCpu, pVCpu->idCpu, enmReason));
    13471347
    13481348    /*
     
    13581358        if (RT_FAILURE(rc))
    13591359            return rc;
     1360        pVM->pUVM->vm.s.enmSuspendReason = enmReason;
    13601361    }
    13611362
     
    13911392 *          code that has to be propagated up the call stack.
    13921393 *
    1393  * @param   pUVM    The VM to suspend.
     1394 * @param   pUVM        The VM to suspend.
     1395 * @param   enmReason   The reason for suspending.
    13941396 *
    13951397 * @thread      Any thread.
     
    13971399 * @vmstateto   Suspending + Suspended or SuspendingExtLS + SuspendedExtLS
    13981400 */
    1399 VMMR3DECL(int) VMR3Suspend(PUVM pUVM)
     1401VMMR3DECL(int) VMR3Suspend(PUVM pUVM, VMSUSPENDREASON enmReason)
    14001402{
    14011403    LogFlow(("VMR3Suspend: pUVM=%p\n", pUVM));
    14021404    UVM_ASSERT_VALID_EXT_RETURN(pUVM, VERR_INVALID_VM_HANDLE);
     1405    AssertReturn(enmReason > VMSUSPENDREASON_INVALID && enmReason < VMSUSPENDREASON_END, VERR_INVALID_PARAMETER);
    14031406
    14041407    /*
     
    14071410     */
    14081411    int rc = VMMR3EmtRendezvous(pUVM->pVM, VMMEMTRENDEZVOUS_FLAGS_TYPE_DESCENDING | VMMEMTRENDEZVOUS_FLAGS_STOP_ON_ERROR,
    1409                                 vmR3Suspend, NULL);
     1412                                vmR3Suspend, (void *)(uintptr_t)enmReason);
    14101413    LogFlow(("VMR3Suspend: returns %Rrc\n", rc));
    14111414    return rc;
     
    14141417
    14151418/**
     1419 * Retrieves the reason for the most recent suspend.
     1420 *
     1421 * @returns Suspend reason. VMSUSPENDREASON_INVALID if no suspend has been done
     1422 *          or the handle is invalid.
     1423 * @param   pUVM        The user mode VM handle.
     1424 */
     1425VMMR3DECL(VMSUSPENDREASON) VMR3GetSuspendReason(PUVM pUVM)
     1426{
     1427    UVM_ASSERT_VALID_EXT_RETURN(pUVM, VMSUSPENDREASON_INVALID);
     1428    return pUVM->vm.s.enmSuspendReason;
     1429}
     1430
     1431
     1432/**
    14161433 * EMT rendezvous worker for VMR3Resume.
    14171434 *
     
    14211438 * @param   pVM             Pointer to the VM.
    14221439 * @param   pVCpu           Pointer to the VMCPU of the EMT.
    1423  * @param   pvUser          Ignored.
     1440 * @param   pvUser          Reason.
    14241441 */
    14251442static DECLCALLBACK(VBOXSTRICTRC) vmR3Resume(PVM pVM, PVMCPU pVCpu, void *pvUser)
    14261443{
    1427     LogFlow(("vmR3Resume: pVM=%p pVCpu=%p/#%u\n", pVM, pVCpu, pVCpu->idCpu));
    1428     Assert(!pvUser); NOREF(pvUser);
     1444    VMRESUMEREASON enmReason = (VMRESUMEREASON)(uintptr_t)pvUser;
     1445    LogFlow(("vmR3Resume: pVM=%p pVCpu=%p/#%u enmReason=%d\n", pVM, pVCpu, pVCpu->idCpu, enmReason));
    14291446
    14301447    /*
     
    14371454        if (RT_FAILURE(rc))
    14381455            return rc;
     1456        pVM->pUVM->vm.s.enmResumeReason = enmReason;
    14391457    }
    14401458
     
    14731491 *
    14741492 * @param   pVM         The VM to resume.
     1493 * @param   enmReason   The reason we're resuming.
    14751494 *
    14761495 * @thread      Any thread.
     
    14781497 * @vmstateto   Running
    14791498 */
    1480 VMMR3DECL(int) VMR3Resume(PUVM pUVM)
     1499VMMR3DECL(int) VMR3Resume(PUVM pUVM, VMRESUMEREASON enmReason)
    14811500{
    14821501    LogFlow(("VMR3Resume: pUVM=%p\n", pUVM));
     
    14841503    PVM pVM = pUVM->pVM;
    14851504    VM_ASSERT_VALID_EXT_RETURN(pVM, VERR_INVALID_VM_HANDLE);
     1505    AssertReturn(enmReason > VMRESUMEREASON_INVALID && enmReason < VMRESUMEREASON_END, VERR_INVALID_PARAMETER);
    14861506
    14871507    /*
     
    14901510     */
    14911511    int rc = VMMR3EmtRendezvous(pVM, VMMEMTRENDEZVOUS_FLAGS_TYPE_DESCENDING | VMMEMTRENDEZVOUS_FLAGS_STOP_ON_ERROR,
    1492                                 vmR3Resume, NULL);
     1512                                vmR3Resume, (void *)(uintptr_t)enmReason);
    14931513    LogFlow(("VMR3Resume: returns %Rrc\n", rc));
    14941514    return rc;
     1515}
     1516
     1517
     1518/**
     1519 * Retrieves the reason for the most recent resume.
     1520 *
     1521 * @returns Resume reason. VMRESUMEREASON_INVALID if no suspend has been
     1522 *          done or the handle is invalid.
     1523 * @param   pUVM        The user mode VM handle.
     1524 */
     1525VMMR3DECL(VMRESUMEREASON) VMR3GetResumeReason(PUVM pUVM)
     1526{
     1527    UVM_ASSERT_VALID_EXT_RETURN(pUVM, VMRESUMEREASON_INVALID);
     1528    return pUVM->vm.s.enmResumeReason;
    14951529}
    14961530
     
    40524086                                vmR3SetRuntimeErrorChangeState, NULL);
    40534087    else if (fFlags & VMSETRTERR_FLAGS_SUSPEND)
    4054         rc = VMR3Suspend(pUVM);
     4088        rc = VMR3Suspend(pUVM, VMSUSPENDREASON_RUNTIME_ERROR);
    40554089    else
    40564090        rc = VINF_SUCCESS;
  • trunk/src/VBox/VMM/include/VMInternal.h

    r44528 r46788  
    228228     * and when debugging. */
    229229    VMSTATE                         enmPrevVMState;
     230
     231    /** Reason for the most recent suspend operation. */
     232    VMSUSPENDREASON                 enmSuspendReason;
     233    /** Reason for the most recent operation. */
     234    VMRESUMEREASON                  enmResumeReason;
    230235
    231236    /** Critical section for pAtError and pAtRuntimeError. */
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