From 7f52dd3960ad30db7ac8f0eff3aa0f691c6dff38 Mon Sep 17 00:00:00 2001 From: liuxu Date: Wed, 23 Oct 2024 16:47:26 +0800 Subject: [PATCH] vmm:qemu support aarch64 Signed-off-by: liuxu --- vmm/sandbox/src/qemu/config.rs | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/vmm/sandbox/src/qemu/config.rs b/vmm/sandbox/src/qemu/config.rs index ce2df24f..bf3c9860 100644 --- a/vmm/sandbox/src/qemu/config.rs +++ b/vmm/sandbox/src/qemu/config.rs @@ -21,7 +21,6 @@ use std::{ }; use containerd_sandbox::error::{Error, Result}; -#[cfg(target_arch = "x86_64")] use lazy_static::lazy_static; use sandbox_derive::{CmdLineParamSet, CmdLineParams}; use serde::{Deserialize, Serialize}; @@ -40,22 +39,23 @@ const DEFAULT_QEMU_PATH: &str = "/usr/bin/qemu-system-x86_64"; #[cfg(target_arch = "aarch64")] const DEFAULT_QEMU_PATH: &str = "/usr/bin/qemu-system-aarch64"; -#[cfg(target_arch = "x86_64")] lazy_static! { static ref SUPPORTED_MACHINES: HashMap = { let mut sms = HashMap::new(); + #[cfg(target_arch = "x86_64")] sms.insert( - "microvm-pci".to_string(), + "pc".to_string(), Machine { - r#type: "microvm-pci".to_string(), - options: None, + r#type: "pc".to_string(), + options: Some("accel=kvm,kernel_irqchip=on".to_string()), }, ); + #[cfg(target_arch = "aarch64")] sms.insert( - "pc".to_string(), + "virt".to_string(), Machine { - r#type: "pc".to_string(), - options: Some("accel=kvm,kernel_irqchip=on".to_string()), + r#type: "virt".to_string(), + options: Some("usb=off,accel=kvm,gic-version=3".to_string()), }, ); sms @@ -155,7 +155,6 @@ impl QemuVMConfig { } else { return Err(Error::InvalidArgument("cpu model".to_string())); } - #[cfg(target_arch = "x86_64")] if let Some(machine) = SUPPORTED_MACHINES.get(&self.machine_type) { result.machine = machine.clone(); } else { @@ -163,10 +162,6 @@ impl QemuVMConfig { "machine_type not supported!".to_string(), )); } - #[cfg(not(target_arch = "x86_64"))] - return Err(Error::Unimplemented( - "cpu other than x86 not supported".to_string(), - )); if !self.firmware_path.is_empty() { result.bios = Some(self.firmware_path.to_string()); }