From ea19bb026fda09111bbcbf7102058d04e69af5e8 Mon Sep 17 00:00:00 2001 From: Rob Bradford Date: Mon, 25 Nov 2019 15:49:41 +0000 Subject: [PATCH] tests: Add a test to check that the boot vs max cpus work The easiest way to detect if the kernel is willing to accept hotplug vCPUs is to check the dmesg output. Switch the test to bionic as the Clear Cloud image lacks "dmesg." Signed-off-by: Rob Bradford --- src/main.rs | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/main.rs b/src/main.rs index dd9ea4497..5b153b7df 100755 --- a/src/main.rs +++ b/src/main.rs @@ -1119,10 +1119,10 @@ mod tests { #[cfg_attr(not(feature = "mmio"), test)] fn test_multi_cpu() { test_block!(tb, "", { - let mut clear = ClearDiskConfig::new(); - let guest = Guest::new(&mut clear); + let mut bionic = UbuntuDiskConfig::new(BIONIC_IMAGE_NAME.to_string()); + let guest = Guest::new(&mut bionic); let mut child = Command::new("target/release/cloud-hypervisor") - .args(&["--cpus", "boot=2"]) + .args(&["--cpus", "boot=2,max=4"]) .args(&["--memory", "size=512M"]) .args(&["--kernel", guest.fw_path.as_str()]) .args(&[ @@ -1146,6 +1146,14 @@ mod tests { aver_eq!(tb, guest.get_cpu_count().unwrap_or_default(), 2); + aver_eq!( + tb, + guest + .ssh_command(r#"dmesg | grep "smpboot: Allowing" | sed "s/\[\ *[0-9.]*\] //""#) + .unwrap_or_default() + .trim(), + "smpboot: Allowing 4 CPUs, 2 hotplug CPUs" + ); guest.ssh_command("sudo shutdown -h now")?; thread::sleep(std::time::Duration::new(10, 0)); let _ = child.kill();