Skip to content

Commit

Permalink
Merge pull request #428 from stlankes/nemo
Browse files Browse the repository at this point in the history
add option to configure the number of cores and the memory size of the VM
  • Loading branch information
stlankes authored Feb 23, 2025
2 parents 4aed238 + 0b66b4d commit 3d4e687
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
11 changes: 9 additions & 2 deletions src/hermit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,21 @@ pub fn get_qemu_args(
kvm_support: bool,
tap_fd: &Option<i32>,
) -> Vec<String> {
let smp: u32 = crate::CONFIG.smp.unwrap_or(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 3d4e687

Please sign in to comment.