Commit 9baab97f authored by Xiaodong Liu's avatar Xiaodong Liu Committed by Jim Harris
Browse files

jsonrpc.md: document NBD RPC methods



Change-Id: Ia4ea6986c2282b3a56ec48ca4f9b0ad05e95e7f1
Signed-off-by: default avatarXiaodong Liu <xiaodong.liu@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/450578


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarChangpeng Liu <changpeng.liu@intel.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
parent 5f51f0af
Loading
Loading
Loading
Loading
+127 −0
Original line number Diff line number Diff line
@@ -5115,6 +5115,133 @@ Example response:
}
~~~

# Linux Network Block Device (NBD) {#jsonrpc_components_nbd}

SPDK supports exporting bdevs through Linux nbd. These devices then appear as standard Linux kernel block devices and can be accessed using standard utilities like fdisk.

In order to export a device over nbd, first make sure the Linux kernel nbd driver is loaded by running 'modprobe nbd'.

## start_nbd_disk {#rpc_start_nbd_disk}

Start to export one SPDK bdev as NBD disk

### Parameters

Name                    | Optional | Type        | Description
----------------------- | -------- | ----------- | -----------
bdev_name               | Required | string      | Bdev name to export
nbd_device              | Optional | string      | NBD device name to assign

### Response

Path of exported NBD disk

### Example

Example request:

~~~
{
 "params": {
    "nbd_device": "/dev/nbd1",
    "bdev_name": "Malloc1"
  },
  "jsonrpc": "2.0",
  "method": "start_nbd_disk",
  "id": 1
}
~~~

Example response:

~~~
{
  "jsonrpc": "2.0",
  "id": 1,
  "result": "/dev/nbd1"
}
~~~

## stop_nbd_disk {#rpc_stop_nbd_disk}

Stop one NBD disk which is based on SPDK bdev.

### Parameters

Name                    | Optional | Type        | Description
----------------------- | -------- | ----------- | -----------
nbd_device              | Required | string      | NBD device name to stop

### Example

Example request:

~~~
{
 "params": {
    "nbd_device": "/dev/nbd1",
  },
  "jsonrpc": "2.0",
  "method": "stop_nbd_disk",
  "id": 1
}
~~~

Example response:

~~~
{
  "jsonrpc": "2.0",
  "id": 1,
  "result": "true"
}
~~~

## get_nbd_disks {#rpc_get_nbd_disks}

Display all or specified NBD device list

### Parameters

Name                    | Optional | Type        | Description
----------------------- | -------- | ----------- | -----------
nbd_device              | Optional | string      | NBD device name to display

### Response

The response is an array of exported NBD devices and their corresponding SPDK bdev.

### Example

Example request:

~~~
{
  "jsonrpc": "2.0",
  "method": "get_nbd_disks",
  "id": 1
}
~~~

Example response:

~~~
{
  "jsonrpc": "2.0",
  "id": 1,
  "result":  [
    {
      "bdev_name": "Malloc0",
      "nbd_device": "/dev/nbd0"
    },
    {
      "bdev_name": "Malloc1",
      "nbd_device": "/dev/nbd1"
    }
  ]
}
~~~

# Miscellaneous RPC commands

## send_nvme_cmd {#rpc_send_nvme_cmd}