Skip to content

Commit

Permalink
vmm:qemu support aarch64
Browse files Browse the repository at this point in the history
Signed-off-by: liuxu <[email protected]>
  • Loading branch information
liuxu committed Oct 24, 2024
1 parent f7cca8a commit 7f52dd3
Showing 1 changed file with 8 additions and 13 deletions.
21 changes: 8 additions & 13 deletions vmm/sandbox/src/qemu/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand All @@ -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<String, Machine> = {
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
Expand Down Expand Up @@ -155,18 +155,13 @@ 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 {
return Err(Error::InvalidArgument(
"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());
}
Expand Down

0 comments on commit 7f52dd3

Please sign in to comment.