Skip to content

Commit 79cdaef

Browse files
committed
TMP commit to check /dev/kvm
Signed-off-by: Ludvig Liljenberg <[email protected]>
1 parent 8ca12fc commit 79cdaef

File tree

2 files changed

+26
-14
lines changed

2 files changed

+26
-14
lines changed

.github/workflows/dep_rust.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,12 @@ jobs:
9696
- name: Verify MSRV
9797
run: ./dev/verify-msrv.sh hyperlight-host hyperlight-guest hyperlight-guest-bin hyperlight-common
9898

99+
- name: check kvm
100+
run: ls -al /dev/kvm || true
101+
102+
- name: check groups
103+
run: groups || true
104+
99105
- name: Run Rust tests
100106
env:
101107
CARGO_TERM_COLOR: always

src/hyperlight_host/src/hypervisor/kvm.rs

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -48,22 +48,28 @@ use crate::{Result, log_then_return, new_error};
4848
/// Return `true` if the KVM API is available, version 12, and has UserMemory capability, or `false` otherwise
4949
#[instrument(skip_all, parent = Span::current(), level = "Trace")]
5050
pub(crate) fn is_hypervisor_present() -> bool {
51-
if let Ok(kvm) = Kvm::new() {
52-
let api_version = kvm.get_api_version();
53-
match api_version {
54-
version if version == 12 && kvm.check_extension(UserMemory) => true,
55-
12 => {
56-
log::info!("KVM does not have KVM_CAP_USER_MEMORY capability");
57-
false
58-
}
59-
version => {
60-
log::info!("KVM GET_API_VERSION returned {}, expected 12", version);
61-
false
51+
match Kvm::new() {
52+
Ok(kvm) => {
53+
let api_version = kvm.get_api_version();
54+
match api_version {
55+
version if version == 12 && kvm.check_extension(UserMemory) => true,
56+
12 => {
57+
println!("KVM does not have KVM_CAP_USER_MEMORY capability");
58+
log::info!("KVM does not have KVM_CAP_USER_MEMORY capability");
59+
false
60+
}
61+
version => {
62+
println!("KVM GET_API_VERSION returned {}, expected 12", version);
63+
log::info!("KVM GET_API_VERSION returned {}, expected 12", version);
64+
false
65+
}
6266
}
6367
}
64-
} else {
65-
log::info!("KVM is not available on this system");
66-
false
68+
Err(e) => {
69+
log::info!("KVM is not available on this system: {:?}", e);
70+
println!("KVM is not available on this system: {:?}", e);
71+
false
72+
}
6773
}
6874
}
6975

0 commit comments

Comments
 (0)