From 8fcee6e6ec06e9958b3ad323b3d1b67e8ceb3be9 Mon Sep 17 00:00:00 2001 From: Hyounggyu Choi Date: Wed, 31 Jan 2024 15:24:34 +0100 Subject: [PATCH] runtime-rs: Use Persist::restore() of QEMU for VirtSandbox It fails to compile virt_container because Dragonball is only used in the implementation of the trait method Persist::restore(). As the hypervisor is not compiled on s390x and QEMU implements the trait method, this commit is to let the method use QEMUi's. Signed-off-by: Hyounggyu Choi --- .../crates/runtimes/virt_container/src/sandbox.rs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/runtime-rs/crates/runtimes/virt_container/src/sandbox.rs b/src/runtime-rs/crates/runtimes/virt_container/src/sandbox.rs index 3d8926018a..6f572083a6 100644 --- a/src/runtime-rs/crates/runtimes/virt_container/src/sandbox.rs +++ b/src/runtime-rs/crates/runtimes/virt_container/src/sandbox.rs @@ -17,10 +17,11 @@ use common::message::{Action, Message}; use common::{Sandbox, SandboxNetworkEnv}; use containerd_shim_protos::events::task::TaskOOM; use hypervisor::VsockConfig; -use hypervisor::{BlockConfig, Hypervisor}; #[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; @@ -588,7 +589,14 @@ impl Persist for VirtSandbox { 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?)), + HYPERVISOR_DRAGONBALL => { + let hypervisor = Arc::new(Dragonball::restore((), h).await?) as Arc; + Ok(hypervisor) + } + HYPERVISOR_QEMU => { + let hypervisor = Arc::new(Qemu::restore((), h).await?) as Arc; + Ok(hypervisor) + } _ => Err(anyhow!("Unsupported hypervisor {}", &h.hypervisor_type)), }?; let agent = Arc::new(KataAgent::new(kata_types::config::Agent::default()));