hyperv_ic_protocol/
heartbeat.rs

1// Copyright (c) Microsoft Corporation.
2// Licensed under the MIT License.
3
4//! Heartbeat component protocol.
5use open_enum::open_enum;
6use zerocopy::FromBytes;
7use zerocopy::Immutable;
8use zerocopy::IntoBytes;
9use zerocopy::KnownLayout;
10
11/// Heartbeat message from guest to host.
12#[repr(C)]
13#[derive(IntoBytes, Immutable, KnownLayout, FromBytes)]
14pub struct HeartbeatMessage {
15    /// Incrementing sequence counter.
16    pub sequence_number: u64,
17    /// Current state of the guest.
18    pub application_state: ApplicationState,
19    /// Reserved.
20    pub reserved: [u8; 4],
21}
22
23open_enum! {
24    #[derive(IntoBytes, Immutable, KnownLayout, FromBytes)]
25    /// Current state of guest.
26    pub enum ApplicationState: u32 {
27        /// Guest is in an unknown state.
28        UNKNOWN = 0,
29        /// Guest is healthy.
30        HEALTHY = 1,
31        /// Guest encountered a critical error.
32        CRITICAL = 2,
33        /// Guest is no longer running.
34        STOPPED = 3,
35    }
36}