RPC: rename construct_virtio_dev to bdev_virtio_attach_controller

Signed-off-by: Maciej Wawryk <maciejx.wawryk@intel.com>
Change-Id: Ic15183de16023a6edb5db3812c6d6e30fdafb8a7
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/468124
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
This commit is contained in:
Maciej Wawryk 2019-09-11 14:50:38 +02:00 committed by Jim Harris
parent 27d8ca2ce7
commit 2aed03f0f5
12 changed files with 62 additions and 55 deletions

View File

@ -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.

View File

@ -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
}
~~~

View File

@ -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);

View File

@ -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,
const struct spdk_json_val *params)
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)

View File

@ -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);

View File

@ -15,7 +15,7 @@ bdev_dict["bdev_nvme_set_hotplug"] = []
bdev_dict["bdev_malloc_create"] = []
bdev_dict["bdev_aio_create"] = []
bdev_dict["bdev_pmem_create"] = []
bdev_dict["construct_virtio_dev"] = []
bdev_dict["bdev_virtio_attach_controller"] = []
vhost_dict = OrderedDict()
vhost_dict["construct_vhost_scsi_controller"] = []
@ -489,7 +489,7 @@ def get_virtio_user_json(config, section):
return [{
"params": to_json_params(params),
"method": "construct_virtio_dev"
"method": "bdev_virtio_attach_controller"
}]

View File

@ -1879,18 +1879,20 @@ Format: 'user:u1 secret:s1 muser:mu1 msecret:ms1,user:u2 secret:s2 muser:mu2 mse
p.add_argument('ctrlr', help='controller name')
p.set_defaults(func=remove_vhost_controller)
def construct_virtio_dev(args):
print_array(rpc.vhost.construct_virtio_dev(args.client,
name=args.name,
trtype=args.trtype,
traddr=args.traddr,
dev_type=args.dev_type,
vq_count=args.vq_count,
vq_size=args.vq_size))
def bdev_virtio_attach_controller(args):
print_array(rpc.vhost.bdev_virtio_attach_controller(args.client,
name=args.name,
trtype=args.trtype,
traddr=args.traddr,
dev_type=args.dev_type,
vq_count=args.vq_count,
vq_size=args.vq_size))
p = subparsers.add_parser('construct_virtio_dev', help="""Construct new virtio device using provided
transport type and device type. In case of SCSI device type this implies scan and add bdevs offered by
remote side. Result is array of added bdevs.""")
p = subparsers.add_parser('bdev_virtio_attach_controller', aliases=['construct_virtio_dev'],
help="""Attach virtio controller using provided
transport type and device type. This will also create bdevs for any block devices connected to the
controller (for example, SCSI devices for a virtio-scsi controller).
Result is array of added bdevs.""")
p.add_argument('name', help="Use this name as base for new created bdevs")
p.add_argument('-t', '--trtype',
help='Virtio target transport type: pci or user', required=True)
@ -1900,7 +1902,7 @@ Format: 'user:u1 secret:s1 muser:mu1 msecret:ms1,user:u2 secret:s2 muser:mu2 mse
help='Device type: blk or scsi', required=True)
p.add_argument('--vq-count', help='Number of virtual queues to be used.', type=int)
p.add_argument('--vq-size', help='Size of each queue', type=int)
p.set_defaults(func=construct_virtio_dev)
p.set_defaults(func=bdev_virtio_attach_controller)
def bdev_virtio_scsi_get_devices(args):
print_dict(rpc.vhost.bdev_virtio_scsi_get_devices(args.client))

View File

@ -133,9 +133,12 @@ def remove_vhost_controller(client, ctrlr):
return client.call('remove_vhost_controller', params)
def construct_virtio_dev(client, name, trtype, traddr, dev_type, vq_count=None, vq_size=None):
"""Construct new virtio device using provided
transport type and device type.
@deprecated_alias('construct_virtio_dev')
def bdev_virtio_attach_controller(client, name, trtype, traddr, dev_type, vq_count=None, vq_size=None):
"""Attaches virtio controller using
provided transport type and device type.
This will also create bdevs for any block
devices connected to that controller.
Args:
name: name base for new created bdevs
trtype: virtio target transport type: pci or user
@ -155,7 +158,7 @@ def construct_virtio_dev(client, name, trtype, traddr, dev_type, vq_count=None,
params['vq_count'] = vq_count
if vq_size:
params['vq_size'] = vq_size
return client.call('construct_virtio_dev', params)
return client.call('bdev_virtio_attach_controller', params)
@deprecated_alias('remove_virtio_bdev ')

View File

@ -241,7 +241,7 @@ class UIRoot(UINode):
@verbose
def create_virtio_dev(self, **kwargs):
response = rpc.vhost.construct_virtio_dev(self.client, **kwargs)
response = rpc.vhost.bdev_virtio_attach_controller(self.client, **kwargs)
return self.print_array(response)
@verbose

View File

@ -48,7 +48,7 @@
"traddr": "naa.vhost.0",
"vq_count": 8
},
"method": "construct_virtio_dev"
"method": "bdev_virtio_attach_controller"
},
{
"params": {
@ -59,7 +59,7 @@
"traddr": "naa.vhost.1",
"vq_count": 8
},
"method": "construct_virtio_dev"
"method": "bdev_virtio_attach_controller"
},
{
"params": {
@ -70,7 +70,7 @@
"traddr": "vhost.1",
"vq_count": 1
},
"method": "construct_virtio_dev"
"method": "bdev_virtio_attach_controller"
}
]
},

View File

@ -38,7 +38,7 @@ def get_bdev_delete_method(bdev):
'bdev_aio_create': "bdev_aio_delete",
'bdev_error_create': "bdev_error_delete",
'construct_split_vbdev': "destruct_split_vbdev",
'construct_virtio_dev': "remove_virtio_bdev",
'bdev_virtio_attach_controller': "remove_virtio_bdev",
'bdev_crypto_create': "bdev_crypto_delete",
'bdev_delay_create': "bdev_delay_delete",
'bdev_passthru_create': "bdev_passthru_delete",

View File

@ -328,9 +328,9 @@ function create_nvmf_subsystem_config() {
function create_virtio_initiator_config() {
timing_enter $FUNCNAME
initiator_rpc construct_virtio_dev -t user -a /var/tmp/VhostScsiCtrlr0 -d scsi VirtioScsiCtrlr0
initiator_rpc construct_virtio_dev -t user -a /var/tmp/VhostBlkCtrlr0 -d blk VirtioBlk0
# TODO: initiator_rpc construct_virtio_dev -t user -a /var/tmp/VhostNvmeCtrlr0 -d nvme VirtioNvme0
initiator_rpc bdev_virtio_attach_controller -t user -a /var/tmp/VhostScsiCtrlr0 -d scsi VirtioScsiCtrlr0
initiator_rpc bdev_virtio_attach_controller -t user -a /var/tmp/VhostBlkCtrlr0 -d blk VirtioBlk0
# TODO: initiator_rpc bdev_virtio_attach_controller -t user -a /var/tmp/VhostNvmeCtrlr0 -d nvme VirtioNvme0
timing_exit $FUNCNAME
}