Skip to content

Commit 53d4210

Browse files
authored
preinstall, like postinstall should also check loadable (versus just loaded or builtin) (#95)
Fixes spurious `msr` failure in #86, and updates PVH/iommu failure messages to be more specific that not being able to detect during preinstall means PVH *may* not be supported. We have logic to check loaded, loadable, and builtins, but `preinstall` was incorrectly missing the load`able` check, causing the spurious failure.
1 parent 3abe432 commit 53d4210

3 files changed

Lines changed: 22 additions & 8 deletions

File tree

src/checkers/preinstall/iommu.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ impl IOMMUChecks {
7272
.await
7373
{
7474
Ok(true) => CheckResult::new(&name, Passed),
75-
Ok(false) => CheckResult::new(&name, Failed("no IOMMU detected".to_string())),
75+
Ok(false) => CheckResult::new(&name, Failed("no hardware IOMMU detected".to_string())),
7676
Err(e) => {
7777
debug!("Error: {}", e);
7878
CheckResult::new(&name, Errored(e.to_string()))

src/checkers/preinstall/kernel.rs

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,18 @@ impl KernelChecks {
4646
}
4747
}
4848

49-
/// Checks that `nf_tables` and `msr` are either built into or loaded by the running kernel.
49+
/// Checks that `nf_tables` and `msr` are built into, currently loaded by, or loadable
50+
/// (present in `modules.dep`) on the running kernel.
5051
///
5152
/// Manual equivalent:
5253
/// ```sh
53-
/// grep -E 'nf_tables|msr' /lib/modules/$(uname -r)/modules.builtin
54-
/// grep -E '^nf_tables |^msr ' /proc/modules
54+
/// KV=$(uname -r)
55+
/// for mod in nf_tables msr; do
56+
/// grep -q "$mod" /lib/modules/$KV/modules.builtin \
57+
/// || grep -q "^${mod} " /proc/modules \
58+
/// || grep -q "$mod" /lib/modules/$KV/modules.dep \
59+
/// && echo "$mod: OK" || echo "$mod: MISSING"
60+
/// done
5561
/// ```
5662
async fn has_modules(&self) -> CheckResult {
5763
let name = String::from("Host Has Necessary Modules");
@@ -74,6 +80,14 @@ impl KernelChecks {
7480
return CheckResult::new(&name, Errored(format!("getting kernel modules {e}")));
7581
}
7682
};
83+
84+
// Search loadable modules (present in modules.dep but not yet loaded)
85+
let remaining = match khelper::find_loadable(&self.host_executor, &remaining).await {
86+
Ok(r) => r,
87+
Err(e) => {
88+
return CheckResult::new(&name, Errored(format!("getting kernel modules {e}")));
89+
}
90+
};
7791
if !remaining.is_empty() {
7892
return CheckResult::new(&name, Failed(format!("missing {:?}", remaining)));
7993
}

src/checkers/preinstall/pvh.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,14 +93,14 @@ impl PVHChecks {
9393

9494
match self.discover_cpu_virtualization().await {
9595
Ok(VirtStatus::Enabled) | Ok(VirtStatus::CanBeEnabled) => {
96-
debug!("Virtualization is enabled or can be enabled");
96+
debug!("Hardware Virtualization is enabled or can be enabled");
9797
CheckResult::new(&name, Passed)
9898
}
9999
Ok(VirtStatus::Disabled) => {
100-
debug!("Virtualization disabled");
100+
debug!("Hardware Virtualization disabled");
101101
CheckResult::new(
102102
&name,
103-
Failed(String::from("PVH Not Supported, Virtualization Disabled")),
103+
Failed(String::from("Hardware Virtualization Disabled")),
104104
)
105105
}
106106
Err(e) => {
@@ -304,7 +304,7 @@ impl CheckGroup for PVHChecks {
304304
}
305305

306306
fn category(&self) -> CheckGroupCategory {
307-
CheckGroupCategory::Optional("PVH feature not available on this system".into())
307+
CheckGroupCategory::Optional("PVH feature may not be available on this system".into())
308308
}
309309
}
310310

0 commit comments

Comments
 (0)