Commit 2aed03f0 authored by Maciej Wawryk's avatar Maciej Wawryk Committed by Jim Harris
Browse files

RPC: rename construct_virtio_dev to bdev_virtio_attach_controller



Signed-off-by: default avatarMaciej Wawryk <maciejx.wawryk@intel.com>
Change-Id: Ic15183de16023a6edb5db3812c6d6e30fdafb8a7
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/468124


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
parent 27d8ca2c
Loading
Loading
Loading
Loading
+5 −5
Original line number Diff line number Diff line
@@ -546,14 +546,14 @@ The following command creates a Virtio-Block device named `VirtioBlk0` from a vh
socket `/tmp/vhost.0` exposed directly by SPDK @ref vhost. Optional `vq-count` and
`vq-size` params specify number of request queues and queue depth to be used.

`rpc.py construct_virtio_dev --dev-type blk --trtype user --traddr /tmp/vhost.0 --vq-count 2 --vq-size 512 VirtioBlk0`
`rpc.py bdev_virtio_attach_controller --dev-type blk --trtype user --traddr /tmp/vhost.0 --vq-count 2 --vq-size 512 VirtioBlk0`

The driver can be also used inside QEMU-based VMs. The following command creates a Virtio
Block device named `VirtioBlk0` from a Virtio PCI device at address `0000:00:01.0`.
The entire configuration will be read automatically from PCI Configuration Space. It will
reflect all parameters passed to QEMU's vhost-user-scsi-pci device.

`rpc.py construct_virtio_dev --dev-type blk --trtype pci --traddr 0000:01:00.0 VirtioBlk1`
`rpc.py bdev_virtio_attach_controller --dev-type blk --trtype pci --traddr 0000:01:00.0 VirtioBlk1`

Virtio-Block devices can be removed with the following command

@@ -563,11 +563,11 @@ Virtio-Block devices can be removed with the following command

The Virtio-SCSI driver allows creating SPDK block devices from Virtio-SCSI LUNs.

Virtio-SCSI bdevs are constructed the same way as Virtio-Block ones.
Virtio-SCSI bdevs are created the same way as Virtio-Block ones.

`rpc.py construct_virtio_dev --dev-type scsi --trtype user --traddr /tmp/vhost.0 --vq-count 2 --vq-size 512 VirtioScsi0`
`rpc.py bdev_virtio_attach_controller --dev-type scsi --trtype user --traddr /tmp/vhost.0 --vq-count 2 --vq-size 512 VirtioScsi0`

`rpc.py construct_virtio_dev --dev-type scsi --trtype pci --traddr 0000:01:00.0 VirtioScsi0`
`rpc.py bdev_virtio_attach_controller --dev-type scsi --trtype pci --traddr 0000:01:00.0 VirtioScsi0`

Each Virtio-SCSI device may export up to 64 block devices named VirtioScsi0t0 ~ VirtioScsi0t63,
one LUN (LUN0) per SCSI device. The above 2 commands will output names of all exposed bdevs.
+3 −3
Original line number Diff line number Diff line
@@ -280,7 +280,7 @@ Example response:
    "context_switch_monitor",
    "kill_instance",
    "scan_ioat_copy_engine",
    "construct_virtio_dev",
    "bdev_virtio_attach_controller",
    "bdev_virtio_scsi_get_devices",
    "bdev_virtio_detach_controller",
    "bdev_aio_delete",
@@ -2394,7 +2394,7 @@ Example response:
}
~~~

## construct_virtio_dev {#rpc_construct_virtio_dev}
## bdev_virtio_attach_controller {#rpc_bdev_virtio_attach_controller}

Create new initiator @ref bdev_config_virtio_scsi or @ref bdev_config_virtio_blk and expose all found bdevs.

