Skip to content

Commit 1d8b289

Browse files
authored
Fix confusing log message when checking present hypervisor (#422)
* Removes the word 'Error' from non-error log messages when checking if specific hypervisors exist. This caused confusion if both kvm and mshv cargo features were enabled Signed-off-by: Ludvig Liljenberg <[email protected]> * Use Mshv::new() instead of Mshv::open_with_cloexec() to avoid manually needing to close fd Signed-off-by: Ludvig Liljenberg <[email protected]> --------- Signed-off-by: Ludvig Liljenberg <[email protected]>
1 parent 34eb326 commit 1d8b289

File tree

5 files changed

+13
-15
lines changed

5 files changed

+13
-15
lines changed

src/hyperlight_host/src/hypervisor/hyperv_linux.rs

+4-9
Original file line numberDiff line numberDiff line change
@@ -271,15 +271,10 @@ mod debug {
271271
/// and functional.
272272
#[instrument(skip_all, parent = Span::current(), level = "Trace")]
273273
pub(crate) fn is_hypervisor_present() -> bool {
274-
match Mshv::open_with_cloexec(true) {
275-
Ok(fd) => {
276-
unsafe {
277-
libc::close(fd);
278-
} // must explicitly close fd to avoid a leak
279-
true
280-
}
281-
Err(e) => {
282-
log::info!("Error creating MSHV object: {:?}", e);
274+
match Mshv::new() {
275+
Ok(_) => true,
276+
Err(_) => {
277+
log::info!("MSHV is not available on this system");
283278
false
284279
}
285280
}

src/hyperlight_host/src/hypervisor/kvm.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ pub(crate) fn is_hypervisor_present() -> bool {
5959
}
6060
}
6161
} else {
62-
log::info!("Error creating KVM object");
62+
log::info!("KVM is not available on this system");
6363
false
6464
}
6565
}

src/hyperlight_host/src/hypervisor/windows_hypervisor_platform.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,10 @@ pub(crate) fn is_hypervisor_present() -> bool {
5353
)
5454
} {
5555
Ok(_) => unsafe { capability.HypervisorPresent.as_bool() },
56-
Err(_) => false,
56+
Err(_) => {
57+
log::info!("Windows Hypervisor Platform is not available on this system");
58+
false
59+
}
5760
}
5861
}
5962

src/tests/rust_guests/callbackguest/Cargo.lock

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/tests/rust_guests/simpleguest/Cargo.lock

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)