Here we use vfu-tgt library and emulate a virtio-blk device as the first use case of vfu-tgt library. Usage example with QEMU: 1. build/bin/spdk_tgt 2. scripts/rpc.py bdev_malloc_create -b malloc0 $((512)) 512 3. scripts/rpc.py vfu_virtio_create_blk_endpoint vfu.0 --bdev-name malloc0 \ --cpumask=0x1 --num-queues=2 \ --qsize=256 --packed-ring 4. Start QEMU with '-device vfio-user-pci,socket=/spdk/vfu.0' Change-Id: I45e45360c669584583b0b8a3f83250ab6c48efec Signed-off-by: Changpeng Liu <changpeng.liu@intel.com> Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/12315 Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Reviewed-by: Konrad Sztyber <konrad.sztyber@intel.com> Reviewed-by: Ben Walker <benjamin.walker@intel.com> Community-CI: Mellanox Build Bot
52 lines
1.2 KiB
Python
52 lines
1.2 KiB
Python
def vfu_tgt_set_base_path(client, path):
|
|
"""Set socket base path.
|
|
|
|
Args:
|
|
path: base path
|
|
"""
|
|
params = {
|
|
'path': path
|
|
}
|
|
|
|
return client.call('vfu_tgt_set_base_path', params)
|
|
|
|
|
|
def vfu_virtio_delete_endpoint(client, name):
|
|
"""Delete specified endpoint name.
|
|
|
|
Args:
|
|
name: endpoint name
|
|
"""
|
|
params = {
|
|
'name': name
|
|
}
|
|
|
|
return client.call('vfu_virtio_delete_endpoint', params)
|
|
|
|
|
|
def vfu_virtio_create_blk_endpoint(client, name, bdev_name, cpumask, num_queues, qsize, packed_ring):
|
|
"""Create virtio-blk endpoint.
|
|
|
|
Args:
|
|
name: endpoint name
|
|
bdev_name: name of block device
|
|
cpumask: CPU core mask
|
|
num_queues: number of vrings
|
|
qsize: number of element of each vring
|
|
packed_ring: enable packed ring
|
|
"""
|
|
params = {
|
|
'name': name,
|
|
'bdev_name': bdev_name
|
|
}
|
|
if cpumask:
|
|
params['cpumask'] = cpumask
|
|
if num_queues:
|
|
params['num_queues'] = num_queues
|
|
if qsize:
|
|
params['qsize'] = qsize
|
|
if packed_ring:
|
|
params['packed_ring'] = packed_ring
|
|
|
|
return client.call('vfu_virtio_create_blk_endpoint', params)
|