Skip to content

Commit

Permalink
Merge pull request #8454 from BbolroC/compile-with-qemu-s390x
Browse files Browse the repository at this point in the history
runtime-rs: make compilation for QEMU on s390x
  • Loading branch information
gkurz committed Feb 2, 2024
2 parents 0520b27 + bb6f507 commit d1a26ea
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 22 deletions.
8 changes: 2 additions & 6 deletions src/runtime-rs/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,11 @@ ARCH_FILE_SUFFIX = -options.mk
ARCH_FILE = $(ARCH_DIR)/$(ARCH)$(ARCH_FILE_SUFFIX)

ifeq ($(ARCH), s390x)
default:
@echo "s390x is not currently supported"
exit 0
default: runtime show-header
test:
@echo "s390x is not currently supported"
exit 0
install:
@echo "s390x is not currently supported"
exit 0
install: install-runtime install-configs
else ifeq ($(ARCH), powerpc64le)
default:
@echo "PowerPC 64 LE is not currently supported"
Expand Down
7 changes: 4 additions & 3 deletions src/runtime-rs/crates/hypervisor/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -35,15 +34,17 @@ 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" }

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 = []

Expand Down
7 changes: 6 additions & 1 deletion src/runtime-rs/crates/hypervisor/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,15 @@ 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;
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;
Expand Down Expand Up @@ -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";
Expand All @@ -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,
Expand Down
26 changes: 16 additions & 10 deletions src/runtime-rs/crates/runtimes/virt_container/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
Expand Down Expand Up @@ -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
Expand All @@ -155,7 +161,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();

Expand Down
15 changes: 13 additions & 2 deletions src/runtime-rs/crates/runtimes/virt_container/src/sandbox.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,11 @@ 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};
#[cfg(not(target_arch = "s390x"))]
use hypervisor::{dragonball::Dragonball, HYPERVISOR_DRAGONBALL};
use hypervisor::{qemu::Qemu, HYPERVISOR_QEMU};
use hypervisor::{utils::get_hvsock_path, HybridVsockConfig, DEFAULT_GUEST_VSOCK_CID};
use hypervisor::{BlockConfig, Hypervisor};
use kata_sys_util::hooks::HookStates;
use kata_types::capabilities::CapabilityBits;
use kata_types::config::TomlConfig;
Expand Down Expand Up @@ -585,7 +588,15 @@ impl Persist for VirtSandbox {
let h = sandbox_state.hypervisor.unwrap_or_default();
let hypervisor = match h.hypervisor_type.as_str() {
// TODO support other hypervisors
HYPERVISOR_DRAGONBALL => Ok(Arc::new(Dragonball::restore((), h).await?)),
#[cfg(not(target_arch = "s390x"))]
HYPERVISOR_DRAGONBALL => {
let hypervisor = Arc::new(Dragonball::restore((), h).await?) as Arc<dyn Hypervisor>;
Ok(hypervisor)
}
HYPERVISOR_QEMU => {
let hypervisor = Arc::new(Qemu::restore((), h).await?) as Arc<dyn Hypervisor>;
Ok(hypervisor)
}
_ => Err(anyhow!("Unsupported hypervisor {}", &h.hypervisor_type)),
}?;
let agent = Arc::new(KataAgent::new(kata_types::config::Agent::default()));
Expand Down

0 comments on commit d1a26ea

Please sign in to comment.