Skip to content

Commit 28f19ff

Browse files
committed
Add memory option to test framework VM config
1 parent 4e98a7b commit 28f19ff

File tree

3 files changed

+18
-1
lines changed

3 files changed

+18
-1
lines changed

test/test-manager/src/config/vm.rs

+5
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,11 @@ pub struct VmConfig {
6565
#[serde(default)]
6666
#[arg(long)]
6767
pub vcpu: Option<usize>,
68+
69+
/// Amount of memory, in MBs
70+
#[serde(default)]
71+
#[arg(long)]
72+
pub memory: Option<usize>,
6873
}
6974

7075
impl VmConfig {

test/test-manager/src/vm/qemu.rs

+10-1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ const OBTAIN_IP_TIMEOUT: Duration = Duration::from_secs(180);
2828
/// Default number of VCPU cores (passed to -smp)
2929
const DEFAULT_NUM_VCPUS: usize = 2;
3030

31+
/// Default amount of memory, in MBs (passed to -m)
32+
const DEFAULT_AMOUNT_MEMORY: usize = 2048;
33+
3134
#[derive(thiserror::Error, Debug)]
3235
pub enum Error {
3336
#[error("Failed to set up network")]
@@ -86,14 +89,20 @@ pub async fn run(config: &Config, vm_config: &VmConfig) -> Result<QemuInstance>
8689
.map_err(Error::Network)?;
8790

8891
let mut qemu_cmd = Command::new("qemu-system-x86_64");
92+
8993
let vcpus = vm_config.vcpu.unwrap_or(DEFAULT_NUM_VCPUS);
94+
let memory = vm_config.memory.unwrap_or(DEFAULT_AMOUNT_MEMORY);
95+
96+
log::debug!("CPU count: {vcpus}");
97+
log::debug!("Memory: {memory}M");
98+
9099
qemu_cmd.args([
91100
"-cpu",
92101
"host",
93102
"-accel",
94103
"kvm",
95104
"-m",
96-
"4096",
105+
&memory.to_string(),
97106
"-smp",
98107
&vcpus.to_string(),
99108
"-drive",

test/test-manager/src/vm/tart.rs

+3
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,9 @@ pub async fn run(config: &Config, vm_config: &VmConfig) -> Result<TartInstance>
5959
if let Some(cpu) = vm_config.vcpu {
6060
tart_cmd.args(["--cpu", &cpu.to_string()]);
6161
}
62+
if vm_config.memory.is_some() {
63+
log::warn!("The memory option is not supported for the Tart backend")
64+
}
6265

6366
match config.runtime_opts.display {
6467
config::Display::None => {

0 commit comments

Comments
 (0)