Lines Matching +full:add +full:- +full:user +full:- +full:device
3 // SPDX-License-Identifier: Apache-2.0
7 // hence have known dead-code. This annotation silences dead-code
36 pub const FOCAL_IMAGE_NAME: &str = "focal-server-cloudimg-amd64-custom-20210609-0.raw";
38 "jammy-server-cloudimg-amd64-custom-vfio-20241012-0.raw";
39 pub const FOCAL_IMAGE_NAME_QCOW2: &str = "focal-server-cloudimg-amd64-custom-20210609-0.qcow2";
41 "focal-server-cloudimg-amd64-custom-20210609-0-backing.qcow2";
42 pub const FOCAL_IMAGE_NAME_VHD: &str = "focal-server-cloudimg-amd64-custom-20210609-0.vhd";
43 pub const FOCAL_IMAGE_NAME_VHDX: &str = "focal-server-cloudimg-amd64-custom-20210609-0.vhdx";
44 pub const JAMMY_IMAGE_NAME: &str = "jammy-server-cloudimg-amd64-custom-20241017-0.raw";
45 pub const WINDOWS_IMAGE_NAME: &str = "windows-server-2022-amd64-2.raw";
47 pub const GREP_SERIAL_IRQ_CMD: &str = "grep -c 'IO-APIC.*ttyS0' /proc/interrupts || true";
55 pub const FOCAL_IMAGE_NAME: &str = "focal-server-cloudimg-arm64-custom-20210929-0.raw";
57 "focal-server-cloudimg-arm64-custom-20210929-0-update-kernel.raw";
58 pub const FOCAL_IMAGE_NAME_QCOW2: &str = "focal-server-cloudimg-arm64-custom-20210929-0.qcow2";
60 "focal-server-cloudimg-arm64-custom-20210929-0-backing.qcow2";
61 pub const FOCAL_IMAGE_NAME_VHD: &str = "focal-server-cloudimg-arm64-custom-20210929-0.vhd";
62 pub const FOCAL_IMAGE_NAME_VHDX: &str = "focal-server-cloudimg-arm64-custom-20210929-0.vhdx";
63 pub const JAMMY_IMAGE_NAME: &str = "jammy-server-cloudimg-arm64-custom-20220329-0.raw";
64 pub const WINDOWS_IMAGE_NAME: &str = "windows-11-iot-enterprise-aarch64.raw";
66 pub const GREP_SERIAL_IRQ_CMD: &str = "grep -c 'GICv3.*uart-pl011' /proc/interrupts || true";
67 pub const GREP_PMU_IRQ_CMD: &str = "grep -c 'GICv3.*arm-pmu' /proc/interrupts || true";
79 // implement test for both D-Bus and REST APIs.
88 fn new_http_api(tmp_dir: &TempDir) -> Self { in new_http_api()
92 fn new_dbus_api(tmp_dir: &TempDir) -> Self { in new_dbus_api()
103 fn guest_args(&self) -> Vec<String> { in guest_args()
106 vec![format!("--api-socket={}", api_socket.as_str())] in guest_args()
110 format!("--dbus-service-name={}", service_name.as_str()), in guest_args()
111 format!("--dbus-object-path={}", object_path.as_str()), in guest_args()
117 fn remote_args(&self) -> Vec<String> { in remote_args()
122 fn remote_command(&self, command: &str, arg: Option<&str>) -> bool { in remote_command()
123 let mut cmd = Command::new(clh_command("ch-remote")); in remote_command()
135 eprintln!("Error running ch-remote command: {:?}", &cmd); in remote_command()
143 // Start cloud-hypervisor with no VM parameters, only the API server running.
187 // Start cloud-hypervisor with no VM parameters, only the API server running.
229 guest.ssh_command("sudo shutdown -H now").unwrap(); in _test_api_shutdown()
253 // Start cloud-hypervisor with no VM parameters, only the API server running.
294 guest.ssh_command("sudo shutdown -H now").unwrap(); in _test_api_delete()
320 // Start cloud-hypervisor with no VM parameters, only the API server running.
369 "grep -c processor /proc/cpuinfo", in _test_api_pause_resume()
440 fn prepare_virtiofsd(tmp_dir: &TempDir, shared_dir: &str) -> (std::process::Child, String) { in prepare_virtiofsd()
453 .args(["--shared-dir", shared_dir]) in prepare_virtiofsd()
454 .args(["--socket-path", virtiofsd_socket_path.as_str()]) in prepare_virtiofsd()
455 .args(["--cache", "never"]) in prepare_virtiofsd()
470 ) -> (std::process::Child, String) { in prepare_vubd()
483 "--block-backend", in prepare_vubd()
497 fn temp_vsock_path(tmp_dir: &TempDir) -> String { in temp_vsock_path()
501 fn temp_api_path(tmp_dir: &TempDir) -> String { in temp_api_path()
505 .join("cloud-hypervisor.sock") in temp_api_path()
511 fn temp_event_monitor_path(tmp_dir: &TempDir) -> String { in temp_event_monitor_path()
516 fn temp_snapshot_dir_path(tmp_dir: &TempDir) -> String { in temp_snapshot_dir_path()
522 fn temp_vmcore_file_path(tmp_dir: &TempDir) -> String { in temp_vmcore_file_path()
530 fn direct_kernel_boot_path() -> PathBuf { in direct_kernel_boot_path()
536 kernel_path.push("vmlinux-x86_64"); in direct_kernel_boot_path()
538 kernel_path.push("Image-arm64"); in direct_kernel_boot_path()
543 fn edk2_path() -> PathBuf { in edk2_path()
552 fn cloud_hypervisor_release_path() -> String { in cloud_hypervisor_release_path()
558 ch_release_path.push("cloud-hypervisor-static"); in cloud_hypervisor_release_path()
560 ch_release_path.push("cloud-hypervisor-static-aarch64"); in cloud_hypervisor_release_path()
572 ) -> (std::process::Command, String) { in prepare_vhost_user_net_daemon()
589 command.args(["--net-backend", net_params.as_str()]); in prepare_vhost_user_net_daemon()
594 fn prepare_swtpm_daemon(tmp_dir: &TempDir) -> (std::process::Command, String) { in prepare_swtpm_daemon()
609 "--tpmstate", in prepare_swtpm_daemon()
611 "--ctrl", in prepare_swtpm_daemon()
613 "--flags", in prepare_swtpm_daemon()
614 "startup-clear", in prepare_swtpm_daemon()
615 "--tpm2", in prepare_swtpm_daemon()
622 fn remote_command(api_socket: &str, command: &str, arg: Option<&str>) -> bool { in remote_command()
623 let mut cmd = Command::new(clh_command("ch-remote")); in remote_command()
624 cmd.args([&format!("--api-socket={api_socket}"), command]); in remote_command()
633 eprintln!("Error running ch-remote command: {:?}", &cmd); in remote_command()
640 fn remote_command_w_output(api_socket: &str, command: &str, arg: Option<&str>) -> (bool, Vec<u8>) { in remote_command_w_output()
641 let mut cmd = Command::new(clh_command("ch-remote")); in remote_command_w_output()
642 cmd.args([&format!("--api-socket={api_socket}"), command]); in remote_command_w_output()
648 let output = cmd.output().expect("Failed to launch ch-remote"); in remote_command_w_output()
659 ) -> bool { in resize_command()
660 let mut cmd = Command::new(clh_command("ch-remote")); in resize_command()
661 cmd.args([&format!("--api-socket={api_socket}"), "resize"]); in resize_command()
664 cmd.arg(format!("--cpus={desired_vcpus}")); in resize_command()
668 cmd.arg(format!("--memory={desired_ram}")); in resize_command()
672 cmd.arg(format!("--balloon={desired_balloon}")); in resize_command()
675 let ret = cmd.status().expect("Failed to launch ch-remote").success(); in resize_command()
696 fn resize_zone_command(api_socket: &str, id: &str, desired_size: &str) -> bool { in resize_zone_command()
697 let mut cmd = Command::new(clh_command("ch-remote")); in resize_zone_command()
699 &format!("--api-socket={api_socket}"), in resize_zone_command()
700 "resize-zone", in resize_zone_command()
701 &format!("--id={id}"), in resize_zone_command()
702 &format!("--size={desired_size}"), in resize_zone_command()
705 cmd.status().expect("Failed to launch ch-remote").success() in resize_zone_command()
708 // setup OVS-DPDK bridge and ports
710 // setup OVS-DPDK in setup_ovs_dpdk()
711 assert!(exec_host_command_status("service openvswitch-switch start").success()); in setup_ovs_dpdk()
712 assert!(exec_host_command_status("ovs-vsctl init").success()); in setup_ovs_dpdk()
714 exec_host_command_status("ovs-vsctl set Open_vSwitch . other_config:dpdk-init=true") in setup_ovs_dpdk()
717 assert!(exec_host_command_status("service openvswitch-switch restart").success()); in setup_ovs_dpdk()
719 // Create OVS-DPDK bridge and ports in setup_ovs_dpdk()
721 "ovs-vsctl add-br ovsbr0 -- set bridge ovsbr0 datapath_type=netdev", in setup_ovs_dpdk()
724 …t_command_status("ovs-vsctl add-port ovsbr0 vhost-user1 -- set Interface vhost-user1 type=dpdkvhos… in setup_ovs_dpdk()
725 …t_command_status("ovs-vsctl add-port ovsbr0 vhost-user2 -- set Interface vhost-user2 type=dpdkvhos… in setup_ovs_dpdk()
727 assert!(exec_host_command_status("service openvswitch-switch restart").success()); in setup_ovs_dpdk()
730 assert!(exec_host_command_status("ovs-vsctl del-br ovsbr0").success()); in cleanup_ovs_dpdk()
731 exec_host_command_status("rm -f ovs-vsctl /tmp/dpdkvhostclient1 /tmp/dpdkvhostclient2"); in cleanup_ovs_dpdk()
733 // Setup two guests and ensure they are connected through ovs-dpdk
739 ) -> (Child, Child) { in setup_ovs_dpdk_guests()
743 clh_command("cloud-hypervisor") in setup_ovs_dpdk_guests()
749 .args(["--cpus", "boot=2"]) in setup_ovs_dpdk_guests()
750 .args(["--memory", "size=0,shared=on"]) in setup_ovs_dpdk_guests()
751 .args(["--memory-zone", "id=mem0,size=1G,shared=on,host_numa_node=0"]) in setup_ovs_dpdk_guests()
752 .args(["--kernel", direct_kernel_boot_path().to_str().unwrap()]) in setup_ovs_dpdk_guests()
753 .args(["--cmdline", DIRECT_KERNEL_BOOT_CMDLINE]) in setup_ovs_dpdk_guests()
755 ….args(["--net", guest1.default_net_string().as_str(), "vhost_user=true,socket=/tmp/dpdkvhostclient… in setup_ovs_dpdk_guests()
770 "sudo ip addr add 172.100.0.1/24 dev {guest_net_iface}" in setup_ovs_dpdk_guests()
780 "nc -l 12345", in setup_ovs_dpdk_guests()
798 .args(["--api-socket", api_socket]) in setup_ovs_dpdk_guests()
799 .args(["--cpus", "boot=2"]) in setup_ovs_dpdk_guests()
800 .args(["--memory", "size=0,shared=on"]) in setup_ovs_dpdk_guests()
801 .args(["--memory-zone", "id=mem0,size=1G,shared=on,host_numa_node=0"]) in setup_ovs_dpdk_guests()
802 .args(["--kernel", direct_kernel_boot_path().to_str().unwrap()]) in setup_ovs_dpdk_guests()
803 .args(["--cmdline", DIRECT_KERNEL_BOOT_CMDLINE]) in setup_ovs_dpdk_guests()
805 ….args(["--net", guest2.default_net_string().as_str(), "vhost_user=true,socket=/tmp/dpdkvhostclient… in setup_ovs_dpdk_guests()
815 "sudo ip addr add 172.100.0.2/24 dev {guest_net_iface}" in setup_ovs_dpdk_guests()
823 guest2.ssh_command("nc -vz 172.100.0.1 12345").unwrap(); in setup_ovs_dpdk_guests()
843 fn fw_path(_fw_type: FwType) -> String { in fw_path()
854 FwType::RustHypervisorFirmware => fw_path.push("hypervisor-fw"), in fw_path()
868 pub fn match_with_json_event(&self, v: &serde_json::Value) -> bool { in match_with_json_event()
885 fn parse_event_file(event_file: &str) -> Vec<serde_json::Value> { in parse_event_file()
901 fn check_sequential_events(expected_events: &[&MetaEvent], event_file: &str) -> bool { in check_sequential_events()
929 fn check_sequential_events_exact(expected_events: &[&MetaEvent], event_file: &str) -> bool { in check_sequential_events_exact()
951 fn check_latest_events_exact(latest_events: &[&MetaEvent], event_file: &str) -> bool { in check_latest_events_exact()
954 let json_events = &json_events[(json_events.len() - latest_events.len())..]; in check_latest_events_exact()
984 "--cpus", in test_cpu_topology()
989 .args(["--memory", "size=512M"]) in test_cpu_topology()
990 .args(["--kernel", kernel_path]) in test_cpu_topology()
991 .args(["--cmdline", DIRECT_KERNEL_BOOT_CMDLINE]) in test_cpu_topology()
1006 .ssh_command("lscpu | grep \"per core\" | cut -f 2 -d \":\" | sed \"s# *##\"") in test_cpu_topology()
1016 .ssh_command("lscpu | grep \"per socket\" | cut -f 2 -d \":\" | sed \"s# *##\"") in test_cpu_topology()
1026 .ssh_command("lscpu | grep \"Socket\" | cut -f 2 -d \":\" | sed \"s# *##\"") in test_cpu_topology()
1090 .args(["--cpus", "boot=6,max=12"]) in _test_guest_numa_nodes()
1091 .args(["--memory", "size=0,hotplug_method=virtio-mem"]) in _test_guest_numa_nodes()
1093 "--memory-zone", in _test_guest_numa_nodes()
1099 "--numa", in _test_guest_numa_nodes()
1100 "guest_numa_id=0,cpus=[0-2,9],distances=[1@15,2@20],memory_zones=mem0", in _test_guest_numa_nodes()
1101 "guest_numa_id=1,cpus=[3-4,6-8],distances=[0@20,2@25],memory_zones=mem1", in _test_guest_numa_nodes()
1102 "guest_numa_id=2,cpus=[5,10-11],distances=[0@25,1@30],memory_zones=mem2", in _test_guest_numa_nodes()
1104 .args(["--kernel", kernel_path.to_str().unwrap()]) in _test_guest_numa_nodes()
1105 .args(["--cmdline", DIRECT_KERNEL_BOOT_CMDLINE]) in _test_guest_numa_nodes()
1106 .args(["--api-socket", &api_socket]) in _test_guest_numa_nodes()
1123 // test hotplug-related function on x86_64 here. in _test_guest_numa_nodes()
1168 cmd.args(["--cpus", "boot=1"]) in _test_power_button()
1169 .args(["--memory", "size=512M"]) in _test_power_button()
1170 .args(["--kernel", kernel_path.to_str().unwrap()]) in _test_power_button()
1171 .args(["--cmdline", DIRECT_KERNEL_BOOT_CMDLINE]) in _test_power_button()
1175 .args(["--api-socket", &api_socket]); in _test_power_button()
1181 assert!(remote_command(&api_socket, "power-button", None)); in _test_power_button()
1196 ) -> (std::process::Command, String);
1247 .args(["--cpus", format!("boot={}", num_queues / 2).as_str()]) in test_vhost_user_net()
1248 .args(["--memory", "size=512M,hotplug_size=2048M,shared=on"]) in test_vhost_user_net()
1249 .args(["--kernel", kernel_path.to_str().unwrap()]) in test_vhost_user_net()
1250 .args(["--cmdline", DIRECT_KERNEL_BOOT_CMDLINE]) in test_vhost_user_net()
1252 .args(["--net", net_params.as_str()]) in test_vhost_user_net()
1253 .args(["--api-socket", &api_socket]) in test_vhost_user_net()
1275 let tap_count = exec_host_command_output(&format!("ip link | grep -c {tap_name}")); in test_vhost_user_net()
1280 let mac_count = exec_host_command_output(&format!("ip link | grep -c {host_mac}")); in test_vhost_user_net()
1299 // vhost-user-net implementation and the associated backend since in test_vhost_user_net()
1300 // it does not define any --net network interface. That means all in test_vhost_user_net()
1302 // interface backed by vhost-user-net. in test_vhost_user_net()
1305 .ssh_command("ip -o link | wc -l") in test_vhost_user_net()
1313 // The following pci devices will appear on guest with PCI-MSI in test_vhost_user_net()
1315 // 1 virtio-console with 3 vectors: config, Rx, Tx in test_vhost_user_net()
1316 // 1 virtio-blk with 2 vectors: config, Request in test_vhost_user_net()
1317 // 1 virtio-blk with 2 vectors: config, Request in test_vhost_user_net()
1318 // 1 virtio-rng with 2 vectors: config, Request in test_vhost_user_net()
1319 // Since virtio-net has 2 queue pairs, its vectors is as follows: in test_vhost_user_net()
1320 // 1 virtio-net with 5 vectors: config, Rx (2), Tx (2) in test_vhost_user_net()
1323 let grep_cmd = "grep -c PCI-MSI /proc/interrupts"; in test_vhost_user_net()
1325 let grep_cmd = "grep -c ITS-PCI-MSIX /proc/interrupts"; in test_vhost_user_net()
1341 // Add RAM to the VM in test_vhost_user_net()
1348 // the connection is still working, which means vhost-user-net in test_vhost_user_net()
1364 type PrepareBlkDaemon = dyn Fn(&TempDir, &str, usize, bool, bool) -> (std::process::Child, String);
1393 .args(["--cpus", format!("boot={num_queues}").as_str()]) in test_vhost_user_blk()
1394 .args(["--memory", "size=512M,hotplug_size=2048M,shared=on"]) in test_vhost_user_blk()
1395 .args(["--kernel", kernel_path.to_str().unwrap()]) in test_vhost_user_blk()
1396 .args(["--cmdline", DIRECT_KERNEL_BOOT_CMDLINE]) in test_vhost_user_blk()
1398 "--disk", in test_vhost_user_blk()
1412 .args(["--api-socket", &api_socket]) in test_vhost_user_blk()
1423 .ssh_command("lsblk | grep vdc | grep -c 16M") in test_vhost_user_blk()
1446 .ssh_command("ls -ll /sys/block/vdc/mq | grep ^d | wc -l") in test_vhost_user_blk()
1454 // Mount the device in test_vhost_user_blk()
1459 format!("sudo mount -o {mount_ro_rw_flag} -t ext4 /dev/vdc mount_image/").as_str(), in test_vhost_user_blk()
1463 // Check the content of the block device. The file "foo" should in test_vhost_user_blk()
1475 // Add RAM to the VM in test_vhost_user_blk()
1483 // Check again the content of the block device after the resize in test_vhost_user_blk()
1491 // Unmount the device in test_vhost_user_blk()
1493 guest.ssh_command("rm -r mount_image").unwrap(); in test_vhost_user_blk()
1541 .args(["--cpus", format!("boot={num_queues}").as_str()]) in test_boot_from_vhost_user_blk()
1542 .args(["--memory", "size=512M,shared=on"]) in test_boot_from_vhost_user_blk()
1543 .args(["--kernel", kernel_path.to_str().unwrap()]) in test_boot_from_vhost_user_blk()
1544 .args(["--cmdline", DIRECT_KERNEL_BOOT_CMDLINE]) in test_boot_from_vhost_user_blk()
1546 "--disk", in test_boot_from_vhost_user_blk()
1579 prepare_daemon: &dyn Fn(&TempDir, &str) -> (std::process::Child, String), in _test_virtio_fs()
1615 .args(["--cpus", "boot=1"]) in _test_virtio_fs()
1616 .args(["--memory", "size=512M,hotplug_size=2048M,shared=on"]) in _test_virtio_fs()
1617 .args(["--kernel", kernel_path.to_str().unwrap()]) in _test_virtio_fs()
1618 .args(["--cmdline", DIRECT_KERNEL_BOOT_CMDLINE]) in _test_virtio_fs()
1621 .args(["--api-socket", &api_socket]); in _test_virtio_fs()
1624 "--platform", in _test_virtio_fs()
1640 guest_command.args(["--fs", fs_params.as_str()]); in _test_virtio_fs()
1649 // Add fs to the VM in _test_virtio_fs()
1651 remote_command_w_output(&api_socket, "add-fs", Some(&fs_params)); in _test_virtio_fs()
1668 .ssh_command("mkdir -p mount_dir && sudo mount -t virtiofs myfs mount_dir/") in _test_virtio_fs()
1678 .ssh_command("[ ! -f 'mount_dir/file2' ] || true") in _test_virtio_fs()
1692 // Add RAM to the VM in _test_virtio_fs()
1710 assert!(remote_command(&api_socket, "remove-device", Some("myfs0"))); in _test_virtio_fs()
1731 // Add back and check it works in _test_virtio_fs()
1733 remote_command_w_output(&api_socket, "add-fs", Some(&fs_params)); in _test_virtio_fs()
1747 .ssh_command("mkdir -p mount_dir && sudo mount -t virtiofs myfs mount_dir/") in _test_virtio_fs()
1791 .args(["--cpus", "boot=1"]) in test_virtio_pmem()
1792 .args(["--memory", "size=512M"]) in test_virtio_pmem()
1793 .args(["--kernel", kernel_path.to_str().unwrap()]) in test_virtio_pmem()
1794 .args(["--cmdline", DIRECT_KERNEL_BOOT_CMDLINE]) in test_virtio_pmem()
1798 "--pmem", in test_virtio_pmem()
1850 fn get_fd_count(pid: u32) -> usize { in get_fd_count()
1871 cmd.args(["--api-socket", &api_socket]); in _test_virtio_vsock()
1872 cmd.args(["--cpus", "boot=1"]); in _test_virtio_vsock()
1873 cmd.args(["--memory", "size=512M"]); in _test_virtio_vsock()
1874 cmd.args(["--kernel", kernel_path.to_str().unwrap()]); in _test_virtio_vsock()
1875 cmd.args(["--cmdline", DIRECT_KERNEL_BOOT_CMDLINE]); in _test_virtio_vsock()
1880 cmd.args(["--vsock", format!("cid=3,socket={socket}").as_str()]); in _test_virtio_vsock()
1891 "add-vsock", in _test_virtio_vsock()
1901 "add-vsock", in _test_virtio_vsock()
1913 assert!(remote_command(&api_socket, "remove-device", Some("test0"))); in _test_virtio_vsock()
1923 fn get_ksm_pages_shared() -> u32 { in get_ksm_pages_shared()
1945 .args(["--cpus", "boot=1"]) in test_memory_mergeable()
1946 .args(["--memory", format!("size=512M,{memory_param}").as_str()]) in test_memory_mergeable()
1947 .args(["--kernel", direct_kernel_boot_path().to_str().unwrap()]) in test_memory_mergeable()
1948 .args(["--cmdline", DIRECT_KERNEL_BOOT_CMDLINE]) in test_memory_mergeable()
1950 .args(["--net", guest1.default_net_string().as_str()]) in test_memory_mergeable()
1951 .args(["--serial", "tty", "--console", "off"]) in test_memory_mergeable()
1971 .args(["--cpus", "boot=1"]) in test_memory_mergeable()
1972 .args(["--memory", format!("size=512M,{memory_param}").as_str()]) in test_memory_mergeable()
1973 .args(["--kernel", direct_kernel_boot_path().to_str().unwrap()]) in test_memory_mergeable()
1974 .args(["--cmdline", DIRECT_KERNEL_BOOT_CMDLINE]) in test_memory_mergeable()
1976 .args(["--net", guest2.default_net_string().as_str()]) in test_memory_mergeable()
1977 .args(["--serial", "tty", "--console", "off"]) in test_memory_mergeable()
2007 fn _get_vmm_overhead(pid: u32, guest_memory_size: u32) -> HashMap<String, u32> { in _get_vmm_overhead()
2017 if l.contains('-') { in _get_vmm_overhead()
2049 fn get_vmm_overhead(pid: u32, guest_memory_size: u32) -> u32 { in get_vmm_overhead()
2060 fn process_rss_kib(pid: u32) -> usize { in process_rss_kib()
2061 let command = format!("ps -q {pid} -o rss="); in process_rss_kib()
2081 fn get_counters(api_socket: &str) -> Counters { in get_counters()
2111 fn pty_read(mut pty: std::fs::File) -> Receiver<String> { in pty_read()
2130 fn get_pty_path(api_socket: &str, pty_type: &str) -> PathBuf { in get_pty_path()
2146 // 'vfio-br0' in setup_vfio_network_interfaces()
2147 assert!(exec_host_command_status("sudo ip link add name vfio-br0 type bridge").success()); in setup_vfio_network_interfaces()
2148 assert!(exec_host_command_status("sudo ip link set vfio-br0 up").success()); in setup_vfio_network_interfaces()
2149 assert!(exec_host_command_status("sudo ip addr add 172.18.0.1/24 dev vfio-br0").success()); in setup_vfio_network_interfaces()
2150 // 'vfio-tap0' in setup_vfio_network_interfaces()
2151 assert!(exec_host_command_status("sudo ip tuntap add vfio-tap0 mode tap").success()); in setup_vfio_network_interfaces()
2152 assert!(exec_host_command_status("sudo ip link set vfio-tap0 master vfio-br0").success()); in setup_vfio_network_interfaces()
2153 assert!(exec_host_command_status("sudo ip link set vfio-tap0 up").success()); in setup_vfio_network_interfaces()
2154 // 'vfio-tap1' in setup_vfio_network_interfaces()
2155 assert!(exec_host_command_status("sudo ip tuntap add vfio-tap1 mode tap").success()); in setup_vfio_network_interfaces()
2156 assert!(exec_host_command_status("sudo ip link set vfio-tap1 master vfio-br0").success()); in setup_vfio_network_interfaces()
2157 assert!(exec_host_command_status("sudo ip link set vfio-tap1 up").success()); in setup_vfio_network_interfaces()
2158 // 'vfio-tap2' in setup_vfio_network_interfaces()
2159 assert!(exec_host_command_status("sudo ip tuntap add vfio-tap2 mode tap").success()); in setup_vfio_network_interfaces()
2160 assert!(exec_host_command_status("sudo ip link set vfio-tap2 master vfio-br0").success()); in setup_vfio_network_interfaces()
2161 assert!(exec_host_command_status("sudo ip link set vfio-tap2 up").success()); in setup_vfio_network_interfaces()
2162 // 'vfio-tap3' in setup_vfio_network_interfaces()
2163 assert!(exec_host_command_status("sudo ip tuntap add vfio-tap3 mode tap").success()); in setup_vfio_network_interfaces()
2164 assert!(exec_host_command_status("sudo ip link set vfio-tap3 master vfio-br0").success()); in setup_vfio_network_interfaces()
2165 assert!(exec_host_command_status("sudo ip link set vfio-tap3 up").success()); in setup_vfio_network_interfaces()
2171 assert!(exec_host_command_status("sudo ip link del vfio-br0").success()); in cleanup_vfio_network_interfaces()
2172 assert!(exec_host_command_status("sudo ip link del vfio-tap0").success()); in cleanup_vfio_network_interfaces()
2173 assert!(exec_host_command_status("sudo ip link del vfio-tap1").success()); in cleanup_vfio_network_interfaces()
2174 assert!(exec_host_command_status("sudo ip link del vfio-tap2").success()); in cleanup_vfio_network_interfaces()
2175 assert!(exec_host_command_status("sudo ip link del vfio-tap3").success()); in cleanup_vfio_network_interfaces()
2178 fn balloon_size(api_socket: &str) -> u64 { in balloon_size()
2191 total_mem - actual_mem in balloon_size()
2194 fn vm_state(api_socket: &str) -> String { in vm_state()
2204 // This test validates that it can find the virtio-iommu device at first.
2211 // Virtio-iommu support is ready in recent kernel (v5.14). But the kernel in in _test_virtio_iommu()
2232 .args(["--cpus", "boot=1"]) in _test_virtio_iommu()
2233 .args(["--memory", "size=512M"]) in _test_virtio_iommu()
2234 .args(["--kernel", kernel_path.to_str().unwrap()]) in _test_virtio_iommu()
2235 .args(["--cmdline", DIRECT_KERNEL_BOOT_CMDLINE]) in _test_virtio_iommu()
2237 "--disk", in _test_virtio_iommu()
2249 .args(["--net", guest.default_net_string_w_iommu().as_str()]) in _test_virtio_iommu()
2257 // Verify the virtio-iommu device is present. in _test_virtio_iommu()
2265 // virtio-iommu device itself. So these devices will all be added to IOMMU groups, in _test_virtio_iommu()
2269 // While on ACPI, console device is not attached to IOMMU. So the IOMMU group '0' in _test_virtio_iommu()
2309 fn get_reboot_count(guest: &Guest) -> u32 { in get_reboot_count()
2311 .ssh_command("sudo last | grep -c reboot") in get_reboot_count()
2319 // Check for PCI device in enable_guest_watchdog()
2327 "echo RuntimeWatchdogSec={watchdog_sec}s | sudo tee -a /etc/systemd/system.conf" in enable_guest_watchdog()
2331 guest.ssh_command("sudo systemctl daemon-reexec").unwrap(); in enable_guest_watchdog()
2335 // Check for pvpanic device in make_guest_panic()
2341 …guest.ssh_command("screen -dmS reboot sh -c \"sleep 5; echo s | tee /proc/sysrq-trigger; echo c | … in make_guest_panic()
2369 .args(["--cpus", "boot=1"]) in test_simple_launch()
2370 .args(["--memory", "size=512M"]) in test_simple_launch()
2371 .args(["--kernel", fw_path.as_str()]) in test_simple_launch()
2374 .args(["--serial", "tty", "--console", "off"]) in test_simple_launch()
2375 .args(["--event-monitor", format!("path={event_path}").as_str()]) in test_simple_launch()
2454 cmd.args(["--cpus", "boot=2,max=4"]) in test_multi_cpu()
2455 .args(["--memory", "size=512M"]) in test_multi_cpu()
2456 .args(["--kernel", direct_kernel_boot_path().to_str().unwrap()]) in test_multi_cpu()
2457 .args(["--cmdline", DIRECT_KERNEL_BOOT_CMDLINE]) in test_multi_cpu()
2472 r#"sudo dmesg | grep "smp: Brought up" | sed "s/\[\ *[0-9.]*\] //""# in test_multi_cpu()
2509 .args(["--cpus", &format!("max_phys_bits={max_phys_bits}")]) in test_cpu_physical_bits()
2510 .args(["--memory", "size=512M"]) in test_cpu_physical_bits()
2511 .args(["--kernel", direct_kernel_boot_path().to_str().unwrap()]) in test_cpu_physical_bits()
2512 .args(["--cmdline", DIRECT_KERNEL_BOOT_CMDLINE]) in test_cpu_physical_bits()
2524 ….ssh_command("lscpu | grep \"Address sizes:\" | cut -f 2 -d \":\" | sed \"s# *##\" | cut -f 1 -d \… in test_cpu_physical_bits()
2555 .args(["--cpus", "boot=2,affinity=[0@[0,2],1@[1,3]]"]) in test_cpu_affinity()
2556 .args(["--memory", "size=512M"]) in test_cpu_affinity()
2557 .args(["--kernel", direct_kernel_boot_path().to_str().unwrap()]) in test_cpu_affinity()
2558 .args(["--cmdline", DIRECT_KERNEL_BOOT_CMDLINE]) in test_cpu_affinity()
2568 …c_host_command_output(format!("taskset -pc $(ps -T -p {pid} | grep vcpu0 | xargs | cut -f 2 -d \" … in test_cpu_affinity()
2570 …c_host_command_output(format!("taskset -pc $(ps -T -p {pid} | grep vcpu1 | xargs | cut -f 2 -d \" … in test_cpu_affinity()
2596 .args(["--cpus", "boot=4"]) in test_virtio_queue_affinity()
2597 .args(["--memory", "size=512M"]) in test_virtio_queue_affinity()
2598 .args(["--kernel", direct_kernel_boot_path().to_str().unwrap()]) in test_virtio_queue_affinity()
2599 .args(["--cmdline", DIRECT_KERNEL_BOOT_CMDLINE]) in test_virtio_queue_affinity()
2601 "--disk", in test_virtio_queue_affinity()
2621 …host_command_output(format!("taskset -pc $(ps -T -p {pid} | grep disk1_q0 | xargs | cut -f 2 -d \"… in test_virtio_queue_affinity()
2623 …host_command_output(format!("taskset -pc $(ps -T -p {pid} | grep disk1_q1 | xargs | cut -f 2 -d \"… in test_virtio_queue_affinity()
2625 …host_command_output(format!("taskset -pc $(ps -T -p {pid} | grep disk1_q2 | xargs | cut -f 2 -d \"… in test_virtio_queue_affinity()
2627 …host_command_output(format!("taskset -pc $(ps -T -p {pid} | grep disk1_q3 | xargs | cut -f 2 -d \"… in test_virtio_queue_affinity()
2642 cmd.args(["--cpus", "boot=48"]) in test_large_vm()
2643 .args(["--memory", "size=5120M"]) in test_large_vm()
2644 .args(["--kernel", direct_kernel_boot_path().to_str().unwrap()]) in test_large_vm()
2645 .args(["--cmdline", DIRECT_KERNEL_BOOT_CMDLINE]) in test_large_vm()
2646 .args(["--serial", "tty"]) in test_large_vm()
2647 .args(["--console", "off"]) in test_large_vm()
2660 .ssh_command("lscpu | grep \"On-line\" | cut -f 2 -d \":\" | sed \"s# *##\"") in test_large_vm()
2663 "0-47" in test_large_vm()
2681 cmd.args(["--cpus", "boot=1"]) in test_huge_memory()
2682 .args(["--memory", "size=128G"]) in test_huge_memory()
2683 .args(["--kernel", direct_kernel_boot_path().to_str().unwrap()]) in test_huge_memory()
2684 .args(["--cmdline", DIRECT_KERNEL_BOOT_CMDLINE]) in test_huge_memory()
2718 .args(["--cpus", "boot=1"]) in test_user_defined_memory_regions()
2719 .args(["--memory", "size=0,hotplug_method=virtio-mem"]) in test_user_defined_memory_regions()
2721 "--memory-zone", in test_user_defined_memory_regions()
2726 .args(["--kernel", kernel_path.to_str().unwrap()]) in test_user_defined_memory_regions()
2727 .args(["--cmdline", DIRECT_KERNEL_BOOT_CMDLINE]) in test_user_defined_memory_regions()
2728 .args(["--api-socket", &api_socket]) in test_user_defined_memory_regions()
2789 // Prepare another disk file for the virtio-disk device in test_iommu_segments()
2794 .join("test-disk.raw") in test_iommu_segments()
2799 exec_host_command_status(format!("truncate {test_disk_path} -s 4M").as_str()).success() in test_iommu_segments()
2806 cmd.args(["--cpus", "boot=1"]) in test_iommu_segments()
2807 .args(["--api-socket", &api_socket]) in test_iommu_segments()
2808 .args(["--memory", "size=512M"]) in test_iommu_segments()
2809 .args(["--kernel", direct_kernel_boot_path().to_str().unwrap()]) in test_iommu_segments()
2810 .args(["--cmdline", DIRECT_KERNEL_BOOT_CMDLINE]) in test_iommu_segments()
2812 "--platform", in test_iommu_segments()
2826 "add-disk", in test_iommu_segments()
2863 cmd.args(["--cpus", "boot=1"]) in test_pci_msi()
2864 .args(["--memory", "size=512M"]) in test_pci_msi()
2865 .args(["--kernel", direct_kernel_boot_path().to_str().unwrap()]) in test_pci_msi()
2866 .args(["--cmdline", DIRECT_KERNEL_BOOT_CMDLINE]) in test_pci_msi()
2876 let grep_cmd = "grep -c PCI-MSI /proc/interrupts"; in test_pci_msi()
2878 let grep_cmd = "grep -c ITS-PCI-MSIX /proc/interrupts"; in test_pci_msi()
2903 cmd.args(["--cpus", "boot=1"]) in test_virtio_net_ctrl_queue()
2904 .args(["--memory", "size=512M"]) in test_virtio_net_ctrl_queue()
2905 .args(["--kernel", direct_kernel_boot_path().to_str().unwrap()]) in test_virtio_net_ctrl_queue()
2906 .args(["--cmdline", DIRECT_KERNEL_BOOT_CMDLINE]) in test_virtio_net_ctrl_queue()
2907 .args(["--net", guest.default_net_string_w_mtu(3000).as_str()]) in test_virtio_net_ctrl_queue()
2924 format!("sudo ethtool -K {iface} rx-gro-hw off && echo success").as_str() in test_virtio_net_ctrl_queue()
2950 // Prepare another disk file for the virtio-disk device in test_pci_multiple_segments()
2955 .join("test-disk.raw") in test_pci_multiple_segments()
2960 exec_host_command_status(format!("truncate {test_disk_path} -s 4M").as_str()).success() in test_pci_multiple_segments()
2965 cmd.args(["--cpus", "boot=1"]) in test_pci_multiple_segments()
2966 .args(["--memory", "size=512M"]) in test_pci_multiple_segments()
2967 .args(["--kernel", direct_kernel_boot_path().to_str().unwrap()]) in test_pci_multiple_segments()
2968 .args(["--cmdline", DIRECT_KERNEL_BOOT_CMDLINE]) in test_pci_multiple_segments()
2970 "--platform", in test_pci_multiple_segments()
2974 "--disk", in test_pci_multiple_segments()
2994 let grep_cmd = "lspci | grep \"Host bridge\" | wc -l"; in test_pci_multiple_segments()
3011 .ssh_command("lsblk | grep vdc | grep -c 4M") in test_pci_multiple_segments()
3019 // Mount the device. in test_pci_multiple_segments()
3022 .ssh_command("sudo mount -o rw -t ext4 /dev/vdc mount_image/") in test_pci_multiple_segments()
3027 // Write something to the device. in test_pci_multiple_segments()
3032 // Check the content of the block device. The file "foo" should in test_pci_multiple_segments()
3059 // Prepare another disk file for the virtio-disk device in test_pci_multiple_segments_numa_node()
3064 .join("test-disk.raw") in test_pci_multiple_segments_numa_node()
3069 exec_host_command_status(format!("truncate {test_disk_path} -s 4M").as_str()).success() in test_pci_multiple_segments_numa_node()
3075 .args(["--platform", "num_pci_segments=2"]) in test_pci_multiple_segments_numa_node()
3076 .args(["--cpus", "boot=2"]) in test_pci_multiple_segments_numa_node()
3077 .args(["--memory", "size=0"]) in test_pci_multiple_segments_numa_node()
3078 .args(["--memory-zone", "id=mem0,size=256M", "id=mem1,size=256M"]) in test_pci_multiple_segments_numa_node()
3080 "--numa", in test_pci_multiple_segments_numa_node()
3084 .args(["--kernel", kernel_path.to_str().unwrap()]) in test_pci_multiple_segments_numa_node()
3085 .args(["--cmdline", DIRECT_KERNEL_BOOT_CMDLINE]) in test_pci_multiple_segments_numa_node()
3086 .args(["--api-socket", &api_socket]) in test_pci_multiple_segments_numa_node()
3089 "--disk", in test_pci_multiple_segments_numa_node()
3106 let cmd = "cat /sys/block/vdc/device/../numa_node"; in test_pci_multiple_segments_numa_node()
3136 .args(["--cpus", "boot=1"]) in test_direct_kernel_boot()
3137 .args(["--memory", "size=512M"]) in test_direct_kernel_boot()
3138 .args(["--kernel", kernel_path.to_str().unwrap()]) in test_direct_kernel_boot()
3139 .args(["--cmdline", DIRECT_KERNEL_BOOT_CMDLINE]) in test_direct_kernel_boot()
3153 "grep -c PCI-MSI /proc/interrupts" in test_direct_kernel_boot()
3155 "grep -c ITS-PCI-MSIX /proc/interrupts" in test_direct_kernel_boot()
3183 kernel_path.push("bzImage-x86_64"); in test_direct_kernel_boot_bzimage()
3186 .args(["--cpus", "boot=1"]) in test_direct_kernel_boot_bzimage()
3187 .args(["--memory", "size=512M"]) in test_direct_kernel_boot_bzimage()
3188 .args(["--kernel", kernel_path.to_str().unwrap()]) in test_direct_kernel_boot_bzimage()
3189 .args(["--cmdline", DIRECT_KERNEL_BOOT_CMDLINE]) in test_direct_kernel_boot_bzimage()
3203 "grep -c PCI-MSI /proc/interrupts" in test_direct_kernel_boot_bzimage()
3205 "grep -c ITS-PCI-MSIX /proc/interrupts" in test_direct_kernel_boot_bzimage()
3237 .args(["--cpus", "boot=4"]) in _test_virtio_block()
3238 .args(["--memory", "size=512M,shared=on"]) in _test_virtio_block()
3239 .args(["--kernel", kernel_path.to_str().unwrap()]) in _test_virtio_block()
3240 .args(["--cmdline", DIRECT_KERNEL_BOOT_CMDLINE]) in _test_virtio_block()
3242 "--disk", in _test_virtio_block()
3272 .ssh_command("lsblk | grep vdc | grep -c 16M") in _test_virtio_block()
3294 .ssh_command("ls -ll /sys/block/vdc/mq | grep ^d | wc -l") in _test_virtio_block()
3345 std::process::Command::new("qemu-img") in test_virtio_block_vhd()
3347 .arg("-p") in test_virtio_block_vhd()
3348 .args(["-f", "raw"]) in test_virtio_block_vhd()
3349 .args(["-O", "vpc"]) in test_virtio_block_vhd()
3350 .args(["-o", "subformat=fixed"]) in test_virtio_block_vhd()
3370 std::process::Command::new("qemu-img") in test_virtio_block_vhdx()
3372 .arg("-p") in test_virtio_block_vhdx()
3373 .args(["-f", "raw"]) in test_virtio_block_vhdx()
3374 .args(["-O", "vhdx"]) in test_virtio_block_vhdx()
3398 std::process::Command::new("qemu-img") in test_virtio_block_dynamic_vhdx_expand()
3400 .args(["-f", "vhdx"]) in test_virtio_block_dynamic_vhdx_expand()
3414 .args(["--cpus", "boot=1"]) in test_virtio_block_dynamic_vhdx_expand()
3415 .args(["--memory", "size=512M"]) in test_virtio_block_dynamic_vhdx_expand()
3416 .args(["--kernel", kernel_path.to_str().unwrap()]) in test_virtio_block_dynamic_vhdx_expand()
3417 .args(["--cmdline", DIRECT_KERNEL_BOOT_CMDLINE]) in test_virtio_block_dynamic_vhdx_expand()
3419 "--disk", in test_virtio_block_dynamic_vhdx_expand()
3443 .ssh_command("lsblk | grep vdc | grep -c 100M") in test_virtio_block_dynamic_vhdx_expand()
3466 fn vhdx_image_size(disk_name: &str) -> u64 { in vhdx_image_size()
3493 .args(["--cpus", "boot=1"]) in test_virtio_block_direct_and_firmware()
3494 .args(["--memory", "size=512M"]) in test_virtio_block_direct_and_firmware()
3495 .args(["--kernel", fw_path(FwType::RustHypervisorFirmware).as_str()]) in test_virtio_block_direct_and_firmware()
3497 "--disk", in test_virtio_block_direct_and_firmware()
3539 Some("vunet-tap0"), in test_vhost_user_net_existing_tap()
3555 Some("vunet-tap1"), in test_vhost_user_net_tap_multiple_queues()
3603 .args(["--cpus", "boot=1"]) in test_split_irqchip()
3604 .args(["--memory", "size=512M"]) in test_split_irqchip()
3605 .args(["--kernel", direct_kernel_boot_path().to_str().unwrap()]) in test_split_irqchip()
3606 .args(["--cmdline", DIRECT_KERNEL_BOOT_CMDLINE]) in test_split_irqchip()
3618 .ssh_command("grep -c IO-APIC.*timer /proc/interrupts || true") in test_split_irqchip()
3627 .ssh_command("grep -c IO-APIC.*cascade /proc/interrupts || true") in test_split_irqchip()
3649 .args(["--cpus", "boot=1"]) in test_dmi_serial_number()
3650 .args(["--memory", "size=512M"]) in test_dmi_serial_number()
3651 .args(["--kernel", direct_kernel_boot_path().to_str().unwrap()]) in test_dmi_serial_number()
3652 .args(["--cmdline", DIRECT_KERNEL_BOOT_CMDLINE]) in test_dmi_serial_number()
3653 .args(["--platform", "serial_number=a=b;c=d"]) in test_dmi_serial_number()
3685 .args(["--cpus", "boot=1"]) in test_dmi_uuid()
3686 .args(["--memory", "size=512M"]) in test_dmi_uuid()
3687 .args(["--kernel", direct_kernel_boot_path().to_str().unwrap()]) in test_dmi_uuid()
3688 .args(["--cmdline", DIRECT_KERNEL_BOOT_CMDLINE]) in test_dmi_uuid()
3689 .args(["--platform", "uuid=1e8aa28a-435d-4027-87f4-40dceff1fa0a"]) in test_dmi_uuid()
3704 "1e8aa28a-435d-4027-87f4-40dceff1fa0a" in test_dmi_uuid()
3726 .args(["--cpus", "boot=1"]) in test_dmi_oem_strings()
3727 .args(["--memory", "size=512M"]) in test_dmi_oem_strings()
3728 .args(["--kernel", direct_kernel_boot_path().to_str().unwrap()]) in test_dmi_oem_strings()
3729 .args(["--cmdline", DIRECT_KERNEL_BOOT_CMDLINE]) in test_dmi_oem_strings()
3730 .args(["--platform", &oem_strings]) in test_dmi_oem_strings()
3742 .ssh_command("sudo dmidecode --oem-string count") in test_dmi_oem_strings()
3750 .ssh_command("sudo dmidecode --oem-string 1") in test_dmi_oem_strings()
3758 .ssh_command("sudo dmidecode --oem-string 2") in test_dmi_oem_strings()
3811 .args(["--cpus", "boot=1"]) in test_boot_from_virtio_pmem()
3812 .args(["--memory", "size=512M"]) in test_boot_from_virtio_pmem()
3813 .args(["--kernel", kernel_path.to_str().unwrap()]) in test_boot_from_virtio_pmem()
3815 "--disk", in test_boot_from_virtio_pmem()
3824 "--pmem", in test_boot_from_virtio_pmem()
3835 "--cmdline", in test_boot_from_virtio_pmem()
3866 .args(["--cpus", "boot=1"]) in test_multiple_network_interfaces()
3867 .args(["--memory", "size=512M"]) in test_multiple_network_interfaces()
3868 .args(["--kernel", kernel_path.to_str().unwrap()]) in test_multiple_network_interfaces()
3869 .args(["--cmdline", DIRECT_KERNEL_BOOT_CMDLINE]) in test_multiple_network_interfaces()
3872 "--net", in test_multiple_network_interfaces()
3884 let tap_count = exec_host_command_output("ip link | grep -c mytap1"); in test_multiple_network_interfaces()
3890 .ssh_command("ip -o link | wc -l") in test_multiple_network_interfaces()
3911 .args(["--cpus", "boot=1"]) in test_pmu_on()
3912 .args(["--memory", "size=512M"]) in test_pmu_on()
3913 .args(["--kernel", direct_kernel_boot_path().to_str().unwrap()]) in test_pmu_on()
3914 .args(["--cmdline", DIRECT_KERNEL_BOOT_CMDLINE]) in test_pmu_on()
3947 .args(["--cpus", "boot=1"]) in test_serial_off()
3948 .args(["--memory", "size=512M"]) in test_serial_off()
3949 .args(["--kernel", direct_kernel_boot_path().to_str().unwrap()]) in test_serial_off()
3950 .args(["--cmdline", DIRECT_KERNEL_BOOT_CMDLINE]) in test_serial_off()
3953 .args(["--serial", "off"]) in test_serial_off()
3989 cmd.args(["--cpus", "boot=1"]) in test_serial_null()
3990 .args(["--memory", "size=512M"]) in test_serial_null()
3991 .args(["--kernel", direct_kernel_boot_path().to_str().unwrap()]) in test_serial_null()
3993 "--cmdline", in test_serial_null()
4000 .args(["--serial", "null"]) in test_serial_null()
4001 .args(["--console", "off"]) in test_serial_null()
4045 .args(["--cpus", "boot=1"]) in test_serial_tty()
4046 .args(["--memory", "size=512M"]) in test_serial_tty()
4047 .args(["--kernel", kernel_path.to_str().unwrap()]) in test_serial_tty()
4049 "--cmdline", in test_serial_tty()
4056 .args(["--serial", "tty"]) in test_serial_tty()
4057 .args(["--console", "off"]) in test_serial_tty()
4096 let serial_path = guest.tmp_dir.as_path().join("serial-output"); in test_serial_file()
4103 .args(["--cpus", "boot=1"]) in test_serial_file()
4104 .args(["--memory", "size=512M"]) in test_serial_file()
4105 .args(["--kernel", direct_kernel_boot_path().to_str().unwrap()]) in test_serial_file()
4107 "--cmdline", in test_serial_file()
4115 "--serial", in test_serial_file()
4136 guest.ssh_command("sudo shutdown -h now").unwrap(); in test_serial_file()
4145 // Check that the cloud-hypervisor binary actually terminated in test_serial_file()
4172 .args(["--cpus", "boot=1"]) in test_pty_interaction()
4173 .args(["--memory", "size=512M"]) in test_pty_interaction()
4174 .args(["--kernel", direct_kernel_boot_path().to_str().unwrap()]) in test_pty_interaction()
4175 .args(["--cmdline", &cmdline]) in test_pty_interaction()
4178 .args(["--serial", "null"]) in test_pty_interaction()
4179 .args(["--console", "pty"]) in test_pty_interaction()
4180 .args(["--api-socket", &api_socket]) in test_pty_interaction()
4190 guest.ssh_command("sudo shutdown -h now").unwrap(); in test_pty_interaction()
4199 // Check that the cloud-hypervisor binary actually terminated in test_pty_interaction()
4219 .args(["--cpus", "boot=1"]) in test_serial_socket_interaction()
4220 .args(["--memory", "size=512M"]) in test_serial_socket_interaction()
4221 .args(["--kernel", direct_kernel_boot_path().to_str().unwrap()]) in test_serial_socket_interaction()
4222 .args(["--cmdline", &cmdline]) in test_serial_socket_interaction()
4225 .args(["--console", "null"]) in test_serial_socket_interaction()
4227 "--serial", in test_serial_socket_interaction()
4240 &format!("UNIX-CONNECT:{}", serial_socket.display()), in test_serial_socket_interaction()
4255 guest.ssh_command("sudo shutdown -h now").unwrap(); in test_serial_socket_interaction()
4264 // Check that the cloud-hypervisor binary actually terminated in test_serial_socket_interaction()
4283 .args(["--cpus", "boot=1"]) in test_virtio_console()
4284 .args(["--memory", "size=512M"]) in test_virtio_console()
4285 .args(["--kernel", kernel_path.to_str().unwrap()]) in test_virtio_console()
4286 .args(["--cmdline", DIRECT_KERNEL_BOOT_CMDLINE]) in test_virtio_console()
4289 .args(["--console", "tty"]) in test_virtio_console()
4290 .args(["--serial", "null"]) in test_virtio_console()
4324 let console_path = guest.tmp_dir.as_path().join("console-output"); in test_console_file()
4326 .args(["--cpus", "boot=1"]) in test_console_file()
4327 .args(["--memory", "size=512M"]) in test_console_file()
4328 .args(["--kernel", direct_kernel_boot_path().to_str().unwrap()]) in test_console_file()
4329 .args(["--cmdline", DIRECT_KERNEL_BOOT_CMDLINE]) in test_console_file()
4333 "--console", in test_console_file()
4342 guest.ssh_command("sudo shutdown -h now").unwrap(); in test_console_file()
4349 // Check that the cloud-hypervisor binary actually terminated in test_console_file()
4372 // The VFIO integration test starts cloud-hypervisor guest with 3 TAP
4374 // So if the nested cloud-hypervisor succeeds in getting a directly
4375 // assigned interface from its cloud-hypervisor host, we should be able to
4377 // line (We tag the command line from cloud-hypervisor for that purpose).
4378 // The third device is added to validate that hotplug works correctly since
4380 // Also, we pass-through a virtio-blk device to the L2 VM to test the 32-bit
4381 // vfio device support
4400 // cloud-hypervisor guest to use. in test_vfio()
4405 .expect("copying of cloud-init disk failed"); in test_vfio()
4412 .arg("-d") in test_vfio()
4426 let vfio_tap0 = "vfio-tap0"; in test_vfio()
4427 let vfio_tap1 = "vfio-tap1"; in test_vfio()
4428 let vfio_tap2 = "vfio-tap2"; in test_vfio()
4429 let vfio_tap3 = "vfio-tap3"; in test_vfio()
4432 .args(["--cpus", "boot=4"]) in test_vfio()
4433 .args(["--memory", "size=2G,hugepages=on,shared=on"]) in test_vfio()
4434 .args(["--kernel", kernel_path.to_str().unwrap()]) in test_vfio()
4436 "--disk", in test_vfio()
4451 "--cmdline", in test_vfio()
4453 … "{DIRECT_KERNEL_BOOT_CMDLINE} kvm-intel.nested=1 vfio_iommu_type1.allow_unsafe_interrupts" in test_vfio()
4458 "--net", in test_vfio()
4497 // Let's also verify from the second virtio-net device passed to in test_vfio()
4521 // Hotplug an extra virtio-net device through L2 VM. in test_vfio()
4528 .ssh_command_l1("echo 0000:00:09.0 | sudo tee /sys/bus/pci/drivers/vfio-pci/bind") in test_vfio()
4532 "sudo /mnt/ch-remote \ in test_vfio()
4533 --api-socket=/tmp/ch_api.sock \ in test_vfio()
4534 add-device path=/sys/bus/pci/devices/0000:00:09.0,id=vfio123", in test_vfio()
4545 // Let's also verify from the third virtio-net device passed to in test_vfio()
4546 // the L2 VM. This third device has been hotplugged through the L2 in test_vfio()
4555 // There should be one more device than before, raising the count in test_vfio()
4565 // Let's now verify that we can correctly remove the virtio-net in test_vfio()
4566 // device through the "remove-device" command responsible for in test_vfio()
4570 "sudo /mnt/ch-remote \ in test_vfio()
4571 --api-socket=/tmp/ch_api.sock \ in test_vfio()
4572 remove-device vfio123", in test_vfio()
4588 // up as expected. In order to check, we will use the virtio-net in test_vfio()
4589 // device already passed through L2 as a VFIO device, this will in test_vfio()
4594 "sudo bash -c 'echo online > /sys/devices/system/memory/auto_online_blocks'", in test_vfio()
4599 "sudo /mnt/ch-remote \ in test_vfio()
4600 --api-socket=/tmp/ch_api.sock \ in test_vfio()
4601 resize --memory=1073741824", in test_vfio()
4623 .args(["--cpus", "boot=1"]) in test_direct_kernel_boot_noacpi()
4624 .args(["--memory", "size=512M"]) in test_direct_kernel_boot_noacpi()
4625 .args(["--kernel", kernel_path.to_str().unwrap()]) in test_direct_kernel_boot_noacpi()
4627 "--cmdline", in test_direct_kernel_boot_noacpi()
4700 // By removing a device from the PCI tree, and then rescanning the tree,
4701 // Linux consistently chooses to reorganize the PCI device BARs to other
4703 // This test creates a dedicated PCI network device to be checked as being
4716 .args(["--cpus", "boot=1"]) in test_pci_bar_reprogramming()
4717 .args(["--memory", "size=512M"]) in test_pci_bar_reprogramming()
4718 .args(["--kernel", kernel_path.to_str().unwrap()]) in test_pci_bar_reprogramming()
4719 .args(["--cmdline", DIRECT_KERNEL_BOOT_CMDLINE]) in test_pci_bar_reprogramming()
4722 "--net", in test_pci_bar_reprogramming()
4736 .ssh_command("ip -o link | wc -l") in test_pci_bar_reprogramming()
4750 // Remove the PCI device in test_pci_bar_reprogramming()
4758 .ssh_command("ip -o link | wc -l") in test_pci_bar_reprogramming()
4766 // Remove the PCI device in test_pci_bar_reprogramming()
4774 .ssh_command("ip -o link | wc -l") in test_pci_bar_reprogramming()
4788 // Let's compare the BAR addresses for our virtio-net device. in test_pci_bar_reprogramming()
4815 .args(["--cpus", "boot=2,max=4"]) in test_cpu_hotplug()
4816 .args(["--memory", "size=512M"]) in test_cpu_hotplug()
4817 .args(["--kernel", kernel_path.to_str().unwrap()]) in test_cpu_hotplug()
4818 .args(["--cmdline", DIRECT_KERNEL_BOOT_CMDLINE]) in test_cpu_hotplug()
4821 .args(["--api-socket", &api_socket]) in test_cpu_hotplug()
4903 .args(["--cpus", "boot=2,max=4"]) in test_memory_hotplug()
4904 .args(["--memory", "size=512M,hotplug_size=8192M"]) in test_memory_hotplug()
4905 .args(["--kernel", kernel_path.to_str().unwrap()]) in test_memory_hotplug()
4906 .args(["--cmdline", DIRECT_KERNEL_BOOT_CMDLINE]) in test_memory_hotplug()
4909 .args(["--balloon", "size=0"]) in test_memory_hotplug()
4910 .args(["--api-socket", &api_socket]) in test_memory_hotplug()
4922 // Add RAM to the VM in test_memory_hotplug()
4941 // Use balloon add RAM to the VM in test_memory_hotplug()
4951 // Add RAM to the VM in test_memory_hotplug()
4984 .args(["--cpus", "boot=2,max=4"]) in test_virtio_mem()
4986 "--memory", in test_virtio_mem()
4987 "size=512M,hotplug_method=virtio-mem,hotplug_size=8192M", in test_virtio_mem()
4989 .args(["--kernel", kernel_path.to_str().unwrap()]) in test_virtio_mem()
4990 .args(["--cmdline", DIRECT_KERNEL_BOOT_CMDLINE]) in test_virtio_mem()
4993 .args(["--api-socket", &api_socket]) in test_virtio_mem()
5005 // Add RAM to the VM in test_virtio_mem()
5012 // Add RAM to the VM in test_virtio_mem()
5059 .args(["--cpus", "boot=2,max=4"]) in test_resize()
5060 .args(["--memory", "size=512M,hotplug_size=8192M"]) in test_resize()
5061 .args(["--kernel", kernel_path.to_str().unwrap()]) in test_resize()
5062 .args(["--cmdline", DIRECT_KERNEL_BOOT_CMDLINE]) in test_resize()
5065 .args(["--api-socket", &api_socket]) in test_resize()
5120 .args(["--cpus", "boot=1"]) in test_memory_overhead()
5121 .args(["--memory", format!("size={guest_memory_size_kb}K").as_str()]) in test_memory_overhead()
5122 .args(["--kernel", kernel_path.to_str().unwrap()]) in test_memory_overhead()
5123 .args(["--cmdline", DIRECT_KERNEL_BOOT_CMDLINE]) in test_memory_overhead()
5147 // the path for the hotplug disk is not pre-added to Landlock rules, this
5161 .args(["--api-socket", &api_socket]) in test_landlock()
5162 .args(["--cpus", "boot=1"]) in test_landlock()
5163 .args(["--memory", "size=512M"]) in test_landlock()
5164 .args(["--kernel", kernel_path.to_str().unwrap()]) in test_landlock()
5165 .args(["--cmdline", DIRECT_KERNEL_BOOT_CMDLINE]) in test_landlock()
5166 .args(["--landlock"]) in test_landlock()
5179 .ssh_command("lsblk | grep -c vdc.*16M || true") in test_landlock()
5187 // Now let's add the extra disk. in test_landlock()
5191 // As the path to the hotplug disk is not pre-added, this remote in test_landlock()
5195 "add-disk", in test_landlock()
5229 cmd.args(["--landlock"]).args([ in _test_disk_hotplug()
5230 "--landlock-rules", in _test_disk_hotplug()
5235 cmd.args(["--api-socket", &api_socket]) in _test_disk_hotplug()
5236 .args(["--cpus", "boot=1"]) in _test_disk_hotplug()
5237 .args(["--memory", "size=512M"]) in _test_disk_hotplug()
5238 .args(["--kernel", kernel_path.to_str().unwrap()]) in _test_disk_hotplug()
5239 .args(["--cmdline", DIRECT_KERNEL_BOOT_CMDLINE]) in _test_disk_hotplug()
5252 .ssh_command("lsblk | grep -c vdc.*16M || true") in _test_disk_hotplug()
5260 // Now let's add the extra disk. in _test_disk_hotplug()
5263 "add-disk", in _test_disk_hotplug()
5281 .ssh_command("lsblk | grep vdc | grep -c 16M") in _test_disk_hotplug()
5288 // And check the block device can be read. in _test_disk_hotplug()
5294 assert!(remote_command(&api_socket, "remove-device", Some("test0"))); in _test_disk_hotplug()
5299 .ssh_command("lsblk | grep -c vdc.*16M || true") in _test_disk_hotplug()
5307 // And add it back to validate unplug did work correctly. in _test_disk_hotplug()
5310 "add-disk", in _test_disk_hotplug()
5328 .ssh_command("lsblk | grep vdc | grep -c 16M") in _test_disk_hotplug()
5335 // And check the block device can be read. in _test_disk_hotplug()
5346 .ssh_command("lsblk | grep vdc | grep -c 16M") in _test_disk_hotplug()
5354 assert!(remote_command(&api_socket, "remove-device", Some("test0"))); in _test_disk_hotplug()
5358 // Check device has gone away in _test_disk_hotplug()
5361 .ssh_command("lsblk | grep -c vdc.*16M || true") in _test_disk_hotplug()
5371 // Check device still absent in _test_disk_hotplug()
5374 .ssh_command("lsblk | grep -c vdc.*16M || true") in _test_disk_hotplug()
5400 fn create_loop_device(backing_file_path: &str, block_size: u32, num_retries: usize) -> String { in create_loop_device()
5403 const LOOP_CTL_PATH: &str = "/dev/loop-control"; in create_loop_device()
5424 fn default() -> Self { in create_loop_device()
5452 // Open loop-control device in create_loop_device()
5459 // Request a free loop device in create_loop_device()
5464 panic!("Couldn't find a free loop device"); in create_loop_device()
5467 // Create loop device path in create_loop_device()
5470 // Open loop device in create_loop_device()
5499 if i < num_retries - 1 { in create_loop_device()
5501 "Iteration {}: Failed to configure the loop device {}: {}", in create_loop_device()
5508 "Failed {} times trying to configure the loop device {}: {}", in create_loop_device()
5535 "qemu-img create -f raw {} 16M", in test_virtio_block_topology()
5543 panic!("qemu-img command failed\nstdout\n{stdout}\nstderr\n{stderr}"); in test_virtio_block_topology()
5549 .args(["--cpus", "boot=1"]) in test_virtio_block_topology()
5550 .args(["--memory", "size=512M"]) in test_virtio_block_topology()
5551 .args(["--kernel", kernel_path.to_str().unwrap()]) in test_virtio_block_topology()
5552 .args(["--cmdline", DIRECT_KERNEL_BOOT_CMDLINE]) in test_virtio_block_topology()
5554 "--disk", in test_virtio_block_topology()
5575 // MIN-IO column in test_virtio_block_topology()
5578 .ssh_command("lsblk -t| grep vdc | awk '{print $3}'") in test_virtio_block_topology()
5585 // PHY-SEC column in test_virtio_block_topology()
5588 .ssh_command("lsblk -t| grep vdc | awk '{print $5}'") in test_virtio_block_topology()
5595 // LOG-SEC column in test_virtio_block_topology()
5598 .ssh_command("lsblk -t| grep vdc | awk '{print $6}'") in test_virtio_block_topology()
5613 .args(["-d", &loop_dev]) in test_virtio_block_topology()
5615 .expect("loop device not found"); in test_virtio_block_topology()
5629 .args(["--api-socket", &api_socket]) in test_virtio_balloon_deflate_on_oom()
5630 .args(["--cpus", "boot=1"]) in test_virtio_balloon_deflate_on_oom()
5631 .args(["--memory", "size=4G"]) in test_virtio_balloon_deflate_on_oom()
5632 .args(["--kernel", kernel_path.to_str().unwrap()]) in test_virtio_balloon_deflate_on_oom()
5633 .args(["--cmdline", DIRECT_KERNEL_BOOT_CMDLINE]) in test_virtio_balloon_deflate_on_oom()
5634 .args(["--balloon", "size=2G,deflate_on_oom=on"]) in test_virtio_balloon_deflate_on_oom()
5645 // The virtio-balloon driver might take a few seconds to report the in test_virtio_balloon_deflate_on_oom()
5656 .ssh_command("echo f | sudo tee /proc/sysrq-trigger") in test_virtio_balloon_deflate_on_oom()
5684 .args(["--cpus", "boot=1"]) in test_virtio_balloon_free_page_reporting()
5685 .args(["--memory", "size=4G"]) in test_virtio_balloon_free_page_reporting()
5686 .args(["--kernel", direct_kernel_boot_path().to_str().unwrap()]) in test_virtio_balloon_free_page_reporting()
5687 .args(["--cmdline", DIRECT_KERNEL_BOOT_CMDLINE]) in test_virtio_balloon_free_page_reporting()
5688 .args(["--balloon", "size=0,free_page_reporting=on"]) in test_virtio_balloon_free_page_reporting()
5709 "stress --vm 1 --vm-bytes 2G --vm-keep --timeout 60", in test_virtio_balloon_free_page_reporting()
5726 // through the virtio-balloon device. We expect the RSS to be under in test_virtio_balloon_free_page_reporting()
5767 cmd.args(["--api-socket", &api_socket]) in _test_pmem_hotplug()
5768 .args(["--cpus", "boot=1"]) in _test_pmem_hotplug()
5769 .args(["--memory", "size=512M"]) in _test_pmem_hotplug()
5770 .args(["--kernel", kernel_path.to_str().unwrap()]) in _test_pmem_hotplug()
5771 .args(["--cmdline", DIRECT_KERNEL_BOOT_CMDLINE]) in _test_pmem_hotplug()
5778 "--platform", in _test_pmem_hotplug()
5791 .ssh_command("lsblk | grep -c pmem0 || true") in _test_pmem_hotplug()
5803 "add-pmem", in _test_pmem_hotplug()
5827 .ssh_command("lsblk | grep pmem0 | grep -c 128M") in _test_pmem_hotplug()
5840 .ssh_command("lsblk | grep pmem0 | grep -c 128M") in _test_pmem_hotplug()
5848 assert!(remote_command(&api_socket, "remove-device", Some("test0"))); in _test_pmem_hotplug()
5852 // Check device has gone away in _test_pmem_hotplug()
5855 .ssh_command("lsblk | grep -c pmem0.*128M || true") in _test_pmem_hotplug()
5868 .ssh_command("lsblk | grep -c pmem0.*128M || true") in _test_pmem_hotplug()
5907 cmd.args(["--api-socket", &api_socket]) in _test_net_hotplug()
5908 .args(["--cpus", "boot=1"]) in _test_net_hotplug()
5909 .args(["--memory", "size=512M"]) in _test_net_hotplug()
5910 .args(["--kernel", kernel_path.to_str().unwrap()]) in _test_net_hotplug()
5911 .args(["--cmdline", DIRECT_KERNEL_BOOT_CMDLINE]) in _test_net_hotplug()
5917 "--platform", in _test_net_hotplug()
5927 // Add network in _test_net_hotplug()
5930 "add-net", in _test_net_hotplug()
5960 .ssh_command("ip -o link | wc -l") in _test_net_hotplug()
5969 assert!(remote_command(&api_socket, "remove-device", Some("test0"),)); in _test_net_hotplug()
5974 "add-net", in _test_net_hotplug()
6004 .ssh_command("ip -o link | wc -l") in _test_net_hotplug()
6018 .ssh_command("ip -o link | wc -l") in _test_net_hotplug()
6048 pvh_kernel_path.push("vmlinux-x86_64"); in test_initramfs()
6060 .args(["--kernel", k_path.to_str().unwrap()]) in test_initramfs()
6061 .args(["--initramfs", initramfs_path.to_str().unwrap()]) in test_initramfs()
6062 .args(["--cmdline", &cmdline]) in test_initramfs()
6089 cmd.args(["--cpus", "boot=1"]) in test_counters()
6090 .args(["--memory", "size=512M"]) in test_counters()
6091 .args(["--kernel", direct_kernel_boot_path().to_str().unwrap()]) in test_counters()
6092 .args(["--cmdline", DIRECT_KERNEL_BOOT_CMDLINE]) in test_counters()
6094 .args(["--net", guest.default_net_string().as_str()]) in test_counters()
6095 .args(["--api-socket", &api_socket]) in test_counters()
6128 cmd.args(["--cpus", "boot=4"]) in test_coredump()
6129 .args(["--memory", "size=4G"]) in test_coredump()
6130 .args(["--kernel", fw_path(FwType::RustHypervisorFirmware).as_str()]) in test_coredump()
6132 .args(["--net", guest.default_net_string().as_str()]) in test_coredump()
6133 .args(["--api-socket", &api_socket]) in test_coredump()
6152 format!("readelf --all {vmcore_file} |grep CORE |grep -v Type |wc -l"); in test_coredump()
6157 let readelf_vmm_num_cmd = format!("readelf --all {vmcore_file} |grep QEMU |wc -l"); in test_coredump()
6176 cmd.args(["--cpus", "boot=4"]) in test_coredump_no_pause()
6177 .args(["--memory", "size=4G"]) in test_coredump_no_pause()
6178 .args(["--kernel", fw_path(FwType::RustHypervisorFirmware).as_str()]) in test_coredump_no_pause()
6180 .args(["--net", guest.default_net_string().as_str()]) in test_coredump_no_pause()
6181 .args(["--api-socket", &api_socket]) in test_coredump_no_pause()
6215 cmd.args(["--cpus", "boot=1"]) in test_watchdog()
6216 .args(["--memory", "size=512M"]) in test_watchdog()
6217 .args(["--kernel", kernel_path.to_str().unwrap()]) in test_watchdog()
6218 .args(["--cmdline", DIRECT_KERNEL_BOOT_CMDLINE]) in test_watchdog()
6220 .args(["--net", guest.default_net_string().as_str()]) in test_watchdog()
6221 .args(["--watchdog"]) in test_watchdog()
6222 .args(["--api-socket", &api_socket]) in test_watchdog()
6223 .args(["--event-monitor", format!("path={event_path}").as_str()]) in test_watchdog()
6239 .ssh_command("sudo journalctl | grep -c -- \"Watchdog started\"") in test_watchdog()
6253 …guest.ssh_command("screen -dmS reboot sh -c \"sleep 5; echo s | tee /proc/sysrq-trigger; echo c | … in test_watchdog()
6298 cmd.args(["--cpus", "boot=1"]) in test_pvpanic()
6299 .args(["--memory", "size=512M"]) in test_pvpanic()
6300 .args(["--kernel", kernel_path.to_str().unwrap()]) in test_pvpanic()
6301 .args(["--cmdline", DIRECT_KERNEL_BOOT_CMDLINE]) in test_pvpanic()
6303 .args(["--net", guest.default_net_string().as_str()]) in test_pvpanic()
6304 .args(["--pvpanic"]) in test_pvpanic()
6305 .args(["--api-socket", &api_socket]) in test_pvpanic()
6306 .args(["--event-monitor", format!("path={event_path}").as_str()]) in test_pvpanic()
6342 // Create a TAP interface with multi-queue enabled in test_tap_from_fd()
6360 .args(["--cpus", &format!("boot={num_queue_pairs}")]) in test_tap_from_fd()
6361 .args(["--memory", "size=512M"]) in test_tap_from_fd()
6362 .args(["--kernel", kernel_path.to_str().unwrap()]) in test_tap_from_fd()
6363 .args(["--cmdline", DIRECT_KERNEL_BOOT_CMDLINE]) in test_tap_from_fd()
6366 "--net", in test_tap_from_fd()
6384 .ssh_command("ip -o link | wc -l") in test_tap_from_fd()
6396 .ssh_command("ip -o link | wc -l") in test_tap_from_fd()
6434 "sudo ip link add link {phy_net} name {guest_macvtap_name} type macvtap mod bridge" in _test_macvtap()
6461 "sudo ip link add link {phy_net} name {host_macvtap_name} type macvtap mod bridge" in _test_macvtap()
6466 "sudo ip address add {}/24 dev {}", in _test_macvtap()
6477 .args(["--cpus", "boot=2"]) in _test_macvtap()
6478 .args(["--memory", "size=512M"]) in _test_macvtap()
6479 .args(["--kernel", kernel_path.to_str().unwrap()]) in _test_macvtap()
6480 .args(["--cmdline", DIRECT_KERNEL_BOOT_CMDLINE]) in _test_macvtap()
6482 .args(["--api-socket", &api_socket]); in _test_macvtap()
6490 guest_command.args(["--net", &net_params]); in _test_macvtap()
6498 // call to ch-remote from failing. in _test_macvtap()
6500 // Hotplug the virtio-net device in _test_macvtap()
6502 remote_command_w_output(&api_socket, "add-net", Some(&net_params)); in _test_macvtap()
6512 // The functional connectivity provided by the virtio-net device in _test_macvtap()
6520 .ssh_command("ip -o link | wc -l") in _test_macvtap()
6532 .ssh_command("ip -o link | wc -l") in _test_macvtap()
6581 assert!(exec_host_command_status("ovs-vsctl del-port vhost-user1").success()); in test_ovs_dpdk()
6587 "nc -l 12345", in test_ovs_dpdk()
6599 guest2.ssh_command("nc -vz 172.100.0.1 12345").unwrap_err(); in test_ovs_dpdk()
6601 // Add the OVS port back in test_ovs_dpdk()
6602 …t_command_status("ovs-vsctl add-port ovsbr0 vhost-user1 -- set Interface vhost-user1 type=dpdkvhos… in test_ovs_dpdk()
6605 guest2.ssh_command("nc -vz 172.100.0.1 12345").unwrap(); in test_ovs_dpdk()
6626 // Remove the vhost-user socket file. in test_ovs_dpdk()
6628 .arg("-f") in test_ovs_dpdk()
6636 .args(["--api-socket", &api_socket_restored]) in test_ovs_dpdk()
6638 "--restore", in test_ovs_dpdk()
6656 "nc -l 12345", in test_ovs_dpdk()
6668 guest2.ssh_command("nc -vz 172.100.0.1 12345").unwrap(); in test_ovs_dpdk()
6682 fn setup_spdk_nvme(nvme_dir: &std::path::Path) -> Child { in setup_spdk_nvme()
6686 "mkdir -p {}", in setup_spdk_nvme()
6687 nvme_dir.join("nvme-vfio-user").to_str().unwrap() in setup_spdk_nvme()
6691 "truncate {} -s 128M", in setup_spdk_nvme()
6692 nvme_dir.join("test-disk.raw").to_str().unwrap() in setup_spdk_nvme()
6697 nvme_dir.join("test-disk.raw").to_str().unwrap() in setup_spdk_nvme()
6701 // Start the SPDK nvmf_tgt daemon to present NVMe device as a VFIO user device in setup_spdk_nvme()
6702 let child = Command::new("/usr/local/bin/spdk-nvme/nvmf_tgt") in setup_spdk_nvme()
6703 .args(["-i", "0", "-m", "0x1"]) in setup_spdk_nvme()
6709 "/usr/local/bin/spdk-nvme/rpc.py nvmf_create_transport -t VFIOUSER", in setup_spdk_nvme()
6714 "/usr/local/bin/spdk-nvme/rpc.py bdev_aio_create {} test 512", in setup_spdk_nvme()
6715 nvme_dir.join("test-disk.raw").to_str().unwrap() in setup_spdk_nvme()
6719 … "/usr/local/bin/spdk-nvme/rpc.py nvmf_create_subsystem nqn.2019-07.io.spdk:cnode -a -s test" in setup_spdk_nvme()
6723 "/usr/local/bin/spdk-nvme/rpc.py nvmf_subsystem_add_ns nqn.2019-07.io.spdk:cnode test" in setup_spdk_nvme()
6727 …"/usr/local/bin/spdk-nvme/rpc.py nvmf_subsystem_add_listener nqn.2019-07.io.spdk:cnode -t VFIOUSER… in setup_spdk_nvme()
6728 nvme_dir.join("nvme-vfio-user").to_str().unwrap() in setup_spdk_nvme()
6736 exec_host_command_status("pkill -f nvmf_tgt"); in cleanup_spdk_nvme()
6745 let spdk_nvme_dir = guest.tmp_dir.as_path().join("test-vfio-user"); in test_vfio_user()
6750 .args(["--api-socket", &api_socket]) in test_vfio_user()
6751 .args(["--cpus", "boot=1"]) in test_vfio_user()
6752 .args(["--memory", "size=1G,shared=on,hugepages=on"]) in test_vfio_user()
6753 .args(["--kernel", fw_path(FwType::RustHypervisorFirmware).as_str()]) in test_vfio_user()
6754 .args(["--serial", "tty", "--console", "off"]) in test_vfio_user()
6764 // Hotplug the SPDK-NVMe device to the VM in test_vfio_user()
6767 "add-user-device", in test_vfio_user()
6772 .join("nvme-vfio-user/cntrl") in test_vfio_user()
6786 .ssh_command("lsblk | grep nvme0n1 | grep -c 128M") in test_vfio_user()
6839 .args(["--cpus", "boot=2"]) in test_vdpa_block()
6840 .args(["--memory", "size=512M,hugepages=on"]) in test_vdpa_block()
6841 .args(["--kernel", kernel_path.to_str().unwrap()]) in test_vdpa_block()
6842 .args(["--cmdline", DIRECT_KERNEL_BOOT_CMDLINE]) in test_vdpa_block()
6845 .args(["--vdpa", "path=/dev/vhost-vdpa-0,num_queues=1"]) in test_vdpa_block()
6846 .args(["--platform", "num_pci_segments=2,iommu_segments=1"]) in test_vdpa_block()
6847 .args(["--api-socket", &api_socket]) in test_vdpa_block()
6858 .ssh_command("lsblk | grep vdc | grep -c 128M") in test_vdpa_block()
6866 // Check the content of the block device after we wrote to it. in test_vdpa_block()
6867 // The vpda-sim-blk should let us read what we previously wrote. in test_vdpa_block()
6869 .ssh_command("sudo bash -c 'echo foobar > /dev/vdc'") in test_vdpa_block()
6872 guest.ssh_command("sudo head -1 /dev/vdc").unwrap().trim(), in test_vdpa_block()
6876 // Hotplug an extra vDPA block device behind the vIOMMU in test_vdpa_block()
6877 // Add a new vDPA device to the VM in test_vdpa_block()
6880 "add-vdpa", in test_vdpa_block()
6881 Some("id=myvdpa0,path=/dev/vhost-vdpa-1,num_queues=1,pci_segment=1,iommu=on"), in test_vdpa_block()
6904 .ssh_command("lsblk | grep vdd | grep -c 128M") in test_vdpa_block()
6912 // Write some content to the block device we've just plugged. in test_vdpa_block()
6914 .ssh_command("sudo bash -c 'echo foobar > /dev/vdd'") in test_vdpa_block()
6919 guest.ssh_command("sudo head -1 /dev/vdd").unwrap().trim(), in test_vdpa_block()
6923 // Unplug the device in test_vdpa_block()
6924 let cmd_success = remote_command(&api_socket, "remove-device", Some("myvdpa0")); in test_vdpa_block()
6931 .ssh_command("lsblk | grep -c vdd || true") in test_vdpa_block()
6961 .args(["--cpus", "boot=2"]) in test_vdpa_net()
6962 .args(["--memory", "size=512M,hugepages=on"]) in test_vdpa_net()
6963 .args(["--kernel", kernel_path.to_str().unwrap()]) in test_vdpa_net()
6964 .args(["--cmdline", DIRECT_KERNEL_BOOT_CMDLINE]) in test_vdpa_net()
6967 .args(["--vdpa", "path=/dev/vhost-vdpa-2,num_queues=2"]) in test_vdpa_net()
6975 // Check we can find network interface related to vDPA device in test_vdpa_net()
6978 .ssh_command("ip -o link | grep -c ens6") in test_vdpa_net()
6987 .ssh_command("sudo ip addr add 172.16.1.2/24 dev ens6") in test_vdpa_net()
6994 .ssh_command("ip -j -p -s link show ens6 | grep -c '\"packets\": 0'") in test_vdpa_net()
7003 guest.ssh_command("ping 172.16.1.10 -c 6 || true").unwrap(); in test_vdpa_net()
7008 .ssh_command("ip -j -p -s link show ens6 | grep -c '\"packets\": 6'") in test_vdpa_net()
7036 .args(["--cpus", "boot=1"]) in test_tpm()
7037 .args(["--memory", "size=1G"]) in test_tpm()
7038 .args(["--kernel", fw_path(FwType::RustHypervisorFirmware).as_str()]) in test_tpm()
7039 .args(["--tpm", &format!("socket={swtpm_socket_path}")]) in test_tpm()
7054 guest.ssh_command("sudo tpm2_selftest -f").unwrap(); in test_tpm()
7085 cmd.args(["--cpus", "boot=1"]) in test_double_tty()
7086 .args(["--memory", "size=512M"]) in test_double_tty()
7087 .args(["--kernel", kernel_path.to_str().unwrap()]) in test_double_tty()
7089 "--cmdline", in test_double_tty()
7097 .args(["--serial", "tty"]) in test_double_tty()
7098 .args(["--console", "tty"]) in test_double_tty()
7099 .args(["--api-socket", &api_socket]); in test_double_tty()
7134 cmd.args(["--cpus", "boot=4"]) in test_nmi()
7135 .args(["--memory", "size=512M"]) in test_nmi()
7136 .args(["--kernel", kernel_path.to_str().unwrap()]) in test_nmi()
7137 .args(["--cmdline", cmd_line.as_str()]) in test_nmi()
7139 .args(["--net", guest.default_net_string().as_str()]) in test_nmi()
7140 .args(["--pvpanic"]) in test_nmi()
7141 .args(["--api-socket", &api_socket]) in test_nmi()
7142 .args(["--event-monitor", format!("path={event_path}").as_str()]) in test_nmi()
7175 // Start cloud-hypervisor with no VM parameters, running both the HTTP
7226 guest.ssh_command("sudo shutdown -H now").unwrap(); in test_api_dbus_and_http_interleaved()
7335 // One thing to note about this test. The virtio-net device is heavily used
7337 // verify the migration went well for virtio-net.
7364 mem_params = "size=2G,hotplug_method=virtio-mem,hotplug_size=32G" in _test_snapshot_restore()
7376 .args(["--api-socket", &api_socket_source]) in _test_snapshot_restore()
7377 .args(["--event-monitor", format!("path={event_path}").as_str()]) in _test_snapshot_restore()
7378 .args(["--cpus", "boot=4"]) in _test_snapshot_restore()
7379 .args(["--memory", mem_params]) in _test_snapshot_restore()
7380 .args(["--balloon", "size=0"]) in _test_snapshot_restore()
7381 .args(["--kernel", kernel_path.to_str().unwrap()]) in _test_snapshot_restore()
7383 "--disk", in _test_snapshot_restore()
7391 .args(["--net", net_params.as_str()]) in _test_snapshot_restore()
7392 .args(["--vsock", format!("cid=3,socket={socket}").as_str()]) in _test_snapshot_restore()
7393 .args(["--cmdline", DIRECT_KERNEL_BOOT_CMDLINE]) in _test_snapshot_restore()
7410 // Increase guest RAM with virtio-mem in _test_snapshot_restore()
7433 // Check the guest virtio-devices, e.g. block, rng, vsock, console, and net in _test_snapshot_restore()
7436 // x86_64: We check that removing and adding back the virtio-net device in _test_snapshot_restore()
7437 // does not break the snapshot/restore support for virtio-pci. in _test_snapshot_restore()
7441 // Unplug the virtio-net device in _test_snapshot_restore()
7442 // AArch64: Device hotplug is currently not supported, skipping here. in _test_snapshot_restore()
7447 "remove-device", in _test_snapshot_restore()
7452 event: "device-removed".to_string(), in _test_snapshot_restore()
7459 // Plug the virtio-net device again in _test_snapshot_restore()
7462 "add-net", in _test_snapshot_restore()
7484 .arg("-f") in _test_snapshot_restore()
7494 .args(["--api-socket", &api_socket_restored]) in _test_snapshot_restore()
7496 "--event-monitor", in _test_snapshot_restore()
7500 "--restore", in _test_snapshot_restore()
7550 // Hypervisor (e.g. the event-monitor thread). in _test_snapshot_restore()
7579 // Decrease guest RAM with virtio-mem in _test_snapshot_restore()
7646 .args(["--api-socket", &api_socket_source]) in test_snapshot_restore_with_fd()
7647 .args(["--event-monitor", format!("path={event_path}").as_str()]) in test_snapshot_restore_with_fd()
7648 .args(["--cpus", format!("boot={n_cpu}").as_str()]) in test_snapshot_restore_with_fd()
7649 .args(["--memory", "size=1G"]) in test_snapshot_restore_with_fd()
7650 .args(["--kernel", kernel_path.to_str().unwrap()]) in test_snapshot_restore_with_fd()
7652 "--disk", in test_snapshot_restore_with_fd()
7660 .args(["--net", net_params.as_str()]) in test_snapshot_restore_with_fd()
7661 .args(["--cmdline", DIRECT_KERNEL_BOOT_CMDLINE]) in test_snapshot_restore_with_fd()
7683 // Check the guest virtio-devices, e.g. block, rng, vsock, console, and net in test_snapshot_restore_with_fd()
7705 .args(["--api-socket", &api_socket_restored]) in test_snapshot_restore_with_fd()
7707 "--event-monitor", in test_snapshot_restore_with_fd()
7789 // Hypervisor (e.g. the event-monitor thread). in test_snapshot_restore_with_fd()
7840 data.push("--pvpanic"); in _test_snapshot_restore_devices()
7849 .args(["--api-socket", &api_socket_source]) in _test_snapshot_restore_devices()
7850 .args(["--event-monitor", format!("path={event_path}").as_str()]) in _test_snapshot_restore_devices()
7851 .args(["--cpus", "boot=2"]) in _test_snapshot_restore_devices()
7852 .args(["--memory", "size=1G"]) in _test_snapshot_restore_devices()
7853 .args(["--kernel", kernel_path.to_str().unwrap()]) in _test_snapshot_restore_devices()
7856 .args(["--vsock", format!("cid=3,socket={socket}").as_str()]) in _test_snapshot_restore_devices()
7857 .args(["--cmdline", DIRECT_KERNEL_BOOT_CMDLINE]) in _test_snapshot_restore_devices()
7883 .arg("-f") in _test_snapshot_restore_devices()
7893 .args(["--api-socket", &api_socket_restored]) in _test_snapshot_restore_devices()
7895 "--event-monitor", in _test_snapshot_restore_devices()
7899 "--restore", in _test_snapshot_restore_devices()
7928 // Hypervisor (e.g. the event-monitor thread). in _test_snapshot_restore_devices()
8005 fn new() -> Self { in new()
8016 fn guest(&self) -> &Guest { in guest()
8020 fn ssh_cmd(&self, cmd: &str) -> String { in ssh_cmd()
8031 fn cpu_count(&self) -> u8 { in cpu_count()
8032 …self.ssh_cmd("powershell -Command \"(Get-CimInstance win32_computersystem).NumberOfLogicalProcesso… in cpu_count()
8038 fn ram_size(&self) -> usize { in ram_size()
8039 … self.ssh_cmd("powershell -Command \"(Get-CimInstance win32_computersystem).TotalPhysicalMemory\"") in ram_size()
8045 fn netdev_count(&self) -> u8 { in netdev_count()
8046 …lf.ssh_cmd("powershell -Command \"netsh int ipv4 show interfaces | Select-String ethernet | Measur… in netdev_count()
8052 fn disk_count(&self) -> u8 { in disk_count()
8053 …self.ssh_cmd("powershell -Command \"Get-Disk | Measure-Object -Line | Format-Table -HideTableHeade… in disk_count()
8067 fn run_dnsmasq(&self) -> std::process::Child { in run_dnsmasq()
8068 let listen_address = format!("--listen-address={}", self.guest.network.host_ip); in run_dnsmasq()
8070 "--dhcp-host={},{}", in run_dnsmasq()
8074 "--dhcp-range=eth,{},{}", in run_dnsmasq()
8079 .arg("--no-daemon") in run_dnsmasq()
8080 .arg("--log-queries") in run_dnsmasq()
8082 .arg("--except-interface=lo") in run_dnsmasq()
8083 … .arg("--bind-dynamic") // Allow listening to host_ip while the interface is not ready yet. in run_dnsmasq()
8084 .arg("--conf-file=/dev/null") in run_dnsmasq()
8092 fn disk_new(&self, fs: u8, sz: usize) -> String { in disk_new()
8097 let img = PathBuf::from(format!("/tmp/test-hotplug-{id}.raw")); in disk_new()
8101 let out = Command::new("qemu-img") in disk_new()
8104 "-f", in disk_new()
8110 .expect("qemu-img command failed") in disk_new()
8114 // Associate image to a loop device in disk_new()
8116 .args(["--show", "-f", img.to_str().unwrap()]) in disk_new()
8118 .expect("failed to create loop device") in disk_new()
8138 // Disengage the loop device in disk_new()
8140 .args(["-d", loop_dev]) in disk_new()
8142 .expect("loop device not found") in disk_new()
8146 // Re-associate loop device pointing to the partition only in disk_new()
8149 "--show", in disk_new()
8150 "--offset", in disk_new()
8152 "-f", in disk_new()
8156 .expect("failed to create loop device") in disk_new()
8175 // Disengage the loop device in disk_new()
8177 .args(["-d", loop_dev]) in disk_new()
8179 .unwrap_or_else(|_| panic!("loop device '{loop_dev}' not found")) in disk_new()
8187 …let _ = self.ssh_cmd("powershell -Command \"Get-Disk | Where-Object IsOffline -eq $True | Set-Disk… in disks_set_rw()
8191 …let _ = self.ssh_cmd("powershell -Command \"Get-Disk | Where-Object IsOffline -eq $True | Set-Disk… in disks_online()
8196 "powershell -Command \"'{data}' | Set-Content -Path {fname}\"" in disk_file_put()
8200 fn disk_file_read(&self, fname: &str) -> String { in disk_file_read()
8202 "powershell -Command \"Get-Content -Path {fname}\"" in disk_file_read()
8206 fn wait_for_boot(&self) -> bool { in wait_for_boot()
8240 fn vcpu_threads_count(pid: u32) -> u8 { in vcpu_threads_count()
8241 // ps -T -p 12345 | grep vcpu | wc -l in vcpu_threads_count()
8243 .args(["-T", "-p", format!("{pid}").as_str()]) in vcpu_threads_count()
8250 fn netdev_ctrl_threads_count(pid: u32) -> u8 { in netdev_ctrl_threads_count()
8251 // ps -T -p 12345 | grep "_net[0-9]*_ctrl" | wc -l in netdev_ctrl_threads_count()
8253 .args(["-T", "-p", format!("{pid}").as_str()]) in netdev_ctrl_threads_count()
8264 fn disk_ctrl_threads_count(pid: u32) -> u8 { in disk_ctrl_threads_count()
8265 // ps -T -p 15782 | grep "_disk[0-9]*_q0" | wc -l in disk_ctrl_threads_count()
8267 .args(["-T", "-p", format!("{pid}").as_str()]) in disk_ctrl_threads_count()
8283 .args(["--cpus", "boot=2,kvm_hyperv=on"]) in test_windows_guest()
8284 .args(["--memory", "size=4G"]) in test_windows_guest()
8285 .args(["--kernel", edk2_path().to_str().unwrap()]) in test_windows_guest()
8286 .args(["--serial", "tty"]) in test_windows_guest()
8287 .args(["--console", "off"]) in test_windows_guest()
8329 .args(["--cpus", "boot=4,kvm_hyperv=on"]) in test_windows_guest_multiple_queues()
8330 .args(["--memory", "size=4G"]) in test_windows_guest_multiple_queues()
8331 .args(["--kernel", ovmf_path.to_str().unwrap()]) in test_windows_guest_multiple_queues()
8332 .args(["--serial", "tty"]) in test_windows_guest_multiple_queues()
8333 .args(["--console", "off"]) in test_windows_guest_multiple_queues()
8335 "--disk", in test_windows_guest_multiple_queues()
8347 "--net", in test_windows_guest_multiple_queues()
8399 .args(["--api-socket", &api_socket_source]) in test_windows_guest_snapshot_restore()
8400 .args(["--cpus", "boot=2,kvm_hyperv=on"]) in test_windows_guest_snapshot_restore()
8401 .args(["--memory", "size=4G"]) in test_windows_guest_snapshot_restore()
8402 .args(["--kernel", ovmf_path.to_str().unwrap()]) in test_windows_guest_snapshot_restore()
8403 .args(["--serial", "tty"]) in test_windows_guest_snapshot_restore()
8404 .args(["--console", "off"]) in test_windows_guest_snapshot_restore()
8445 .args(["--api-socket", &api_socket_restored]) in test_windows_guest_snapshot_restore()
8447 "--restore", in test_windows_guest_snapshot_restore()
8488 .args(["--api-socket", &api_socket]) in test_windows_guest_cpu_hotplug()
8489 .args(["--cpus", "boot=2,max=8,kvm_hyperv=on"]) in test_windows_guest_cpu_hotplug()
8490 .args(["--memory", "size=4G"]) in test_windows_guest_cpu_hotplug()
8491 .args(["--kernel", ovmf_path.to_str().unwrap()]) in test_windows_guest_cpu_hotplug()
8492 .args(["--serial", "tty"]) in test_windows_guest_cpu_hotplug()
8493 .args(["--console", "off"]) in test_windows_guest_cpu_hotplug()
8523 // Remove some CPUs. Note that Windows doesn't support hot-remove. in test_windows_guest_cpu_hotplug()
8563 .args(["--api-socket", &api_socket]) in test_windows_guest_ram_hotplug()
8564 .args(["--cpus", "boot=2,kvm_hyperv=on"]) in test_windows_guest_ram_hotplug()
8565 .args(["--memory", "size=2G,hotplug_size=5G"]) in test_windows_guest_ram_hotplug()
8566 .args(["--kernel", ovmf_path.to_str().unwrap()]) in test_windows_guest_ram_hotplug()
8567 .args(["--serial", "tty"]) in test_windows_guest_ram_hotplug()
8568 .args(["--console", "off"]) in test_windows_guest_ram_hotplug()
8586 let reserved_ram_size = ram_size - current_ram_size; in test_windows_guest_ram_hotplug()
8597 assert_eq!(windows_guest.ram_size(), ram_size - reserved_ram_size); in test_windows_guest_ram_hotplug()
8600 // Unplug some RAM. Note that hot-remove most likely won't work. in test_windows_guest_ram_hotplug()
8609 assert_eq!(windows_guest.ram_size(), ram_size - reserved_ram_size); in test_windows_guest_ram_hotplug()
8637 .args(["--api-socket", &api_socket]) in test_windows_guest_netdev_hotplug()
8638 .args(["--cpus", "boot=2,kvm_hyperv=on"]) in test_windows_guest_netdev_hotplug()
8639 .args(["--memory", "size=4G"]) in test_windows_guest_netdev_hotplug()
8640 .args(["--kernel", ovmf_path.to_str().unwrap()]) in test_windows_guest_netdev_hotplug()
8641 .args(["--serial", "tty"]) in test_windows_guest_netdev_hotplug()
8642 .args(["--console", "off"]) in test_windows_guest_netdev_hotplug()
8655 // Initially present network device in test_windows_guest_netdev_hotplug()
8660 // Hotplug network device in test_windows_guest_netdev_hotplug()
8663 "add-net", in test_windows_guest_netdev_hotplug()
8669 // Verify the device is on the system in test_windows_guest_netdev_hotplug()
8674 // Remove network device in test_windows_guest_netdev_hotplug()
8675 let cmd_success = remote_command(&api_socket, "remove-device", Some("_net2")); in test_windows_guest_netdev_hotplug()
8678 // Verify the device has been removed in test_windows_guest_netdev_hotplug()
8711 .args(["--api-socket", &api_socket]) in test_windows_guest_disk_hotplug()
8712 .args(["--cpus", "boot=2,kvm_hyperv=on"]) in test_windows_guest_disk_hotplug()
8713 .args(["--memory", "size=4G"]) in test_windows_guest_disk_hotplug()
8714 .args(["--kernel", ovmf_path.to_str().unwrap()]) in test_windows_guest_disk_hotplug()
8715 .args(["--serial", "tty"]) in test_windows_guest_disk_hotplug()
8716 .args(["--console", "off"]) in test_windows_guest_disk_hotplug()
8731 // Initially present disk device in test_windows_guest_disk_hotplug()
8736 // Hotplug disk device in test_windows_guest_disk_hotplug()
8739 "add-disk", in test_windows_guest_disk_hotplug()
8745 // Online disk device in test_windows_guest_disk_hotplug()
8748 // Verify the device is on the system in test_windows_guest_disk_hotplug()
8757 // Unmount disk device in test_windows_guest_disk_hotplug()
8758 let cmd_success = remote_command(&api_socket, "remove-device", Some("_disk2")); in test_windows_guest_disk_hotplug()
8761 // Verify the device has been removed in test_windows_guest_disk_hotplug()
8769 "add-disk", in test_windows_guest_disk_hotplug()
8807 .args(["--api-socket", &api_socket]) in test_windows_guest_disk_hotplug_multi()
8808 .args(["--cpus", "boot=2,kvm_hyperv=on"]) in test_windows_guest_disk_hotplug_multi()
8809 .args(["--memory", "size=2G"]) in test_windows_guest_disk_hotplug_multi()
8810 .args(["--kernel", ovmf_path.to_str().unwrap()]) in test_windows_guest_disk_hotplug_multi()
8811 .args(["--serial", "tty"]) in test_windows_guest_disk_hotplug_multi()
8812 .args(["--console", "off"]) in test_windows_guest_disk_hotplug_multi()
8841 // Initially present disk device in test_windows_guest_disk_hotplug_multi()
8849 // Hotplug disk device in test_windows_guest_disk_hotplug_multi()
8852 "add-disk", in test_windows_guest_disk_hotplug_multi()
8878 let cmd_success = remote_command(&api_socket, "remove-device", Some(disk_id)); in test_windows_guest_disk_hotplug_multi()
8893 "add-disk", in test_windows_guest_disk_hotplug_multi()
8937 .args(["--api-socket", &api_socket]) in test_windows_guest_netdev_multi()
8938 .args(["--cpus", "boot=2,kvm_hyperv=on"]) in test_windows_guest_netdev_multi()
8939 .args(["--memory", "size=4G"]) in test_windows_guest_netdev_multi()
8940 .args(["--kernel", ovmf_path.to_str().unwrap()]) in test_windows_guest_netdev_multi()
8941 .args(["--serial", "tty"]) in test_windows_guest_netdev_multi()
8942 .args(["--console", "off"]) in test_windows_guest_netdev_multi()
8946 "--net", in test_windows_guest_netdev_multi()
8965 let tap_count = exec_host_command_output("ip link | grep -c mytap42"); in test_windows_guest_netdev_multi()
8993 .args(["--cpus", "boot=1"]) in test_sgx()
8994 .args(["--memory", "size=512M"]) in test_sgx()
8995 .args(["--kernel", fw_path(FwType::RustHypervisorFirmware).as_str()]) in test_sgx()
8998 .args(["--sgx-epc", "id=epc0,size=64M"]) in test_sgx()
9012 .ssh_command("cpuid -l 0x12 -s 2 | grep 'section size' | cut -d '=' -f 2") in test_sgx()
9037 .args(["--cpus", "boot=4"]) in test_nvidia_card_memory_hotplug()
9039 "--memory", in test_nvidia_card_memory_hotplug()
9042 .args(["--kernel", fw_path(FwType::RustHypervisorFirmware).as_str()]) in test_nvidia_card_memory_hotplug()
9043 .args(["--device", format!("path={NVIDIA_VFIO_DEVICE}").as_str()]) in test_nvidia_card_memory_hotplug()
9044 .args(["--api-socket", &api_socket]) in test_nvidia_card_memory_hotplug()
9058 // Add RAM to the VM in test_nvidia_card_memory_hotplug()
9064 // Check the VFIO device works when RAM is increased to 6GiB in test_nvidia_card_memory_hotplug()
9081 test_nvidia_card_memory_hotplug("virtio-mem") in test_nvidia_card_memory_hotplug_virtio_mem()
9091 .args(["--cpus", "boot=4"]) in test_nvidia_card_pci_hotplug()
9092 .args(["--memory", "size=4G"]) in test_nvidia_card_pci_hotplug()
9093 .args(["--kernel", fw_path(FwType::RustHypervisorFirmware).as_str()]) in test_nvidia_card_pci_hotplug()
9094 .args(["--api-socket", &api_socket]) in test_nvidia_card_pci_hotplug()
9107 "add-device", in test_nvidia_card_pci_hotplug()
9116 // Check the VFIO device works after hotplug in test_nvidia_card_pci_hotplug()
9133 .args(["--cpus", "boot=4"]) in test_nvidia_card_reboot()
9134 .args(["--memory", "size=4G"]) in test_nvidia_card_reboot()
9135 .args(["--kernel", fw_path(FwType::RustHypervisorFirmware).as_str()]) in test_nvidia_card_reboot()
9137 "--device", in test_nvidia_card_reboot()
9140 .args(["--api-socket", &api_socket]) in test_nvidia_card_reboot()
9150 // Check the VFIO device works after boot in test_nvidia_card_reboot()
9155 // Check the VFIO device works after reboot in test_nvidia_card_reboot()
9172 .args(["--cpus", "boot=4"]) in test_nvidia_card_iommu_address_width()
9173 .args(["--memory", "size=4G"]) in test_nvidia_card_iommu_address_width()
9174 .args(["--kernel", fw_path(FwType::RustHypervisorFirmware).as_str()]) in test_nvidia_card_iommu_address_width()
9175 .args(["--device", format!("path={NVIDIA_VFIO_DEVICE}").as_str()]) in test_nvidia_card_iommu_address_width()
9177 "--platform", in test_nvidia_card_iommu_address_width()
9180 .args(["--api-socket", &api_socket]) in test_nvidia_card_iommu_address_width()
9211 ) -> bool { in start_live_migration()
9213 let mut receive_migration = Command::new(clh_command("ch-remote")) in start_live_migration()
9215 &format!("--api-socket={dest_api_socket}"), in start_live_migration()
9216 "receive-migration", in start_live_migration()
9228 format!("--api-socket={}", &src_api_socket), in start_live_migration()
9229 "send-migration".to_string(), in start_live_migration()
9235 args.insert(2, "--local".to_string()); in start_live_migration()
9238 let mut send_migration = Command::new(clh_command("ch-remote")) in start_live_migration()
9245 // The 'send-migration' command should be executed successfully within the given timeout in start_live_migration()
9260 \n\n---stdout---\n{}\n\n---stderr---\n{} \ in start_live_migration()
9267 // The 'receive-migration' command should be executed successfully within the given timeout in start_live_migration()
9282 \n\n---stdout---\n{}\n\n---stderr---\n{} \ in start_live_migration()
9292 fn print_and_panic(src_vm: Child, dest_vm: Child, ovs_vm: Option<Child>, message: &str) -> ! { in print_and_panic()
9336 // This test exercises the local live-migration between two Cloud Hypervisor VMs on the
9338 … // 1. The source VM is up and functional (including various virtio-devices are working properly);
9339 // 2. The 'send-migration' and 'receive-migration' command finished successfully;
9341 …// 4. The destination VM is functional (including various virtio-devices are working properly) aft…
9356 &["--memory", "size=4G,shared=on"] in _test_live_migration()
9358 &["--memory", "size=4G"] in _test_live_migration()
9374 clh_command("cloud-hypervisor") in _test_live_migration()
9382 "--cpus", in _test_live_migration()
9386 .args(["--kernel", kernel_path.to_str().unwrap()]) in _test_live_migration()
9387 .args(["--cmdline", DIRECT_KERNEL_BOOT_CMDLINE]) in _test_live_migration()
9389 .args(["--net", net_params.as_str()]) in _test_live_migration()
9390 .args(["--api-socket", &src_api_socket]) in _test_live_migration()
9392 "--pmem", in _test_live_migration()
9401 .args(["--api-socket", &dest_api_socket]) in _test_live_migration()
9416 // Check the guest virtio-devices, e.g. block, rng, console, and net in _test_live_migration()
9420 // to make sure that removing and adding back the virtio-net device does in _test_live_migration()
9421 // not break the live-migration support for virtio-pci. in _test_live_migration()
9426 "remove-device", in _test_live_migration()
9431 // Plug the virtio-net device again in _test_live_migration()
9434 "add-net", in _test_live_migration()
9440 // Start the live-migration in _test_live_migration()
9445 .join("live-migration.sock") in _test_live_migration()
9452 "Unsuccessful command: 'send-migration' or 'receive-migration'." in _test_live_migration()
9456 // Check and report any errors occurred during the live-migration in _test_live_migration()
9462 "Error occurred during live-migration", in _test_live_migration()
9477 // Post live-migration check to make sure the destination VM is functional in _test_live_migration()
9486 // Clean-up the destination VM and make sure it terminated correctly in _test_live_migration()
9511 "--memory", in _test_live_migration_balloon()
9512 "size=4G,hotplug_method=virtio-mem,hotplug_size=8G,shared=on", in _test_live_migration_balloon()
9513 "--balloon", in _test_live_migration_balloon()
9518 "--memory", in _test_live_migration_balloon()
9519 "size=4G,hotplug_method=virtio-mem,hotplug_size=8G", in _test_live_migration_balloon()
9520 "--balloon", in _test_live_migration_balloon()
9538 clh_command("cloud-hypervisor") in _test_live_migration_balloon()
9546 "--cpus", in _test_live_migration_balloon()
9550 .args(["--kernel", kernel_path.to_str().unwrap()]) in _test_live_migration_balloon()
9551 .args(["--cmdline", DIRECT_KERNEL_BOOT_CMDLINE]) in _test_live_migration_balloon()
9553 .args(["--net", net_params.as_str()]) in _test_live_migration_balloon()
9554 .args(["--api-socket", &src_api_socket]) in _test_live_migration_balloon()
9556 "--pmem", in _test_live_migration_balloon()
9565 .args(["--api-socket", &dest_api_socket]) in _test_live_migration_balloon()
9590 // Check the guest virtio-devices, e.g. block, rng, console, and net in _test_live_migration_balloon()
9594 // to make sure that removing and adding back the virtio-net device does in _test_live_migration_balloon()
9595 // not break the live-migration support for virtio-pci. in _test_live_migration_balloon()
9600 "remove-device", in _test_live_migration_balloon()
9605 // Plug the virtio-net device again in _test_live_migration_balloon()
9608 "add-net", in _test_live_migration_balloon()
9614 // Start the live-migration in _test_live_migration_balloon()
9619 .join("live-migration.sock") in _test_live_migration_balloon()
9626 "Unsuccessful command: 'send-migration' or 'receive-migration'." in _test_live_migration_balloon()
9630 // Check and report any errors occurred during the live-migration in _test_live_migration_balloon()
9636 "Error occurred during live-migration", in _test_live_migration_balloon()
9651 // Post live-migration check to make sure the destination VM is functional in _test_live_migration_balloon()
9667 // Decrease guest RAM with virtio-mem in _test_live_migration_balloon()
9675 // Clean-up the destination VM and make sure it terminated correctly in _test_live_migration_balloon()
9700 "--memory", in _test_live_migration_numa()
9701 "size=0,hotplug_method=virtio-mem,shared=on", in _test_live_migration_numa()
9702 "--memory-zone", in _test_live_migration_numa()
9706 "--numa", in _test_live_migration_numa()
9707 "guest_numa_id=0,cpus=[0-2,9],distances=[1@15,2@20],memory_zones=mem0", in _test_live_migration_numa()
9708 "guest_numa_id=1,cpus=[3-4,6-8],distances=[0@20,2@25],memory_zones=mem1", in _test_live_migration_numa()
9709 "guest_numa_id=2,cpus=[5,10-11],distances=[0@25,1@30],memory_zones=mem2", in _test_live_migration_numa()
9713 "--memory", in _test_live_migration_numa()
9714 "size=0,hotplug_method=virtio-mem", in _test_live_migration_numa()
9715 "--memory-zone", in _test_live_migration_numa()
9719 "--numa", in _test_live_migration_numa()
9720 "guest_numa_id=0,cpus=[0-2,9],distances=[1@15,2@20],memory_zones=mem0", in _test_live_migration_numa()
9721 "guest_numa_id=1,cpus=[3-4,6-8],distances=[0@20,2@25],memory_zones=mem1", in _test_live_migration_numa()
9722 "guest_numa_id=2,cpus=[5,10-11],distances=[0@25,1@30],memory_zones=mem2", in _test_live_migration_numa()
9739 clh_command("cloud-hypervisor") in _test_live_migration_numa()
9747 "--cpus", in _test_live_migration_numa()
9751 .args(["--kernel", kernel_path.to_str().unwrap()]) in _test_live_migration_numa()
9752 .args(["--cmdline", DIRECT_KERNEL_BOOT_CMDLINE]) in _test_live_migration_numa()
9754 .args(["--net", net_params.as_str()]) in _test_live_migration_numa()
9755 .args(["--api-socket", &src_api_socket]) in _test_live_migration_numa()
9757 "--pmem", in _test_live_migration_numa()
9766 .args(["--api-socket", &dest_api_socket]) in _test_live_migration_numa()
9781 // Check the guest virtio-devices, e.g. block, rng, console, and net in _test_live_migration_numa()
9786 // virtio-mem regions being used. in _test_live_migration_numa()
9795 // test hotplug-related function on x86_64 here. in _test_live_migration_numa()
9812 // to make sure that removing and adding back the virtio-net device does in _test_live_migration_numa()
9813 // not break the live-migration support for virtio-pci. in _test_live_migration_numa()
9818 "remove-device", in _test_live_migration_numa()
9823 // Plug the virtio-net device again in _test_live_migration_numa()
9826 "add-net", in _test_live_migration_numa()
9832 // Start the live-migration in _test_live_migration_numa()
9837 .join("live-migration.sock") in _test_live_migration_numa()
9844 "Unsuccessful command: 'send-migration' or 'receive-migration'." in _test_live_migration_numa()
9848 // Check and report any errors occurred during the live-migration in _test_live_migration_numa()
9854 "Error occurred during live-migration", in _test_live_migration_numa()
9869 // Post live-migration check to make sure the destination VM is functional in _test_live_migration_numa()
9892 // test hotplug-related function on x86_64 here. in _test_live_migration_numa()
9922 // Clean-up the destination VM and make sure it terminated correctly in _test_live_migration_numa()
9946 &["--memory", "size=4G,shared=on"] in _test_live_migration_watchdog()
9948 &["--memory", "size=4G"] in _test_live_migration_watchdog()
9964 clh_command("cloud-hypervisor") in _test_live_migration_watchdog()
9972 "--cpus", in _test_live_migration_watchdog()
9976 .args(["--kernel", kernel_path.to_str().unwrap()]) in _test_live_migration_watchdog()
9977 .args(["--cmdline", DIRECT_KERNEL_BOOT_CMDLINE]) in _test_live_migration_watchdog()
9979 .args(["--net", net_params.as_str()]) in _test_live_migration_watchdog()
9980 .args(["--api-socket", &src_api_socket]) in _test_live_migration_watchdog()
9982 "--pmem", in _test_live_migration_watchdog()
9985 .args(["--watchdog"]); in _test_live_migration_watchdog()
9992 .args(["--api-socket", &dest_api_socket]) in _test_live_migration_watchdog()
10005 // Check the guest virtio-devices, e.g. block, rng, console, and net in _test_live_migration_watchdog()
10008 // to make sure that removing and adding back the virtio-net device does in _test_live_migration_watchdog()
10009 // not break the live-migration support for virtio-pci. in _test_live_migration_watchdog()
10014 "remove-device", in _test_live_migration_watchdog()
10019 // Plug the virtio-net device again in _test_live_migration_watchdog()
10022 "add-net", in _test_live_migration_watchdog()
10036 .ssh_command("sudo journalctl | grep -c -- \"Watchdog started\"") in _test_live_migration_watchdog()
10048 // Start the live-migration in _test_live_migration_watchdog()
10053 .join("live-migration.sock") in _test_live_migration_watchdog()
10060 "Unsuccessful command: 'send-migration' or 'receive-migration'." in _test_live_migration_watchdog()
10064 // Check and report any errors occurred during the live-migration in _test_live_migration_watchdog()
10070 "Error occurred during live-migration", in _test_live_migration_watchdog()
10085 // Post live-migration check to make sure the destination VM is functional in _test_live_migration_watchdog()
10102 …guest.ssh_command("screen -dmS reboot sh -c \"sleep 5; echo s | tee /proc/sysrq-trigger; echo c | … in _test_live_migration_watchdog()
10121 // Clean-up the destination VM and make sure it terminated correctly in _test_live_migration_watchdog()
10141 …// Start two VMs that are connected through ovs-dpdk and one of the VMs is the source VM for live-… in _test_live_migration_ovs_dpdk()
10149 .args(["--api-socket", &dest_api_socket]) in _test_live_migration_ovs_dpdk()
10158 // Start the live-migration in _test_live_migration_ovs_dpdk()
10163 .join("live-migration.sock") in _test_live_migration_ovs_dpdk()
10170 "Unsuccessful command: 'send-migration' or 'receive-migration'." in _test_live_migration_ovs_dpdk()
10174 // Check and report any errors occurred during the live-migration in _test_live_migration_ovs_dpdk()
10180 "Error occurred during live-migration", in _test_live_migration_ovs_dpdk()
10195 // Post live-migration check to make sure the destination VM is functional in _test_live_migration_ovs_dpdk()
10202 "nc -l 12345", in _test_live_migration_ovs_dpdk()
10213 // And check the connection is still functional after live-migration in _test_live_migration_ovs_dpdk()
10215 .ssh_command("nc -vz 172.100.0.1 12345") in _test_live_migration_ovs_dpdk()
10219 // Clean-up the destination VM and OVS VM, and make sure they terminated correctly in _test_live_migration_ovs_dpdk()
10231 // This test exercises the local live-migration between two Cloud Hypervisor VMs on the
10236 // 3. The 'send-migration' and 'receive-migration' command finished successfully;
10261 "--cpus", in _test_live_migration_with_landlock()
10264 .args(["--memory", "size=4G,shared=on"]) in _test_live_migration_with_landlock()
10265 .args(["--kernel", kernel_path.to_str().unwrap()]) in _test_live_migration_with_landlock()
10266 .args(["--cmdline", DIRECT_KERNEL_BOOT_CMDLINE]) in _test_live_migration_with_landlock()
10268 .args(["--api-socket", &src_api_socket]) in _test_live_migration_with_landlock()
10269 .args(["--landlock"]) in _test_live_migration_with_landlock()
10270 .args(["--net", net_params.as_str()]) in _test_live_migration_with_landlock()
10272 "--landlock-rules", in _test_live_migration_with_landlock()
10283 .args(["--api-socket", &dest_api_socket]) in _test_live_migration_with_landlock()
10298 // Check Landlock is enabled by hot-plugging a disk. in _test_live_migration_with_landlock()
10301 "add-disk", in _test_live_migration_with_landlock()
10305 // Start the live-migration in _test_live_migration_with_landlock()
10310 .join("live-migration.sock") in _test_live_migration_with_landlock()
10317 "Unsuccessful command: 'send-migration' or 'receive-migration'." in _test_live_migration_with_landlock()
10321 // Check and report any errors occurred during the live-migration in _test_live_migration_with_landlock()
10327 "Error occurred during live-migration", in _test_live_migration_with_landlock()
10342 // Post live-migration check to make sure the destination VM is funcational in _test_live_migration_with_landlock()
10349 // Check Landlock is enabled on destination VM by hot-plugging a disk. in _test_live_migration_with_landlock()
10352 "add-disk", in _test_live_migration_with_landlock()
10356 // Clean-up the destination VM and make sure it terminated correctly in _test_live_migration_with_landlock()
10363 fn get_available_port() -> u16 { in get_available_port()
10371 fn start_live_migration_tcp(src_api_socket: &str, dest_api_socket: &str) -> bool { in start_live_migration_tcp()
10376 // Start the 'receive-migration' command on the destination in start_live_migration_tcp()
10377 let mut receive_migration = Command::new(clh_command("ch-remote")) in start_live_migration_tcp()
10379 &format!("--api-socket={dest_api_socket}"), in start_live_migration_tcp()
10380 "receive-migration", in start_live_migration_tcp()
10392 // Start the 'send-migration' command on the source in start_live_migration_tcp()
10393 let mut send_migration = Command::new(clh_command("ch-remote")) in start_live_migration_tcp()
10395 &format!("--api-socket={src_api_socket}"), in start_live_migration_tcp()
10396 "send-migration", in start_live_migration_tcp()
10405 // Check if the 'send-migration' command executed successfully in start_live_migration_tcp()
10419 …"\n\n==== Start 'send_migration' output ====\n\n---stdout---\n{}\n\n---stderr---\n{}\n\n==== End '… in start_live_migration_tcp()
10425 // Check if the 'receive-migration' command executed successfully in start_live_migration_tcp()
10439 …"\n\n==== Start 'receive_migration' output ====\n\n---stdout---\n{}\n\n---stderr---\n{}\n\n==== En… in start_live_migration_tcp()
10458 let memory_param: &[&str] = &["--memory", "size=4G,shared=on"]; in _test_live_migration_tcp()
10470 let src_vm_path = clh_command("cloud-hypervisor"); in _test_live_migration_tcp()
10475 "--cpus", in _test_live_migration_tcp()
10479 .args(["--kernel", kernel_path.to_str().unwrap()]) in _test_live_migration_tcp()
10480 .args(["--cmdline", DIRECT_KERNEL_BOOT_CMDLINE]) in _test_live_migration_tcp()
10482 .args(["--net", net_params.as_str()]) in _test_live_migration_tcp()
10483 .args(["--api-socket", &src_api_socket]) in _test_live_migration_tcp()
10485 "--pmem", in _test_live_migration_tcp()
10499 .args(["--api-socket", &dest_api_socket]) in _test_live_migration_tcp()
10511 // On x86_64 architecture, remove and re-add the virtio-net device in _test_live_migration_tcp()
10516 "remove-device", in _test_live_migration_tcp()
10520 // Re-add the virtio-net device in _test_live_migration_tcp()
10523 "add-net", in _test_live_migration_tcp()
10531 "Unsuccessful command: 'send-migration' or 'receive-migration'." in _test_live_migration_tcp()
10541 "Error occurred during live-migration", in _test_live_migration_tcp()
10678 // Require to run ovs-dpdk tests sequentially because they rely on the same ovs-dpdk setup
10724 .args(["--cpus", "boot=1"]) in test_simple_launch_acpi()
10725 .args(["--memory", "size=512M"]) in test_simple_launch_acpi()
10726 .args(["--kernel", edk2_path().to_str().unwrap()]) in test_simple_launch_acpi()
10729 .args(["--serial", "tty", "--console", "off"]) in test_simple_launch_acpi()
10785 fn check_rate_limit(measured: f64, limit: f64, difference: f64) -> bool { in check_rate_limit()
10787 let lower_limit = limit * (1_f64 - difference); in check_rate_limit()
10824 .args(["--cpus", &format!("boot={}", num_queues / 2)]) in _test_rate_limiter_net()
10825 .args(["--memory", "size=4G"]) in _test_rate_limiter_net()
10826 .args(["--kernel", direct_kernel_boot_path().to_str().unwrap()]) in _test_rate_limiter_net()
10827 .args(["--cmdline", DIRECT_KERNEL_BOOT_CMDLINE]) in _test_rate_limiter_net()
10829 .args(["--net", net_params.as_str()]) in _test_rate_limiter_net()
10894 .args(["--cpus", &format!("boot={num_queues}")]) in _test_rate_limiter_block()
10895 .args(["--memory", "size=4G"]) in _test_rate_limiter_block()
10896 .args(["--kernel", direct_kernel_boot_path().to_str().unwrap()]) in _test_rate_limiter_block()
10897 .args(["--cmdline", DIRECT_KERNEL_BOOT_CMDLINE]) in _test_rate_limiter_block()
10899 "--disk", in _test_rate_limiter_block()
10913 .args(["--api-socket", &api_socket]) in _test_rate_limiter_block()
10922 "sudo fio --filename=/dev/vdc --name=test --output-format=json \ in _test_rate_limiter_block()
10923 --direct=1 --bs=4k --ioengine=io_uring --iodepth=64 \ in _test_rate_limiter_block()
10924 --rw={fio_ops} --runtime={test_timeout} --numjobs={num_queues}" in _test_rate_limiter_block()
10966 "--disk".to_string(), in _test_rate_limiter_group_block()
10998 .args(["--cpus", &format!("boot={}", num_queues * num_disks)]) in _test_rate_limiter_group_block()
10999 .args(["--memory", "size=4G"]) in _test_rate_limiter_group_block()
11000 .args(["--kernel", direct_kernel_boot_path().to_str().unwrap()]) in _test_rate_limiter_group_block()
11001 .args(["--cmdline", DIRECT_KERNEL_BOOT_CMDLINE]) in _test_rate_limiter_group_block()
11002 .args(["--rate-limit-group", &rate_limit_group_arg]) in _test_rate_limiter_group_block()
11005 .args(["--api-socket", &api_socket]) in _test_rate_limiter_group_block()
11014 "sudo fio --name=global --output-format=json \ in _test_rate_limiter_group_block()
11015 --direct=1 --bs=4k --ioengine=io_uring --iodepth=64 \ in _test_rate_limiter_group_block()
11016 --rw={fio_ops} --runtime={test_timeout} --numjobs={num_queues}" in _test_rate_limiter_group_block()
11020 // --name=job0 --filename=/dev/vdc \ in _test_rate_limiter_group_block()
11021 // --name=job1 --filename=/dev/vdd \ in _test_rate_limiter_group_block()
11022 // --name=job2 --filename=/dev/vde \ in _test_rate_limiter_group_block()
11027 " --name=job{i} --filename=/dev/vd{}", in _test_rate_limiter_group_block()