Commit 4afe9d1a authored by Daniel Verkamp's avatar Daniel Verkamp
Browse files

nvmf/rpc: make hosts parameter optional in create



Instead of a magical "All" value for allowing all hosts, allow the
caller of construct_nvmf_subsystem to omit the "hosts" parameter.

Change-Id: I97c7ae806a0be7142fb59708d47023e42e127fcc
Signed-off-by: default avatarDaniel Verkamp <daniel.verkamp@intel.com>
parent 45c04144
Loading
Loading
Loading
Loading
+1 −6
Original line number Diff line number Diff line
@@ -730,12 +730,7 @@ spdk_nvmf_parse_subsystem_for_rpc(const char *name,

	/* Parse Host sections */
	for (i = 0; i < num_hosts; i++) {
		char *host_nqn;

		host_nqn = hosts[i];
		if (strcmp(host_nqn, "All") == 0)
			break;
		spdk_nvmf_subsystem_add_host(subsystem, host_nqn);
		spdk_nvmf_subsystem_add_host(subsystem, hosts[i]);
	}

	if (subsystem->mode == NVMF_SUBSYSTEM_MODE_DIRECT) {
+1 −1
Original line number Diff line number Diff line
@@ -283,7 +283,7 @@ static const struct spdk_json_object_decoder rpc_subsystem_decoders[] = {
	{"mode", offsetof(struct rpc_subsystem, mode), spdk_json_decode_string},
	{"nqn", offsetof(struct rpc_subsystem, nqn), spdk_json_decode_string},
	{"listen_addresses", offsetof(struct rpc_subsystem, listen_addresses), decode_rpc_listen_addresses},
	{"hosts", offsetof(struct rpc_subsystem, hosts), decode_rpc_hosts},
	{"hosts", offsetof(struct rpc_subsystem, hosts), decode_rpc_hosts, true},
	{"pci_address", offsetof(struct rpc_subsystem, pci_address), spdk_json_decode_string, true},
	{"serial_number", offsetof(struct rpc_subsystem, serial_number), spdk_json_decode_string, true},
	{"namespaces", offsetof(struct rpc_subsystem, namespaces), decode_rpc_dev_names, true},
+6 −6
Original line number Diff line number Diff line
@@ -309,23 +309,23 @@ p = subparsers.add_parser('get_nvmf_subsystems', help='Display nvmf subsystems')
p.set_defaults(func=get_nvmf_subsystems)

def construct_nvmf_subsystem(args):
    hosts = []

    listen_addresses = [dict(u.split(":") for u in a.split(" ")) for a in args.listen.split(",")]

    for u in args.hosts.split(" "):
        hosts.append(u)

    params = {
        'core': args.core,
        'mode': args.mode,
        'nqn': args.nqn,
        'listen_addresses': listen_addresses,
        'hosts': hosts,
        'pci_address': args.pci_address,
        'serial_number': args.serial_number,
    }

    if args.hosts:
        hosts = []
        for u in args.hosts.split(" "):
            hosts.append(u)
        params['hosts'] = hosts

    if args.namespaces:
        namespaces = []
        for u in args.namespaces.split(" "):
+2 −2
Original line number Diff line number Diff line
@@ -35,8 +35,8 @@ if [ -e "/dev/nvme-fabrics" ]; then
	chmod a+rw /dev/nvme-fabrics
fi

$rpc_py construct_nvmf_subsystem Direct nqn.2016-06.io.spdk:cnode1 'transport:RDMA traddr:192.168.100.8 trsvcid:4420' All -p "*"
$rpc_py construct_nvmf_subsystem Virtual nqn.2016-06.io.spdk:cnode2 'transport:RDMA traddr:192.168.100.8 trsvcid:4420' All -s SPDK00000000000001 -n 'Malloc0 Malloc1'
$rpc_py construct_nvmf_subsystem Direct nqn.2016-06.io.spdk:cnode1 'transport:RDMA traddr:192.168.100.8 trsvcid:4420' '' -p "*"
$rpc_py construct_nvmf_subsystem Virtual nqn.2016-06.io.spdk:cnode2 'transport:RDMA traddr:192.168.100.8 trsvcid:4420' '' -s SPDK00000000000001 -n 'Malloc0 Malloc1'

nvme discover -t rdma -a $NVMF_FIRST_TARGET_IP -s $NVMF_PORT

+2 −2
Original line number Diff line number Diff line
@@ -30,8 +30,8 @@ if [ -e "/dev/nvme-fabrics" ]; then
	chmod a+rw /dev/nvme-fabrics
fi

$rpc_py construct_nvmf_subsystem Direct nqn.2016-06.io.spdk:cnode1 'transport:RDMA traddr:192.168.100.8 trsvcid:4420' All -p "*"
$rpc_py construct_nvmf_subsystem Virtual nqn.2016-06.io.spdk:cnode2 'transport:RDMA traddr:192.168.100.8 trsvcid:4420' All -s SPDK00000000000001 -n 'Malloc0 Malloc1'
$rpc_py construct_nvmf_subsystem Direct nqn.2016-06.io.spdk:cnode1 'transport:RDMA traddr:192.168.100.8 trsvcid:4420' '' -p "*"
$rpc_py construct_nvmf_subsystem Virtual nqn.2016-06.io.spdk:cnode2 'transport:RDMA traddr:192.168.100.8 trsvcid:4420' '' -s SPDK00000000000001 -n 'Malloc0 Malloc1'

nvme connect -t rdma -n "nqn.2016-06.io.spdk:cnode1" -a "$NVMF_FIRST_TARGET_IP" -s "$NVMF_PORT"
nvme connect -t rdma -n "nqn.2016-06.io.spdk:cnode2" -a "$NVMF_FIRST_TARGET_IP" -s "$NVMF_PORT"
Loading