xref: /spdk/doc/jsonrpc.md (revision f86f10757912918b8ba7b4b3bfdab1cd4c2d180c)
1# JSON-RPC Methods {#jsonrpc}
2
3# Overview {#jsonrpc_overview}
4
5SPDK implements a [JSON-RPC 2.0](http://www.jsonrpc.org/specification) server
6to allow external management tools to dynamically configure SPDK components.
7
8# App Framework {#jsonrpc_components_app}
9
10## kill_instance {#rpc_kill_instance}
11
12Send a signal to the application.
13
14### Parameters
15
16Name                    | Optional | Type        | Description
17----------------------- | -------- | ----------- | -----------
18sig_name                | Required | string      | Signal to send (SIGINT, SIGTERM, SIGQUIT, SIGHUP, or SIGKILL)
19
20### Example
21
22Example request:
23~~~
24{
25  "jsonrpc": "2.0",
26  "id": 1,
27  "method": "kill_instance",
28  "params": {
29    "sig_name": "SIGINT"
30  }
31}
32~~~
33
34Example response:
35~~~
36{
37  "jsonrpc": "2.0",
38  "id": 1,
39  "result": true
40}
41~~~
42
43## context_switch_monitor {#rpc_context_switch_monitor}
44
45Query, enable, or disable the context switch monitoring functionality.
46
47### Parameters
48
49Name                    | Optional | Type        | Description
50----------------------- | -------- | ----------- | -----------
51enabled                 | Optional | boolean     | Enable (`true`) or disable (`false`) monitoring (omit this parameter to query the current state)
52
53### Response
54
55The current state of context switch monitoring is returned as a boolean.
56
57### Example
58
59Example request:
60~~~
61{
62  "jsonrpc": "2.0",
63  "id": 1,
64  "method": "context_switch_monitor",
65  "params": {
66    "enabled": false
67  }
68}
69~~~
70
71Example response:
72~~~
73{
74  "jsonrpc": "2.0",
75  "id": 1,
76  "result": false
77}
78~~~
79
80
81# Block Device Abstraction Layer {#jsonrpc_components_bdev}
82
83## get_bdevs {#rpc_get_bdevs}
84
85Get information about block devices (bdevs).
86
87### Parameters
88
89The user may specify no parameters in order to list all block devices, or a block device may be
90specified by name.
91
92Name                    | Optional | Type        | Description
93----------------------- | -------- | ----------- | -----------
94name                    | Optional | string      | Block device name
95
96### Response
97
98The response is an array of objects containing information about the requested block devices.
99
100### Example
101
102Example request:
103~~~
104{
105  "jsonrpc": "2.0",
106  "id": 1,
107  "method": "get_bdevs",
108  "params": {
109    "name": "Malloc0"
110  }
111}
112~~~
113
114Example response:
115~~~
116{
117  "jsonrpc": "2.0",
118  "id": 1,
119  "result": [
120    {
121      "name": "Malloc0",
122      "product_name": "Malloc disk",
123      "block_size": 512,
124      "num_blocks": 20480,
125      "claimed": false,
126      "supported_io_types": {
127        "read": true,
128        "write": true,
129        "unmap": true,
130        "write_zeroes": true,
131        "flush": true,
132        "reset": true,
133        "nvme_admin": false,
134        "nvme_io": false
135      },
136      "driver_specific": {}
137    }
138  ]
139}
140~~~
141
142## delete_bdev {#rpc_delete_bdev}
143
144Unregister a block device.
145
146### Example
147
148Example request:
149~~~
150{
151  "jsonrpc": "2.0",
152  "id": 1,
153  "method": "delete_bdev",
154  "params": {
155    "name": "Malloc0"
156  }
157}
158~~~
159
160Example response:
161~~~
162{
163  "jsonrpc": "2.0",
164  "id": 1,
165  "result": true
166}
167~~~
168
169### Parameters
170
171Name                    | Optional | Type        | Description
172----------------------- | -------- | ----------- | -----------
173name                    | Required | string      | Block device name
174
175
176# NVMe-oF Target {#jsonrpc_components_nvmf_tgt}
177
178## get_nvmf_subsystems method {#rpc_get_nvmf_subsystems}
179
180### Parameters
181
182This method has no parameters.
183
184### Example
185
186Example request:
187~~~
188{
189  "jsonrpc": "2.0",
190  "id": 1,
191  "method": "get_nvmf_subsystems"
192}
193~~~
194
195Example response:
196~~~
197{
198  "jsonrpc": "2.0",
199  "id": 1,
200  "result": [
201    {
202      "core": 0,
203      "nqn": "nqn.2014-08.org.nvmexpress.discovery",
204      "subtype": "Discovery"
205      "listen_addresses": [],
206      "hosts": [],
207      "allow_any_host": true
208    },
209    {
210      "core": 5,
211      "nqn": "nqn.2016-06.io.spdk:cnode1",
212      "subtype": "NVMe",
213      "listen_addresses": [
214        {
215          "trtype": "RDMA",
216          "adrfam": "IPv4",
217          "traddr": "192.168.0.123",
218          "trsvcid": "4420"
219        }
220      ],
221      "hosts": [
222        {"nqn": "nqn.2016-06.io.spdk:host1"}
223      ],
224      "allow_any_host": false,
225      "serial_number": "abcdef",
226      "namespaces": [
227        {"nsid": 1, "name": "Malloc2"},
228        {"nsid": 2, "name": "Nvme0n1"}
229      ]
230    }
231  ]
232}
233~~~
234
235## construct_nvmf_subsystem method {#rpc_construct_nvmf_subsystem}
236
237Construct an NVMe over Fabrics target subsystem.
238
239### Parameters
240
241Name                    | Optional | Type        | Description
242----------------------- | -------- | ----------- | -----------
243core                    | Optional | number      | Core to run the subsystem's poller on. Default: Automatically assign a core.
244nqn                     | Required | string      | Subsystem NQN
245listen_addresses        | Required | array       | Array of @ref rpc_construct_nvmf_subsystem_listen_address objects
246hosts                   | Optional | array       | Array of strings containing allowed host NQNs. Default: No hosts allowed.
247allow_any_host          | Optional | boolean     | Allow any host (`true`) or enforce allowed host whitelist (`false`). Default: `false`.
248serial_number           | Required | string      | Serial number of virtual controller
249namespaces              | Optional | array       | Array of @ref rpc_construct_nvmf_subsystem_namespace objects. Default: No namespaces.
250
251### listen_address {#rpc_construct_nvmf_subsystem_listen_address}
252
253Name                    | Optional | Type        | Description
254----------------------- | -------- | ----------- | -----------
255trtype                  | Required | string      | Transport type ("RDMA")
256adrfam                  | Required | string      | Address family ("IPv4", "IPv6", "IB", or "FC")
257traddr                  | Required | string      | Transport address
258trsvcid                 | Required | string      | Transport service ID
259
260### namespace {#rpc_construct_nvmf_subsystem_namespace}
261
262Name                    | Optional | Type        | Description
263----------------------- | -------- | ----------- | -----------
264nsid                    | Optional | number      | Namespace ID between 1 and 4294967294, inclusive. Default: Automatically assign NSID.
265bdev_name               | Required | string      | Name of bdev to expose as a namespace.
266
267### Example
268
269Example request:
270
271~~~
272{
273  "jsonrpc": "2.0",
274  "id": 1,
275  "method": "construct_nvmf_subsystem",
276  "params": {
277    "core": 5,
278    "nqn": "nqn.2016-06.io.spdk:cnode1",
279    "listen_addresses": [
280      {
281        "trtype": "RDMA",
282        "adrfam": "IPv4",
283        "traddr": "192.168.0.123",
284        "trsvcid: "4420"
285      }
286    ],
287    "hosts": [
288      "nqn.2016-06.io.spdk:host1",
289      "nqn.2016-06.io.spdk:host2"
290    ],
291    "allow_any_host": false,
292    "serial_number": "abcdef",
293    "namespaces": [
294      {"nsid": 1, "name": "Malloc2"},
295      {"nsid": 2, "name": "Nvme0n1"}
296    ]
297  }
298}
299~~~
300
301Example response:
302
303~~~
304{
305  "jsonrpc": "2.0",
306  "id": 1,
307  "result": true
308}
309~~~
310
311## delete_nvmf_subsystem method {#rpc_delete_nvmf_subsystem}
312
313Delete an existing NVMe-oF subsystem.
314
315### Parameters
316
317Parameter              | Optional | Type        | Description
318---------------------- | -------- | ----------- | -----------
319nqn                    | Required | string      | Subsystem NQN to delete.
320
321### Example
322
323Example request:
324
325~~~
326{
327  "jsonrpc": "2.0",
328  "id": 1,
329  "method": "delete_nvmf_subsystem",
330  "params": {
331    "nqn": "nqn.2016-06.io.spdk:cnode1"
332  }
333}
334~~~
335
336Example response:
337
338~~~
339{
340  "jsonrpc": "2.0",
341  "id": 1,
342  "result": true
343}
344~~~
345