From 5ec0b3227d68b3ae0e397bdd500946b5df9b9865 Mon Sep 17 00:00:00 2001 From: Daniel Verkamp Date: Mon, 10 Oct 2016 16:04:24 -0700 Subject: [PATCH] nvmf/rpc: make sure NVMe device is found in create Extend the check added in commit 7552ee5512f6a6eccbdfbde8554ddd2fc1f877a4 ("nvmf_tgt: fail if NVMe controller is not found") to the RPC interface. Also remove the default PCI address from rpc.py, since it is not a useful default - the user must specify a PCI address, which will vary depending on the configuration of the machine. Change-Id: If9a4e19ef2a84c9d839b467abc011046613f7168 Signed-off-by: Daniel Verkamp --- app/nvmf_tgt/conf.c | 6 ++++++ scripts/rpc.py | 6 ++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/app/nvmf_tgt/conf.c b/app/nvmf_tgt/conf.c index a19948299..9e1c71dc5 100644 --- a/app/nvmf_tgt/conf.c +++ b/app/nvmf_tgt/conf.c @@ -762,6 +762,12 @@ spdk_nvmf_parse_subsystem_for_rpc(const char *name, 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 at PCI address %04x:%02x:%02x.%x\n", + ctx.domain, ctx.bus, ctx.device, ctx.function); + return -1; + } } else { struct spdk_bdev *bdev; const char *namespace; diff --git a/scripts/rpc.py b/scripts/rpc.py index b334ea86e..be4a0ffbc 100755 --- a/scripts/rpc.py +++ b/scripts/rpc.py @@ -316,7 +316,6 @@ def construct_nvmf_subsystem(args): 'mode': args.mode, 'nqn': args.nqn, 'listen_addresses': listen_addresses, - 'pci_address': args.pci_address, 'serial_number': args.serial_number, } @@ -332,6 +331,9 @@ def construct_nvmf_subsystem(args): namespaces.append(u) params['namespaces'] = namespaces + if args.pci_address: + params['pci_address'] = args.pci_address + jsonrpc_call('construct_nvmf_subsystem', params) p = subparsers.add_parser('construct_nvmf_subsystem', help='Add a nvmf subsystem') @@ -346,7 +348,7 @@ Format: 'nqn1 nqn2' etc Example: 'nqn.2016-06.io.spdk:init nqn.2016-07.io.spdk:init'""") p.add_argument("-p", "--pci_address", help="""Valid if mode == Direct. Format: 'domain:device:function' etc -Example: '0000:00:01.0'""", default='0000:00:01.0') +Example: '0000:00:01.0'""") p.add_argument("-s", "--serial_number", help="""Valid if mode == Virtual. Format: 'sn' etc Example: 'SPDK00000000000001'""", default='0000:00:01.0')