mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2025-03-20 07:58:55 +00:00
ci: Add integration test for VFIO hot-unplug
Extend the existing test_vfio by unplugging the previously hotplugged device. Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
This commit is contained in:
parent
b50cbe5064
commit
f7277140bb
@ -2374,6 +2374,18 @@ mod tests {
|
||||
1
|
||||
);
|
||||
|
||||
// Check the amount of PCI devices appearing in L2 VM.
|
||||
aver_eq!(
|
||||
tb,
|
||||
guest
|
||||
.ssh_command_l2_1("ls /sys/bus/pci/devices | wc -l")
|
||||
.unwrap_or_default()
|
||||
.trim()
|
||||
.parse::<u32>()
|
||||
.unwrap_or_default(),
|
||||
7,
|
||||
);
|
||||
|
||||
// Hotplug an extra virtio-net device through L2 VM.
|
||||
guest.ssh_command_l1(
|
||||
"echo 0000:00:07.0 | sudo tee /sys/bus/pci/devices/0000:00:07.0/driver/unbind",
|
||||
@ -2404,6 +2416,48 @@ mod tests {
|
||||
1
|
||||
);
|
||||
|
||||
// Check the amount of PCI devices appearing in L2 VM.
|
||||
// There should be one more device than before, raising the count
|
||||
// up to 8 PCI devices.
|
||||
aver_eq!(
|
||||
tb,
|
||||
guest
|
||||
.ssh_command_l2_1("ls /sys/bus/pci/devices | wc -l")
|
||||
.unwrap_or_default()
|
||||
.trim()
|
||||
.parse::<u32>()
|
||||
.unwrap_or_default(),
|
||||
8,
|
||||
);
|
||||
|
||||
// Let's now verify that we can correctly remove the virtio-net
|
||||
// device through the "remove-device" command responsible for
|
||||
// unplugging VFIO devices.
|
||||
// "vfio2" is used here because the two previous devices will be
|
||||
// affected with the values "vfio0" and "vfio1" by default.
|
||||
guest.ssh_command_l1(
|
||||
"sudo curl \
|
||||
--unix-socket /tmp/ch_api.sock \
|
||||
-i \
|
||||
-X PUT http://localhost/api/v1/vm.remove-device \
|
||||
-H 'Accept: application/json' -H 'Content-Type: application/json' \
|
||||
-d '{\"id\":\"vfio2\"}'",
|
||||
)?;
|
||||
thread::sleep(std::time::Duration::new(10, 0));
|
||||
|
||||
// Check the amount of PCI devices appearing in L2 VM is back down
|
||||
// to 7 devices.
|
||||
aver_eq!(
|
||||
tb,
|
||||
guest
|
||||
.ssh_command_l2_1("ls /sys/bus/pci/devices | wc -l")
|
||||
.unwrap_or_default()
|
||||
.trim()
|
||||
.parse::<u32>()
|
||||
.unwrap_or_default(),
|
||||
7,
|
||||
);
|
||||
|
||||
let _ = child.kill();
|
||||
let _ = daemon_child.kill();
|
||||
let _ = child.wait();
|
||||
|
Loading…
x
Reference in New Issue
Block a user