diff --git a/cloud-hypervisor/tests/integration.rs b/cloud-hypervisor/tests/integration.rs index 59db256f1..5093d0537 100644 --- a/cloud-hypervisor/tests/integration.rs +++ b/cloud-hypervisor/tests/integration.rs @@ -234,7 +234,7 @@ fn _test_api_shutdown(target_api: &TargetApi, guest: &Guest) { // Then boot it assert!(target_api.remote_command("boot", None)); - guest.wait_vm_boot(None).unwrap(); + guest.wait_vm_boot().unwrap(); // Check that the VM booted as expected assert_eq!(guest.get_cpu_count().unwrap_or_default() as u8, cpu_count); @@ -254,7 +254,7 @@ fn _test_api_shutdown(target_api: &TargetApi, guest: &Guest) { // Then boot it again assert!(target_api.remote_command("boot", None)); - guest.wait_vm_boot(None).unwrap(); + guest.wait_vm_boot().unwrap(); // Check that the VM booted as expected assert_eq!(guest.get_cpu_count().unwrap_or_default() as u8, cpu_count); @@ -299,7 +299,7 @@ fn _test_api_delete(target_api: &TargetApi, guest: &Guest) { // Then boot it assert!(target_api.remote_command("boot", None)); - guest.wait_vm_boot(None).unwrap(); + guest.wait_vm_boot().unwrap(); // Check that the VM booted as expected assert_eq!(guest.get_cpu_count().unwrap_or_default() as u8, cpu_count); @@ -321,7 +321,7 @@ fn _test_api_delete(target_api: &TargetApi, guest: &Guest) { // Then boot it again assert!(target_api.remote_command("boot", None)); - guest.wait_vm_boot(None).unwrap(); + guest.wait_vm_boot().unwrap(); // Check that the VM booted as expected assert_eq!(guest.get_cpu_count().unwrap_or_default() as u8, cpu_count); @@ -793,7 +793,7 @@ fn setup_ovs_dpdk_guests( let guest_net_iface = "enp0s5"; let r = std::panic::catch_unwind(|| { - guest1.wait_vm_boot(None).unwrap(); + guest1.wait_vm_boot().unwrap(); guest1 .ssh_command(&format!( @@ -838,7 +838,7 @@ fn setup_ovs_dpdk_guests( .unwrap(); let r = std::panic::catch_unwind(|| { - guest2.wait_vm_boot(None).unwrap(); + guest2.wait_vm_boot().unwrap(); guest2 .ssh_command(&format!( @@ -1026,7 +1026,7 @@ fn test_cpu_topology(threads_per_core: u8, cores_per_package: u8, packages: u8, .unwrap(); let r = std::panic::catch_unwind(|| { - guest.wait_vm_boot(None).unwrap(); + guest.wait_vm_boot().unwrap(); assert_eq!( guest.get_cpu_count().unwrap_or_default(), u32::from(total_vcpus) @@ -1141,7 +1141,7 @@ fn _test_guest_numa_nodes(acpi: bool) { .unwrap(); let r = std::panic::catch_unwind(|| { - guest.wait_vm_boot(None).unwrap(); + guest.wait_vm_boot().unwrap(); guest.check_numa_common( Some(&[960_000, 1_920_000, 2_880_000]), @@ -1207,7 +1207,7 @@ fn _test_power_button(acpi: bool) { let child = cmd.spawn().unwrap(); let r = std::panic::catch_unwind(|| { - guest.wait_vm_boot(None).unwrap(); + guest.wait_vm_boot().unwrap(); assert!(remote_command(&api_socket, "power-button", None)); }); @@ -1314,7 +1314,7 @@ fn test_vhost_user_net( } let r = std::panic::catch_unwind(|| { - guest.wait_vm_boot(None).unwrap(); + guest.wait_vm_boot().unwrap(); if let Some(tap_name) = tap { let tap_count = exec_host_command_output(&format!("ip link | grep -c {tap_name}")); @@ -1458,7 +1458,7 @@ fn test_vhost_user_blk( .unwrap(); let r = std::panic::catch_unwind(|| { - guest.wait_vm_boot(None).unwrap(); + guest.wait_vm_boot().unwrap(); // Check both if /dev/vdc exists and if the block size is 16M. assert_eq!( @@ -1600,7 +1600,7 @@ fn test_boot_from_vhost_user_blk( .unwrap(); let r = std::panic::catch_unwind(|| { - guest.wait_vm_boot(None).unwrap(); + guest.wait_vm_boot().unwrap(); // Just check the VM booted correctly. assert_eq!(guest.get_cpu_count().unwrap_or_default(), num_queues as u32); @@ -1686,7 +1686,7 @@ fn _test_virtio_fs( let mut child = guest_command.capture_output().spawn().unwrap(); let r = std::panic::catch_unwind(|| { - guest.wait_vm_boot(None).unwrap(); + guest.wait_vm_boot().unwrap(); if hotplug { // Add fs to the VM @@ -1860,7 +1860,7 @@ fn test_virtio_pmem(discard_writes: bool, specify_size: bool) { .unwrap(); let r = std::panic::catch_unwind(|| { - guest.wait_vm_boot(None).unwrap(); + guest.wait_vm_boot().unwrap(); // Check for the presence of /dev/pmem0 assert_eq!( @@ -1877,7 +1877,7 @@ fn test_virtio_pmem(discard_writes: bool, specify_size: bool) { assert_eq!(guest.ssh_command("sudo umount /mnt").unwrap(), ""); assert_eq!(guest.ssh_command("ls /mnt").unwrap(), ""); - guest.reboot_linux(0, None); + guest.reboot_linux(0); assert_eq!(guest.ssh_command("sudo mount /dev/pmem0 /mnt").unwrap(), ""); assert_eq!( guest @@ -1930,7 +1930,7 @@ fn _test_virtio_vsock(hotplug: bool) { let mut child = cmd.capture_output().spawn().unwrap(); let r = std::panic::catch_unwind(|| { - guest.wait_vm_boot(None).unwrap(); + guest.wait_vm_boot().unwrap(); if hotplug { let (cmd_success, cmd_output) = remote_command_w_output( @@ -1954,7 +1954,7 @@ fn _test_virtio_vsock(hotplug: bool) { // Validate vsock works as expected. guest.check_vsock(socket.as_str()); - guest.reboot_linux(0, None); + guest.reboot_linux(0); // Validate vsock still works after a reboot. guest.check_vsock(socket.as_str()); @@ -2002,7 +2002,7 @@ fn test_memory_mergeable(mergeable: bool) { .unwrap(); let r = std::panic::catch_unwind(|| { - guest1.wait_vm_boot(None).unwrap(); + guest1.wait_vm_boot().unwrap(); }); if r.is_err() { kill_child(&mut child1); @@ -2028,7 +2028,7 @@ fn test_memory_mergeable(mergeable: bool) { .unwrap(); let r = std::panic::catch_unwind(|| { - guest2.wait_vm_boot(None).unwrap(); + guest2.wait_vm_boot().unwrap(); let ksm_ps_guest2 = get_ksm_pages_shared(); if mergeable { @@ -2302,7 +2302,7 @@ fn _test_virtio_iommu(acpi: bool) { .unwrap(); let r = std::panic::catch_unwind(|| { - guest.wait_vm_boot(None).unwrap(); + guest.wait_vm_boot().unwrap(); // Verify the virtio-iommu device is present. assert!( @@ -2555,7 +2555,7 @@ fn _test_simple_launch(guest: &Guest) { .unwrap(); let r = std::panic::catch_unwind(|| { - guest.wait_vm_boot(None).unwrap(); + guest.wait_vm_boot().unwrap(); assert_eq!(guest.get_cpu_count().unwrap_or_default(), 1); assert!(guest.get_total_memory().unwrap_or_default() > 480_000); @@ -2665,7 +2665,7 @@ mod common_parallel { let mut child = cmd.spawn().unwrap(); let r = std::panic::catch_unwind(|| { - guest.wait_vm_boot(Some(120)).unwrap(); + guest.wait_vm_boot().unwrap(); assert_eq!(guest.get_cpu_count().unwrap_or_default(), 2); @@ -2720,7 +2720,7 @@ mod common_parallel { .unwrap(); let r = std::panic::catch_unwind(|| { - guest.wait_vm_boot(None).unwrap(); + guest.wait_vm_boot().unwrap(); assert!( guest @@ -2766,7 +2766,7 @@ mod common_parallel { .unwrap(); let r = std::panic::catch_unwind(|| { - guest.wait_vm_boot(None).unwrap(); + guest.wait_vm_boot().unwrap(); let pid = child.id(); let taskset_vcpu0 = exec_host_command_output(format!("taskset -pc $(ps -T -p {pid} | grep vcpu0 | xargs | cut -f 2 -d \" \") | cut -f 6 -d \" \"").as_str()); assert_eq!(String::from_utf8_lossy(&taskset_vcpu0.stdout).trim(), "0,2"); @@ -2819,7 +2819,7 @@ mod common_parallel { .unwrap(); let r = std::panic::catch_unwind(|| { - guest.wait_vm_boot(None).unwrap(); + guest.wait_vm_boot().unwrap(); let pid = child.id(); let taskset_q0 = exec_host_command_output(format!("taskset -pc $(ps -T -p {pid} | grep disk1_q0 | xargs | cut -f 2 -d \" \") | cut -f 6 -d \" \"").as_str()); assert_eq!(String::from_utf8_lossy(&taskset_q0.stdout).trim(), "0,2"); @@ -2854,7 +2854,7 @@ mod common_parallel { let mut child = cmd.spawn().unwrap(); - guest.wait_vm_boot(None).unwrap(); + guest.wait_vm_boot().unwrap(); let r = std::panic::catch_unwind(|| { assert_eq!(guest.get_cpu_count().unwrap_or_default(), 48); @@ -2891,7 +2891,7 @@ mod common_parallel { let mut child = cmd.spawn().unwrap(); - guest.wait_vm_boot(Some(120)).unwrap(); + guest.wait_vm_boot().unwrap(); let r = std::panic::catch_unwind(|| { assert!(guest.get_total_memory().unwrap_or_default() > 128_000_000); @@ -2936,7 +2936,7 @@ mod common_parallel { .unwrap(); let r = std::panic::catch_unwind(|| { - guest.wait_vm_boot(None).unwrap(); + guest.wait_vm_boot().unwrap(); assert!(guest.get_total_memory().unwrap_or_default() > 2_880_000); @@ -2955,7 +2955,7 @@ mod common_parallel { thread::sleep(std::time::Duration::new(5, 0)); assert!(guest.get_total_memory().unwrap_or_default() > 4_800_000); - guest.reboot_linux(0, None); + guest.reboot_linux(0); // Check the amount of RAM after reboot assert!(guest.get_total_memory().unwrap_or_default() > 4_800_000); @@ -3021,7 +3021,7 @@ mod common_parallel { let mut child = cmd.spawn().unwrap(); - guest.wait_vm_boot(None).unwrap(); + guest.wait_vm_boot().unwrap(); let r = std::panic::catch_unwind(|| { let (cmd_success, cmd_output) = remote_command_w_output( @@ -3077,7 +3077,7 @@ mod common_parallel { let mut child = cmd.spawn().unwrap(); - guest.wait_vm_boot(None).unwrap(); + guest.wait_vm_boot().unwrap(); let grep_cmd = format!("grep -c {} /proc/interrupts", get_msi_interrupt_pattern()); @@ -3114,7 +3114,7 @@ mod common_parallel { let mut child = cmd.spawn().unwrap(); - guest.wait_vm_boot(None).unwrap(); + guest.wait_vm_boot().unwrap(); #[cfg(target_arch = "aarch64")] let iface = "enp0s4"; @@ -3193,7 +3193,7 @@ mod common_parallel { let mut child = cmd.spawn().unwrap(); - guest.wait_vm_boot(None).unwrap(); + guest.wait_vm_boot().unwrap(); let grep_cmd = "lspci | grep \"Host bridge\" | wc -l"; @@ -3310,7 +3310,7 @@ mod common_parallel { let cmd = "cat /sys/block/vdc/device/../numa_node"; let r = std::panic::catch_unwind(|| { - guest.wait_vm_boot(None).unwrap(); + guest.wait_vm_boot().unwrap(); assert_eq!( guest @@ -3348,7 +3348,7 @@ mod common_parallel { .unwrap(); let r = std::panic::catch_unwind(|| { - guest.wait_vm_boot(None).unwrap(); + guest.wait_vm_boot().unwrap(); assert_eq!(guest.get_cpu_count().unwrap_or_default(), 1); assert!(guest.get_total_memory().unwrap_or_default() > 480_000); @@ -3394,7 +3394,7 @@ mod common_parallel { .unwrap(); let r = std::panic::catch_unwind(|| { - guest.wait_vm_boot(None).unwrap(); + guest.wait_vm_boot().unwrap(); assert_eq!(guest.get_cpu_count().unwrap_or_default(), 1); assert!(guest.get_total_memory().unwrap_or_default() > 480_000); @@ -3471,7 +3471,7 @@ mod common_parallel { .unwrap(); let r = std::panic::catch_unwind(|| { - guest.wait_vm_boot(None).unwrap(); + guest.wait_vm_boot().unwrap(); // Check both if /dev/vdc exists and if the block size is 16M. assert_eq!( @@ -3881,7 +3881,7 @@ mod common_parallel { .unwrap(); let r = std::panic::catch_unwind(|| { - guest.wait_vm_boot(None).unwrap(); + guest.wait_vm_boot().unwrap(); test_fn(&guest); }); @@ -4254,7 +4254,7 @@ mod common_parallel { .unwrap(); let r = std::panic::catch_unwind(|| { - guest.wait_vm_boot(None).unwrap(); + guest.wait_vm_boot().unwrap(); assert_eq!( check_dirty_flag(&test_image_path).expect("Failed to check dirty flag"), @@ -4317,7 +4317,7 @@ mod common_parallel { .unwrap(); let r = std::panic::catch_unwind(|| { - guest.wait_vm_boot(None).unwrap(); + guest.wait_vm_boot().unwrap(); assert_eq!( check_dirty_flag(&test_image_path).expect("Failed to check dirty flag"), @@ -4569,7 +4569,7 @@ mod common_parallel { .unwrap(); let r = std::panic::catch_unwind(|| { - guest.wait_vm_boot(None).unwrap(); + guest.wait_vm_boot().unwrap(); // Check both if /dev/vdc exists and if the block size is 100 MiB. assert_eq!( @@ -4644,7 +4644,7 @@ mod common_parallel { .unwrap(); let r = std::panic::catch_unwind(|| { - guest.wait_vm_boot(Some(120)).unwrap(); + guest.wait_vm_boot().unwrap(); }); kill_child(&mut child); @@ -4747,7 +4747,7 @@ mod common_parallel { .unwrap(); let r = std::panic::catch_unwind(|| { - guest.wait_vm_boot(None).unwrap(); + guest.wait_vm_boot().unwrap(); assert_eq!( guest @@ -4794,7 +4794,7 @@ mod common_parallel { .unwrap(); let r = std::panic::catch_unwind(|| { - guest.wait_vm_boot(None).unwrap(); + guest.wait_vm_boot().unwrap(); assert_eq!( guest @@ -4830,7 +4830,7 @@ mod common_parallel { .unwrap(); let r = std::panic::catch_unwind(|| { - guest.wait_vm_boot(None).unwrap(); + guest.wait_vm_boot().unwrap(); assert_eq!( guest @@ -4871,7 +4871,7 @@ mod common_parallel { .unwrap(); let r = std::panic::catch_unwind(|| { - guest.wait_vm_boot(None).unwrap(); + guest.wait_vm_boot().unwrap(); assert_eq!( guest @@ -4976,7 +4976,7 @@ mod common_parallel { .unwrap(); let r = std::panic::catch_unwind(|| { - guest.wait_vm_boot(None).unwrap(); + guest.wait_vm_boot().unwrap(); // Simple checks to validate the VM booted properly assert_eq!(guest.get_cpu_count().unwrap_or_default(), 1); @@ -5013,7 +5013,7 @@ mod common_parallel { .unwrap(); let r = std::panic::catch_unwind(|| { - guest.wait_vm_boot(None).unwrap(); + guest.wait_vm_boot().unwrap(); let tap_count = exec_host_command_output("ip link | grep -c mytap1"); assert_eq!(String::from_utf8_lossy(&tap_count.stdout).trim(), "1"); @@ -5053,7 +5053,7 @@ mod common_parallel { .unwrap(); let r = std::panic::catch_unwind(|| { - guest.wait_vm_boot(None).unwrap(); + guest.wait_vm_boot().unwrap(); // Test that PMU exists. assert_eq!( @@ -5090,7 +5090,7 @@ mod common_parallel { .unwrap(); let r = std::panic::catch_unwind(|| { - guest.wait_vm_boot(None).unwrap(); + guest.wait_vm_boot().unwrap(); // Test that there is no ttyS0 assert_eq!( @@ -5138,7 +5138,7 @@ mod common_parallel { let mut child = cmd.spawn().unwrap(); let r = std::panic::catch_unwind(|| { - guest.wait_vm_boot(None).unwrap(); + guest.wait_vm_boot().unwrap(); // Test that there is a ttyS0 assert_eq!( @@ -5194,7 +5194,7 @@ mod common_parallel { .unwrap(); let r = std::panic::catch_unwind(|| { - guest.wait_vm_boot(None).unwrap(); + guest.wait_vm_boot().unwrap(); // Test that there is a ttyS0 assert_eq!( @@ -5254,7 +5254,7 @@ mod common_parallel { .unwrap(); let r = std::panic::catch_unwind(|| { - guest.wait_vm_boot(None).unwrap(); + guest.wait_vm_boot().unwrap(); // Test that there is a ttyS0 assert_eq!( @@ -5316,7 +5316,7 @@ mod common_parallel { .unwrap(); let r = std::panic::catch_unwind(|| { - guest.wait_vm_boot(None).unwrap(); + guest.wait_vm_boot().unwrap(); // Get pty fd for console let console_path = get_pty_path(&api_socket, "console"); _test_pty_interaction(console_path); @@ -5365,7 +5365,7 @@ mod common_parallel { .unwrap(); let _ = std::panic::catch_unwind(|| { - guest.wait_vm_boot(None).unwrap(); + guest.wait_vm_boot().unwrap(); }); let mut socat_command = Command::new("socat"); @@ -5430,7 +5430,7 @@ mod common_parallel { let cmd = format!("echo {text} | sudo tee /dev/hvc0"); let r = std::panic::catch_unwind(|| { - guest.wait_vm_boot(None).unwrap(); + guest.wait_vm_boot().unwrap(); assert!( guest @@ -5473,7 +5473,7 @@ mod common_parallel { .spawn() .unwrap(); - guest.wait_vm_boot(None).unwrap(); + guest.wait_vm_boot().unwrap(); guest.ssh_command("sudo shutdown -h now").unwrap(); @@ -5770,7 +5770,7 @@ mod common_parallel { .unwrap(); let r = std::panic::catch_unwind(|| { - guest.wait_vm_boot(None).unwrap(); + guest.wait_vm_boot().unwrap(); assert_eq!(guest.get_cpu_count().unwrap_or_default(), 1); assert!(guest.get_total_memory().unwrap_or_default() > 480_000); @@ -5868,7 +5868,7 @@ mod common_parallel { .unwrap(); let r = std::panic::catch_unwind(|| { - guest.wait_vm_boot(None).unwrap(); + guest.wait_vm_boot().unwrap(); // 2 network interfaces + default localhost ==> 3 interfaces assert_eq!( @@ -5973,7 +5973,7 @@ mod common_parallel { .unwrap(); let r = std::panic::catch_unwind(|| { - guest.wait_vm_boot(None).unwrap(); + guest.wait_vm_boot().unwrap(); assert_eq!(guest.get_cpu_count().unwrap_or_default(), 2); @@ -5993,7 +5993,7 @@ mod common_parallel { u32::from(desired_vcpus) ); - guest.reboot_linux(0, None); + guest.reboot_linux(0); assert_eq!( guest.get_cpu_count().unwrap_or_default(), @@ -6062,7 +6062,7 @@ mod common_parallel { .unwrap(); let r = std::panic::catch_unwind(|| { - guest.wait_vm_boot(None).unwrap(); + guest.wait_vm_boot().unwrap(); assert!(guest.get_total_memory().unwrap_or_default() > 480_000); @@ -6083,7 +6083,7 @@ mod common_parallel { assert!(guest.get_total_memory().unwrap_or_default() > 480_000); assert!(guest.get_total_memory().unwrap_or_default() < 960_000); - guest.reboot_linux(0, None); + guest.reboot_linux(0); assert!(guest.get_total_memory().unwrap_or_default() < 960_000); @@ -6108,7 +6108,7 @@ mod common_parallel { let desired_ram = 1024 << 20; resize_command(&api_socket, None, Some(desired_ram), None, None); - guest.reboot_linux(1, None); + guest.reboot_linux(1); assert!(guest.get_total_memory().unwrap_or_default() > 960_000); assert!(guest.get_total_memory().unwrap_or_default() < 1_920_000); @@ -6145,7 +6145,7 @@ mod common_parallel { .unwrap(); let r = std::panic::catch_unwind(|| { - guest.wait_vm_boot(None).unwrap(); + guest.wait_vm_boot().unwrap(); assert!(guest.get_total_memory().unwrap_or_default() > 480_000); @@ -6173,7 +6173,7 @@ mod common_parallel { assert!(guest.get_total_memory().unwrap_or_default() > 960_000); assert!(guest.get_total_memory().unwrap_or_default() < 1_920_000); - guest.reboot_linux(0, None); + guest.reboot_linux(0); // Check the amount of memory after reboot is 1GiB assert!(guest.get_total_memory().unwrap_or_default() > 960_000); @@ -6216,7 +6216,7 @@ mod common_parallel { .unwrap(); let r = std::panic::catch_unwind(|| { - guest.wait_vm_boot(None).unwrap(); + guest.wait_vm_boot().unwrap(); assert_eq!(guest.get_cpu_count().unwrap_or_default(), 2); assert!(guest.get_total_memory().unwrap_or_default() > 480_000); @@ -6275,7 +6275,7 @@ mod common_parallel { .spawn() .unwrap(); - guest.wait_vm_boot(None).unwrap(); + guest.wait_vm_boot().unwrap(); let r = std::panic::catch_unwind(|| { let overhead = get_vmm_overhead(child.id(), guest_memory_size_kb); @@ -6319,7 +6319,7 @@ mod common_parallel { .unwrap(); let r = std::panic::catch_unwind(|| { - guest.wait_vm_boot(None).unwrap(); + guest.wait_vm_boot().unwrap(); // Check /dev/vdc is not there assert_eq!( @@ -6392,7 +6392,7 @@ mod common_parallel { let mut child = cmd.spawn().unwrap(); let r = std::panic::catch_unwind(|| { - guest.wait_vm_boot(None).unwrap(); + guest.wait_vm_boot().unwrap(); // Check /dev/vdc is not there assert_eq!( @@ -6490,7 +6490,7 @@ mod common_parallel { .unwrap(); // Reboot the VM. - guest.reboot_linux(0, None); + guest.reboot_linux(0); // Check still there after reboot assert_eq!( @@ -6518,7 +6518,7 @@ mod common_parallel { 0 ); - guest.reboot_linux(1, None); + guest.reboot_linux(1); // Check device still absent assert_eq!( @@ -6584,7 +6584,7 @@ mod common_parallel { let mut child = cmd.spawn().unwrap(); let r = std::panic::catch_unwind(|| { - guest.wait_vm_boot(None).unwrap(); + guest.wait_vm_boot().unwrap(); // Add the disk to the VM let (cmd_success, cmd_output) = remote_command_w_output( @@ -6834,7 +6834,7 @@ mod common_parallel { .unwrap(); let r = std::panic::catch_unwind(|| { - guest.wait_vm_boot(None).unwrap(); + guest.wait_vm_boot().unwrap(); // MIN-IO column assert_eq!( @@ -6903,7 +6903,7 @@ mod common_parallel { .unwrap(); let r = std::panic::catch_unwind(|| { - guest.wait_vm_boot(None).unwrap(); + guest.wait_vm_boot().unwrap(); // Wait for balloon memory's initialization and check its size. // The virtio-balloon driver might take a few seconds to report the @@ -6958,7 +6958,7 @@ mod common_parallel { let pid = child.id(); let r = std::panic::catch_unwind(|| { - guest.wait_vm_boot(None).unwrap(); + guest.wait_vm_boot().unwrap(); // Check the initial RSS is less than 1GiB let rss = process_rss_kib(pid); @@ -7047,7 +7047,7 @@ mod common_parallel { let mut child = cmd.spawn().unwrap(); let r = std::panic::catch_unwind(|| { - guest.wait_vm_boot(None).unwrap(); + guest.wait_vm_boot().unwrap(); // Check /dev/pmem0 is not there assert_eq!( @@ -7098,7 +7098,7 @@ mod common_parallel { 1 ); - guest.reboot_linux(0, None); + guest.reboot_linux(0); // Check still there after reboot assert_eq!( @@ -7126,7 +7126,7 @@ mod common_parallel { 0 ); - guest.reboot_linux(1, None); + guest.reboot_linux(1); // Check still absent after reboot assert_eq!( @@ -7188,7 +7188,7 @@ mod common_parallel { let mut child = cmd.spawn().unwrap(); - guest.wait_vm_boot(None).unwrap(); + guest.wait_vm_boot().unwrap(); let r = std::panic::catch_unwind(|| { // Add network @@ -7298,7 +7298,7 @@ mod common_parallel { 3 ); - guest.reboot_linux(0, None); + guest.reboot_linux(0); // 2 network interfaces + default localhost ==> 3 interfaces assert_eq!( @@ -7401,7 +7401,7 @@ mod common_parallel { let mut child = cmd.spawn().unwrap(); let r = std::panic::catch_unwind(|| { - guest.wait_vm_boot(None).unwrap(); + guest.wait_vm_boot().unwrap(); let orig_counters = get_counters(&api_socket); guest @@ -7440,7 +7440,7 @@ mod common_parallel { let vmcore_file = temp_vmcore_file_path(&guest.tmp_dir); let r = std::panic::catch_unwind(|| { - guest.wait_vm_boot(None).unwrap(); + guest.wait_vm_boot().unwrap(); assert!(remote_command(&api_socket, "pause", None)); @@ -7488,7 +7488,7 @@ mod common_parallel { let vmcore_file = temp_vmcore_file_path(&guest.tmp_dir); let r = std::panic::catch_unwind(|| { - guest.wait_vm_boot(None).unwrap(); + guest.wait_vm_boot().unwrap(); assert!(remote_command( &api_socket, @@ -7529,7 +7529,7 @@ mod common_parallel { let mut child = cmd.spawn().unwrap(); let r = std::panic::catch_unwind(|| { - guest.wait_vm_boot(None).unwrap(); + guest.wait_vm_boot().unwrap(); let mut expected_reboot_count = 1; @@ -7555,7 +7555,7 @@ mod common_parallel { // Trigger a panic (sync first). We need to do this inside a screen with a delay so the SSH command returns. guest.ssh_command("screen -dmS reboot sh -c \"sleep 5; echo s | tee /proc/sysrq-trigger; echo c | sudo tee /proc/sysrq-trigger\"").unwrap(); // Allow some time for the watchdog to trigger (max 30s) and reboot to happen - guest.wait_vm_boot(Some(50)).unwrap(); + guest.wait_vm_boot_custom_timeout(50).unwrap(); // Check a reboot is triggered by the watchdog expected_reboot_count += 1; assert_eq!(get_reboot_count(&guest), expected_reboot_count); @@ -7612,7 +7612,7 @@ mod common_parallel { let mut child = cmd.spawn().unwrap(); let r = std::panic::catch_unwind(|| { - guest.wait_vm_boot(None).unwrap(); + guest.wait_vm_boot().unwrap(); // Trigger guest a panic make_guest_panic(&guest); @@ -7680,7 +7680,7 @@ mod common_parallel { .unwrap(); let r = std::panic::catch_unwind(|| { - guest.wait_vm_boot(None).unwrap(); + guest.wait_vm_boot().unwrap(); assert_eq!( guest @@ -7692,7 +7692,7 @@ mod common_parallel { 2 ); - guest.reboot_linux(0, None); + guest.reboot_linux(0); assert_eq!( guest @@ -7828,7 +7828,7 @@ mod common_parallel { // gets tested through wait_vm_boot() as it expects to receive a // HTTP request, and through the SSH command as well. let r = std::panic::catch_unwind(|| { - guest.wait_vm_boot(None).unwrap(); + guest.wait_vm_boot().unwrap(); assert_eq!( guest @@ -7840,7 +7840,7 @@ mod common_parallel { 2 ); - guest.reboot_linux(0, None); + guest.reboot_linux(0); assert_eq!( guest @@ -8082,7 +8082,7 @@ mod common_parallel { .unwrap(); let r = std::panic::catch_unwind(|| { - guest.wait_vm_boot(None).unwrap(); + guest.wait_vm_boot().unwrap(); // Hotplug the SPDK-NVMe device to the VM let (cmd_success, cmd_output) = remote_command_w_output( @@ -8128,7 +8128,7 @@ mod common_parallel { assert_eq!(guest.ssh_command("sudo umount /mnt").unwrap(), ""); assert_eq!(guest.ssh_command("ls /mnt").unwrap(), ""); - guest.reboot_linux(0, None); + guest.reboot_linux(0); assert_eq!( guest.ssh_command("sudo mount /dev/nvme0n1 /mnt").unwrap(), "" @@ -8175,7 +8175,7 @@ mod common_parallel { .unwrap(); let r = std::panic::catch_unwind(|| { - guest.wait_vm_boot(None).unwrap(); + guest.wait_vm_boot().unwrap(); // Check both if /dev/vdc exists and if the block size is 128M. assert_eq!( @@ -8298,7 +8298,7 @@ mod common_parallel { .unwrap(); let r = std::panic::catch_unwind(|| { - guest.wait_vm_boot(None).unwrap(); + guest.wait_vm_boot().unwrap(); // Check we can find network interface related to vDPA device assert_eq!( @@ -8378,7 +8378,7 @@ mod common_parallel { thread::sleep(std::time::Duration::new(10, 0)); let mut child = guest_cmd.spawn().unwrap(); let r = std::panic::catch_unwind(|| { - guest.wait_vm_boot(None).unwrap(); + guest.wait_vm_boot().unwrap(); assert_eq!( guest.ssh_command("ls /dev/tpm0").unwrap().trim(), "/dev/tpm0" @@ -8433,7 +8433,7 @@ mod common_parallel { let mut child = cmd.spawn().unwrap(); let mut r = std::panic::catch_unwind(|| { - guest.wait_vm_boot(None).unwrap(); + guest.wait_vm_boot().unwrap(); }); kill_child(&mut child); @@ -8477,7 +8477,7 @@ mod common_parallel { let mut child = cmd.spawn().unwrap(); let r = std::panic::catch_unwind(|| { - guest.wait_vm_boot(None).unwrap(); + guest.wait_vm_boot().unwrap(); assert!(remote_command(&api_socket, "nmi", None)); @@ -8546,7 +8546,7 @@ mod dbus_api { // Then boot it assert!(http_api.remote_command("boot", None)); - guest.wait_vm_boot(None).unwrap(); + guest.wait_vm_boot().unwrap(); // Check that the VM booted as expected assert_eq!(guest.get_cpu_count().unwrap_or_default() as u8, cpu_count); @@ -8565,7 +8565,7 @@ mod dbus_api { // Then boot it again assert!(http_api.remote_command("boot", None)); - guest.wait_vm_boot(None).unwrap(); + guest.wait_vm_boot().unwrap(); // Check that the VM booted as expected assert_eq!(guest.get_cpu_count().unwrap_or_default() as u8, cpu_count); @@ -8708,7 +8708,7 @@ mod ivshmem { .unwrap(); let r = std::panic::catch_unwind(|| { - guest.wait_vm_boot(None).unwrap(); + guest.wait_vm_boot().unwrap(); // Make sure the source VM is functional // Check the number of vCPUs @@ -8855,7 +8855,7 @@ mod ivshmem { .unwrap(); let r = std::panic::catch_unwind(|| { - guest.wait_vm_boot(None).unwrap(); + guest.wait_vm_boot().unwrap(); _test_ivshmem(&guest, &ivshmem_file_path, file_size); }); kill_child(&mut child); @@ -8920,7 +8920,7 @@ mod ivshmem { let snapshot_dir = temp_snapshot_dir_path(&guest.tmp_dir); let r = std::panic::catch_unwind(|| { - guest.wait_vm_boot(None).unwrap(); + guest.wait_vm_boot().unwrap(); // Check the number of vCPUs assert_eq!(guest.get_cpu_count().unwrap_or_default(), 2); @@ -9157,7 +9157,7 @@ mod common_sequential { let snapshot_dir = temp_snapshot_dir_path(&guest.tmp_dir); let r = std::panic::catch_unwind(|| { - guest.wait_vm_boot(None).unwrap(); + guest.wait_vm_boot().unwrap(); // Check the number of vCPUs assert_eq!(guest.get_cpu_count().unwrap_or_default(), 4); @@ -9426,7 +9426,7 @@ mod common_sequential { let snapshot_dir = temp_snapshot_dir_path(&guest.tmp_dir); let r = std::panic::catch_unwind(|| { - guest.wait_vm_boot(None).unwrap(); + guest.wait_vm_boot().unwrap(); // close the fds after VM boots, as CH duplicates them before using for tap in taps.iter() { @@ -9624,7 +9624,7 @@ mod common_sequential { let snapshot_dir = temp_snapshot_dir_path(&guest.tmp_dir); let r = std::panic::catch_unwind(|| { - guest.wait_vm_boot(None).unwrap(); + guest.wait_vm_boot().unwrap(); // Check the number of vCPUs assert_eq!(guest.get_cpu_count().unwrap_or_default(), 2); @@ -10766,7 +10766,7 @@ mod vfio { .unwrap(); let r = std::panic::catch_unwind(|| { - guest.wait_vm_boot(None).unwrap(); + guest.wait_vm_boot().unwrap(); assert!(guest.get_total_memory().unwrap_or_default() > 3_840_000); @@ -10816,7 +10816,7 @@ mod vfio { .unwrap(); let r = std::panic::catch_unwind(|| { - guest.wait_vm_boot(None).unwrap(); + guest.wait_vm_boot().unwrap(); // Hotplug the card to the VM let (cmd_success, cmd_output) = remote_command_w_output( @@ -10864,12 +10864,12 @@ mod vfio { .unwrap(); let r = std::panic::catch_unwind(|| { - guest.wait_vm_boot(None).unwrap(); + guest.wait_vm_boot().unwrap(); // Check the VFIO device works after boot guest.check_nvidia_gpu(); - guest.reboot_linux(0, None); + guest.reboot_linux(0); // Check the VFIO device works after reboot guest.check_nvidia_gpu(); @@ -10904,7 +10904,7 @@ mod vfio { .unwrap(); let r = std::panic::catch_unwind(|| { - guest.wait_vm_boot(None).unwrap(); + guest.wait_vm_boot().unwrap(); assert!( guest @@ -11130,7 +11130,7 @@ mod live_migration { .unwrap(); let r = std::panic::catch_unwind(|| { - guest.wait_vm_boot(None).unwrap(); + guest.wait_vm_boot().unwrap(); // Make sure the source VM is functional // Check the number of vCPUs @@ -11294,7 +11294,7 @@ mod live_migration { .unwrap(); let r = std::panic::catch_unwind(|| { - guest.wait_vm_boot(None).unwrap(); + guest.wait_vm_boot().unwrap(); // Make sure the source VM is functional // Check the number of vCPUs @@ -11495,7 +11495,7 @@ mod live_migration { .unwrap(); let r = std::panic::catch_unwind(|| { - guest.wait_vm_boot(None).unwrap(); + guest.wait_vm_boot().unwrap(); // Make sure the source VM is functional // Check the number of vCPUs @@ -11721,7 +11721,7 @@ mod live_migration { .unwrap(); let r = std::panic::catch_unwind(|| { - guest.wait_vm_boot(None).unwrap(); + guest.wait_vm_boot().unwrap(); // Make sure the source VM is functional // Check the number of vCPUs @@ -11827,7 +11827,7 @@ mod live_migration { // Trigger a panic (sync first). We need to do this inside a screen with a delay so the SSH command returns. guest.ssh_command("screen -dmS reboot sh -c \"sleep 5; echo s | tee /proc/sysrq-trigger; echo c | sudo tee /proc/sysrq-trigger\"").unwrap(); // Allow some time for the watchdog to trigger (max 30s) and reboot to happen - guest.wait_vm_boot(Some(50)).unwrap(); + guest.wait_vm_boot_custom_timeout(50).unwrap(); // Check a reboot is triggered by the watchdog expected_reboot_count += 1; assert_eq!(get_reboot_count(&guest), expected_reboot_count); @@ -12012,7 +12012,7 @@ mod live_migration { .unwrap(); let r = std::panic::catch_unwind(|| { - guest.wait_vm_boot(None).unwrap(); + guest.wait_vm_boot().unwrap(); // Make sure the source VM is functaionl // Check the number of vCPUs @@ -12228,7 +12228,7 @@ mod live_migration { .unwrap(); let r = std::panic::catch_unwind(|| { - guest.wait_vm_boot(None).unwrap(); + guest.wait_vm_boot().unwrap(); // Ensure the source VM is running normally assert_eq!(guest.get_cpu_count().unwrap_or_default(), boot_vcpus); assert!(guest.get_total_memory().unwrap_or_default() > 3_840_000); @@ -12464,7 +12464,7 @@ mod aarch64_acpi { .unwrap(); let r = std::panic::catch_unwind(|| { - guest.wait_vm_boot(Some(120)).unwrap(); + guest.wait_vm_boot().unwrap(); assert_eq!(guest.get_cpu_count().unwrap_or_default(), 1); assert!(guest.get_total_memory().unwrap_or_default() > 400_000); @@ -12564,7 +12564,7 @@ mod rate_limiter { .unwrap(); let r = std::panic::catch_unwind(|| { - guest.wait_vm_boot(None).unwrap(); + guest.wait_vm_boot().unwrap(); let measured_bps = measure_virtio_net_throughput(test_timeout, num_queues / 2, &guest, rx, true) .unwrap(); @@ -12650,7 +12650,7 @@ mod rate_limiter { .unwrap(); let r = std::panic::catch_unwind(|| { - guest.wait_vm_boot(None).unwrap(); + guest.wait_vm_boot().unwrap(); let fio_command = format!( "sudo fio --filename=/dev/vdc --name=test --output-format=json \ @@ -12744,7 +12744,7 @@ mod rate_limiter { .unwrap(); let r = std::panic::catch_unwind(|| { - guest.wait_vm_boot(None).unwrap(); + guest.wait_vm_boot().unwrap(); let mut fio_command = format!( "sudo fio --name=global --output-format=json \ @@ -12845,7 +12845,7 @@ mod fw_cfg { let mut child = cmd.spawn().unwrap(); let r = std::panic::catch_unwind(|| { - guest.wait_vm_boot(None).unwrap(); + guest.wait_vm_boot().unwrap(); // Wait a while for guest thread::sleep(std::time::Duration::new(3, 0)); let result = guest diff --git a/performance-metrics/src/performance_tests.rs b/performance-metrics/src/performance_tests.rs index 573db69ae..7dcf443d3 100644 --- a/performance-metrics/src/performance_tests.rs +++ b/performance-metrics/src/performance_tests.rs @@ -169,7 +169,7 @@ pub fn performance_net_throughput(control: &PerformanceTestControl) -> f64 { .unwrap(); let r = std::panic::catch_unwind(|| { - guest.wait_vm_boot(None).unwrap(); + guest.wait_vm_boot().unwrap(); measure_virtio_net_throughput(test_timeout, num_queues / 2, &guest, rx, bandwidth).unwrap() }); @@ -210,7 +210,7 @@ pub fn performance_net_latency(control: &PerformanceTestControl) -> f64 { .unwrap(); let r = std::panic::catch_unwind(|| { - guest.wait_vm_boot(None).unwrap(); + guest.wait_vm_boot().unwrap(); // 'ethr' tool will measure the latency multiple times with provided test time let latency = measure_virtio_net_latency(&guest, control.test_timeout).unwrap(); @@ -441,7 +441,7 @@ pub fn performance_block_io(control: &PerformanceTestControl) -> f64 { .unwrap(); let r = std::panic::catch_unwind(|| { - guest.wait_vm_boot(None).unwrap(); + guest.wait_vm_boot().unwrap(); let fio_command = format!( "sudo fio --filename=/dev/vdc --name=test --output-format=json \ diff --git a/test_infra/src/lib.rs b/test_infra/src/lib.rs index 25548b557..d9a04bce9 100644 --- a/test_infra/src/lib.rs +++ b/test_infra/src/lib.rs @@ -91,16 +91,12 @@ pub enum WaitForBootError { } impl GuestNetworkConfig { - pub fn wait_vm_boot(&self, custom_timeout: Option) -> Result<(), WaitForBootError> { + pub fn wait_vm_boot(&self, custom_timeout: u32) -> Result<(), WaitForBootError> { let start = std::time::Instant::now(); // The 'port' is unique per 'GUEST' and listening to wild-card ip avoids retrying on 'TcpListener::bind()' let listen_addr = format!("0.0.0.0:{}", self.tcp_listener_port); let expected_guest_addr = self.guest_ip0.as_str(); let mut s = String::new(); - let timeout = match custom_timeout { - Some(t) => t, - None => DEFAULT_TCP_LISTENER_TIMEOUT, - }; let mut closure = || -> Result<(), WaitForBootError> { let listener = @@ -122,15 +118,18 @@ impl GuestNetworkConfig { .expect("Cannot add 'tcp_listener' event to epoll"); let mut events = [epoll::Event::new(epoll::Events::empty(), 0); 1]; loop { - let num_events = - match epoll::wait(epoll_fd, (timeout * 1000) as i32, &mut events[..]) { - Ok(num_events) => Ok(num_events), - Err(e) => match e.raw_os_error() { - Some(libc::EAGAIN) | Some(libc::EINTR) => continue, - _ => Err(e), - }, - } - .map_err(WaitForBootError::EpollWait)?; + let num_events = match epoll::wait( + epoll_fd, + (custom_timeout * 1000).try_into().unwrap(), + &mut events[..], + ) { + Ok(num_events) => Ok(num_events), + Err(e) => match e.raw_os_error() { + Some(libc::EAGAIN) | Some(libc::EINTR) => continue, + _ => Err(e), + }, + } + .map_err(WaitForBootError::EpollWait)?; if num_events == 0 { return Err(WaitForBootError::EpollWaitTimeout); } @@ -163,7 +162,7 @@ impl GuestNetworkConfig { let duration = start.elapsed(); eprintln!( "\n\n==== Start 'wait_vm_boot' (FAILED) ==== \ - \n\nduration =\"{duration:?}, timeout = {timeout}s\" \ + \n\nduration =\"{duration:?}, timeout = {custom_timeout}s\" \ \nlisten_addr=\"{listen_addr}\" \ \nexpected_guest_addr=\"{expected_guest_addr}\" \ \nmessage=\"{s}\" \ @@ -1085,7 +1084,17 @@ impl Guest { .map_err(Error::Parsing) } - pub fn wait_vm_boot(&self, custom_timeout: Option) -> Result<(), Error> { + fn default_boot_timeout(&self) -> u32 { + self.boot_timeout + } + + pub fn wait_vm_boot(&self) -> Result<(), Error> { + self.network + .wait_vm_boot(self.default_boot_timeout()) + .map_err(Error::WaitForBoot) + } + + pub fn wait_vm_boot_custom_timeout(&self, custom_timeout: u32) -> Result<(), Error> { self.network .wait_vm_boot(custom_timeout) .map_err(Error::WaitForBoot) @@ -1223,7 +1232,7 @@ impl Guest { ); } - pub fn reboot_linux(&self, current_reboot_count: u32, custom_timeout: Option) { + pub fn reboot_linux(&self, current_reboot_count: u32) { let list_boots_cmd = "sudo last | grep -c reboot"; let boot_count = self .ssh_command(list_boots_cmd) @@ -1235,7 +1244,7 @@ impl Guest { assert_eq!(boot_count, current_reboot_count + 1); self.ssh_command("sudo reboot").unwrap(); - self.wait_vm_boot(custom_timeout).unwrap(); + self.wait_vm_boot().unwrap(); let boot_count = self .ssh_command(list_boots_cmd) .unwrap()