Skip to content

Commit 792722e

Browse files
committed
GOGO
Signed-off-by: Ludvig Liljenberg <[email protected]>
1 parent ca0916f commit 792722e

File tree

5 files changed

+20
-24
lines changed

5 files changed

+20
-24
lines changed

src/hyperlight_host/src/hypervisor/hyperlight_vm.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,10 @@ use super::handlers::DbgMemAccessHandlerWrapper;
2727
use super::handlers::{
2828
MemAccessHandlerCaller, MemAccessHandlerWrapper, OutBHandlerCaller, OutBHandlerWrapper,
2929
};
30-
#[cfg(mshv)]
31-
use super::hyperv_linux::MshvVm;
3230
#[cfg(kvm)]
3331
use super::kvm::KvmVm;
32+
#[cfg(mshv)]
33+
use super::mshv::MshvVm;
3434
use super::regs::{
3535
CommonFpu, CommonRegisters, FP_CONTROL_WORD_DEFAULT, FP_TAG_WORD_DEFAULT, MXCSR_DEFAULT,
3636
};
@@ -41,10 +41,10 @@ use super::{
4141
};
4242
#[cfg(crashdump)]
4343
use crate::hypervisor::crashdump;
44-
#[cfg(target_os = "windows")]
45-
use crate::hypervisor::hyperv_windows::WhpVm;
4644
use crate::hypervisor::hypervisor_handler::HypervisorHandler;
4745
#[cfg(target_os = "windows")]
46+
use crate::hypervisor::whp::WhpVm;
47+
#[cfg(target_os = "windows")]
4848
use crate::hypervisor::wrappers::HandleWrapper;
4949
use crate::mem::memory_region::{MemoryRegion, MemoryRegionFlags};
5050
use crate::mem::ptr::{GuestPtr, RawPtr};

src/hyperlight_host/src/hypervisor/mod.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,15 @@ use crate::Result;
2121
/// Handlers for Hypervisor custom logic
2222
pub mod handlers;
2323
pub(crate) mod hyperlight_vm;
24+
pub(crate) mod hypervisor_handler;
2425
/// HyperV-on-linux functionality
2526
#[cfg(mshv)]
26-
pub mod hyperv_linux;
27-
#[cfg(target_os = "windows")]
28-
/// Hyperv-on-windows functionality
29-
pub(crate) mod hyperv_windows;
30-
pub(crate) mod hypervisor_handler;
27+
pub mod mshv;
3128
mod regs;
3229
mod vm;
30+
#[cfg(target_os = "windows")]
31+
/// Hyperv-on-windows functionality
32+
pub(crate) mod whp;
3333

3434
/// GDB debugging support
3535
#[cfg(gdb)]

src/hyperlight_host/src/hypervisor/hyperv_windows.rs renamed to src/hyperlight_host/src/hypervisor/whp.rs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -127,8 +127,7 @@ impl WhpVm {
127127
register_names.as_ptr(),
128128
register_count as u32,
129129
register_values.as_ptr(),
130-
)
131-
.unwrap();
130+
)?;
132131
}
133132

134133
Ok(())
@@ -147,8 +146,7 @@ impl Vm for WhpVm {
147146
WHP_REGS_NAMES.as_ptr(),
148147
WHP_REGS_NAMES_LEN as u32,
149148
whv_regs_values.as_mut_ptr(),
150-
)
151-
.unwrap();
149+
)?;
152150
}
153151

154152
WHP_REGS_NAMES
@@ -182,8 +180,7 @@ impl Vm for WhpVm {
182180
WHP_SREGS_NAMES.as_ptr(),
183181
whp_sregs_values.len() as u32,
184182
whp_sregs_values.as_mut_ptr(),
185-
)
186-
.unwrap();
183+
)?;
187184
}
188185

189186
WHP_SREGS_NAMES
@@ -217,8 +214,7 @@ impl Vm for WhpVm {
217214
WHP_FPU_NAMES.as_ptr(),
218215
whp_fpu_values.len() as u32,
219216
whp_fpu_values.as_mut_ptr(),
220-
)
221-
.unwrap();
217+
)?;
222218
}
223219

224220
WHP_FPU_NAMES

src/hyperlight_host/src/sandbox/hypervisor.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@ limitations under the License.
1717
use std::fmt::Debug;
1818
use std::sync::OnceLock;
1919

20-
#[cfg(mshv)]
21-
use crate::hypervisor::hyperv_linux;
22-
#[cfg(target_os = "windows")]
23-
use crate::hypervisor::hyperv_windows;
2420
#[cfg(kvm)]
2521
use crate::hypervisor::kvm;
22+
#[cfg(mshv)]
23+
use crate::hypervisor::mshv;
24+
#[cfg(target_os = "windows")]
25+
use crate::hypervisor::whp;
2626

2727
static AVAILABLE_HYPERVISOR: OnceLock<Option<HypervisorType>> = OnceLock::new();
2828

@@ -33,7 +33,7 @@ pub fn get_available_hypervisor() -> &'static Option<HypervisorType> {
3333
// If both features are enabled, we need to determine hypervisor at runtime.
3434
// Currently /dev/kvm and /dev/mshv cannot exist on the same machine, so the first one
3535
// that works is guaranteed to be correct.
36-
if hyperv_linux::is_hypervisor_present() {
36+
if mshv::is_hypervisor_present() {
3737
Some(HypervisorType::Mshv)
3838
} else if kvm::is_hypervisor_present() {
3939
Some(HypervisorType::Kvm)
@@ -47,13 +47,13 @@ pub fn get_available_hypervisor() -> &'static Option<HypervisorType> {
4747
None
4848
}
4949
} else if #[cfg(mshv)] {
50-
if hyperv_linux::is_hypervisor_present() {
50+
if mshv::is_hypervisor_present() {
5151
Some(HypervisorType::Mshv)
5252
} else {
5353
None
5454
}
5555
} else if #[cfg(target_os = "windows")] {
56-
if hyperv_windows::is_hypervisor_present() {
56+
if whp::is_hypervisor_present() {
5757
Some(HypervisorType::Whp)
5858
} else {
5959
None

0 commit comments

Comments
 (0)