runtime-rs: Exclude hypervisors plugins except QEMU for s390x

Dragonball and cloud-hypervisor are not supported on s390x.
We need to exclude the plugins for these hypervisors from compilation.

Signed-off-by: Hyounggyu Choi <Hyounggyu.Choi@ibm.com>
This commit is contained in:
Hyounggyu Choi
2024-01-31 13:46:16 +01:00
parent 9c0312d466
commit 56aef3741d
4 changed files with 30 additions and 15 deletions

View File

@@ -11,7 +11,6 @@ license = "Apache-2.0"
actix-rt = "2.7.0"
anyhow = "^1.0"
async-trait = "0.1.48"
dbs-utils = { path = "../../../dragonball/src/dbs_utils" }
go-flag = "0.1.0"
libc = ">=0.2.39"
nix = "0.24.2"
@@ -35,8 +34,6 @@ kata-types = { path = "../../../libs/kata-types" }
logging = { path = "../../../libs/logging" }
shim-interface = { path = "../../../libs/shim-interface" }
dragonball = { path = "../../../dragonball", features = ["atomic-guest-memory", "virtio-vsock", "hotplug", "virtio-blk", "virtio-net", "virtio-fs", "vhost-net", "dbs-upcall", "virtio-mem", "virtio-balloon", "vhost-user-net", "host-device"] }
ch-config = { path = "ch-config", optional = true }
tests_utils = { path = "../../tests/utils" }
@@ -44,6 +41,10 @@ futures = "0.3.25"
safe-path = "0.1.0"
crossbeam-channel = "0.5.6"
[target.'cfg(not(target_arch = "s390x"))'.dependencies]
dragonball = { path = "../../../dragonball", features = ["atomic-guest-memory", "virtio-vsock", "hotplug", "virtio-blk", "virtio-net", "virtio-fs", "vhost-net", "dbs-upcall", "virtio-mem", "virtio-balloon", "vhost-user-net", "host-device"] }
dbs-utils = { path = "../../../dragonball/src/dbs_utils" }
[features]
default = []

View File

