diff --git a/cloud-hypervisor/tests/integration.rs b/cloud-hypervisor/tests/integration.rs index c836f631d..9838e1497 100644 --- a/cloud-hypervisor/tests/integration.rs +++ b/cloud-hypervisor/tests/integration.rs @@ -2545,7 +2545,7 @@ fn _test_simple_launch(guest: &Guest) { let event_path = temp_event_monitor_path(&guest.tmp_dir); let mut child = GuestCommand::new(guest) - .args(["--cpus", "boot=1"]) + .default_cpus() .args(["--memory", "size=512M"]) .default_kernel_cmdline() .default_disks() diff --git a/test_infra/src/lib.rs b/test_infra/src/lib.rs index cab400082..f45ed3e70 100644 --- a/test_infra/src/lib.rs +++ b/test_infra/src/lib.rs @@ -916,6 +916,8 @@ pub struct Guest { pub kernel_path: Option, pub kernel_cmdline: Option, pub console_type: Option, + pub num_cpu: u32, + pub nested: bool, } // Return the next id that can be used for this guest. This is stored in a @@ -985,6 +987,8 @@ impl Guest { kernel_path: None, kernel_cmdline: None, console_type: None, + num_cpu: 1u32, + nested: true, } } @@ -1373,6 +1377,14 @@ impl Guest { } out_evt } + + pub fn default_cpus_string(&self) -> String { + format!( + "boot={}{}", + self.num_cpu, + if self.nested { "" } else { ",nested=off" } + ) + } } #[derive(Default)] @@ -1555,6 +1567,10 @@ impl<'a> GuestCommand<'a> { self } + + pub fn default_cpus(&mut self) -> &mut Self { + self.args(["--cpus", self.guest.default_cpus_string().as_str()]) + } } /// Returns the absolute path into the workspaces target directory to locate the desired