guest_emulation_transport/
error.rs1use thiserror::Error;
7
8#[derive(Debug, Error)]
10#[error("vmgs io error: {0:?}")]
11pub struct VmgsIoError(pub(crate) get_protocol::VmgsIoStatus);
12
13#[expect(missing_docs)] #[derive(Debug, Error)]
16pub enum DevicePlatformSettingsError {
17 #[error("unknown secure boot template type: {0:?}")]
18 UnknownSecureBootTemplateType(get_protocol::SecureBootTemplateType),
19 #[error("invalid console mode (must be 0b00..=0b11): {}", 0.0)]
20 InvalidConsoleMode(get_protocol::UefiConsoleMode),
21 #[error("invalid memory protection mode (must be 0b00..=0b11): {0}")]
22 InvalidMemoryProtectionMode(u8),
23 #[error("could not parse DPSv2 JSON")]
24 BadJson(#[source] serde_json::Error),
25 #[error("could not parse embedded VTL2 settings data")]
26 BadVtl2Settings(#[source] underhill_config::schema::ParseError),
27 #[error("invalid legacy bool representation ({0:?})")]
28 InvalidProtocolBool(#[from] InvalidProtocolBool),
29}
30
31#[derive(Debug, Error)]
33#[error("expected 0 or 1, found {0}")]
34pub struct InvalidProtocolBool(pub(crate) u8);
35
36#[derive(Debug, Error)]
38#[error("map framebuffer error: {0:?}")]
39pub struct MapFramebufferError(pub(crate) get_protocol::MapFramebufferStatus);
40
41#[derive(Debug, Error)]
43#[error("unmap framebuffer error: {0:?}")]
44pub struct UnmapFramebufferError(pub(crate) get_protocol::UnmapFramebufferStatus);
45
46#[derive(Debug, Error)]
48#[error("vpci operation error: {0:?}")]
49pub struct VpciControlError(pub(crate) get_protocol::VpciDeviceControlStatus);
50
51#[derive(Debug, Error)]
53#[error("create ram GPA range error: {0:?}")]
54pub struct CreateRamGpaRangeError(pub(crate) get_protocol::CreateRamGpaRangeStatus);
55
56#[derive(Debug, Error)]
58#[error("malformed response - reported len > actual len: {0} > {1}")]
59pub struct GuestStateProtectionByIdError(pub(crate) u32, pub(crate) u32);
60
61#[derive(Debug, Error)]
63#[error("host rejected save/restore operation")]
64#[non_exhaustive]
65pub struct SaveRestoreOperationFailure {}
66
67#[expect(missing_docs)] #[derive(Debug, Error)]
70pub enum IgvmAttestError {
71 #[error("`agent_data` size {input_size} was larger than expected {expected_size}")]
72 InvalidAgentDataSize {
73 input_size: usize,
74 expected_size: usize,
75 },
76 #[error("`report` size {input_size} was larger than expected {expected_size}")]
77 InvalidReportSize {
78 input_size: usize,
79 expected_size: usize,
80 },
81 #[error("IGVM agent returned an error")]
82 IgvmAgentGenericError,
83}
84
85pub(crate) trait TryIntoProtocolBool {
86 fn into_bool(self) -> Result<bool, InvalidProtocolBool>;
87}
88
89impl TryIntoProtocolBool for get_protocol::ProtocolBool {
90 fn into_bool(self) -> Result<bool, InvalidProtocolBool> {
91 match self.0 {
92 0 => Ok(false),
93 1 => Ok(true),
94 _ => Err(InvalidProtocolBool(self.0)),
95 }
96 }
97}