VirtualBox

Changeset 105463 in vbox for trunk


Ignore:
Timestamp:
Jul 24, 2024 9:01:08 AM (6 months ago)
Author:
vboxsync
Message:

VMM/TM: An automatic power off timer for debugging - disabled by default. bugref:10727

Location:
trunk/src/VBox/VMM
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/VMM/VMMR3/TM.cpp

    r104131 r105463  
    186186static DECLCALLBACK(int)    tmR3Save(PVM pVM, PSSMHANDLE pSSM);
    187187static DECLCALLBACK(int)    tmR3Load(PVM pVM, PSSMHANDLE pSSM, uint32_t uVersion, uint32_t uPass);
     188static DECLCALLBACK(int)    tmR3LoadDone(PVM pVM, PSSMHANDLE pSSM);
    188189#ifdef VBOX_WITH_STATISTICS
    189190static void                 tmR3TimerQueueRegisterStats(PVM pVM, PTMTIMERQUEUE pQueue, uint32_t cTimers);
     
    693694                               NULL, NULL, NULL,
    694695                               NULL, tmR3Save, NULL,
    695                                NULL, tmR3Load, NULL);
     696                               NULL, tmR3Load, tmR3LoadDone);
    696697    if (RT_FAILURE(rc))
    697698        return rc;
     
    10931094}
    10941095
     1096#if 1
     1097# include <iprt/message.h>
     1098/** @callback_method_impl{FNTMTIMERINT} */
     1099static DECLCALLBACK(void) tmR3AutoPowerOffTimer(PVM pVM, TMTIMERHANDLE hTimer, void *pvUser)
     1100{
     1101    RT_NOREF(hTimer, pvUser);
     1102    RTMsgInfo("The automatic power off timer fired...\n");
     1103    LogRel(("The automatic power off timer fired...\n"));
     1104    int rc = VMR3ReqCallNoWait(pVM, VMCPUID_ANY_QUEUE, (PFNRT)VMR3PowerOff, 1, pVM->pUVM);
     1105    AssertLogRelRC(rc);
     1106}
     1107#endif
     1108
    10951109
    10961110/**
     
    11481162        tmR3TimerQueueRegisterStats(pVM, &pVM->tm.s.aTimerQueues[idxQueue], UINT32_MAX);
    11491163    }
     1164#endif
     1165
     1166#ifdef TM_SECONDS_TO_AUTOMATIC_POWER_OFF
     1167    /*
     1168     * Automatic VM shutdown timer.
     1169     */
     1170    rc = TMR3TimerCreate(pVM, TMCLOCK_VIRTUAL, tmR3AutoPowerOffTimer, NULL, TMTIMER_FLAGS_NO_RING0,
     1171                         "Auto power off after " RT_XSTR(TM_SECONDS_TO_AUTOMATIC_POWER_OFF) " sec", &hTimer);
     1172    AssertLogRelRCReturn(rc, rc);
     1173    TMTimerSetMillies(pVM, hTimer, TM_SECONDS_TO_AUTOMATIC_POWER_OFF * RT_MS_1SEC);
     1174    pVM->tm.s.hAutoPowerOff = hTimer;
    11501175#endif
    11511176
     
    14861511    return VINF_SUCCESS;
    14871512}
     1513
     1514
     1515/**
     1516 * @callback_method_impl{FNSSMINTLOADDONE, For rearming autopoweroff}
     1517 */
     1518static DECLCALLBACK(int) tmR3LoadDone(PVM pVM, PSSMHANDLE pSSM)
     1519{
     1520    RT_NOREF(pVM, pSSM);
     1521#ifdef TM_SECONDS_TO_AUTOMATIC_POWER_OFF
     1522    TMTimerSetMillies(pVM, pVM->tm.s.hAutoPowerOff, TM_SECONDS_TO_AUTOMATIC_POWER_OFF * RT_MS_1SEC);
     1523#endif
     1524    return VINF_SUCCESS;
     1525}
     1526
    14881527
    14891528#ifdef VBOX_WITH_STATISTICS
  • trunk/src/VBox/VMM/include/TMInternal.h

    r104131 r105463  
    5555#define TMCLOCK_FREQ_VIRTUAL    UINT32_C(1000000000)
    5656
     57/** @def TM_SECONDS_TO_AUTOMATIC_POWER_OFF
     58 * Powers off the VM automatically after the defined number of seconds.
     59 * This is for debugging only. */
     60#if defined(DOXYGEN_RUNNING) || 0
     61# define TM_SECONDS_TO_AUTOMATIC_POWER_OFF 45
     62#endif
    5763
    5864/**
     
    740746    STAMCOUNTER                 StatTSCSyncNotTicking;
    741747    /** @} */
     748
     749#ifdef TM_SECONDS_TO_AUTOMATIC_POWER_OFF
     750    /** The automatic power off timer. */
     751    TMTIMERHANDLE               hAutoPowerOff;
     752#endif
    742753} TM;
    743754/** Pointer to TM VM instance data. */
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