mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2024-10-05 13:05:45 +00:00
ci: Extend integration tests for checking PCI hotplug response
Upon PCI hotplug, the VMM now returns some information about the device name and the associated b/d/f. This patch extends the integration tests so that we validate the response is the one that is expected. Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
This commit is contained in:
parent
b62d5d22ff
commit
4f311b56eb
@ -497,6 +497,23 @@ mod tests {
|
|||||||
cmd.status().expect("Failed to launch ch-remote").success()
|
cmd.status().expect("Failed to launch ch-remote").success()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn remote_command_w_output(
|
||||||
|
api_socket: &str,
|
||||||
|
command: &str,
|
||||||
|
arg: Option<&str>,
|
||||||
|
) -> (bool, Vec<u8>) {
|
||||||
|
let mut cmd = Command::new(clh_command("ch-remote"));
|
||||||
|
cmd.args(&[&format!("--api-socket={}", api_socket), command]);
|
||||||
|
|
||||||
|
if let Some(arg) = arg {
|
||||||
|
cmd.arg(arg);
|
||||||
|
}
|
||||||
|
|
||||||
|
let output = cmd.output().expect("Failed to launch ch-remote");
|
||||||
|
|
||||||
|
(output.status.success(), output.stdout)
|
||||||
|
}
|
||||||
|
|
||||||
fn resize_command(
|
fn resize_command(
|
||||||
api_socket: &str,
|
api_socket: &str,
|
||||||
desired_vcpus: Option<u8>,
|
desired_vcpus: Option<u8>,
|
||||||
@ -1944,7 +1961,14 @@ mod tests {
|
|||||||
|
|
||||||
if hotplug {
|
if hotplug {
|
||||||
// Add fs to the VM
|
// Add fs to the VM
|
||||||
aver!(tb, remote_command(&api_socket, "add-fs", Some(&fs_params),));
|
let (cmd_success, cmd_output) =
|
||||||
|
remote_command_w_output(&api_socket, "add-fs", Some(&fs_params));
|
||||||
|
aver!(tb, cmd_success);
|
||||||
|
aver!(
|
||||||
|
tb,
|
||||||
|
String::from_utf8_lossy(&cmd_output)
|
||||||
|
.contains("{\"id\":\"myfs0\",\"bdf\":\"0000:00:06.0\"}")
|
||||||
|
);
|
||||||
|
|
||||||
thread::sleep(std::time::Duration::new(10, 0));
|
thread::sleep(std::time::Duration::new(10, 0));
|
||||||
}
|
}
|
||||||
@ -2057,7 +2081,14 @@ mod tests {
|
|||||||
);
|
);
|
||||||
|
|
||||||
// Add back and check it works
|
// Add back and check it works
|
||||||
aver!(tb, remote_command(&api_socket, "add-fs", Some(&fs_params),));
|
let (cmd_success, cmd_output) =
|
||||||
|
remote_command_w_output(&api_socket, "add-fs", Some(&fs_params));
|
||||||
|
aver!(tb, cmd_success);
|
||||||
|
aver!(
|
||||||
|
tb,
|
||||||
|
String::from_utf8_lossy(&cmd_output)
|
||||||
|
.contains("{\"id\":\"myfs0\",\"bdf\":\"0000:00:06.0\"}")
|
||||||
|
);
|
||||||
thread::sleep(std::time::Duration::new(10, 0));
|
thread::sleep(std::time::Duration::new(10, 0));
|
||||||
// Mount shared directory through virtio_fs filesystem
|
// Mount shared directory through virtio_fs filesystem
|
||||||
let mount_cmd = format!(
|
let mount_cmd = format!(
|
||||||
@ -2826,11 +2857,15 @@ mod tests {
|
|||||||
)?;
|
)?;
|
||||||
guest
|
guest
|
||||||
.ssh_command_l1("echo 1af4 1041 | sudo tee /sys/bus/pci/drivers/vfio-pci/new_id")?;
|
.ssh_command_l1("echo 1af4 1041 | sudo tee /sys/bus/pci/drivers/vfio-pci/new_id")?;
|
||||||
guest.ssh_command_l1(
|
let vfio_hotplug_output = guest.ssh_command_l1(
|
||||||
"sudo /mnt/ch-remote \
|
"sudo /mnt/ch-remote \
|
||||||
--api-socket=/tmp/ch_api.sock \
|
--api-socket=/tmp/ch_api.sock \
|
||||||
add-device path=/sys/bus/pci/devices/0000:00:07.0,id=vfio123",
|
add-device path=/sys/bus/pci/devices/0000:00:07.0,id=vfio123",
|
||||||
)?;
|
)?;
|
||||||
|
aver!(
|
||||||
|
tb,
|
||||||
|
vfio_hotplug_output.contains("{\"id\":\"vfio123\",\"bdf\":\"0000:00:07.0\"}")
|
||||||
|
);
|
||||||
|
|
||||||
thread::sleep(std::time::Duration::new(10, 0));
|
thread::sleep(std::time::Duration::new(10, 0));
|
||||||
|
|
||||||
@ -3113,13 +3148,16 @@ mod tests {
|
|||||||
thread::sleep(std::time::Duration::new(20, 0));
|
thread::sleep(std::time::Duration::new(20, 0));
|
||||||
|
|
||||||
if hotplug {
|
if hotplug {
|
||||||
aver!(
|
let (cmd_success, cmd_output) = remote_command_w_output(
|
||||||
tb,
|
|
||||||
remote_command(
|
|
||||||
&api_socket,
|
&api_socket,
|
||||||
"add-vsock",
|
"add-vsock",
|
||||||
Some(format!("cid=3,socket={},id=test0", socket).as_str())
|
Some(format!("cid=3,socket={},id=test0", socket).as_str()),
|
||||||
)
|
);
|
||||||
|
aver!(tb, cmd_success);
|
||||||
|
aver!(
|
||||||
|
tb,
|
||||||
|
String::from_utf8_lossy(&cmd_output)
|
||||||
|
.contains("{\"id\":\"test0\",\"bdf\":\"0000:00:06.0\"}")
|
||||||
);
|
);
|
||||||
thread::sleep(std::time::Duration::new(10, 0));
|
thread::sleep(std::time::Duration::new(10, 0));
|
||||||
// Check adding a second one fails
|
// Check adding a second one fails
|
||||||
@ -3998,16 +4036,16 @@ mod tests {
|
|||||||
let mut blk_file_path = dirs::home_dir().unwrap();
|
let mut blk_file_path = dirs::home_dir().unwrap();
|
||||||
blk_file_path.push("workloads");
|
blk_file_path.push("workloads");
|
||||||
blk_file_path.push("blk.img");
|
blk_file_path.push("blk.img");
|
||||||
aver!(
|
let (cmd_success, cmd_output) = remote_command_w_output(
|
||||||
tb,
|
|
||||||
remote_command(
|
|
||||||
&api_socket,
|
&api_socket,
|
||||||
"add-disk",
|
"add-disk",
|
||||||
Some(&format!(
|
Some(format!("path={},id=test0", blk_file_path.to_str().unwrap()).as_str()),
|
||||||
"path={},id=test0",
|
);
|
||||||
blk_file_path.to_str().unwrap()
|
aver!(tb, cmd_success);
|
||||||
))
|
aver!(
|
||||||
)
|
tb,
|
||||||
|
String::from_utf8_lossy(&cmd_output)
|
||||||
|
.contains("{\"id\":\"test0\",\"bdf\":\"0000:00:06.0\"}")
|
||||||
);
|
);
|
||||||
|
|
||||||
// Check that if /dev/vdc exists and the block size is 16M.
|
// Check that if /dev/vdc exists and the block size is 16M.
|
||||||
@ -4127,16 +4165,19 @@ mod tests {
|
|||||||
|
|
||||||
let mut pmem_temp_file = NamedTempFile::new().unwrap();
|
let mut pmem_temp_file = NamedTempFile::new().unwrap();
|
||||||
pmem_temp_file.as_file_mut().set_len(128 << 20).unwrap();
|
pmem_temp_file.as_file_mut().set_len(128 << 20).unwrap();
|
||||||
aver!(
|
let (cmd_success, cmd_output) = remote_command_w_output(
|
||||||
tb,
|
|
||||||
remote_command(
|
|
||||||
&api_socket,
|
&api_socket,
|
||||||
"add-pmem",
|
"add-pmem",
|
||||||
Some(&format!(
|
Some(&format!(
|
||||||
"file={},id=test0",
|
"file={},id=test0",
|
||||||
pmem_temp_file.path().to_str().unwrap()
|
pmem_temp_file.path().to_str().unwrap()
|
||||||
))
|
)),
|
||||||
)
|
);
|
||||||
|
aver!(tb, cmd_success);
|
||||||
|
aver!(
|
||||||
|
tb,
|
||||||
|
String::from_utf8_lossy(&cmd_output)
|
||||||
|
.contains("{\"id\":\"test0\",\"bdf\":\"0000:00:06.0\"}")
|
||||||
);
|
);
|
||||||
|
|
||||||
// Check that /dev/pmem0 exists and the block size is 128M
|
// Check that /dev/pmem0 exists and the block size is 128M
|
||||||
@ -4243,13 +4284,16 @@ mod tests {
|
|||||||
thread::sleep(std::time::Duration::new(20, 0));
|
thread::sleep(std::time::Duration::new(20, 0));
|
||||||
|
|
||||||
// Add network
|
// Add network
|
||||||
aver!(
|
let (cmd_success, cmd_output) = remote_command_w_output(
|
||||||
tb,
|
|
||||||
remote_command(
|
|
||||||
&api_socket,
|
&api_socket,
|
||||||
"add-net",
|
"add-net",
|
||||||
Some(guest.default_net_string().as_str())
|
Some(guest.default_net_string().as_str()),
|
||||||
)
|
);
|
||||||
|
aver!(tb, cmd_success);
|
||||||
|
aver!(
|
||||||
|
tb,
|
||||||
|
String::from_utf8_lossy(&cmd_output)
|
||||||
|
.contains("{\"id\":\"_net2\",\"bdf\":\"0000:00:05.0\"}")
|
||||||
);
|
);
|
||||||
|
|
||||||
// 1 network interfaces + default localhost ==> 2 interfaces
|
// 1 network interfaces + default localhost ==> 2 interfaces
|
||||||
|
Loading…
Reference in New Issue
Block a user