kata-ctl: add check framework support for non-x86

x86 changes the check framwork. Enable them for non-x86 accordingly.

Fixes: #5923
Signed-off-by: Jianyong Wu <jianyong.wu@arm.com>
This commit is contained in:
Jianyong Wu 2022-12-17 13:06:00 +08:00
parent 1bd533f10b
commit 3480780bd8
3 changed files with 31 additions and 1 deletions

View File

@ -7,12 +7,21 @@
pub use arch_specific::*;
mod arch_specific {
use crate::types::*;
use anyhow::Result;
use std::path::Path;
const KVM_DEV: &str = "/dev/kvm";
pub fn check() -> Result<()> {
// List of check functions
static CHECK_LIST: &[CheckItem] = &[CheckItem {
name: CheckType::CheckCpu,
descr: "This parameter performs the host check",
fp: check,
perm: PermissionType::NonPrivileged,
}];
pub fn check(_args: &str) -> Result<()> {
println!("INFO: check: aarch64");
if Path::new(KVM_DEV).exists() {
println!("Kata Containers can run on this host\n");
@ -22,4 +31,8 @@ mod arch_specific {
Ok(())
}
pub fn get_checks() -> Option<&'static [CheckItem<'static>]> {
Some(CHECK_LIST)
}
}

View File

@ -3,6 +3,7 @@
// SPDX-License-Identifier: Apache-2.0
//
use crate::types::*;
#[cfg(target_arch = "powerpc64le")]
pub use arch_specific::*;
@ -12,4 +13,8 @@ mod arch_specific {
pub fn check() -> Result<()> {
unimplemented!("Check not implemented in powerpc64le");
}
pub fn get_checks() -> Option<&'static [CheckItem<'static>]> {
None
}
}

View File

@ -48,4 +48,16 @@ mod arch_specific {
Ok(())
}
// List of check functions
static CHECK_LIST: &[CheckItem] = &[CheckItem {
name: CheckType::CheckCpu,
descr: "This parameter performs the cpu check",
fp: check,
perm: PermissionType::NonPrivileged,
}];
pub fn get_checks() -> Option<&'static [CheckItem<'static>]> {
Some(CHECK_LIST)
}
}