From 80aa0a753d607f346842f820a384095513a6c9e7 Mon Sep 17 00:00:00 2001 From: Rob Bradford Date: Tue, 12 May 2020 12:14:03 +0100 Subject: [PATCH] tests: Test unplugging virtio-fs Now that virtio-fs has unplug support try unplugging and readding the virtio-fs device. Fixes: #1050 Signed-off-by: Rob Bradford --- tests/integration.rs | 57 +++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 56 insertions(+), 1 deletion(-) diff --git a/tests/integration.rs b/tests/integration.rs index 9af0c2f7e..1abb106e6 100644 --- a/tests/integration.rs +++ b/tests/integration.rs @@ -1850,7 +1850,7 @@ mod tests { .args(&["--api-socket", &api_socket]); let fs_params = format!( - "tag=myfs,sock={},num_queues=1,queue_size=1024,dax={}{}", + "id=myfs0,tag=myfs,sock={},num_queues=1,queue_size=1024,dax={}{}", virtiofsd_socket_path, dax_vmm_param, cache_size_vmm_param ); @@ -1949,6 +1949,61 @@ mod tests { ); } + if hotplug { + // Remove from VM + aver_eq!( + tb, + guest + .ssh_command("sudo umount mount_dir && echo ok") + .unwrap_or_default() + .trim(), + "ok" + ); + aver!( + tb, + remote_command(&api_socket, "remove-device", Some("myfs0"),) + ); + + thread::sleep(std::time::Duration::new(10, 0)); + let (mut daemon_child, virtiofsd_socket_path) = prepare_daemon( + &guest.tmp_dir, + shared_dir.to_str().unwrap(), + virtiofsd_cache, + ); + thread::sleep(std::time::Duration::new(10, 0)); + let fs_params = format!( + "id=myfs0,tag=myfs,sock={},num_queues=1,queue_size=1024,dax={}{}", + virtiofsd_socket_path, dax_vmm_param, cache_size_vmm_param + ); + + // Add back and check it works + aver!(tb, remote_command(&api_socket, "add-fs", Some(&fs_params),)); + thread::sleep(std::time::Duration::new(10, 0)); + // Mount shared directory through virtio_fs filesystem + let mount_cmd = format!( + "mkdir -p mount_dir && \ + sudo mount -t virtiofs {} myfs mount_dir/ && \ + echo ok", + dax_mount_param + ); + aver_eq!( + tb, + guest.ssh_command(&mount_cmd).unwrap_or_default().trim(), + "ok" + ); + // Check file1 exists and its content is "foo" + aver_eq!( + tb, + guest + .ssh_command("cat mount_dir/file1") + .unwrap_or_default() + .trim(), + "foo" + ); + let _ = daemon_child.kill(); + let _ = daemon_child.wait(); + } + let _ = child.kill(); let _ = daemon_child.kill(); let _ = child.wait();