Spdk/python/spdk/rpc/ublk.py
Yifan Bian e8a94a7122 ublk: add ublk to export block device
ublk could export a backend device as ublk block device (/dev/ublkb*).
A rpc method is used to add ublk device and it should be done
after creating ublk target. Corresponding, ublk_del_dev is
used to delete the specified ublk device.

Signed-off-by: Yifan Bian <yifan.bian@intel.com>
Co-authored-by: Xiaodong Liu <xiaodong.liu@intel.com>
Change-Id: I3a4ba8d8dc5f5ad241511ccbc9d3336b582a6dc5
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/15976
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-by: Xiaodong Liu <xiaodong.liu@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Paul Luse <paul.e.luse@intel.com>
2023-01-20 07:48:25 +00:00

31 lines
818 B
Python

# SPDX-License-Identifier: BSD-3-Clause
# Copyright (C) 2022 Intel Corporation.
# All rights reserved.
def ublk_create_target(client, cpumask=None):
params = {}
if cpumask:
params['cpumask'] = cpumask
return client.call('ublk_create_target', params)
def ublk_destroy_target(client):
return client.call('ublk_destroy_target')
def ublk_start_disk(client, bdev_name, ublk_id=1, num_queues=1, queue_depth=128):
params = {
'bdev_name': bdev_name,
'ublk_id': ublk_id
}
if num_queues:
params['num_queues'] = num_queues
if queue_depth:
params['queue_depth'] = queue_depth
return client.call('ublk_start_disk', params)
def ublk_stop_disk(client, ublk_id=1):
params = {'ublk_id': ublk_id}
return client.call('ublk_stop_disk', params)