Commit 164d7914 authored by paul luse's avatar paul luse Committed by Jim Harris
Browse files

passthru: add RPC testing



And change names of parms to be consistent with others used in
RPC testing.

Change-Id: I8331c6a22866d89a2a4ffb5fc8d41d74b4b7b07d
Signed-off-by: default avatarpaul luse <paul.e.luse@intel.com>
Reviewed-on: https://review.gerrithub.io/428724


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Chandler-Test-Pool: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
Reviewed-by: default avatarShuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
parent 7259370c
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -1589,7 +1589,7 @@ and a starting point in development of new bdev type.

Name                    | Optional | Type        | Description
----------------------- | -------- | ----------- | -----------
passthru_bdev_name      | Required | string      | Bdev name
name                    | Required | string      | Bdev name
base_bdev_name          | Required | string      | Base bdev name

### Result
@@ -1604,7 +1604,7 @@ Example request:
{
  "params": {
    "base_bdev_name": "Malloc0",
    "passthru_bdev_name": "Passsthru0"
    "name": "Passsthru0"
  },
  "jsonrpc": "2.0",
  "method": "construct_passthru_bdev",
+12 −6
Original line number Diff line number Diff line
@@ -618,16 +618,22 @@ create_passthru_disk(const char *bdev_name, const char *vbdev_name)
	struct spdk_bdev *bdev = NULL;
	int rc = 0;

	bdev = spdk_bdev_get_by_name(bdev_name);
	if (!bdev) {
		return -1;
	}

	/* Insert the bdev into our global name list even if it doesn't exist yet,
	 * it may show up soon...
	 */
	rc = vbdev_passthru_insert_name(bdev_name, vbdev_name);
	if (rc != 0) {
	if (rc) {
		return rc;
	}

	bdev = spdk_bdev_get_by_name(bdev_name);
	if (!bdev) {
		/* This is not an error, we tracked the name above and it still
		 * may show up later.
		 */
		return 0;
	}

	vbdev_passthru_register(bdev);

	return 0;
+5 −5
Original line number Diff line number Diff line
@@ -40,7 +40,7 @@
/* Structure to hold the parameters for this RPC method. */
struct rpc_construct_passthru {
	char *base_bdev_name;
	char *passthru_bdev_name;
	char *name;
};

/* Free the allocated memory resource after the RPC handling. */
@@ -48,13 +48,13 @@ static void
free_rpc_construct_passthru(struct rpc_construct_passthru *r)
{
	free(r->base_bdev_name);
	free(r->passthru_bdev_name);
	free(r->name);
}

/* Structure to decode the input parameters for this RPC method. */
static const struct spdk_json_object_decoder rpc_construct_passthru_decoders[] = {
	{"base_bdev_name", offsetof(struct rpc_construct_passthru, base_bdev_name), spdk_json_decode_string},
	{"passthru_bdev_name", offsetof(struct rpc_construct_passthru, passthru_bdev_name), spdk_json_decode_string},
	{"name", offsetof(struct rpc_construct_passthru, name), spdk_json_decode_string},
};

/* Decode the parameters for this RPC method and properly construct the passthru
@@ -75,7 +75,7 @@ spdk_rpc_construct_passthru_bdev(struct spdk_jsonrpc_request *request,
		goto invalid;
	}

	rc = create_passthru_disk(req.base_bdev_name, req.passthru_bdev_name);
	rc = create_passthru_disk(req.base_bdev_name, req.name);
	if (rc != 0) {
		goto invalid;
	}
@@ -86,7 +86,7 @@ spdk_rpc_construct_passthru_bdev(struct spdk_jsonrpc_request *request,
		return;
	}

	spdk_json_write_string(w, req.passthru_bdev_name);
	spdk_json_write_string(w, req.name);
	spdk_jsonrpc_end_result(request, w);
	free_rpc_construct_passthru(&req);
	return;
+2 −2
Original line number Diff line number Diff line
@@ -402,12 +402,12 @@ if __name__ == "__main__":
    def construct_passthru_bdev(args):
        print(rpc.bdev.construct_passthru_bdev(args.client,
                                               base_bdev_name=args.base_bdev_name,
                                               passthru_bdev_name=args.passthru_bdev_name))
                                               name=args.name))

    p = subparsers.add_parser('construct_passthru_bdev',
                              help='Add a pass through bdev on existing bdev')
    p.add_argument('-b', '--base-bdev-name', help="Name of the existing bdev", required=True)
    p.add_argument('-p', '--passthru-bdev-name', help="Name of the pass through bdev", required=True)
    p.add_argument('-p', '--name', help="Name of the pass through bdev", required=True)
    p.set_defaults(func=construct_passthru_bdev)

    @call_cmd
+3 −3
Original line number Diff line number Diff line
@@ -366,19 +366,19 @@ def delete_pmem_bdev(client, name):
    return client.call('delete_pmem_bdev', params)


def construct_passthru_bdev(client, base_bdev_name, passthru_bdev_name):
def construct_passthru_bdev(client, base_bdev_name, name):
    """Construct a pass-through block device.

    Args:
        base_bdev_name: name of the existing bdev
        passthru_bdev_name: name of block device
        name: name of block device

    Returns:
        Name of created block device.
    """
    params = {
        'base_bdev_name': base_bdev_name,
        'passthru_bdev_name': passthru_bdev_name,
        'name': name,
    }
    return client.call('construct_passthru_bdev', params)

Loading