tests: Simplify test_vdpa_block() to increase stability

It seems the vdpa_sim_block isn't behaving properly after the vhost
device is closed, as it sometimes returns EBUSY when we try to open it
again. The easiest way to deal with this issue is by simplifying the
integration test, avoid to plug the same device after it's been
unplugged.

Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
This commit is contained in:
Sebastien Boeuf 2022-03-28 09:57:39 +02:00 committed by Rob Bradford
parent acd914f02d
commit 2ef201e43f

View File

@ -5925,10 +5925,16 @@ mod parallel {
.ssh_command("sudo bash -c 'echo foobar > /dev/vdd'") .ssh_command("sudo bash -c 'echo foobar > /dev/vdd'")
.unwrap(); .unwrap();
// Check we can read the content back.
assert_eq!(
guest.ssh_command("sudo head -1 /dev/vdd").unwrap().trim(),
"foobar"
);
// Unplug the device // Unplug the device
let cmd_success = remote_command(&api_socket, "remove-device", Some("myvdpa0")); let cmd_success = remote_command(&api_socket, "remove-device", Some("myvdpa0"));
assert!(cmd_success); assert!(cmd_success);
thread::sleep(std::time::Duration::new(30, 0)); thread::sleep(std::time::Duration::new(10, 0));
// Check /dev/vdd doesn't exist anymore // Check /dev/vdd doesn't exist anymore
assert_eq!( assert_eq!(
@ -5940,24 +5946,6 @@ mod parallel {
.unwrap_or(1), .unwrap_or(1),
0 0
); );
// Now let's plug it back
let (cmd_success, cmd_output) = remote_command_w_output(
&api_socket,
"add-vdpa",
Some("id=myvdpa0,path=/dev/vhost-vdpa-1,num_queues=1"),
);
assert!(cmd_success);
assert!(String::from_utf8_lossy(&cmd_output)
.contains("{\"id\":\"myvdpa0\",\"bdf\":\"0000:00:07.0\"}"));
thread::sleep(std::time::Duration::new(10, 0));
// And finally check the content
assert_eq!(
guest.ssh_command("sudo head -1 /dev/vdd").unwrap().trim(),
"foobar"
);
}); });
let _ = child.kill(); let _ = child.kill();