VirtualBox

Changeset 58162 in vbox for trunk/src


Ignore:
Timestamp:
Oct 9, 2015 6:45:30 PM (9 years ago)
Author:
vboxsync
Message:

VMMDev: Bumped saved state version to save heartbeat state. Wrote short section in the VMMDev @page about the heartbeat stuff.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/VMMDev/VMMDev.cpp

    r58161 r58162  
    5151 * This seems to be fast method. It requires only one context switch for an
    5252 * event processing.
     53 *
     54 *
     55 * @section sec_vmmdev_heartbeat    Heartbeat
     56 *
     57 * The heartbeat is a feature to monitor whether the guest OS is hung or not.
     58 *
     59 * The main kernel component of the guest additions, VBoxGuest, sets up a timer
     60 * at a frequency returned by VMMDevReq_HeartbeatConfigure
     61 * (VMMDevReqHeartbeat::cNsInterval, VMMDEV::cNsHeartbeatInterval) and performs
     62 * a VMMDevReq_GuestHeartbeat request every time the timer ticks.
     63 *
     64 * The host side (VMMDev) arms a timer with a more distant deadline
     65 * (VMMDEV::cNsHeartbeatTimeout), twice cNsHeartbeatInterval by default.  Each
     66 * time a VMMDevReq_GuestHeartbeat request comes in, the timer is rearmed with
     67 * the same relative deadline.  So, as long as VMMDevReq_GuestHeartbeat comes
     68 * when they should, the host timer will never fire.
     69 *
     70 * When the timer fires, we consider the guest as hung / flatlined / dead.
     71 * Currently we only LogRel that, but it's easy to extend this with an event in
     72 * Main API.
     73 *
     74 * Should the guest reawaken at some later point, we LogRel that event and
     75 * continue as normal.  Again something which would merit an API event.
    5376 *
    5477 */
     
    120143
    121144/** The saved state version. */
    122 #define VMMDEV_SAVED_STATE_VERSION                              15
     145#define VMMDEV_SAVED_STATE_VERSION                              VMMDEV_SAVED_STATE_VERSION_HEARTBEAT
     146/** The saved state version with heartbeat state. */
     147#define VMMDEV_SAVED_STATE_VERSION_HEARTBEAT                    16
     148/** The saved state version without heartbeat state. */
     149#define VMMDEV_SAVED_STATE_VERSION_NO_HEARTBEAT                 15
    123150/** The saved state version which is missing the guest facility statuses. */
    124151#define VMMDEV_SAVED_STATE_VERSION_MISSING_FACILITY_STATUSES    14
     
    501528        if (pReq->fEnabled)
    502529        {
    503             /* Start the countdown. */
     530            /*
     531             * Activate the heartbeat monitor.
     532             */
     533            pThis->nsLastHeartbeatTS = TMTimerGetNano(pThis->pFlatlinedTimer);
    504534            rc = TMTimerSetNano(pThis->pFlatlinedTimer, pThis->cNsHeartbeatTimeout);
    505535            if (RT_SUCCESS(rc))
    506                 LogRel(("VMMDev: Heartbeat checking timer set to trigger every %RU64 milliseconds\n",
    507                         pThis->cNsHeartbeatTimeout / RT_NS_1MS));
     536                LogRel(("VMMDev: Heartbeat flatline timer set to trigger after %'RU64 ns\n", pThis->cNsHeartbeatTimeout));
    508537            else
    509                 LogRel(("VMMDev: Cannot create heartbeat check timer, rc=%Rrc\n", rc));
     538                LogRel(("VMMDev: Error starting flatline timer (heartbeat): %Rrc\n", rc));
    510539        }
    511540        else
    512541        {
     542            /*
     543             * Deactivate the heartbeat monitor.
     544             */
    513545            rc = TMTimerStop(pThis->pFlatlinedTimer);
    514             LogRel(("VMMDev: Heartbeat checking timer has been stopped, rc=%Rrc\n", rc));
     546            LogRel(("VMMDev: Heartbeat checking timer has been stopped (rc=%Rrc)\n", rc));
    515547        }
    516548    }
    517549    else
    518550    {
    519         LogRel(("VMMDev: vmmDevReqHandler_HeartbeatConfigure: fHBCheckEnabled=%RTbool\n", pThis->fHeartbeatActive));
     551        LogRel(("VMMDev: vmmDevReqHandler_HeartbeatConfigure: No change (fHeartbeatActive=%RTbool).\n", pThis->fHeartbeatActive));
    520552        rc = VINF_SUCCESS;
    521553    }
     
    34923524    }
    34933525
     3526    /* Heartbeat: */
     3527    SSMR3PutBool(pSSM, pThis->fHeartbeatActive);
     3528    SSMR3PutBool(pSSM, pThis->fFlatlined);
     3529    SSMR3PutU64(pSSM, pThis->nsLastHeartbeatTS);
     3530    TMR3TimerSave(pThis->pFlatlinedTimer, pSSM);
     3531
    34943532    PDMCritSectLeave(&pThis->CritSect);
    34953533    return VINF_SUCCESS;
     
    36133651    }
    36143652
     3653    /*
     3654     * Heartbeat.
     3655     */
     3656    if (uVersion >= VMMDEV_SAVED_STATE_VERSION_HEARTBEAT)
     3657    {
     3658        SSMR3GetBool(pSSM, (bool *)&pThis->fHeartbeatActive);
     3659        SSMR3GetBool(pSSM, (bool *)&pThis->fFlatlined);
     3660        SSMR3GetU64(pSSM, (uint64_t *)&pThis->nsLastHeartbeatTS);
     3661        rc = TMR3TimerLoad(pThis->pFlatlinedTimer, pSSM);
     3662        AssertRCReturn(rc, rc);
     3663        if (pThis->fFlatlined)
     3664            LogRel(("vmmdevLoadState: Guest has flatlined. Last heartbeat %'RU64 ns before state was saved.\n",
     3665                    TMTimerGetNano(pThis->pFlatlinedTimer) - pThis->nsLastHeartbeatTS));
     3666    }
    36153667
    36163668    /*
     
    37903842
    37913843    /*
     3844     * Deactive heartbeat.
     3845     */
     3846    if (pThis->fHeartbeatActive)
     3847    {
     3848        TMTimerStop(pThis->pFlatlinedTimer);
     3849        pThis->fFlatlined       = false;
     3850        pThis->fHeartbeatActive = true;
     3851    }
     3852
     3853    /*
    37923854     * Clear the event variables.
    37933855     *
     
    38103872        pThis->pDrv->pfnUpdateGuestCapabilities(pThis->pDrv, pThis->guestCaps);
    38113873
    3812     /* Generate a unique session id for this VM; it will be changed for each start, reset or restore.
     3874    /*
     3875     * Generate a unique session id for this VM; it will be changed for each start, reset or restore.
    38133876     * This can be used for restore detection inside the guest.
    38143877     */
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