mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2024-12-21 21:25:19 +00:00
tests: Add integration test for pvpanic
Add integration test for pvpanic, by two methods: - the vendor id and device id of pci device in guest - triggering a guest panic and check event-monitor. Also, to support pvpanic-pci driver, add pvpanic config in resources. Signed-off-by: Yi Wang <foxywang@tencent.com> Signed-off-by: Rob Bradford <rbradford@rivosinc.com>
This commit is contained in:
parent
d99c0c0d1d
commit
99353856ef
@ -1402,7 +1402,8 @@ CONFIG_NVME_MULTIPATH=y
|
||||
# CONFIG_MISC_RTSX_PCI is not set
|
||||
# CONFIG_HABANA_AI is not set
|
||||
# CONFIG_UACCE is not set
|
||||
# CONFIG_PVPANIC is not set
|
||||
CONFIG_PVPANIC=y
|
||||
CONFIG_PVPANIC_PCI=y
|
||||
# CONFIG_GP_PCI1XXXX is not set
|
||||
# end of Misc devices
|
||||
|
||||
|
@ -1378,7 +1378,8 @@ CONFIG_NVME_MULTIPATH=y
|
||||
# CONFIG_MISC_RTSX_PCI is not set
|
||||
# CONFIG_HABANA_AI is not set
|
||||
# CONFIG_UACCE is not set
|
||||
# CONFIG_PVPANIC is not set
|
||||
CONFIG_PVPANIC=y
|
||||
CONFIG_PVPANIC_PCI=y
|
||||
# CONFIG_GP_PCI1XXXX is not set
|
||||
# end of Misc devices
|
||||
|
||||
|
@ -2225,6 +2225,16 @@ fn enable_guest_watchdog(guest: &Guest, watchdog_sec: u32) {
|
||||
.unwrap();
|
||||
}
|
||||
|
||||
fn make_guest_panic(guest: &Guest) {
|
||||
// Check for pvpanic device
|
||||
assert!(guest
|
||||
.does_device_vendor_pair_match("0x0011", "0x1b36")
|
||||
.unwrap_or_default());
|
||||
|
||||
// Trigger guest a panic
|
||||
guest.ssh_command("screen -dmS reboot sh -c \"sleep 5; echo s | tee /proc/sysrq-trigger; echo c | sudo tee /proc/sysrq-trigger\"").unwrap();
|
||||
}
|
||||
|
||||
mod common_parallel {
|
||||
use std::{fs::OpenOptions, io::SeekFrom};
|
||||
|
||||
@ -6131,6 +6141,54 @@ mod common_parallel {
|
||||
handle_child_output(r, &output);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_pvpanic() {
|
||||
let jammy = UbuntuDiskConfig::new(JAMMY_IMAGE_NAME.to_string());
|
||||
let guest = Guest::new(Box::new(jammy));
|
||||
let api_socket = temp_api_path(&guest.tmp_dir);
|
||||
let event_path = temp_event_monitor_path(&guest.tmp_dir);
|
||||
|
||||
let kernel_path = direct_kernel_boot_path();
|
||||
|
||||
let mut cmd = GuestCommand::new(&guest);
|
||||
cmd.args(["--cpus", "boot=1"])
|
||||
.args(["--memory", "size=512M"])
|
||||
.args(["--kernel", kernel_path.to_str().unwrap()])
|
||||
.args(["--cmdline", DIRECT_KERNEL_BOOT_CMDLINE])
|
||||
.default_disks()
|
||||
.args(["--net", guest.default_net_string().as_str()])
|
||||
.args(["--pvpanic"])
|
||||
.args(["--api-socket", &api_socket])
|
||||
.args(["--event-monitor", format!("path={event_path}").as_str()])
|
||||
.capture_output();
|
||||
|
||||
let mut child = cmd.spawn().unwrap();
|
||||
|
||||
let r = std::panic::catch_unwind(|| {
|
||||
guest.wait_vm_boot(None).unwrap();
|
||||
|
||||
// Trigger guest a panic
|
||||
make_guest_panic(&guest);
|
||||
|
||||
// Wait a while for guest
|
||||
thread::sleep(std::time::Duration::new(10, 0));
|
||||
|
||||
let expected_sequential_events = [&MetaEvent {
|
||||
event: "panic".to_string(),
|
||||
device_id: None,
|
||||
}];
|
||||
assert!(check_latest_events_exact(
|
||||
&expected_sequential_events,
|
||||
&event_path
|
||||
));
|
||||
});
|
||||
|
||||
let _ = child.kill();
|
||||
let output = child.wait_with_output().unwrap();
|
||||
|
||||
handle_child_output(r, &output);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_tap_from_fd() {
|
||||
let focal = UbuntuDiskConfig::new(FOCAL_IMAGE_NAME.to_string());
|
||||
|
Loading…
Reference in New Issue
Block a user