mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
tests: Add integration test for nested virtualization
Since we run integration tests on Intel & AMD this should test the
behaviour of `--cpus nested={on|off}` correctly.
Signed-off-by: Rob Bradford <rbradford@meta.com>
This commit is contained in:
@@ -2616,6 +2616,51 @@ mod common_parallel {
|
||||
handle_child_output(r, &output);
|
||||
}
|
||||
|
||||
fn _test_nested_virtualization(nested: bool) {
|
||||
let disk_config = UbuntuDiskConfig::new(JAMMY_IMAGE_NAME.to_string());
|
||||
let guest = Guest::new(Box::new(disk_config)).with_nested(nested);
|
||||
let mut child = GuestCommand::new(&guest)
|
||||
.default_cpus()
|
||||
.default_memory()
|
||||
.args(["--kernel", direct_kernel_boot_path().to_str().unwrap()])
|
||||
.args(["--cmdline", DIRECT_KERNEL_BOOT_CMDLINE])
|
||||
.default_disks()
|
||||
.default_net()
|
||||
.capture_output()
|
||||
.spawn()
|
||||
.unwrap();
|
||||
|
||||
let r = std::panic::catch_unwind(|| {
|
||||
guest.wait_vm_boot().unwrap();
|
||||
|
||||
let expected = if nested { "yes" } else { "no" };
|
||||
assert_eq!(
|
||||
guest
|
||||
.ssh_command("test -c /dev/kvm && echo yes || echo no")
|
||||
.unwrap()
|
||||
.trim(),
|
||||
expected
|
||||
);
|
||||
});
|
||||
|
||||
kill_child(&mut child);
|
||||
let output = child.wait_with_output().unwrap();
|
||||
|
||||
handle_child_output(r, &output);
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(target_arch = "x86_64")]
|
||||
fn test_nested_virtualization_on() {
|
||||
_test_nested_virtualization(true);
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(target_arch = "x86_64")]
|
||||
fn test_nested_virtualization_off() {
|
||||
_test_nested_virtualization(false);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_cpu_affinity() {
|
||||
let disk_config = UbuntuDiskConfig::new(JAMMY_IMAGE_NAME.to_string());
|
||||
|
||||
Reference in New Issue
Block a user