@@ -13,6 +13,7 @@ pub mod device;
pub mod hypervisor_persist;
pub use device::driver::*;
use device::DeviceType;
#[cfg(not(target_arch = "s390x"))]
pub mod dragonball;
mod kernel_param;
pub mod qemu;
@@ -20,7 +21,7 @@ pub use kernel_param::Param;
pub mod utils;
use std::collections::HashMap;
#[cfg(feature = "cloud-hypervisor")]
#[cfg(all(feature = "cloud-hypervisor", not(target_arch = "s390x")))]
pub mod ch;
use anyhow::Result;
@@ -49,9 +50,12 @@ const VM_ROOTFS_FILESYSTEM_EROFS: &str = "erofs";
// /dev/hugepages will be the mount point
// mkdir -p /dev/hugepages
// mount -t hugetlbfs none /dev/hugepages
#[cfg(not(target_arch = "s390x"))]
const DEV_HUGEPAGES: &str = "/dev/hugepages";
pub const HUGETLBFS: &str = "hugetlbfs";
#[cfg(not(target_arch = "s390x"))]
const SHMEM: &str = "shmem";
#[cfg(not(target_arch = "s390x"))]
const HUGE_SHMEM: &str = "hugeshmem";
pub const HYPERVISOR_DRAGONBALL: &str = "dragonball";
@@ -60,6 +64,7 @@ pub const HYPERVISOR_QEMU: &str = "qemu";
pub const DEFAULT_HYBRID_VSOCK_NAME: &str = "kata.hvsock";
pub const JAILER_ROOT: &str = "root";
#[cfg(not(target_arch = "s390x"))]
#[derive(PartialEq, Debug, Clone)]
pub(crate) enum VmmState {
NotReady,

View File

@@ -20,15 +20,17 @@ use agent::{kata::KataAgent, AGENT_KATA};
use anyhow::{anyhow, Context, Result};
use async_trait::async_trait;
use common::{message::Message, RuntimeHandler, RuntimeInstance};
use hypervisor::{dragonball::Dragonball, Hypervisor, HYPERVISOR_DRAGONBALL};
use hypervisor::Hypervisor;
#[cfg(not(target_arch = "s390x"))]
use hypervisor::{dragonball::Dragonball, HYPERVISOR_DRAGONBALL};
use hypervisor::{qemu::Qemu, HYPERVISOR_QEMU};
use kata_types::config::{
hypervisor::register_hypervisor_plugin, DragonballConfig, QemuConfig, TomlConfig,
};
#[cfg(not(target_arch = "s390x"))]
use kata_types::config::DragonballConfig;
use kata_types::config::{hypervisor::register_hypervisor_plugin, QemuConfig, TomlConfig};
#[cfg(feature = "cloud-hypervisor")]
#[cfg(all(feature = "cloud-hypervisor", not(target_arch = "s390x")))]
use hypervisor::ch::CloudHypervisor;
#[cfg(feature = "cloud-hypervisor")]
#[cfg(all(feature = "cloud-hypervisor", not(target_arch = "s390x")))]
use kata_types::config::{hypervisor::HYPERVISOR_NAME_CH, CloudHypervisorConfig};
use resource::cpu_mem::initial_size::InitialSizeManager;
@@ -49,13 +51,16 @@ impl RuntimeHandler for VirtContainer {
logging::register_subsystem_logger("runtimes", "virt-container");
// register
let dragonball_config = Arc::new(DragonballConfig::new());
register_hypervisor_plugin("dragonball", dragonball_config);
#[cfg(not(target_arch = "s390x"))]
{
let dragonball_config = Arc::new(DragonballConfig::new());
register_hypervisor_plugin("dragonball", dragonball_config);
}
let qemu_config = Arc::new(QemuConfig::new());
register_hypervisor_plugin("qemu", qemu_config);
#[cfg(feature = "cloud-hypervisor")]
#[cfg(all(feature = "cloud-hypervisor", not(target_arch = "s390x")))]
{
let ch_config = Arc::new(CloudHypervisorConfig::new());
register_hypervisor_plugin(HYPERVISOR_NAME_CH, ch_config);
@@ -135,6 +140,7 @@ async fn new_hypervisor(toml_config: &TomlConfig) -> Result<Arc<dyn Hypervisor>>
// TODO: support other hypervisor
// issue: https://github.com/kata-containers/kata-containers/issues/4634
match hypervisor_name.as_str() {
#[cfg(not(target_arch = "s390x"))]
HYPERVISOR_DRAGONBALL => {
let mut hypervisor = Dragonball::new();
hypervisor
@@ -150,7 +156,7 @@ async fn new_hypervisor(toml_config: &TomlConfig) -> Result<Arc<dyn Hypervisor>>
Ok(Arc::new(hypervisor))
}
#[cfg(feature = "cloud-hypervisor")]
#[cfg(all(feature = "cloud-hypervisor", not(target_arch = "s390x")))]
HYPERVISOR_NAME_CH => {
let mut hypervisor = CloudHypervisor::new();

View File

@@ -17,7 +17,9 @@ use common::message::{Action, Message};
use common::{Sandbox, SandboxNetworkEnv};
use containerd_shim_protos::events::task::TaskOOM;
use hypervisor::VsockConfig;
use hypervisor::{dragonball::Dragonball, BlockConfig, Hypervisor, HYPERVISOR_DRAGONBALL};
use hypervisor::{BlockConfig, Hypervisor};
#[cfg(not(target_arch = "s390x"))]
use hypervisor::{dragonball::Dragonball, HYPERVISOR_DRAGONBALL};
use hypervisor::{utils::get_hvsock_path, HybridVsockConfig, DEFAULT_GUEST_VSOCK_CID};
use kata_sys_util::hooks::HookStates;
use kata_types::capabilities::CapabilityBits;
@@ -585,6 +587,7 @@ impl Persist for VirtSandbox {
let h = sandbox_state.hypervisor.unwrap_or_default();
let hypervisor = match h.hypervisor_type.as_str() {
// TODO support other hypervisors
#[cfg(not(target_arch = "s390x"))]
HYPERVISOR_DRAGONBALL => Ok(Arc::new(Dragonball::restore((), h).await?)),
_ => Err(anyhow!("Unsupported hypervisor {}", &h.hypervisor_type)),
}?;