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