From 7552ee5512f6a6eccbdfbde8554ddd2fc1f877a4 Mon Sep 17 00:00:00 2001 From: Daniel Verkamp Date: Fri, 16 Sep 2016 16:31:09 -0700 Subject: [PATCH] nvmf_tgt: fail if NVMe controller is not found For subsystems in Direct mode, make sure the NVMe controller specified is actually located during the probe call. Change-Id: I7d5212ea628eadba3e720172a5ead8902eaaf6d0 Signed-off-by: Daniel Verkamp --- app/nvmf_tgt/conf.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/app/nvmf_tgt/conf.c b/app/nvmf_tgt/conf.c index 730940e36..824d04050 100644 --- a/app/nvmf_tgt/conf.c +++ b/app/nvmf_tgt/conf.c @@ -287,6 +287,7 @@ probe_cb(void *cb_ctx, struct spdk_pci_device *dev, struct spdk_nvme_ctrlr_opts found_dev == ctx->device && found_func == ctx->function) { if (!spdk_pci_device_has_non_uio_driver(dev)) { + ctx->found = true; return true; } SPDK_ERRLOG("Requested device is still bound to the kernel. Unbind your NVMe devices first.\n"); @@ -473,6 +474,11 @@ spdk_nvmf_parse_subsystem(struct spdk_conf_section *sp) if (spdk_nvme_probe(&ctx, probe_cb, attach_cb, NULL)) { SPDK_ERRLOG("One or more controllers failed in spdk_nvme_probe()\n"); } + + if (!ctx.found) { + SPDK_ERRLOG("Could not find NVMe controller for Subsystem%d\n", sp->num); + return -1; + } } else { struct spdk_bdev *bdev; const char *namespace, *sn, *val;