2019-09-11 11:57:14 +00:00
|
|
|
from .helpers import deprecated_alias
|
|
|
|
|
|
|
|
|
2019-09-30 12:16:22 +00:00
|
|
|
@deprecated_alias('set_vhost_controller_coalescing')
|
|
|
|
def vhost_controller_set_coalescing(client, ctrlr, delay_base_us, iops_threshold):
|
2018-06-13 10:55:38 +00:00
|
|
|
"""Set coalescing for vhost controller.
|
|
|
|
Args:
|
|
|
|
ctrlr: controller name
|
|
|
|
delay_base_us: base delay time
|
|
|
|
iops_threshold: IOPS threshold when coalescing is enabled
|
|
|
|
"""
|
2017-06-06 21:22:03 +00:00
|
|
|
params = {
|
2018-06-13 10:55:38 +00:00
|
|
|
'ctrlr': ctrlr,
|
|
|
|
'delay_base_us': delay_base_us,
|
|
|
|
'iops_threshold': iops_threshold,
|
2017-06-06 21:22:03 +00:00
|
|
|
}
|
2019-09-30 12:16:22 +00:00
|
|
|
return client.call('vhost_controller_set_coalescing', params)
|
2017-06-06 21:22:03 +00:00
|
|
|
|
2018-02-14 21:34:55 +00:00
|
|
|
|
2019-09-24 14:29:10 +00:00
|
|
|
@deprecated_alias('construct_vhost_scsi_controller')
|
|
|
|
def vhost_create_scsi_controller(client, ctrlr, cpumask=None):
|
|
|
|
"""Create a vhost scsi controller.
|
2018-06-13 10:55:38 +00:00
|
|
|
Args:
|
|
|
|
ctrlr: controller name
|
|
|
|
cpumask: cpu mask for this controller
|
|
|
|
"""
|
|
|
|
params = {'ctrlr': ctrlr}
|
2017-06-06 21:22:03 +00:00
|
|
|
|
2018-06-13 10:55:38 +00:00
|
|
|
if cpumask:
|
|
|
|
params['cpumask'] = cpumask
|
2017-06-06 21:22:03 +00:00
|
|
|
|
2019-09-24 14:29:10 +00:00
|
|
|
return client.call('vhost_create_scsi_controller', params)
|
2017-06-06 21:22:03 +00:00
|
|
|
|
|
|
|
|
2019-09-27 20:53:41 +00:00
|
|
|
@deprecated_alias('add_vhost_scsi_lun')
|
|
|
|
def vhost_scsi_controller_add_target(client, ctrlr, scsi_target_num, bdev_name):
|
2018-06-13 10:55:38 +00:00
|
|
|
"""Add LUN to vhost scsi controller target.
|
|
|
|
Args:
|
|
|
|
ctrlr: controller name
|
|
|
|
scsi_target_num: target number to use
|
|
|
|
bdev_name: name of bdev to add to target
|
|
|
|
"""
|
2017-06-06 21:22:03 +00:00
|
|
|
params = {
|
2018-06-13 10:55:38 +00:00
|
|
|
'ctrlr': ctrlr,
|
|
|
|
'scsi_target_num': scsi_target_num,
|
|
|
|
'bdev_name': bdev_name,
|
2017-06-06 21:22:03 +00:00
|
|
|
}
|
2019-09-27 20:53:41 +00:00
|
|
|
return client.call('vhost_scsi_controller_add_target', params)
|
2017-06-06 21:22:03 +00:00
|
|
|
|
|
|
|
|
2019-09-27 21:06:04 +00:00
|
|
|
@deprecated_alias('remove_vhost_scsi_target')
|
|
|
|
def vhost_scsi_controller_remove_target(client, ctrlr, scsi_target_num):
|
2018-06-13 10:55:38 +00:00
|
|
|
"""Remove target from vhost scsi controller.
|
|
|
|
Args:
|
|
|
|
ctrlr: controller name to remove target from
|
|
|
|
scsi_target_num: number of target to remove from controller
|
|
|
|
"""
|
2017-06-06 21:22:03 +00:00
|
|
|
params = {
|
2018-06-13 10:55:38 +00:00
|
|
|
'ctrlr': ctrlr,
|
|
|
|
'scsi_target_num': scsi_target_num
|
2017-06-06 21:22:03 +00:00
|
|
|
}
|
2019-09-27 21:06:04 +00:00
|
|
|
return client.call('vhost_scsi_controller_remove_target', params)
|
2017-06-06 21:22:03 +00:00
|
|
|
|
|
|
|
|
2019-09-30 10:51:55 +00:00
|
|
|
@deprecated_alias('construct_vhost_blk_controller')
|
2020-08-19 10:02:07 +00:00
|
|
|
def vhost_create_blk_controller(client, ctrlr, dev_name, cpumask=None, readonly=None, packed_ring=None, packed_ring_recovery=None):
|
2019-09-30 10:51:55 +00:00
|
|
|
"""Create vhost BLK controller.
|
2018-06-13 10:55:38 +00:00
|
|
|
Args:
|
|
|
|
ctrlr: controller name
|
|
|
|
dev_name: device name to add to controller
|
|
|
|
cpumask: cpu mask for this controller
|
|
|
|
readonly: set controller as read-only
|
2020-03-30 11:16:24 +00:00
|
|
|
packed_ring: support controller packed_ring
|
2020-08-19 10:02:07 +00:00
|
|
|
packed_ring_recovery: enable packed ring live recovery
|
2018-06-13 10:55:38 +00:00
|
|
|
"""
|
2017-06-06 21:22:03 +00:00
|
|
|
params = {
|
2018-06-13 10:55:38 +00:00
|
|
|
'ctrlr': ctrlr,
|
|
|
|
'dev_name': dev_name,
|
2017-06-06 21:22:03 +00:00
|
|
|
}
|
2018-06-13 10:55:38 +00:00
|
|
|
if cpumask:
|
|
|
|
params['cpumask'] = cpumask
|
|
|
|
if readonly:
|
|
|
|
params['readonly'] = readonly
|
2020-03-30 11:16:24 +00:00
|
|
|
if packed_ring:
|
|
|
|
params['packed_ring'] = packed_ring
|
2020-08-19 10:02:07 +00:00
|
|
|
if packed_ring_recovery:
|
|
|
|
params['packed_ring_recovery'] = packed_ring_recovery
|
2019-09-30 10:51:55 +00:00
|
|
|
return client.call('vhost_create_blk_controller', params)
|
2017-06-06 21:22:03 +00:00
|
|
|
|
|
|
|
|
2019-09-30 12:00:12 +00:00
|
|
|
@deprecated_alias('get_vhost_controllers')
|
|
|
|
def vhost_get_controllers(client, name=None):
|
2018-09-13 03:58:55 +00:00
|
|
|
"""Get information about configured vhost controllers.
|
|
|
|
|
|
|
|
Args:
|
|
|
|
name: controller name to query (optional; if omitted, query all controllers)
|
|
|
|
|
2018-06-13 10:55:38 +00:00
|
|
|
Returns:
|
|
|
|
List of vhost controllers.
|
|
|
|
"""
|
2018-09-13 03:58:55 +00:00
|
|
|
params = {}
|
|
|
|
if name:
|
|
|
|
params['name'] = name
|
2019-09-30 12:00:12 +00:00
|
|
|
return client.call('vhost_get_controllers', params)
|
2017-06-06 21:22:03 +00:00
|
|
|
|
|
|
|
|
2019-09-30 11:01:44 +00:00
|
|
|
@deprecated_alias('remove_vhost_controller')
|
|
|
|
def vhost_delete_controller(client, ctrlr):
|
|
|
|
"""Delete vhost controller from configuration.
|
2018-06-13 10:55:38 +00:00
|
|
|
Args:
|
|
|
|
ctrlr: controller name to remove
|
|
|
|
"""
|
|
|
|
params = {'ctrlr': ctrlr}
|
2019-09-30 11:01:44 +00:00
|
|
|
return client.call('vhost_delete_controller', params)
|
2017-06-06 21:22:03 +00:00
|
|
|
|
|
|
|
|
2019-09-11 12:50:38 +00:00
|
|
|
@deprecated_alias('construct_virtio_dev')
|
|
|
|
def bdev_virtio_attach_controller(client, name, trtype, traddr, dev_type, vq_count=None, vq_size=None):
|
|
|
|
"""Attaches virtio controller using
|
|
|
|
provided transport type and device type.
|
|
|
|
This will also create bdevs for any block
|
|
|
|
devices connected to that controller.
|
2018-06-13 10:55:38 +00:00
|
|
|
Args:
|
|
|
|
name: name base for new created bdevs
|
|
|
|
trtype: virtio target transport type: pci or user
|
|
|
|
traddr: transport type specific target address: e.g. UNIX
|
|
|
|
domain socket path or BDF
|
|
|
|
dev_type: device type: blk or scsi
|
|
|
|
vq_count: number of virtual queues to be used
|
|
|
|
vq_size: size of each queue
|
|
|
|
"""
|
2018-03-27 13:45:10 +00:00
|
|
|
params = {
|
2018-06-13 10:55:38 +00:00
|
|
|
'name': name,
|
|
|
|
'trtype': trtype,
|
|
|
|
'traddr': traddr,
|
|
|
|
'dev_type': dev_type
|
2018-03-27 13:45:10 +00:00
|
|
|
}
|
2018-06-13 10:55:38 +00:00
|
|
|
if vq_count:
|
|
|
|
params['vq_count'] = vq_count
|
|
|
|
if vq_size:
|
|
|
|
params['vq_size'] = vq_size
|
2019-09-11 12:50:38 +00:00
|
|
|
return client.call('bdev_virtio_attach_controller', params)
|
2018-03-27 13:45:10 +00:00
|
|
|
|
|
|
|
|
2019-09-11 11:57:14 +00:00
|
|
|
@deprecated_alias('remove_virtio_bdev ')
|
|
|
|
def bdev_virtio_detach_controller(client, name):
|
2018-07-26 14:08:16 +00:00
|
|
|
"""Remove a Virtio device
|
|
|
|
This will delete all bdevs exposed by this device.
|
|
|
|
Args:
|
|
|
|
name: virtio device name
|
|
|
|
"""
|
|
|
|
params = {'name': name}
|
2019-09-11 11:57:14 +00:00
|
|
|
return client.call('bdev_virtio_detach_controller', params)
|
2018-07-26 14:08:16 +00:00
|
|
|
|
|
|
|
|
2019-09-11 12:03:46 +00:00
|
|
|
@deprecated_alias('get_virtio_scsi_devs')
|
|
|
|
def bdev_virtio_scsi_get_devices(client):
|
2018-06-13 10:55:38 +00:00
|
|
|
"""Get list of virtio scsi devices."""
|
2019-09-11 12:03:46 +00:00
|
|
|
return client.call('bdev_virtio_scsi_get_devices')
|
2020-12-09 13:57:35 +00:00
|
|
|
|
|
|
|
|
|
|
|
def bdev_virtio_blk_set_hotplug(client, enable, period_us=None):
|
|
|
|
"""Set options for the bdev virtio blk. This is startup command.
|
|
|
|
|
|
|
|
Args:
|
|
|
|
enable: True to enable hotplug, False to disable.
|
|
|
|
period_us: how often the hotplug is processed for insert and remove events. Set 0 to reset to default. (optional)
|
|
|
|
"""
|
|
|
|
params = {'enable': enable}
|
|
|
|
|
|
|
|
if period_us:
|
|
|
|
params['period_us'] = period_us
|
|
|
|
|
|
|
|
return client.call('bdev_virtio_blk_set_hotplug', params)
|