(nvme_dir: &std::path::Path)
| 5396 | } |
| 5397 | |
| 5398 | fn setup_spdk_nvme(nvme_dir: &std::path::Path) -> Child { |
| 5399 | cleanup_spdk_nvme(); |
| 5400 | |
| 5401 | assert!( |
| 5402 | exec_host_command_status(&format!( |
| 5403 | "mkdir -p {}", |
| 5404 | nvme_dir.join("nvme-vfio-user").to_str().unwrap() |
| 5405 | )) |
| 5406 | .success() |
| 5407 | ); |
| 5408 | assert!( |
| 5409 | exec_host_command_status(&format!( |
| 5410 | "truncate {} -s 128M", |
| 5411 | nvme_dir.join("test-disk.raw").to_str().unwrap() |
| 5412 | )) |
| 5413 | .success() |
| 5414 | ); |
| 5415 | assert!( |
| 5416 | exec_host_command_status(&format!( |
| 5417 | "mkfs.ext4 {}", |
| 5418 | nvme_dir.join("test-disk.raw").to_str().unwrap() |
| 5419 | )) |
| 5420 | .success() |
| 5421 | ); |
| 5422 | |
| 5423 | // Start the SPDK nvmf_tgt daemon to present NVMe device as a VFIO user device |
| 5424 | let child = Command::new("/usr/local/bin/spdk-nvme/nvmf_tgt") |
| 5425 | .args(["-i", "0", "-m", "0x1"]) |
| 5426 | .spawn() |
| 5427 | .unwrap(); |
| 5428 | thread::sleep(std::time::Duration::new(2, 0)); |
| 5429 | |
| 5430 | assert!(exec_host_command_with_retries( |
| 5431 | "/usr/local/bin/spdk-nvme/rpc.py nvmf_create_transport -t VFIOUSER", |
| 5432 | 3, |
| 5433 | std::time::Duration::new(5, 0), |
| 5434 | )); |
| 5435 | assert!( |
| 5436 | exec_host_command_status(&format!( |
| 5437 | "/usr/local/bin/spdk-nvme/rpc.py bdev_aio_create {} test 512", |
| 5438 | nvme_dir.join("test-disk.raw").to_str().unwrap() |
| 5439 | )) |
| 5440 | .success() |
| 5441 | ); |
| 5442 | assert!(exec_host_command_status( |
| 5443 | "/usr/local/bin/spdk-nvme/rpc.py nvmf_create_subsystem nqn.2019-07.io.spdk:cnode -a -s test" |
| 5444 | ) |
| 5445 | .success()); |
| 5446 | assert!(exec_host_command_status( |
| 5447 | "/usr/local/bin/spdk-nvme/rpc.py nvmf_subsystem_add_ns nqn.2019-07.io.spdk:cnode test" |
| 5448 | ) |
| 5449 | .success()); |
| 5450 | assert!(exec_host_command_status(&format!( |
| 5451 | "/usr/local/bin/spdk-nvme/rpc.py nvmf_subsystem_add_listener nqn.2019-07.io.spdk:cnode -t VFIOUSER -a {} -s 0", |
| 5452 | nvme_dir.join("nvme-vfio-user").to_str().unwrap() |
| 5453 | )) |
| 5454 | .success()); |
| 5455 |
no test coverage detected