From 6bfff2f1cc8030d34df97ad99c62f990850b68f2 Mon Sep 17 00:00:00 2001 From: Liang Yan Date: Fri, 22 Sep 2017 11:40:23 +0800 Subject: [PATCH] examples/perf: exit perf tool if no controllers found Change-Id: Ie70236f6be40ad9598969da2a462af44763c4ac4 Signed-off-by: Liang Yan Reviewed-on: https://review.gerrithub.io/379437 Reviewed-by: Daniel Verkamp Reviewed-by: Changpeng Liu Tested-by: SPDK Automated Test System --- examples/nvme/perf/perf.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/examples/nvme/perf/perf.c b/examples/nvme/perf/perf.c index 1290f4bf1..e6ed247d1 100644 --- a/examples/nvme/perf/perf.c +++ b/examples/nvme/perf/perf.c @@ -147,6 +147,7 @@ static bool g_latency_ssd_tracking_enable = false; static int g_latency_sw_tracking_level = 0; static struct ctrlr_entry *g_controllers = NULL; +static int g_controllers_found = 0; static struct ns_entry *g_namespaces = NULL; static int g_num_namespaces = 0; static struct worker_thread *g_workers = NULL; @@ -1202,6 +1203,7 @@ attach_cb(void *cb_ctx, const struct spdk_nvme_transport_id *trid, struct spdk_pci_device *pci_dev; struct spdk_pci_id pci_id; + g_controllers_found++; if (trid->trtype != SPDK_NVME_TRANSPORT_PCIE) { printf("Attached to NVMe over Fabrics controller at %s:%s: %s\n", trid->traddr, trid->trsvcid, @@ -1365,6 +1367,11 @@ int main(int argc, char **argv) goto cleanup; } + if (g_controllers_found == 0) { + fprintf(stderr, "No NVMe controllers found.\n"); + return 0; + } + if (associate_workers_with_ns() != 0) { rc = -1; goto cleanup;