Skip to content

Commit

Permalink
add option to configure the number of cores and the memory size of th…
Browse files Browse the repository at this point in the history
…e VM
  • Loading branch information
stlankes committed Feb 23, 2025
1 parent 4aed238 commit b38b345
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
15 changes: 13 additions & 2 deletions src/hermit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,25 @@ pub fn get_qemu_args(
kvm_support: bool,
tap_fd: &Option<i32>,
) -> Vec<String> {
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<String> = vec![
"qemu-system-x86_64",
"-display",
"none",
"-smp",
"1",
&smp.to_string(),
"-m",
"1G",
&memory_size,
"-serial",
"stdio",
"-device",
Expand Down
11 changes: 10 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<bool>,
/// defines the number of cores, which the VM should use
smp: Option<u32>,
/// define the memory size (in MiB), which the VM should use
memory_size: Option<u64>,
}

impl Config {
pub const fn new() -> Self {
Self { kvm: None }
Self {
kvm: None,
smp: None,
memory_size: None,
}
}
}

Expand Down

0 comments on commit b38b345

Please sign in to comment.