tests: Use ch-remote to add/remove devices in test_vfio

Signed-off-by: Rob Bradford <robert.bradford@intel.com>
This commit is contained in:
Rob Bradford 2020-03-12 11:05:19 +00:00 committed by Sebastien Boeuf
parent 5c3ce9dd00
commit abccf766ce
2 changed files with 8 additions and 12 deletions

View File

@ -172,6 +172,7 @@ sudo setcap cap_net_admin+ep target/release/vhost_user_net
# We always copy a fresh version of our binary for our L2 guest.
cp target/release/cloud-hypervisor $VFIO_DIR
cp target/release/ch-remote $VFIO_DIR
# Enable KSM with some reasonable parameters so that it won't take too long
# for the memory to be merged between two processes.

View File

@ -2407,13 +2407,11 @@ mod tests {
guest
.ssh_command_l1("echo 1af4 1041 | sudo tee /sys/bus/pci/drivers/vfio-pci/new_id")?;
guest.ssh_command_l1(
"sudo curl \
--unix-socket /tmp/ch_api.sock \
-i \
-X PUT http://localhost/api/v1/vm.add-device \
-H 'Accept: application/json' -H 'Content-Type: application/json' \
-d '{\"path\":\"/sys/bus/pci/devices/0000:00:07.0\",\"id\":\"vfio123\"}'",
"sudo /mnt/ch-remote \
--api-socket=/tmp/ch_api.sock \
add-device path=/sys/bus/pci/devices/0000:00:07.0,id=vfio123",
)?;
thread::sleep(std::time::Duration::new(10, 0));
// Let's also verify from the third virtio-net device passed to
@ -2448,12 +2446,9 @@ mod tests {
// device through the "remove-device" command responsible for
// unplugging VFIO devices.
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\":\"vfio123\"}'",
"sudo /mnt/ch-remote \
--api-socket=/tmp/ch_api.sock \
remove-device vfio123",
)?;
thread::sleep(std::time::Duration::new(10, 0));