Skip to content

Commit 65217f3

Browse files
authored
Introduces a separate KVM error variant of HyperlightError. (#771)
Fixes a common build error which occurs when the version of vmm-sys-util crate does not match between mshv/kvm. VmmSysError variant is now solely used for our signal registration, and is not used by mshv nor kvm code. Signed-off-by: Ludvig Liljenberg <[email protected]>
1 parent 9ad8569 commit 65217f3

File tree

4 files changed

+30
-16
lines changed

4 files changed

+30
-16
lines changed

Cargo.lock

Lines changed: 17 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/hyperlight_host/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ tracing-log = "0.2.0"
4040
tracing-core = "0.1.34"
4141
hyperlight-common = { workspace = true, default-features = true, features = [ "std" ] }
4242
hyperlight-guest-tracing = { workspace = true, default-features = true, optional = true }
43-
vmm-sys-util = "0.14.0"
43+
vmm-sys-util = "0.15.0"
4444
crossbeam-channel = "0.5.15"
4545
thiserror = "2.0.12"
4646
chrono = { version = "0.4", optional = true }

src/hyperlight_host/src/error.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,11 @@ pub enum HyperlightError {
138138
#[error("Conversion of str data to json failed")]
139139
JsonConversionFailure(#[from] serde_json::Error),
140140

141+
/// KVM Error Occurred
142+
#[error("KVM Error {0:?}")]
143+
#[cfg(kvm)]
144+
KVMError(#[from] kvm_ioctls::Error),
145+
141146
/// An attempt to get a lock from a Mutex failed.
142147
#[error("Unable to lock resource")]
143148
LockAttemptFailed(String),

src/hyperlight_host/src/hypervisor/hyperv_linux.rs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ use mshv_bindings::{
5353
hv_register_name, hv_register_name_HV_X64_REGISTER_RAX, hv_register_name_HV_X64_REGISTER_RBP,
5454
hv_register_name_HV_X64_REGISTER_RCX, hv_register_name_HV_X64_REGISTER_RSP,
5555
};
56-
use mshv_ioctls::{Mshv, MshvError, VcpuFd, VmFd};
56+
use mshv_ioctls::{Mshv, VcpuFd, VmFd};
5757
use tracing::{Span, instrument};
5858
#[cfg(crashdump)]
5959
use {super::crashdump, std::path::Path};
@@ -794,9 +794,7 @@ impl Hypervisor for HypervLinuxDriver {
794794
.load(Ordering::Relaxed)
795795
|| debug_interrupt
796796
{
797-
Err(MshvError::Errno(vmm_sys_util::errno::Error::new(
798-
libc::EINTR,
799-
)))
797+
Err(mshv_ioctls::MshvError::from(libc::EINTR))
800798
} else {
801799
#[cfg(feature = "trace_guest")]
802800
if self.trace_info.guest_start_epoch.is_none() {
@@ -847,7 +845,7 @@ impl Hypervisor for HypervLinuxDriver {
847845
HyperlightExit::Halt()
848846
}
849847
IO_PORT_INTERCEPT_MESSAGE => {
850-
let io_message = m.to_ioport_info()?;
848+
let io_message = m.to_ioport_info().map_err(mshv_ioctls::MshvError::from)?;
851849
let port_number = io_message.port_number;
852850
let rip = io_message.header.rip;
853851
let rax = io_message.rax;
@@ -861,7 +859,7 @@ impl Hypervisor for HypervLinuxDriver {
861859
)
862860
}
863861
UNMAPPED_GPA_MESSAGE => {
864-
let mimo_message = m.to_memory_info()?;
862+
let mimo_message = m.to_memory_info().map_err(mshv_ioctls::MshvError::from)?;
865863
let addr = mimo_message.guest_physical_address;
866864
crate::debug!(
867865
"mshv MMIO unmapped GPA -Details: Address: {} \n {:#?}",
@@ -871,7 +869,7 @@ impl Hypervisor for HypervLinuxDriver {
871869
HyperlightExit::Mmio(addr)
872870
}
873871
INVALID_GPA_ACCESS_MESSAGE => {
874-
let mimo_message = m.to_memory_info()?;
872+
let mimo_message = m.to_memory_info().map_err(mshv_ioctls::MshvError::from)?;
875873
let gpa = mimo_message.guest_physical_address;
876874
let access_info = MemoryRegionFlags::try_from(mimo_message)?;
877875
crate::debug!(
@@ -896,7 +894,8 @@ impl Hypervisor for HypervLinuxDriver {
896894
EXCEPTION_INTERCEPT => {
897895
// Extract exception info from the message so we can figure out
898896
// more information about the vCPU state
899-
let ex_info = match m.to_exception_info() {
897+
let ex_info = match m.to_exception_info().map_err(mshv_ioctls::MshvError::from)
898+
{
900899
Ok(info) => info,
901900
Err(e) => {
902901
log_then_return!("Error converting to exception info: {:?}", e);

0 commit comments

Comments
 (0)