sock/rpc: Add sock_set_default_impl RPC call
Change-Id: I11160b6e8e2a1500c80a2512a1344094b2813aa9 Signed-off-by: Alexey Marchuk <alexeymar@mellanox.com> Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/4328 Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com> Reviewed-by: Ben Walker <benjamin.walker@intel.com> Reviewed-by: Jim Harris <james.r.harris@intel.com>
This commit is contained in:
parent
079f2d0abe
commit
89d9fe558a
@ -7467,6 +7467,45 @@ Example response:
|
|||||||
}
|
}
|
||||||
~~~
|
~~~
|
||||||
|
|
||||||
|
## sock_set_default_impl {#rpc_sock_set_default_impl}
|
||||||
|
|
||||||
|
Set the default sock implementation.
|
||||||
|
|
||||||
|
### Parameters
|
||||||
|
|
||||||
|
Name | Optional | Type | Description
|
||||||
|
----------------------- | -------- | ----------- | -----------
|
||||||
|
impl_name | Required | string | Name of socket implementation, e.g. posix
|
||||||
|
|
||||||
|
### Response
|
||||||
|
|
||||||
|
True if the default socket layer configuration was set successfully.
|
||||||
|
|
||||||
|
### Example
|
||||||
|
|
||||||
|
Example request:
|
||||||
|
|
||||||
|
~~~
|
||||||
|
{
|
||||||
|
"jsonrpc": "2.0",
|
||||||
|
"method": "sock_set_default_impl",
|
||||||
|
"id": 1,
|
||||||
|
"params": {
|
||||||
|
"impl_name": "posix"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
~~~
|
||||||
|
|
||||||
|
Example response:
|
||||||
|
|
||||||
|
~~~
|
||||||
|
{
|
||||||
|
"jsonrpc": "2.0",
|
||||||
|
"id": 1,
|
||||||
|
"result": true
|
||||||
|
}
|
||||||
|
~~~
|
||||||
|
|
||||||
# Miscellaneous RPC commands
|
# Miscellaneous RPC commands
|
||||||
|
|
||||||
## bdev_nvme_send_cmd {#rpc_bdev_nvme_send_cmd}
|
## bdev_nvme_send_cmd {#rpc_bdev_nvme_send_cmd}
|
||||||
|
@ -803,6 +803,15 @@ spdk_sock_write_config_json(struct spdk_json_write_ctx *w)
|
|||||||
|
|
||||||
spdk_json_write_array_begin(w);
|
spdk_json_write_array_begin(w);
|
||||||
|
|
||||||
|
if (g_default_impl) {
|
||||||
|
spdk_json_write_object_begin(w);
|
||||||
|
spdk_json_write_named_string(w, "method", "sock_set_default_impl");
|
||||||
|
spdk_json_write_named_object_begin(w, "params");
|
||||||
|
spdk_json_write_named_string(w, "impl_name", g_default_impl->name);
|
||||||
|
spdk_json_write_object_end(w);
|
||||||
|
spdk_json_write_object_end(w);
|
||||||
|
}
|
||||||
|
|
||||||
STAILQ_FOREACH(impl, &g_net_impls, link) {
|
STAILQ_FOREACH(impl, &g_net_impls, link) {
|
||||||
if (!impl->get_opts) {
|
if (!impl->get_opts) {
|
||||||
continue;
|
continue;
|
||||||
|
@ -170,3 +170,35 @@ rpc_sock_impl_set_options(struct spdk_jsonrpc_request *request,
|
|||||||
free(opts.impl_name);
|
free(opts.impl_name);
|
||||||
}
|
}
|
||||||
SPDK_RPC_REGISTER("sock_impl_set_options", rpc_sock_impl_set_options, SPDK_RPC_STARTUP)
|
SPDK_RPC_REGISTER("sock_impl_set_options", rpc_sock_impl_set_options, SPDK_RPC_STARTUP)
|
||||||
|
|
||||||
|
static void
|
||||||
|
rpc_sock_set_default_impl(struct spdk_jsonrpc_request *request,
|
||||||
|
const struct spdk_json_val *params)
|
||||||
|
{
|
||||||
|
char *impl_name = NULL;
|
||||||
|
struct spdk_json_write_ctx *w;
|
||||||
|
int rc;
|
||||||
|
|
||||||
|
/* Reuse get_opts decoder */
|
||||||
|
if (spdk_json_decode_object(params, rpc_sock_impl_get_opts_decoders,
|
||||||
|
SPDK_COUNTOF(rpc_sock_impl_get_opts_decoders), &impl_name)) {
|
||||||
|
SPDK_ERRLOG("spdk_json_decode_object() failed\n");
|
||||||
|
spdk_jsonrpc_send_error_response(request, SPDK_JSONRPC_ERROR_INVALID_PARAMS,
|
||||||
|
"Invalid parameters");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
rc = spdk_sock_set_default_impl(impl_name);
|
||||||
|
if (rc) {
|
||||||
|
free(impl_name);
|
||||||
|
spdk_jsonrpc_send_error_response(request, SPDK_JSONRPC_ERROR_INVALID_PARAMS,
|
||||||
|
"Invalid parameters");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
w = spdk_jsonrpc_begin_result(request);
|
||||||
|
spdk_json_write_bool(w, true);
|
||||||
|
spdk_jsonrpc_end_result(request, w);
|
||||||
|
free(impl_name);
|
||||||
|
}
|
||||||
|
SPDK_RPC_REGISTER("sock_set_default_impl", rpc_sock_set_default_impl, SPDK_RPC_STARTUP)
|
||||||
|
@ -2567,6 +2567,14 @@ Format: 'user:u1 secret:s1 muser:mu1 msecret:ms1,user:u2 secret:s2 muser:mu2 mse
|
|||||||
p.set_defaults(func=sock_impl_set_options, enable_recv_pipe=None, enable_zerocopy_send=None,
|
p.set_defaults(func=sock_impl_set_options, enable_recv_pipe=None, enable_zerocopy_send=None,
|
||||||
enable_quickack=None, enable_placement_id=None)
|
enable_quickack=None, enable_placement_id=None)
|
||||||
|
|
||||||
|
def sock_set_default_impl(args):
|
||||||
|
print_json(rpc.sock.sock_set_default_impl(args.client,
|
||||||
|
impl_name=args.impl))
|
||||||
|
|
||||||
|
p = subparsers.add_parser('sock_set_default_impl', help="""Set the default sock implementation""")
|
||||||
|
p.add_argument('-i', '--impl', help='Socket implementation name, e.g. posix', required=True)
|
||||||
|
p.set_defaults(func=sock_set_default_impl)
|
||||||
|
|
||||||
def check_called_name(name):
|
def check_called_name(name):
|
||||||
if name in deprecated_aliases:
|
if name in deprecated_aliases:
|
||||||
print("{} is deprecated, use {} instead.".format(name, deprecated_aliases[name]), file=sys.stderr)
|
print("{} is deprecated, use {} instead.".format(name, deprecated_aliases[name]), file=sys.stderr)
|
||||||
|
@ -47,3 +47,16 @@ def sock_impl_set_options(client,
|
|||||||
params['enable_placement_id'] = enable_placement_id
|
params['enable_placement_id'] = enable_placement_id
|
||||||
|
|
||||||
return client.call('sock_impl_set_options', params)
|
return client.call('sock_impl_set_options', params)
|
||||||
|
|
||||||
|
|
||||||
|
def sock_set_default_impl(client, impl_name=None):
|
||||||
|
"""Set the default socket implementation.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
impl_name: name of socket implementation, e.g. posix
|
||||||
|
"""
|
||||||
|
params = {}
|
||||||
|
|
||||||
|
params['impl_name'] = impl_name
|
||||||
|
|
||||||
|
return client.call('sock_set_default_impl', params)
|
||||||
|
@ -32,6 +32,7 @@ def filter_methods(do_remove_global_rpcs):
|
|||||||
'bdev_nvme_set_options',
|
'bdev_nvme_set_options',
|
||||||
'bdev_nvme_set_hotplug',
|
'bdev_nvme_set_hotplug',
|
||||||
'sock_impl_set_options',
|
'sock_impl_set_options',
|
||||||
|
'sock_set_default_impl',
|
||||||
]
|
]
|
||||||
|
|
||||||
data = json.loads(sys.stdin.read())
|
data = json.loads(sys.stdin.read())
|
||||||
|
Loading…
Reference in New Issue
Block a user