@@ -2433,7 +2433,7 @@ Example request:
    "vq_count": 4
  },
  "jsonrpc": "2.0",
  "method": "construct_virtio_dev",
  "method": "bdev_virtio_attach_controller",
  "id": 1
}
~~~
+1 −1
Original line number Diff line number Diff line
@@ -321,7 +321,7 @@ bdev_virtio_write_config_json(struct spdk_bdev *bdev, struct spdk_json_write_ctx

	spdk_json_write_object_begin(w);

	spdk_json_write_named_string(w, "method", "construct_virtio_dev");
	spdk_json_write_named_string(w, "method", "bdev_virtio_attach_controller");

	spdk_json_write_named_object_begin(w, "params");
	spdk_json_write_named_string(w, "name", bvdev->vdev.name);
+21 −19
Original line number Diff line number Diff line
@@ -119,7 +119,7 @@ SPDK_RPC_REGISTER("bdev_virtio_scsi_get_devices",
		  spdk_rpc_bdev_virtio_scsi_get_devices, SPDK_RPC_RUNTIME)
SPDK_RPC_REGISTER_ALIAS_DEPRECATED(bdev_virtio_scsi_get_devices, get_virtio_scsi_devs)

struct rpc_construct_virtio_dev {
struct rpc_bdev_virtio_attach_controller {
	char *name;
	char *trtype;
	char *traddr;
@@ -129,17 +129,17 @@ struct rpc_construct_virtio_dev {
	struct spdk_jsonrpc_request *request;
};

static const struct spdk_json_object_decoder rpc_construct_virtio_dev[] = {
	{"name", offsetof(struct rpc_construct_virtio_dev, name), spdk_json_decode_string },
	{"trtype", offsetof(struct rpc_construct_virtio_dev, trtype), spdk_json_decode_string },
	{"traddr", offsetof(struct rpc_construct_virtio_dev, traddr), spdk_json_decode_string },
	{"dev_type", offsetof(struct rpc_construct_virtio_dev, dev_type), spdk_json_decode_string },
	{"vq_count", offsetof(struct rpc_construct_virtio_dev, vq_count), spdk_json_decode_uint32, true },
	{"vq_size", offsetof(struct rpc_construct_virtio_dev, vq_size), spdk_json_decode_uint32, true },
static const struct spdk_json_object_decoder rpc_bdev_virtio_attach_controller[] = {
	{"name", offsetof(struct rpc_bdev_virtio_attach_controller, name), spdk_json_decode_string },
	{"trtype", offsetof(struct rpc_bdev_virtio_attach_controller, trtype), spdk_json_decode_string },
	{"traddr", offsetof(struct rpc_bdev_virtio_attach_controller, traddr), spdk_json_decode_string },
	{"dev_type", offsetof(struct rpc_bdev_virtio_attach_controller, dev_type), spdk_json_decode_string },
	{"vq_count", offsetof(struct rpc_bdev_virtio_attach_controller, vq_count), spdk_json_decode_uint32, true },
	{"vq_size", offsetof(struct rpc_bdev_virtio_attach_controller, vq_size), spdk_json_decode_uint32, true },
};

static void
free_rpc_construct_virtio_dev(struct rpc_construct_virtio_dev *req)
free_rpc_bdev_virtio_attach_controller(struct rpc_bdev_virtio_attach_controller *req)
{
	free(req->name);
	free(req->trtype);
@@ -151,14 +151,14 @@ free_rpc_construct_virtio_dev(struct rpc_construct_virtio_dev *req)
static void
spdk_rpc_create_virtio_dev_cb(void *ctx, int result, struct spdk_bdev **bdevs, size_t cnt)
{
	struct rpc_construct_virtio_dev *req = ctx;
	struct rpc_bdev_virtio_attach_controller *req = ctx;
	struct spdk_json_write_ctx *w;
	size_t i;

	if (result) {
		spdk_jsonrpc_send_error_response(req->request, SPDK_JSONRPC_ERROR_INVALID_PARAMS,
						 spdk_strerror(-result));
		free_rpc_construct_virtio_dev(req);
		free_rpc_bdev_virtio_attach_controller(req);
		return;
	}

@@ -172,14 +172,14 @@ spdk_rpc_create_virtio_dev_cb(void *ctx, int result, struct spdk_bdev **bdevs, s
	spdk_json_write_array_end(w);
	spdk_jsonrpc_end_result(req->request, w);

	free_rpc_construct_virtio_dev(ctx);
	free_rpc_bdev_virtio_attach_controller(ctx);
}

static void
spdk_rpc_construct_virtio_dev(struct spdk_jsonrpc_request *request,
spdk_rpc_bdev_virtio_attach_controller(struct spdk_jsonrpc_request *request,
				       const struct spdk_json_val *params)
{
	struct rpc_construct_virtio_dev *req;
	struct rpc_bdev_virtio_attach_controller *req;
	struct spdk_bdev *bdev;
	struct spdk_pci_addr pci_addr;
	bool pci;
@@ -192,8 +192,8 @@ spdk_rpc_construct_virtio_dev(struct spdk_jsonrpc_request *request,
		return;
	}

	if (spdk_json_decode_object(params, rpc_construct_virtio_dev,
				    SPDK_COUNTOF(rpc_construct_virtio_dev),
	if (spdk_json_decode_object(params, rpc_bdev_virtio_attach_controller,
				    SPDK_COUNTOF(rpc_bdev_virtio_attach_controller),
				    req)) {
		spdk_jsonrpc_send_error_response(request, SPDK_JSONRPC_ERROR_INTERNAL_ERROR,
						 "spdk_json_decode_object failed");
@@ -257,6 +257,8 @@ spdk_rpc_construct_virtio_dev(struct spdk_jsonrpc_request *request,
	return;

cleanup:
	free_rpc_construct_virtio_dev(req);
	free_rpc_bdev_virtio_attach_controller(req);
}
SPDK_RPC_REGISTER("construct_virtio_dev", spdk_rpc_construct_virtio_dev, SPDK_RPC_RUNTIME);
SPDK_RPC_REGISTER("bdev_virtio_attach_controller",
		  spdk_rpc_bdev_virtio_attach_controller, SPDK_RPC_RUNTIME);
SPDK_RPC_REGISTER_ALIAS_DEPRECATED(bdev_virtio_attach_controller, construct_virtio_dev)
+1 −1
Original line number Diff line number Diff line
@@ -427,7 +427,7 @@ bdev_virtio_scsi_config_json(struct spdk_json_write_ctx *w)
	TAILQ_FOREACH(svdev, &g_virtio_scsi_devs, tailq) {
		spdk_json_write_object_begin(w);

		spdk_json_write_named_string(w, "method", "construct_virtio_dev");
		spdk_json_write_named_string(w, "method", "bdev_virtio_attach_controller");

		spdk_json_write_named_object_begin(w, "params");
		spdk_json_write_named_string(w, "name", svdev->vdev.name);
Loading