Skip to content

Commit 010b286

Browse files
committed
Use Mshv::new() instead of Mshv::open_with_cloexec() to avoid manually needing to close fd
Signed-off-by: Ludvig Liljenberg <[email protected]>
1 parent ec248ed commit 010b286

File tree

1 file changed

+2
-7
lines changed

1 file changed

+2
-7
lines changed

src/hyperlight_host/src/hypervisor/hyperv_linux.rs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -271,13 +271,8 @@ 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-
}
274+
match Mshv::new() {
275+
Ok(_) => true,
281276
Err(_) => {
282277
log::info!("MSHV is not available on this system");
283278
false

0 commit comments

Comments
 (0)