From b38b3454a712cfaa5255f8f153798401ace0900d Mon Sep 17 00:00:00 2001 From: Stefan Lankes Date: Sun, 23 Feb 2025 13:41:13 +0000 Subject: [PATCH] add option to configure the number of cores and the memory size of the VM --- src/hermit.rs | 15 +++++++++++++-- src/main.rs | 11 ++++++++++- 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/src/hermit.rs b/src/hermit.rs index e7dc0d54..14ab77a4 100644 --- a/src/hermit.rs +++ b/src/hermit.rs @@ -30,14 +30,25 @@ pub fn get_qemu_args( kvm_support: bool, tap_fd: &Option, ) -> Vec { + let smp: u32 = if let Some(smp) = crate::CONFIG.smp { + smp + } else { + 1 + }; + let memory_size: String = if let Some(memory_size) = crate::CONFIG.memory_size { + format!("{}M", memory_size) + } else { + "1G".to_string() + }; + let mut exec_args: Vec = vec![ "qemu-system-x86_64", "-display", "none", "-smp", - "1", + &smp.to_string(), "-m", - "1G", + &memory_size, "-serial", "stdio", "-device", diff --git a/src/main.rs b/src/main.rs index ac4e9d0c..2699ee3a 100644 --- a/src/main.rs +++ b/src/main.rs @@ -46,12 +46,21 @@ use std::{env, path::Path, path::PathBuf}; /// that it doesn't have to be present in TOML. #[derive(Debug, Deserialize)] struct Config { + /// specifies if KVM support should be enabled kvm: Option, + /// defines the number of cores, which the VM should use + smp: Option, + /// define the memory size (in MiB), which the VM should use + memory_size: Option, } impl Config { pub const fn new() -> Self { - Self { kvm: None } + Self { + kvm: None, + smp: None, + memory_size: None, + } } }