- Timestamp:
- Oct 9, 2015 6:45:30 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/VMMDev/VMMDev.cpp
r58161 r58162 51 51 * This seems to be fast method. It requires only one context switch for an 52 52 * 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. 53 76 * 54 77 */ … … 120 143 121 144 /** 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 123 150 /** The saved state version which is missing the guest facility statuses. */ 124 151 #define VMMDEV_SAVED_STATE_VERSION_MISSING_FACILITY_STATUSES 14 … … 501 528 if (pReq->fEnabled) 502 529 { 503 /* Start the countdown. */ 530 /* 531 * Activate the heartbeat monitor. 532 */ 533 pThis->nsLastHeartbeatTS = TMTimerGetNano(pThis->pFlatlinedTimer); 504 534 rc = TMTimerSetNano(pThis->pFlatlinedTimer, pThis->cNsHeartbeatTimeout); 505 535 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)); 508 537 else 509 LogRel(("VMMDev: Cannot create heartbeat check timer, rc=%Rrc\n", rc));538 LogRel(("VMMDev: Error starting flatline timer (heartbeat): %Rrc\n", rc)); 510 539 } 511 540 else 512 541 { 542 /* 543 * Deactivate the heartbeat monitor. 544 */ 513 545 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)); 515 547 } 516 548 } 517 549 else 518 550 { 519 LogRel(("VMMDev: vmmDevReqHandler_HeartbeatConfigure: fHBCheckEnabled=%RTbool\n", pThis->fHeartbeatActive));551 LogRel(("VMMDev: vmmDevReqHandler_HeartbeatConfigure: No change (fHeartbeatActive=%RTbool).\n", pThis->fHeartbeatActive)); 520 552 rc = VINF_SUCCESS; 521 553 } … … 3492 3524 } 3493 3525 3526 /* Heartbeat: */ 3527 SSMR3PutBool(pSSM, pThis->fHeartbeatActive); 3528 SSMR3PutBool(pSSM, pThis->fFlatlined); 3529 SSMR3PutU64(pSSM, pThis->nsLastHeartbeatTS); 3530 TMR3TimerSave(pThis->pFlatlinedTimer, pSSM); 3531 3494 3532 PDMCritSectLeave(&pThis->CritSect); 3495 3533 return VINF_SUCCESS; … … 3613 3651 } 3614 3652 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 } 3615 3667 3616 3668 /* … … 3790 3842 3791 3843 /* 3844 * Deactive heartbeat. 3845 */ 3846 if (pThis->fHeartbeatActive) 3847 { 3848 TMTimerStop(pThis->pFlatlinedTimer); 3849 pThis->fFlatlined = false; 3850 pThis->fHeartbeatActive = true; 3851 } 3852 3853 /* 3792 3854 * Clear the event variables. 3793 3855 * … … 3810 3872 pThis->pDrv->pfnUpdateGuestCapabilities(pThis->pDrv, pThis->guestCaps); 3811 3873 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. 3813 3876 * This can be used for restore detection inside the guest. 3814 3877 */
Note:
See TracChangeset
for help on using the changeset viewer.