nvme_fuzz: add -U option to skip IOMMU check

There are many cases where we can safely run the nvme_fuzz
app without having to worry about DMA corruptions - for
example, any test using the TCP/RDMA/vfio-user transports
against a target using an emulated backend like null or
malloc.  So add a -U option to skip the IOMMU check if
the user so desires.

Signed-off-by: Jim Harris <james.r.harris@intel.com>
Change-Id: Ia123b7fb49056f49e2d805c9c3d5b3169c0d589e
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/9724
Community-CI: Broadcom CI <spdk-ci.pdl@broadcom.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Aleksey Marchuk <alexeymar@mellanox.com>
Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
This commit is contained in:
Jim Harris 2021-10-04 22:39:51 +00:00 committed by Tomasz Zawadzki
parent c42d8a16df
commit a29c5a164f

View File

@ -54,6 +54,7 @@ int g_runtime;
int g_num_active_threads = 0;
uint32_t g_admin_depth = 16;
uint32_t g_io_depth = 128;
bool g_check_iommu = true;
bool g_valid_ns_only = false;
bool g_verbose_mode = false;
@ -713,7 +714,7 @@ begin_fuzz(void *ctx)
struct spdk_nvme_ctrlr *ctrlr;
int rc;
if (!spdk_iommu_is_enabled()) {
if (g_check_iommu && !spdk_iommu_is_enabled()) {
/* Don't set rc to an error code here. We don't want to fail an automated test based on this. */
fprintf(stderr, "The IOMMU must be enabled to run this program to avoid unsafe memory accesses.\n");
rc = 0;
@ -783,6 +784,7 @@ This helps dig deeper into other errors besides invalid namespace.\n");
fprintf(stderr, " -S <integer> Seed value for test.\n");
fprintf(stderr,
" -t <integer> Time in seconds to run the fuzz test. Only valid if -j is not specified.\n");
fprintf(stderr, " -U Do not check if IOMMU is enabled.\n");
fprintf(stderr, " -V Enable logging of each submitted command.\n");
}
@ -833,6 +835,9 @@ nvme_fuzz_parse(int ch, char *arg)
return -1;
}
break;
case 'U':
g_check_iommu = false;
break;
case 'V':
g_verbose_mode = true;
break;
@ -855,7 +860,7 @@ main(int argc, char **argv)
g_runtime = DEFAULT_RUNTIME;
g_run = true;
if ((rc = spdk_app_parse_args(argc, argv, &opts, "aF:j:NS:t:V", NULL, nvme_fuzz_parse,
if ((rc = spdk_app_parse_args(argc, argv, &opts, "aF:j:NS:t:UV", NULL, nvme_fuzz_parse,
nvme_fuzz_usage) != SPDK_APP_PARSE_ARGS_SUCCESS)) {
return rc;
}