rpc: Add state_mask to each RPC method to make sets of RPCs
Add state_mask to each RPC method and state to RPC server, respectively. State mask of RPC method is set at registration. State of RPC server is changed according to the state of the SPDK. When any RPC method is recieved, if the bit of the RPC server is on in the state mask of the RPC method, it is allowed. Otherwise, it is rejected. When any RPC is rejected by state_mask control, the new error code is returned to describe the error clearly. Change-Id: I84e52b8725a286e9329d61c56f498aa2c8664ec1 Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com> Reviewed-on: https://review.gerrithub.io/407397 Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com> Reviewed-by: Pawel Wodkowski <pawelx.wodkowski@intel.com> Reviewed-by: Ben Walker <benjamin.walker@intel.com> Reviewed-by: Jim Harris <james.r.harris@intel.com> Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
This commit is contained in:
parent
cc87019ab6
commit
e008db08e7
@ -47,12 +47,20 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Defined error codes in JSON-RPC specification 2.0 */
|
||||
#define SPDK_JSONRPC_ERROR_PARSE_ERROR -32700
|
||||
#define SPDK_JSONRPC_ERROR_INVALID_REQUEST -32600
|
||||
#define SPDK_JSONRPC_ERROR_METHOD_NOT_FOUND -32601
|
||||
#define SPDK_JSONRPC_ERROR_INVALID_PARAMS -32602
|
||||
#define SPDK_JSONRPC_ERROR_INTERNAL_ERROR -32603
|
||||
|
||||
/* Custom error codes in SPDK
|
||||
|
||||
* Error codes from and including -32768 to -32000 are reserved for
|
||||
* predefined errors, hence custom error codes must be outside of the range.
|
||||
*/
|
||||
#define SPDK_JSONRPC_ERROR_INVALID_STATE -1
|
||||
|
||||
struct spdk_jsonrpc_server;
|
||||
struct spdk_jsonrpc_request;
|
||||
|
||||
|
@ -75,15 +75,30 @@ typedef void (*spdk_rpc_method_handler)(struct spdk_jsonrpc_request *request,
|
||||
*
|
||||
* \param method Name for the registered method.
|
||||
* \param func Function registered for this method to handle the RPC request.
|
||||
* \param state_mask State mask of the registered method. If the bit of the state of
|
||||
* the RPC server is set in the state_mask, the method is allowed. Otherwise, it is rejected.
|
||||
*/
|
||||
void spdk_rpc_register_method(const char *method, spdk_rpc_method_handler func);
|
||||
void spdk_rpc_register_method(const char *method, spdk_rpc_method_handler func,
|
||||
uint32_t state_mask);
|
||||
|
||||
#define SPDK_RPC_REGISTER(method, func) \
|
||||
#define SPDK_RPC_STARTUP 0x1
|
||||
#define SPDK_RPC_RUNTIME 0x2
|
||||
|
||||
#define SPDK_RPC_REGISTER(method, func, state_mask) \
|
||||
static void __attribute__((constructor)) rpc_register_##func(void) \
|
||||
{ \
|
||||
spdk_rpc_register_method(method, func); \
|
||||
spdk_rpc_register_method(method, func, state_mask); \
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the state mask of the RPC server. Any RPC method whose state mask is
|
||||
* equal to the state of the RPC server is allowed.
|
||||
*
|
||||
* \param state_mask New state mask of the RPC server.
|
||||
*/
|
||||
void spdk_rpc_set_state(uint32_t state_mask);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@ -97,4 +97,4 @@ invalid:
|
||||
spdk_jsonrpc_send_error_response(request, SPDK_JSONRPC_ERROR_INVALID_PARAMS, "Invalid parameters");
|
||||
free_rpc_construct_aio(&req);
|
||||
}
|
||||
SPDK_RPC_REGISTER("construct_aio_bdev", spdk_rpc_construct_aio_bdev)
|
||||
SPDK_RPC_REGISTER("construct_aio_bdev", spdk_rpc_construct_aio_bdev, SPDK_RPC_RUNTIME)
|
||||
|
@ -122,7 +122,7 @@ invalid:
|
||||
spdk_jsonrpc_send_error_response(request, SPDK_JSONRPC_ERROR_INVALID_PARAMS, "Invalid parameters");
|
||||
free_rpc_construct_error_bdev(&req);
|
||||
}
|
||||
SPDK_RPC_REGISTER("construct_error_bdev", spdk_rpc_construct_error_bdev)
|
||||
SPDK_RPC_REGISTER("construct_error_bdev", spdk_rpc_construct_error_bdev, SPDK_RPC_RUNTIME)
|
||||
|
||||
struct rpc_error_information {
|
||||
char *name;
|
||||
@ -193,4 +193,4 @@ invalid:
|
||||
spdk_jsonrpc_send_error_response(request, SPDK_JSONRPC_ERROR_INVALID_PARAMS, "Invalid parameters");
|
||||
free_rpc_error_information(&req);
|
||||
}
|
||||
SPDK_RPC_REGISTER("bdev_inject_error", spdk_rpc_bdev_inject_error)
|
||||
SPDK_RPC_REGISTER("bdev_inject_error", spdk_rpc_bdev_inject_error, SPDK_RPC_RUNTIME)
|
||||
|
@ -166,7 +166,7 @@ invalid:
|
||||
spdk_strerror(-rc));
|
||||
free_rpc_construct_lvol_store(&req);
|
||||
}
|
||||
SPDK_RPC_REGISTER("construct_lvol_store", spdk_rpc_construct_lvol_store)
|
||||
SPDK_RPC_REGISTER("construct_lvol_store", spdk_rpc_construct_lvol_store, SPDK_RPC_RUNTIME)
|
||||
|
||||
struct rpc_rename_lvol_store {
|
||||
char *old_name;
|
||||
@ -242,7 +242,7 @@ invalid:
|
||||
spdk_jsonrpc_send_error_response(request, SPDK_JSONRPC_ERROR_INVALID_PARAMS, spdk_strerror(-rc));
|
||||
free_rpc_rename_lvol_store(&req);
|
||||
}
|
||||
SPDK_RPC_REGISTER("rename_lvol_store", spdk_rpc_rename_lvol_store)
|
||||
SPDK_RPC_REGISTER("rename_lvol_store", spdk_rpc_rename_lvol_store, SPDK_RPC_RUNTIME)
|
||||
|
||||
struct rpc_destroy_lvol_store {
|
||||
char *uuid;
|
||||
@ -317,7 +317,7 @@ invalid:
|
||||
spdk_strerror(-rc));
|
||||
free_rpc_destroy_lvol_store(&req);
|
||||
}
|
||||
SPDK_RPC_REGISTER("destroy_lvol_store", spdk_rpc_destroy_lvol_store)
|
||||
SPDK_RPC_REGISTER("destroy_lvol_store", spdk_rpc_destroy_lvol_store, SPDK_RPC_RUNTIME)
|
||||
|
||||
struct rpc_construct_lvol_bdev {
|
||||
char *uuid;
|
||||
@ -413,7 +413,7 @@ invalid:
|
||||
free_rpc_construct_lvol_bdev(&req);
|
||||
}
|
||||
|
||||
SPDK_RPC_REGISTER("construct_lvol_bdev", spdk_rpc_construct_lvol_bdev)
|
||||
SPDK_RPC_REGISTER("construct_lvol_bdev", spdk_rpc_construct_lvol_bdev, SPDK_RPC_RUNTIME)
|
||||
|
||||
struct rpc_snapshot_lvol_bdev {
|
||||
char *lvol_name;
|
||||
@ -501,7 +501,7 @@ invalid:
|
||||
free_rpc_snapshot_lvol_bdev(&req);
|
||||
}
|
||||
|
||||
SPDK_RPC_REGISTER("snapshot_lvol_bdev", spdk_rpc_snapshot_lvol_bdev)
|
||||
SPDK_RPC_REGISTER("snapshot_lvol_bdev", spdk_rpc_snapshot_lvol_bdev, SPDK_RPC_RUNTIME)
|
||||
|
||||
struct rpc_clone_lvol_bdev {
|
||||
char *snapshot_name;
|
||||
@ -589,7 +589,7 @@ invalid:
|
||||
free_rpc_clone_lvol_bdev(&req);
|
||||
}
|
||||
|
||||
SPDK_RPC_REGISTER("clone_lvol_bdev", spdk_rpc_clone_lvol_bdev)
|
||||
SPDK_RPC_REGISTER("clone_lvol_bdev", spdk_rpc_clone_lvol_bdev, SPDK_RPC_RUNTIME)
|
||||
|
||||
struct rpc_rename_lvol_bdev {
|
||||
char *old_name;
|
||||
@ -675,7 +675,7 @@ invalid:
|
||||
free_rpc_rename_lvol_bdev(&req);
|
||||
}
|
||||
|
||||
SPDK_RPC_REGISTER("rename_lvol_bdev", spdk_rpc_rename_lvol_bdev)
|
||||
SPDK_RPC_REGISTER("rename_lvol_bdev", spdk_rpc_rename_lvol_bdev, SPDK_RPC_RUNTIME)
|
||||
|
||||
struct rpc_resize_lvol_bdev {
|
||||
char *name;
|
||||
@ -766,7 +766,7 @@ invalid:
|
||||
free_rpc_resize_lvol_bdev(&req);
|
||||
}
|
||||
|
||||
SPDK_RPC_REGISTER("resize_lvol_bdev", spdk_rpc_resize_lvol_bdev)
|
||||
SPDK_RPC_REGISTER("resize_lvol_bdev", spdk_rpc_resize_lvol_bdev, SPDK_RPC_RUNTIME)
|
||||
|
||||
struct rpc_destroy_lvol_bdev {
|
||||
char *name;
|
||||
@ -847,7 +847,7 @@ invalid:
|
||||
free_rpc_destroy_lvol_bdev(&req);
|
||||
}
|
||||
|
||||
SPDK_RPC_REGISTER("destroy_lvol_bdev", spdk_rpc_destroy_lvol_bdev)
|
||||
SPDK_RPC_REGISTER("destroy_lvol_bdev", spdk_rpc_destroy_lvol_bdev, SPDK_RPC_RUNTIME)
|
||||
|
||||
struct rpc_get_lvol_stores {
|
||||
char *uuid;
|
||||
@ -965,4 +965,4 @@ invalid:
|
||||
free_rpc_get_lvol_stores(&req);
|
||||
}
|
||||
|
||||
SPDK_RPC_REGISTER("get_lvol_stores", spdk_rpc_get_lvol_stores)
|
||||
SPDK_RPC_REGISTER("get_lvol_stores", spdk_rpc_get_lvol_stores, SPDK_RPC_RUNTIME)
|
||||
|
@ -105,4 +105,4 @@ invalid:
|
||||
free_rpc_construct_malloc(&req);
|
||||
spdk_jsonrpc_send_error_response(request, SPDK_JSONRPC_ERROR_INVALID_PARAMS, "Invalid parameters");
|
||||
}
|
||||
SPDK_RPC_REGISTER("construct_malloc_bdev", spdk_rpc_construct_malloc_bdev)
|
||||
SPDK_RPC_REGISTER("construct_malloc_bdev", spdk_rpc_construct_malloc_bdev, SPDK_RPC_RUNTIME)
|
||||
|
@ -106,4 +106,4 @@ invalid:
|
||||
spdk_jsonrpc_send_error_response(request, SPDK_JSONRPC_ERROR_INVALID_PARAMS, "Invalid parameters");
|
||||
free_rpc_construct_null(&req);
|
||||
}
|
||||
SPDK_RPC_REGISTER("construct_null_bdev", spdk_rpc_construct_null_bdev)
|
||||
SPDK_RPC_REGISTER("construct_null_bdev", spdk_rpc_construct_null_bdev, SPDK_RPC_RUNTIME)
|
||||
|
@ -155,7 +155,7 @@ invalid:
|
||||
spdk_jsonrpc_send_error_response(request, SPDK_JSONRPC_ERROR_INVALID_PARAMS, "Invalid parameters");
|
||||
free_rpc_construct_nvme(&req);
|
||||
}
|
||||
SPDK_RPC_REGISTER("construct_nvme_bdev", spdk_rpc_construct_nvme_bdev)
|
||||
SPDK_RPC_REGISTER("construct_nvme_bdev", spdk_rpc_construct_nvme_bdev, SPDK_RPC_RUNTIME)
|
||||
|
||||
struct rpc_apply_firmware {
|
||||
char *filename;
|
||||
@ -490,4 +490,4 @@ spdk_rpc_apply_nvme_firmware(struct spdk_jsonrpc_request *request,
|
||||
return;
|
||||
}
|
||||
}
|
||||
SPDK_RPC_REGISTER("apply_nvme_firmware", spdk_rpc_apply_nvme_firmware)
|
||||
SPDK_RPC_REGISTER("apply_nvme_firmware", spdk_rpc_apply_nvme_firmware, SPDK_RPC_RUNTIME)
|
||||
|
@ -97,4 +97,4 @@ invalid:
|
||||
free_rpc_construct_passthru(&req);
|
||||
spdk_jsonrpc_send_error_response(request, SPDK_JSONRPC_ERROR_INVALID_PARAMS, "Invalid parameters");
|
||||
}
|
||||
SPDK_RPC_REGISTER("construct_passthru_bdev", spdk_rpc_construct_passthru_bdev)
|
||||
SPDK_RPC_REGISTER("construct_passthru_bdev", spdk_rpc_construct_passthru_bdev, SPDK_RPC_RUNTIME)
|
||||
|
@ -99,7 +99,7 @@ invalid:
|
||||
spdk_jsonrpc_send_error_response(request, SPDK_JSONRPC_ERROR_INVALID_PARAMS, spdk_strerror(rc));
|
||||
free_rpc_construct_pmem_bdev(&req);
|
||||
}
|
||||
SPDK_RPC_REGISTER("construct_pmem_bdev", spdk_rpc_construct_pmem_bdev)
|
||||
SPDK_RPC_REGISTER("construct_pmem_bdev", spdk_rpc_construct_pmem_bdev, SPDK_RPC_RUNTIME)
|
||||
|
||||
struct rpc_create_pmem_pool {
|
||||
char *pmem_file;
|
||||
@ -167,7 +167,7 @@ invalid:
|
||||
spdk_jsonrpc_send_error_response(request, SPDK_JSONRPC_ERROR_INVALID_PARAMS, "Invalid parameters");
|
||||
free_rpc_create_pmem_pool(&req);
|
||||
}
|
||||
SPDK_RPC_REGISTER("create_pmem_pool", spdk_rpc_create_pmem_pool)
|
||||
SPDK_RPC_REGISTER("create_pmem_pool", spdk_rpc_create_pmem_pool, SPDK_RPC_RUNTIME)
|
||||
|
||||
struct rpc_pmem_pool_info {
|
||||
char *pmem_file;
|
||||
@ -237,7 +237,7 @@ invalid:
|
||||
spdk_jsonrpc_send_error_response(request, SPDK_JSONRPC_ERROR_INVALID_PARAMS, "Invalid parameters");
|
||||
free_rpc_pmem_pool_info(&req);
|
||||
}
|
||||
SPDK_RPC_REGISTER("pmem_pool_info", spdk_rpc_pmem_pool_info)
|
||||
SPDK_RPC_REGISTER("pmem_pool_info", spdk_rpc_pmem_pool_info, SPDK_RPC_RUNTIME)
|
||||
|
||||
struct rpc_delete_pmem_pool {
|
||||
char *pmem_file;
|
||||
@ -289,4 +289,4 @@ invalid:
|
||||
spdk_jsonrpc_send_error_response(request, SPDK_JSONRPC_ERROR_INVALID_PARAMS, "Invalid parameters");
|
||||
free_rpc_delete_pmem_pool(&req);
|
||||
}
|
||||
SPDK_RPC_REGISTER("delete_pmem_pool", spdk_rpc_delete_pmem_pool)
|
||||
SPDK_RPC_REGISTER("delete_pmem_pool", spdk_rpc_delete_pmem_pool, SPDK_RPC_RUNTIME)
|
||||
|
@ -96,4 +96,4 @@ invalid:
|
||||
spdk_jsonrpc_send_error_response(request, SPDK_JSONRPC_ERROR_INVALID_PARAMS, "Invalid parameters");
|
||||
free_rpc_construct_rbd(&req);
|
||||
}
|
||||
SPDK_RPC_REGISTER("construct_rbd_bdev", spdk_rpc_construct_rbd_bdev)
|
||||
SPDK_RPC_REGISTER("construct_rbd_bdev", spdk_rpc_construct_rbd_bdev, SPDK_RPC_RUNTIME)
|
||||
|
@ -178,7 +178,7 @@ invalid:
|
||||
|
||||
free_rpc_get_bdevs(&req);
|
||||
}
|
||||
SPDK_RPC_REGISTER("get_bdevs", spdk_rpc_get_bdevs)
|
||||
SPDK_RPC_REGISTER("get_bdevs", spdk_rpc_get_bdevs, SPDK_RPC_RUNTIME)
|
||||
|
||||
struct rpc_get_bdevs_config {
|
||||
char *name;
|
||||
@ -240,7 +240,7 @@ spdk_rpc_get_bdevs_config(struct spdk_jsonrpc_request *request,
|
||||
|
||||
spdk_jsonrpc_end_result(request, w);
|
||||
}
|
||||
SPDK_RPC_REGISTER("get_bdevs_config", spdk_rpc_get_bdevs_config)
|
||||
SPDK_RPC_REGISTER("get_bdevs_config", spdk_rpc_get_bdevs_config, SPDK_RPC_RUNTIME)
|
||||
|
||||
struct rpc_delete_bdev {
|
||||
char *name;
|
||||
@ -306,8 +306,7 @@ invalid:
|
||||
spdk_jsonrpc_send_error_response(request, SPDK_JSONRPC_ERROR_INVALID_PARAMS, "Invalid parameters");
|
||||
free_rpc_delete_bdev(&req);
|
||||
}
|
||||
SPDK_RPC_REGISTER("delete_bdev", spdk_rpc_delete_bdev)
|
||||
|
||||
SPDK_RPC_REGISTER("delete_bdev", spdk_rpc_delete_bdev, SPDK_RPC_RUNTIME)
|
||||
|
||||
struct rpc_set_bdev_qos_limit_iops {
|
||||
char *name;
|
||||
@ -377,4 +376,4 @@ invalid:
|
||||
free_rpc_set_bdev_qos_limit_iops(&req);
|
||||
}
|
||||
|
||||
SPDK_RPC_REGISTER("set_bdev_qos_limit_iops", spdk_rpc_set_bdev_qos_limit_iops)
|
||||
SPDK_RPC_REGISTER("set_bdev_qos_limit_iops", spdk_rpc_set_bdev_qos_limit_iops, SPDK_RPC_RUNTIME)
|
||||
|
@ -96,7 +96,7 @@ spdk_rpc_construct_split_vbdev(struct spdk_jsonrpc_request *request,
|
||||
out:
|
||||
free(req.base_bdev);
|
||||
}
|
||||
SPDK_RPC_REGISTER("construct_split_vbdev", spdk_rpc_construct_split_vbdev)
|
||||
SPDK_RPC_REGISTER("construct_split_vbdev", spdk_rpc_construct_split_vbdev, SPDK_RPC_RUNTIME)
|
||||
|
||||
struct rpc_destruct_split {
|
||||
char *base_bdev;
|
||||
@ -140,4 +140,4 @@ spdk_rpc_destruct_split(struct spdk_jsonrpc_request *request,
|
||||
out:
|
||||
free(req.base_bdev);
|
||||
}
|
||||
SPDK_RPC_REGISTER("destruct_split_vbdev", spdk_rpc_destruct_split)
|
||||
SPDK_RPC_REGISTER("destruct_split_vbdev", spdk_rpc_destruct_split, SPDK_RPC_RUNTIME)
|
||||
|
@ -140,7 +140,8 @@ invalid:
|
||||
spdk_strerror(-rc));
|
||||
free_rpc_construct_virtio_scsi_dev(req);
|
||||
}
|
||||
SPDK_RPC_REGISTER("construct_virtio_user_scsi_bdev", spdk_rpc_create_virtio_user_scsi_bdev);
|
||||
SPDK_RPC_REGISTER("construct_virtio_user_scsi_bdev", spdk_rpc_create_virtio_user_scsi_bdev,
|
||||
SPDK_RPC_RUNTIME);
|
||||
|
||||
static const struct spdk_json_object_decoder rpc_construct_virtio_pci_scsi_dev[] = {
|
||||
{"pci_address", offsetof(struct rpc_construct_virtio_scsi_dev, pci_address), spdk_json_decode_string },
|
||||
@ -190,7 +191,8 @@ invalid:
|
||||
spdk_strerror(-rc));
|
||||
free_rpc_construct_virtio_scsi_dev(req);
|
||||
}
|
||||
SPDK_RPC_REGISTER("construct_virtio_pci_scsi_bdev", spdk_rpc_construct_virtio_pci_scsi_dev);
|
||||
SPDK_RPC_REGISTER("construct_virtio_pci_scsi_bdev", spdk_rpc_construct_virtio_pci_scsi_dev,
|
||||
SPDK_RPC_RUNTIME);
|
||||
|
||||
struct rpc_remove_virtio_scsi_dev {
|
||||
char *name;
|
||||
@ -266,7 +268,7 @@ invalid:
|
||||
spdk_strerror(-rc));
|
||||
free_rpc_remove_virtio_scsi_dev(req);
|
||||
}
|
||||
SPDK_RPC_REGISTER("remove_virtio_scsi_bdev", spdk_rpc_remove_virtio_scsi_bdev);
|
||||
SPDK_RPC_REGISTER("remove_virtio_scsi_bdev", spdk_rpc_remove_virtio_scsi_bdev, SPDK_RPC_RUNTIME);
|
||||
|
||||
static void
|
||||
spdk_rpc_get_virtio_scsi_devs(struct spdk_jsonrpc_request *request,
|
||||
@ -288,7 +290,7 @@ spdk_rpc_get_virtio_scsi_devs(struct spdk_jsonrpc_request *request,
|
||||
bdev_virtio_scsi_dev_list(w);
|
||||
spdk_jsonrpc_end_result(request, w);
|
||||
}
|
||||
SPDK_RPC_REGISTER("get_virtio_scsi_devs", spdk_rpc_get_virtio_scsi_devs)
|
||||
SPDK_RPC_REGISTER("get_virtio_scsi_devs", spdk_rpc_get_virtio_scsi_devs, SPDK_RPC_RUNTIME)
|
||||
|
||||
struct rpc_construct_virtio_blk_dev {
|
||||
char *path;
|
||||
@ -355,7 +357,8 @@ invalid:
|
||||
spdk_strerror(-rc));
|
||||
free_rpc_construct_virtio_blk_dev(&req);
|
||||
}
|
||||
SPDK_RPC_REGISTER("construct_virtio_user_blk_bdev", spdk_rpc_create_virtio_user_blk_bdev);
|
||||
SPDK_RPC_REGISTER("construct_virtio_user_blk_bdev", spdk_rpc_create_virtio_user_blk_bdev,
|
||||
SPDK_RPC_RUNTIME);
|
||||
|
||||
static const struct spdk_json_object_decoder rpc_construct_virtio_pci_blk_dev[] = {
|
||||
{"pci_address", offsetof(struct rpc_construct_virtio_blk_dev, pci_address), spdk_json_decode_string },
|
||||
@ -409,7 +412,8 @@ invalid:
|
||||
spdk_strerror(-rc));
|
||||
free_rpc_construct_virtio_blk_dev(&req);
|
||||
}
|
||||
SPDK_RPC_REGISTER("construct_virtio_pci_blk_bdev", spdk_rpc_create_virtio_pci_blk_bdev);
|
||||
SPDK_RPC_REGISTER("construct_virtio_pci_blk_bdev", spdk_rpc_create_virtio_pci_blk_bdev,
|
||||
SPDK_RPC_RUNTIME);
|
||||
|
||||
struct rpc_construct_virtio_dev {
|
||||
char *name;
|
||||
@ -554,4 +558,4 @@ spdk_rpc_create_virtio_dev(struct spdk_jsonrpc_request *request,
|
||||
invalid:
|
||||
free_rpc_construct_virtio_dev(req);
|
||||
}
|
||||
SPDK_RPC_REGISTER("construct_virtio_dev", spdk_rpc_create_virtio_dev);
|
||||
SPDK_RPC_REGISTER("construct_virtio_dev", spdk_rpc_create_virtio_dev, SPDK_RPC_RUNTIME);
|
||||
|
@ -40,6 +40,7 @@
|
||||
#include "spdk/conf.h"
|
||||
#include "spdk/trace.h"
|
||||
#include "spdk/string.h"
|
||||
#include "spdk/rpc.h"
|
||||
|
||||
#define SPDK_APP_DEFAULT_LOG_LEVEL SPDK_LOG_NOTICE
|
||||
#define SPDK_APP_DEFAULT_LOG_PRINT_LEVEL SPDK_LOG_INFO
|
||||
@ -266,12 +267,19 @@ spdk_app_setup_signal_handlers(struct spdk_app_opts *opts)
|
||||
}
|
||||
|
||||
static void
|
||||
start_rpc(void *arg1, void *arg2)
|
||||
spdk_app_start_application(void)
|
||||
{
|
||||
spdk_rpc_set_state(SPDK_RPC_RUNTIME);
|
||||
g_app_start_fn(g_app_start_arg1, g_app_start_arg2);
|
||||
}
|
||||
|
||||
static void
|
||||
spdk_app_start_rpc(void *arg1, void *arg2)
|
||||
{
|
||||
const char *rpc_addr = arg1;
|
||||
|
||||
spdk_rpc_initialize(rpc_addr);
|
||||
g_app_start_fn(g_app_start_arg1, g_app_start_arg2);
|
||||
spdk_app_start_application();
|
||||
}
|
||||
|
||||
static struct spdk_conf *
|
||||
@ -465,7 +473,7 @@ spdk_app_start(struct spdk_app_opts *opts, spdk_event_fn start_fn,
|
||||
{
|
||||
struct spdk_conf *config = NULL;
|
||||
int rc;
|
||||
struct spdk_event *app_start_event;
|
||||
struct spdk_event *rpc_start_event;
|
||||
|
||||
if (!opts) {
|
||||
SPDK_ERRLOG("opts should not be NULL\n");
|
||||
@ -545,9 +553,10 @@ spdk_app_start(struct spdk_app_opts *opts, spdk_event_fn start_fn,
|
||||
g_app_start_fn = start_fn;
|
||||
g_app_start_arg1 = arg1;
|
||||
g_app_start_arg2 = arg2;
|
||||
app_start_event = spdk_event_allocate(g_init_lcore, start_rpc, (void *)opts->rpc_addr, NULL);
|
||||
rpc_start_event = spdk_event_allocate(g_init_lcore, spdk_app_start_rpc,
|
||||
(void *)opts->rpc_addr, NULL);
|
||||
|
||||
spdk_subsystem_init(app_start_event);
|
||||
spdk_subsystem_init(rpc_start_event);
|
||||
|
||||
/* This blocks until spdk_app_stop is called */
|
||||
spdk_reactors_start();
|
||||
|
@ -68,6 +68,8 @@ spdk_rpc_initialize(const char *listen_addr)
|
||||
return;
|
||||
}
|
||||
|
||||
spdk_rpc_set_state(SPDK_RPC_STARTUP);
|
||||
|
||||
/* Register a poller to periodically check for RPCs */
|
||||
g_rpc_poller = spdk_poller_register(spdk_rpc_subsystem_poll, NULL, RPC_SELECT_INTERVAL);
|
||||
}
|
||||
|
@ -108,7 +108,7 @@ invalid:
|
||||
spdk_jsonrpc_send_error_response(request, SPDK_JSONRPC_ERROR_INVALID_PARAMS, "Invalid parameters");
|
||||
free_rpc_kill_instance(&req);
|
||||
}
|
||||
SPDK_RPC_REGISTER("kill_instance", spdk_rpc_kill_instance)
|
||||
SPDK_RPC_REGISTER("kill_instance", spdk_rpc_kill_instance, SPDK_RPC_RUNTIME)
|
||||
|
||||
|
||||
struct rpc_context_switch_monitor {
|
||||
@ -152,4 +152,4 @@ spdk_rpc_context_switch_monitor(struct spdk_jsonrpc_request *request,
|
||||
spdk_jsonrpc_end_result(request, w);
|
||||
}
|
||||
|
||||
SPDK_RPC_REGISTER("context_switch_monitor", spdk_rpc_context_switch_monitor)
|
||||
SPDK_RPC_REGISTER("context_switch_monitor", spdk_rpc_context_switch_monitor, SPDK_RPC_RUNTIME)
|
||||
|
@ -75,7 +75,7 @@ spdk_rpc_get_subsystems(struct spdk_jsonrpc_request *request,
|
||||
spdk_jsonrpc_end_result(request, w);
|
||||
}
|
||||
|
||||
SPDK_RPC_REGISTER("get_subsystems", spdk_rpc_get_subsystems)
|
||||
SPDK_RPC_REGISTER("get_subsystems", spdk_rpc_get_subsystems, SPDK_RPC_RUNTIME)
|
||||
|
||||
struct rpc_get_subsystem_config {
|
||||
char *name;
|
||||
@ -126,4 +126,4 @@ spdk_rpc_get_subsystem_config(struct spdk_jsonrpc_request *request,
|
||||
}
|
||||
}
|
||||
|
||||
SPDK_RPC_REGISTER("get_subsystem_config", spdk_rpc_get_subsystem_config)
|
||||
SPDK_RPC_REGISTER("get_subsystem_config", spdk_rpc_get_subsystem_config, SPDK_RPC_RUNTIME)
|
||||
|
@ -305,7 +305,7 @@ spdk_rpc_get_nvmf_subsystems(struct spdk_jsonrpc_request *request,
|
||||
spdk_json_write_array_end(w);
|
||||
spdk_jsonrpc_end_result(request, w);
|
||||
}
|
||||
SPDK_RPC_REGISTER("get_nvmf_subsystems", spdk_rpc_get_nvmf_subsystems)
|
||||
SPDK_RPC_REGISTER("get_nvmf_subsystems", spdk_rpc_get_nvmf_subsystems, SPDK_RPC_RUNTIME)
|
||||
|
||||
struct rpc_listen_address {
|
||||
char *transport;
|
||||
@ -765,7 +765,7 @@ invalid:
|
||||
spdk_jsonrpc_send_error_response(request, SPDK_JSONRPC_ERROR_INVALID_PARAMS, "Invalid parameters");
|
||||
free_rpc_subsystem(req);
|
||||
}
|
||||
SPDK_RPC_REGISTER("construct_nvmf_subsystem", spdk_rpc_construct_nvmf_subsystem)
|
||||
SPDK_RPC_REGISTER("construct_nvmf_subsystem", spdk_rpc_construct_nvmf_subsystem, SPDK_RPC_RUNTIME)
|
||||
|
||||
struct rpc_delete_subsystem {
|
||||
char *nqn;
|
||||
@ -835,7 +835,7 @@ invalid:
|
||||
spdk_jsonrpc_send_error_response(request, SPDK_JSONRPC_ERROR_INVALID_PARAMS, "Invalid parameters");
|
||||
free_rpc_delete_subsystem(&req);
|
||||
}
|
||||
SPDK_RPC_REGISTER("delete_nvmf_subsystem", spdk_rpc_delete_nvmf_subsystem)
|
||||
SPDK_RPC_REGISTER("delete_nvmf_subsystem", spdk_rpc_delete_nvmf_subsystem, SPDK_RPC_RUNTIME)
|
||||
|
||||
enum nvmf_rpc_listen_op {
|
||||
NVMF_RPC_LISTEN_ADD,
|
||||
@ -998,7 +998,7 @@ nvmf_rpc_subsystem_add_listener(struct spdk_jsonrpc_request *request,
|
||||
return;
|
||||
}
|
||||
}
|
||||
SPDK_RPC_REGISTER("nvmf_subsystem_add_listener", nvmf_rpc_subsystem_add_listener);
|
||||
SPDK_RPC_REGISTER("nvmf_subsystem_add_listener", nvmf_rpc_subsystem_add_listener, SPDK_RPC_RUNTIME);
|
||||
|
||||
static void
|
||||
nvmf_rpc_subsystem_remove_listener(struct spdk_jsonrpc_request *request,
|
||||
@ -1050,7 +1050,8 @@ nvmf_rpc_subsystem_remove_listener(struct spdk_jsonrpc_request *request,
|
||||
}
|
||||
|
||||
}
|
||||
SPDK_RPC_REGISTER("nvmf_subsystem_remove_listener", nvmf_rpc_subsystem_remove_listener);
|
||||
SPDK_RPC_REGISTER("nvmf_subsystem_remove_listener", nvmf_rpc_subsystem_remove_listener,
|
||||
SPDK_RPC_RUNTIME);
|
||||
|
||||
struct nvmf_rpc_ns_ctx {
|
||||
char *nqn;
|
||||
@ -1181,7 +1182,7 @@ nvmf_rpc_subsystem_add_ns(struct spdk_jsonrpc_request *request,
|
||||
return;
|
||||
}
|
||||
}
|
||||
SPDK_RPC_REGISTER("nvmf_subsystem_add_ns", nvmf_rpc_subsystem_add_ns)
|
||||
SPDK_RPC_REGISTER("nvmf_subsystem_add_ns", nvmf_rpc_subsystem_add_ns, SPDK_RPC_RUNTIME)
|
||||
|
||||
struct nvmf_rpc_remove_ns_ctx {
|
||||
char *nqn;
|
||||
@ -1304,7 +1305,7 @@ nvmf_rpc_subsystem_remove_ns(struct spdk_jsonrpc_request *request,
|
||||
return;
|
||||
}
|
||||
}
|
||||
SPDK_RPC_REGISTER("nvmf_subsystem_remove_ns", nvmf_rpc_subsystem_remove_ns)
|
||||
SPDK_RPC_REGISTER("nvmf_subsystem_remove_ns", nvmf_rpc_subsystem_remove_ns, SPDK_RPC_RUNTIME)
|
||||
|
||||
enum nvmf_rpc_host_op {
|
||||
NVMF_RPC_HOST_ADD,
|
||||
@ -1436,7 +1437,7 @@ nvmf_rpc_subsystem_add_host(struct spdk_jsonrpc_request *request,
|
||||
return;
|
||||
}
|
||||
}
|
||||
SPDK_RPC_REGISTER("nvmf_subsystem_add_host", nvmf_rpc_subsystem_add_host)
|
||||
SPDK_RPC_REGISTER("nvmf_subsystem_add_host", nvmf_rpc_subsystem_add_host, SPDK_RPC_RUNTIME)
|
||||
|
||||
static void
|
||||
nvmf_rpc_subsystem_remove_host(struct spdk_jsonrpc_request *request,
|
||||
@ -1478,7 +1479,7 @@ nvmf_rpc_subsystem_remove_host(struct spdk_jsonrpc_request *request,
|
||||
return;
|
||||
}
|
||||
}
|
||||
SPDK_RPC_REGISTER("nvmf_subsystem_remove_host", nvmf_rpc_subsystem_remove_host)
|
||||
SPDK_RPC_REGISTER("nvmf_subsystem_remove_host", nvmf_rpc_subsystem_remove_host, SPDK_RPC_RUNTIME)
|
||||
|
||||
|
||||
static const struct spdk_json_object_decoder nvmf_rpc_subsystem_any_host_decoder[] = {
|
||||
@ -1526,4 +1527,5 @@ nvmf_rpc_subsystem_allow_any_host(struct spdk_jsonrpc_request *request,
|
||||
return;
|
||||
}
|
||||
}
|
||||
SPDK_RPC_REGISTER("nvmf_subsystem_allow_any_host", nvmf_rpc_subsystem_allow_any_host)
|
||||
SPDK_RPC_REGISTER("nvmf_subsystem_allow_any_host", nvmf_rpc_subsystem_allow_any_host,
|
||||
SPDK_RPC_RUNTIME)
|
||||
|
@ -100,7 +100,7 @@ spdk_rpc_get_initiator_groups(struct spdk_jsonrpc_request *request,
|
||||
|
||||
spdk_jsonrpc_end_result(request, w);
|
||||
}
|
||||
SPDK_RPC_REGISTER("get_initiator_groups", spdk_rpc_get_initiator_groups)
|
||||
SPDK_RPC_REGISTER("get_initiator_groups", spdk_rpc_get_initiator_groups, SPDK_RPC_RUNTIME)
|
||||
|
||||
struct rpc_initiator_list {
|
||||
size_t num_initiators;
|
||||
@ -211,7 +211,7 @@ invalid:
|
||||
spdk_jsonrpc_send_error_response(request, SPDK_JSONRPC_ERROR_INVALID_PARAMS, "Invalid parameters");
|
||||
free_rpc_initiator_group(&req);
|
||||
}
|
||||
SPDK_RPC_REGISTER("add_initiator_group", spdk_rpc_add_initiator_group)
|
||||
SPDK_RPC_REGISTER("add_initiator_group", spdk_rpc_add_initiator_group, SPDK_RPC_RUNTIME)
|
||||
|
||||
static const struct spdk_json_object_decoder rpc_add_or_delete_initiators_decoders[] = {
|
||||
{"tag", offsetof(struct rpc_initiator_group, tag), spdk_json_decode_int32},
|
||||
@ -256,7 +256,8 @@ invalid:
|
||||
spdk_jsonrpc_send_error_response(request, SPDK_JSONRPC_ERROR_INVALID_PARAMS, "Invalid parameters");
|
||||
free_rpc_initiator_group(&req);
|
||||
}
|
||||
SPDK_RPC_REGISTER("add_initiators_to_initiator_group", spdk_rpc_add_initiators_to_initiator_group)
|
||||
SPDK_RPC_REGISTER("add_initiators_to_initiator_group",
|
||||
spdk_rpc_add_initiators_to_initiator_group, SPDK_RPC_RUNTIME)
|
||||
|
||||
static void
|
||||
spdk_rpc_delete_initiators_from_initiator_group(struct spdk_jsonrpc_request *request,
|
||||
@ -296,7 +297,7 @@ invalid:
|
||||
free_rpc_initiator_group(&req);
|
||||
}
|
||||
SPDK_RPC_REGISTER("delete_initiators_from_initiator_group",
|
||||
spdk_rpc_delete_initiators_from_initiator_group)
|
||||
spdk_rpc_delete_initiators_from_initiator_group, SPDK_RPC_RUNTIME)
|
||||
|
||||
struct rpc_delete_initiator_group {
|
||||
int32_t tag;
|
||||
@ -340,7 +341,7 @@ spdk_rpc_delete_initiator_group(struct spdk_jsonrpc_request *request,
|
||||
invalid:
|
||||
spdk_jsonrpc_send_error_response(request, SPDK_JSONRPC_ERROR_INVALID_PARAMS, "Invalid parameters");
|
||||
}
|
||||
SPDK_RPC_REGISTER("delete_initiator_group", spdk_rpc_delete_initiator_group)
|
||||
SPDK_RPC_REGISTER("delete_initiator_group", spdk_rpc_delete_initiator_group, SPDK_RPC_RUNTIME)
|
||||
|
||||
static void
|
||||
dump_target_node(struct spdk_json_write_ctx *w, struct spdk_iscsi_tgt_node *tgtnode)
|
||||
@ -441,7 +442,7 @@ spdk_rpc_get_target_nodes(struct spdk_jsonrpc_request *request,
|
||||
|
||||
spdk_jsonrpc_end_result(request, w);
|
||||
}
|
||||
SPDK_RPC_REGISTER("get_target_nodes", spdk_rpc_get_target_nodes)
|
||||
SPDK_RPC_REGISTER("get_target_nodes", spdk_rpc_get_target_nodes, SPDK_RPC_RUNTIME)
|
||||
|
||||
struct rpc_pg_ig_map {
|
||||
int32_t pg_tag;
|
||||
@ -631,7 +632,7 @@ invalid:
|
||||
spdk_jsonrpc_send_error_response(request, SPDK_JSONRPC_ERROR_INVALID_PARAMS, "Invalid parameters");
|
||||
free_rpc_target_node(&req);
|
||||
}
|
||||
SPDK_RPC_REGISTER("construct_target_node", spdk_rpc_construct_target_node)
|
||||
SPDK_RPC_REGISTER("construct_target_node", spdk_rpc_construct_target_node, SPDK_RPC_RUNTIME)
|
||||
|
||||
struct rpc_tgt_node_pg_ig_maps {
|
||||
char *name;
|
||||
@ -693,7 +694,7 @@ invalid:
|
||||
"Invalid parameters");
|
||||
free(req.name);
|
||||
}
|
||||
SPDK_RPC_REGISTER("add_pg_ig_maps", spdk_rpc_add_pg_ig_maps)
|
||||
SPDK_RPC_REGISTER("add_pg_ig_maps", spdk_rpc_add_pg_ig_maps, SPDK_RPC_RUNTIME)
|
||||
|
||||
static void
|
||||
spdk_rpc_delete_pg_ig_maps(struct spdk_jsonrpc_request *request,
|
||||
@ -745,7 +746,7 @@ invalid:
|
||||
"Invalid parameters");
|
||||
free(req.name);
|
||||
}
|
||||
SPDK_RPC_REGISTER("delete_pg_ig_maps", spdk_rpc_delete_pg_ig_maps)
|
||||
SPDK_RPC_REGISTER("delete_pg_ig_maps", spdk_rpc_delete_pg_ig_maps, SPDK_RPC_RUNTIME)
|
||||
|
||||
struct rpc_delete_target_node {
|
||||
char *name;
|
||||
@ -800,7 +801,7 @@ invalid:
|
||||
spdk_jsonrpc_send_error_response(request, SPDK_JSONRPC_ERROR_INVALID_PARAMS, "Invalid parameters");
|
||||
free_rpc_delete_target_node(&req);
|
||||
}
|
||||
SPDK_RPC_REGISTER("delete_target_node", spdk_rpc_delete_target_node)
|
||||
SPDK_RPC_REGISTER("delete_target_node", spdk_rpc_delete_target_node, SPDK_RPC_RUNTIME)
|
||||
|
||||
static void
|
||||
dump_portal_group(struct spdk_json_write_ctx *w, struct spdk_iscsi_portal_grp *pg)
|
||||
@ -857,7 +858,7 @@ spdk_rpc_get_portal_groups(struct spdk_jsonrpc_request *request,
|
||||
|
||||
spdk_jsonrpc_end_result(request, w);
|
||||
}
|
||||
SPDK_RPC_REGISTER("get_portal_groups", spdk_rpc_get_portal_groups)
|
||||
SPDK_RPC_REGISTER("get_portal_groups", spdk_rpc_get_portal_groups, SPDK_RPC_RUNTIME)
|
||||
|
||||
struct rpc_portal {
|
||||
char *host;
|
||||
@ -991,7 +992,7 @@ out:
|
||||
}
|
||||
free_rpc_portal_group(&req);
|
||||
}
|
||||
SPDK_RPC_REGISTER("add_portal_group", spdk_rpc_add_portal_group)
|
||||
SPDK_RPC_REGISTER("add_portal_group", spdk_rpc_add_portal_group, SPDK_RPC_RUNTIME)
|
||||
|
||||
struct rpc_delete_portal_group {
|
||||
int32_t tag;
|
||||
@ -1036,7 +1037,7 @@ spdk_rpc_delete_portal_group(struct spdk_jsonrpc_request *request,
|
||||
invalid:
|
||||
spdk_jsonrpc_send_error_response(request, SPDK_JSONRPC_ERROR_INVALID_PARAMS, "Invalid parameters");
|
||||
}
|
||||
SPDK_RPC_REGISTER("delete_portal_group", spdk_rpc_delete_portal_group)
|
||||
SPDK_RPC_REGISTER("delete_portal_group", spdk_rpc_delete_portal_group, SPDK_RPC_RUNTIME)
|
||||
|
||||
static void
|
||||
spdk_rpc_get_iscsi_connections(struct spdk_jsonrpc_request *request,
|
||||
@ -1107,7 +1108,7 @@ spdk_rpc_get_iscsi_connections(struct spdk_jsonrpc_request *request,
|
||||
|
||||
spdk_jsonrpc_end_result(request, w);
|
||||
}
|
||||
SPDK_RPC_REGISTER("get_iscsi_connections", spdk_rpc_get_iscsi_connections)
|
||||
SPDK_RPC_REGISTER("get_iscsi_connections", spdk_rpc_get_iscsi_connections, SPDK_RPC_RUNTIME)
|
||||
|
||||
struct rpc_target_lun {
|
||||
char *name;
|
||||
@ -1173,7 +1174,7 @@ invalid:
|
||||
"Invalid parameters");
|
||||
free_rpc_target_lun(&req);
|
||||
}
|
||||
SPDK_RPC_REGISTER("target_node_add_lun", spdk_rpc_target_node_add_lun)
|
||||
SPDK_RPC_REGISTER("target_node_add_lun", spdk_rpc_target_node_add_lun, SPDK_RPC_RUNTIME)
|
||||
|
||||
static void
|
||||
spdk_rpc_get_iscsi_global_params(struct spdk_jsonrpc_request *request,
|
||||
@ -1249,4 +1250,4 @@ spdk_rpc_get_iscsi_global_params(struct spdk_jsonrpc_request *request,
|
||||
|
||||
spdk_jsonrpc_end_result(request, w);
|
||||
}
|
||||
SPDK_RPC_REGISTER("get_iscsi_global_params", spdk_rpc_get_iscsi_global_params)
|
||||
SPDK_RPC_REGISTER("get_iscsi_global_params", spdk_rpc_get_iscsi_global_params, SPDK_RPC_RUNTIME)
|
||||
|
@ -134,7 +134,7 @@ invalid:
|
||||
spdk_jsonrpc_send_error_response(request, SPDK_JSONRPC_ERROR_INVALID_PARAMS, "Invalid parameters");
|
||||
free_rpc_log_level(&req);
|
||||
}
|
||||
SPDK_RPC_REGISTER("set_log_print_level", spdk_rpc_set_log_print_level)
|
||||
SPDK_RPC_REGISTER("set_log_print_level", spdk_rpc_set_log_print_level, SPDK_RPC_RUNTIME)
|
||||
|
||||
static void
|
||||
spdk_rpc_get_log_print_level(struct spdk_jsonrpc_request *request,
|
||||
@ -162,7 +162,7 @@ spdk_rpc_get_log_print_level(struct spdk_jsonrpc_request *request,
|
||||
|
||||
spdk_jsonrpc_end_result(request, w);
|
||||
}
|
||||
SPDK_RPC_REGISTER("get_log_print_level", spdk_rpc_get_log_print_level)
|
||||
SPDK_RPC_REGISTER("get_log_print_level", spdk_rpc_get_log_print_level, SPDK_RPC_RUNTIME)
|
||||
|
||||
static void
|
||||
spdk_rpc_set_log_level(struct spdk_jsonrpc_request *request,
|
||||
@ -201,7 +201,7 @@ invalid:
|
||||
spdk_jsonrpc_send_error_response(request, SPDK_JSONRPC_ERROR_INVALID_PARAMS, "Invalid parameters");
|
||||
free_rpc_log_level(&req);
|
||||
}
|
||||
SPDK_RPC_REGISTER("set_log_level", spdk_rpc_set_log_level)
|
||||
SPDK_RPC_REGISTER("set_log_level", spdk_rpc_set_log_level, SPDK_RPC_RUNTIME)
|
||||
|
||||
static void
|
||||
spdk_rpc_get_log_level(struct spdk_jsonrpc_request *request,
|
||||
@ -228,7 +228,7 @@ spdk_rpc_get_log_level(struct spdk_jsonrpc_request *request,
|
||||
|
||||
spdk_jsonrpc_end_result(request, w);
|
||||
}
|
||||
SPDK_RPC_REGISTER("get_log_level", spdk_rpc_get_log_level)
|
||||
SPDK_RPC_REGISTER("get_log_level", spdk_rpc_get_log_level, SPDK_RPC_RUNTIME)
|
||||
|
||||
static void
|
||||
spdk_rpc_set_trace_flag(struct spdk_jsonrpc_request *request,
|
||||
@ -264,7 +264,7 @@ invalid:
|
||||
spdk_jsonrpc_send_error_response(request, SPDK_JSONRPC_ERROR_INVALID_PARAMS, "Invalid parameters");
|
||||
free_rpc_trace_flag(&req);
|
||||
}
|
||||
SPDK_RPC_REGISTER("set_trace_flag", spdk_rpc_set_trace_flag)
|
||||
SPDK_RPC_REGISTER("set_trace_flag", spdk_rpc_set_trace_flag, SPDK_RPC_RUNTIME)
|
||||
|
||||
static void
|
||||
spdk_rpc_clear_trace_flag(struct spdk_jsonrpc_request *request,
|
||||
@ -300,7 +300,7 @@ invalid:
|
||||
spdk_jsonrpc_send_error_response(request, SPDK_JSONRPC_ERROR_INVALID_PARAMS, "Invalid parameters");
|
||||
free_rpc_trace_flag(&req);
|
||||
}
|
||||
SPDK_RPC_REGISTER("clear_trace_flag", spdk_rpc_clear_trace_flag)
|
||||
SPDK_RPC_REGISTER("clear_trace_flag", spdk_rpc_clear_trace_flag, SPDK_RPC_RUNTIME)
|
||||
|
||||
static void
|
||||
spdk_rpc_get_trace_flags(struct spdk_jsonrpc_request *request,
|
||||
@ -330,4 +330,4 @@ spdk_rpc_get_trace_flags(struct spdk_jsonrpc_request *request,
|
||||
spdk_json_write_object_end(w);
|
||||
spdk_jsonrpc_end_result(request, w);
|
||||
}
|
||||
SPDK_RPC_REGISTER("get_trace_flags", spdk_rpc_get_trace_flags)
|
||||
SPDK_RPC_REGISTER("get_trace_flags", spdk_rpc_get_trace_flags, SPDK_RPC_RUNTIME)
|
||||
|
@ -104,7 +104,7 @@ invalid:
|
||||
spdk_jsonrpc_send_error_response(request, SPDK_JSONRPC_ERROR_INVALID_PARAMS, "Invalid parameters");
|
||||
}
|
||||
|
||||
SPDK_RPC_REGISTER("start_nbd_disk", spdk_rpc_start_nbd_disk)
|
||||
SPDK_RPC_REGISTER("start_nbd_disk", spdk_rpc_start_nbd_disk, SPDK_RPC_RUNTIME)
|
||||
|
||||
struct rpc_stop_nbd_disk {
|
||||
char *nbd_device;
|
||||
@ -217,7 +217,7 @@ out:
|
||||
free_rpc_stop_nbd_disk(&req);
|
||||
}
|
||||
|
||||
SPDK_RPC_REGISTER("stop_nbd_disk", spdk_rpc_stop_nbd_disk)
|
||||
SPDK_RPC_REGISTER("stop_nbd_disk", spdk_rpc_stop_nbd_disk, SPDK_RPC_RUNTIME)
|
||||
|
||||
static void
|
||||
spdk_rpc_dump_nbd_info(struct spdk_json_write_ctx *w,
|
||||
@ -304,4 +304,4 @@ invalid:
|
||||
|
||||
free_rpc_get_nbd_disks(&req);
|
||||
}
|
||||
SPDK_RPC_REGISTER("get_nbd_disks", spdk_rpc_get_nbd_disks)
|
||||
SPDK_RPC_REGISTER("get_nbd_disks", spdk_rpc_get_nbd_disks, SPDK_RPC_RUNTIME)
|
||||
|
@ -90,7 +90,7 @@ invalid:
|
||||
spdk_jsonrpc_send_error_response(request, SPDK_JSONRPC_ERROR_INVALID_PARAMS, "Invalid parameters");
|
||||
free_rpc_ip_address(&req);
|
||||
}
|
||||
SPDK_RPC_REGISTER("add_ip_address", spdk_rpc_add_ip_address)
|
||||
SPDK_RPC_REGISTER("add_ip_address", spdk_rpc_add_ip_address, SPDK_RPC_RUNTIME)
|
||||
|
||||
static void
|
||||
spdk_rpc_delete_ip_address(struct spdk_jsonrpc_request *request,
|
||||
@ -125,7 +125,7 @@ invalid:
|
||||
spdk_jsonrpc_send_error_response(request, SPDK_JSONRPC_ERROR_INVALID_PARAMS, "Invalid parameters");
|
||||
free_rpc_ip_address(&req);
|
||||
}
|
||||
SPDK_RPC_REGISTER("delete_ip_address", spdk_rpc_delete_ip_address)
|
||||
SPDK_RPC_REGISTER("delete_ip_address", spdk_rpc_delete_ip_address, SPDK_RPC_RUNTIME)
|
||||
|
||||
static void
|
||||
spdk_rpc_get_interfaces(struct spdk_jsonrpc_request *request,
|
||||
@ -175,6 +175,6 @@ spdk_rpc_get_interfaces(struct spdk_jsonrpc_request *request,
|
||||
|
||||
spdk_jsonrpc_end_result(request, w);
|
||||
}
|
||||
SPDK_RPC_REGISTER("get_interfaces", spdk_rpc_get_interfaces)
|
||||
SPDK_RPC_REGISTER("get_interfaces", spdk_rpc_get_interfaces, SPDK_RPC_RUNTIME)
|
||||
|
||||
SPDK_LOG_REGISTER_COMPONENT("net", SPDK_LOG_NET)
|
||||
|
@ -48,15 +48,23 @@ static char g_rpc_lock_path[sizeof(g_rpc_listen_addr_unix.sun_path) + sizeof(".l
|
||||
static int g_rpc_lock_fd = -1;
|
||||
|
||||
static struct spdk_jsonrpc_server *g_jsonrpc_server = NULL;
|
||||
static uint32_t g_rpc_state;
|
||||
|
||||
struct spdk_rpc_method {
|
||||
const char *name;
|
||||
spdk_rpc_method_handler func;
|
||||
SLIST_ENTRY(spdk_rpc_method) slist;
|
||||
uint32_t state_mask;
|
||||
};
|
||||
|
||||
static SLIST_HEAD(, spdk_rpc_method) g_rpc_methods = SLIST_HEAD_INITIALIZER(g_rpc_methods);
|
||||
|
||||
void
|
||||
spdk_rpc_set_state(uint32_t state)
|
||||
{
|
||||
g_rpc_state = state;
|
||||
}
|
||||
|
||||
static void
|
||||
spdk_jsonrpc_handler(struct spdk_jsonrpc_request *request,
|
||||
const struct spdk_json_val *method,
|
||||
@ -68,7 +76,14 @@ spdk_jsonrpc_handler(struct spdk_jsonrpc_request *request,
|
||||
|
||||
SLIST_FOREACH(m, &g_rpc_methods, slist) {
|
||||
if (spdk_json_strequal(method, m->name)) {
|
||||
m->func(request, params);
|
||||
if ((m->state_mask & g_rpc_state) == g_rpc_state) {
|
||||
m->func(request, params);
|
||||
} else {
|
||||
spdk_jsonrpc_send_error_response_fmt(request, SPDK_JSONRPC_ERROR_INVALID_STATE,
|
||||
"Method is allowed in any state in the mask (%"PRIx32"),"
|
||||
" but current state is (%"PRIx32")",
|
||||
m->state_mask, g_rpc_state);
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -184,7 +199,7 @@ spdk_rpc_accept(void)
|
||||
}
|
||||
|
||||
void
|
||||
spdk_rpc_register_method(const char *method, spdk_rpc_method_handler func)
|
||||
spdk_rpc_register_method(const char *method, spdk_rpc_method_handler func, uint32_t state_mask)
|
||||
{
|
||||
struct spdk_rpc_method *m;
|
||||
|
||||
@ -195,6 +210,7 @@ spdk_rpc_register_method(const char *method, spdk_rpc_method_handler func)
|
||||
assert(m->name != NULL);
|
||||
|
||||
m->func = func;
|
||||
m->state_mask = state_mask;
|
||||
|
||||
/* TODO: use a hash table or sorted list */
|
||||
SLIST_INSERT_HEAD(&g_rpc_methods, m, slist);
|
||||
@ -250,4 +266,4 @@ spdk_rpc_get_rpc_methods(struct spdk_jsonrpc_request *request,
|
||||
spdk_json_write_array_end(w);
|
||||
spdk_jsonrpc_end_result(request, w);
|
||||
}
|
||||
SPDK_RPC_REGISTER("get_rpc_methods", spdk_rpc_get_rpc_methods)
|
||||
SPDK_RPC_REGISTER("get_rpc_methods", spdk_rpc_get_rpc_methods, SPDK_RPC_RUNTIME)
|
||||
|
@ -79,4 +79,4 @@ spdk_rpc_get_scsi_devices(struct spdk_jsonrpc_request *request,
|
||||
|
||||
spdk_jsonrpc_end_result(request, w);
|
||||
}
|
||||
SPDK_RPC_REGISTER("get_scsi_devices", spdk_rpc_get_scsi_devices)
|
||||
SPDK_RPC_REGISTER("get_scsi_devices", spdk_rpc_get_scsi_devices, SPDK_RPC_RUNTIME)
|
||||
|
@ -98,7 +98,8 @@ invalid:
|
||||
spdk_jsonrpc_send_error_response(request, SPDK_JSONRPC_ERROR_INVALID_PARAMS,
|
||||
spdk_strerror(-rc));
|
||||
}
|
||||
SPDK_RPC_REGISTER("construct_vhost_scsi_controller", spdk_rpc_construct_vhost_scsi_controller)
|
||||
SPDK_RPC_REGISTER("construct_vhost_scsi_controller", spdk_rpc_construct_vhost_scsi_controller,
|
||||
SPDK_RPC_RUNTIME)
|
||||
|
||||
struct rpc_add_vhost_scsi_ctrlr_lun {
|
||||
char *ctrlr;
|
||||
@ -197,7 +198,7 @@ invalid:
|
||||
spdk_jsonrpc_send_error_response(request, SPDK_JSONRPC_ERROR_INVALID_PARAMS,
|
||||
spdk_strerror(-rc));
|
||||
}
|
||||
SPDK_RPC_REGISTER("add_vhost_scsi_lun", spdk_rpc_add_vhost_scsi_lun)
|
||||
SPDK_RPC_REGISTER("add_vhost_scsi_lun", spdk_rpc_add_vhost_scsi_lun, SPDK_RPC_RUNTIME)
|
||||
|
||||
struct rpc_remove_vhost_scsi_ctrlr_target {
|
||||
char *ctrlr;
|
||||
@ -297,7 +298,7 @@ invalid:
|
||||
spdk_strerror(-rc));
|
||||
}
|
||||
|
||||
SPDK_RPC_REGISTER("remove_vhost_scsi_target", spdk_rpc_remove_vhost_scsi_target)
|
||||
SPDK_RPC_REGISTER("remove_vhost_scsi_target", spdk_rpc_remove_vhost_scsi_target, SPDK_RPC_RUNTIME)
|
||||
|
||||
struct rpc_vhost_blk_ctrlr {
|
||||
char *ctrlr;
|
||||
@ -359,7 +360,8 @@ invalid:
|
||||
spdk_strerror(-rc));
|
||||
|
||||
}
|
||||
SPDK_RPC_REGISTER("construct_vhost_blk_controller", spdk_rpc_construct_vhost_blk_controller)
|
||||
SPDK_RPC_REGISTER("construct_vhost_blk_controller", spdk_rpc_construct_vhost_blk_controller,
|
||||
SPDK_RPC_RUNTIME)
|
||||
|
||||
struct rpc_remove_vhost_ctrlr {
|
||||
char *ctrlr;
|
||||
@ -446,7 +448,7 @@ invalid:
|
||||
spdk_strerror(-rc));
|
||||
|
||||
}
|
||||
SPDK_RPC_REGISTER("remove_vhost_controller", spdk_rpc_remove_vhost_controller)
|
||||
SPDK_RPC_REGISTER("remove_vhost_controller", spdk_rpc_remove_vhost_controller, SPDK_RPC_RUNTIME)
|
||||
|
||||
struct rpc_get_vhost_ctrlrs {
|
||||
struct spdk_json_write_ctx *w;
|
||||
@ -516,7 +518,7 @@ spdk_rpc_get_vhost_controllers(struct spdk_jsonrpc_request *request,
|
||||
ctx->request = request;
|
||||
spdk_vhost_call_external_event_foreach(spdk_rpc_get_vhost_controllers_cb, ctx);
|
||||
}
|
||||
SPDK_RPC_REGISTER("get_vhost_controllers", spdk_rpc_get_vhost_controllers)
|
||||
SPDK_RPC_REGISTER("get_vhost_controllers", spdk_rpc_get_vhost_controllers, SPDK_RPC_RUNTIME)
|
||||
|
||||
|
||||
struct rpc_vhost_ctrlr_coalescing {
|
||||
@ -605,7 +607,8 @@ invalid:
|
||||
spdk_jsonrpc_send_error_response(request, SPDK_JSONRPC_ERROR_INVALID_PARAMS,
|
||||
spdk_strerror(-rc));
|
||||
}
|
||||
SPDK_RPC_REGISTER("set_vhost_controller_coalescing", spdk_rpc_set_vhost_controller_coalescing)
|
||||
SPDK_RPC_REGISTER("set_vhost_controller_coalescing", spdk_rpc_set_vhost_controller_coalescing,
|
||||
SPDK_RPC_RUNTIME)
|
||||
|
||||
struct rpc_vhost_nvme_ctrlr {
|
||||
char *ctrlr;
|
||||
@ -663,7 +666,8 @@ invalid:
|
||||
spdk_strerror(-rc));
|
||||
|
||||
}
|
||||
SPDK_RPC_REGISTER("construct_vhost_nvme_controller", spdk_rpc_construct_vhost_nvme_controller)
|
||||
SPDK_RPC_REGISTER("construct_vhost_nvme_controller", spdk_rpc_construct_vhost_nvme_controller,
|
||||
SPDK_RPC_RUNTIME)
|
||||
|
||||
struct rpc_add_vhost_nvme_ctrlr_ns {
|
||||
char *ctrlr;
|
||||
@ -751,7 +755,7 @@ invalid:
|
||||
spdk_jsonrpc_send_error_response(request, SPDK_JSONRPC_ERROR_INVALID_PARAMS,
|
||||
spdk_strerror(-rc));
|
||||
}
|
||||
SPDK_RPC_REGISTER("add_vhost_nvme_ns", spdk_rpc_add_vhost_nvme_ns)
|
||||
SPDK_RPC_REGISTER("add_vhost_nvme_ns", spdk_rpc_add_vhost_nvme_ns, SPDK_RPC_RUNTIME)
|
||||
|
||||
|
||||
SPDK_LOG_REGISTER_COMPONENT("vhost_rpc", SPDK_LOG_VHOST_RPC)
|
||||
|
Loading…
x
Reference in New Issue
Block a user