]>
Commit | Line | Data |
---|---|---|
11fdf7f2 TL |
1 | def set_vhost_controller_coalescing(client, ctrlr, delay_base_us, iops_threshold): |
2 | """Set coalescing for vhost controller. | |
3 | Args: | |
4 | ctrlr: controller name | |
5 | delay_base_us: base delay time | |
6 | iops_threshold: IOPS threshold when coalescing is enabled | |
7 | """ | |
8 | params = { | |
9 | 'ctrlr': ctrlr, | |
10 | 'delay_base_us': delay_base_us, | |
11 | 'iops_threshold': iops_threshold, | |
12 | } | |
13 | return client.call('set_vhost_controller_coalescing', params) | |
14 | ||
15 | ||
16 | def construct_vhost_scsi_controller(client, ctrlr, cpumask=None): | |
17 | """Construct a vhost scsi controller. | |
18 | Args: | |
19 | ctrlr: controller name | |
20 | cpumask: cpu mask for this controller | |
21 | """ | |
22 | params = {'ctrlr': ctrlr} | |
23 | ||
24 | if cpumask: | |
25 | params['cpumask'] = cpumask | |
26 | ||
27 | return client.call('construct_vhost_scsi_controller', params) | |
28 | ||
29 | ||
30 | def add_vhost_scsi_lun(client, ctrlr, scsi_target_num, bdev_name): | |
31 | """Add LUN to vhost scsi controller target. | |
32 | Args: | |
33 | ctrlr: controller name | |
34 | scsi_target_num: target number to use | |
35 | bdev_name: name of bdev to add to target | |
36 | """ | |
37 | params = { | |
38 | 'ctrlr': ctrlr, | |
39 | 'scsi_target_num': scsi_target_num, | |
40 | 'bdev_name': bdev_name, | |
41 | } | |
42 | return client.call('add_vhost_scsi_lun', params) | |
43 | ||
44 | ||
45 | def remove_vhost_scsi_target(client, ctrlr, scsi_target_num): | |
46 | """Remove target from vhost scsi controller. | |
47 | Args: | |
48 | ctrlr: controller name to remove target from | |
49 | scsi_target_num: number of target to remove from controller | |
50 | """ | |
51 | params = { | |
52 | 'ctrlr': ctrlr, | |
53 | 'scsi_target_num': scsi_target_num | |
54 | } | |
55 | return client.call('remove_vhost_scsi_target', params) | |
56 | ||
57 | ||
58 | def construct_vhost_nvme_controller(client, ctrlr, io_queues, cpumask=None): | |
59 | """Construct vhost NVMe controller. | |
60 | Args: | |
61 | ctrlr: controller name | |
62 | io_queues: number of IO queues for the controller | |
63 | cpumask: cpu mask for this controller | |
64 | """ | |
65 | params = { | |
66 | 'ctrlr': ctrlr, | |
67 | 'io_queues': io_queues | |
68 | } | |
69 | ||
70 | if cpumask: | |
71 | params['cpumask'] = cpumask | |
72 | ||
73 | return client.call('construct_vhost_nvme_controller', params) | |
74 | ||
75 | ||
76 | def add_vhost_nvme_ns(client, ctrlr, bdev_name): | |
77 | """Add namespace to vhost nvme controller. | |
78 | Args: | |
79 | ctrlr: controller name where to add a namespace | |
80 | bdev_name: block device name for a new namespace | |
81 | """ | |
82 | params = { | |
83 | 'ctrlr': ctrlr, | |
84 | 'bdev_name': bdev_name, | |
85 | } | |
86 | ||
87 | return client.call('add_vhost_nvme_ns', params) | |
88 | ||
89 | ||
90 | def construct_vhost_blk_controller(client, ctrlr, dev_name, cpumask=None, readonly=None): | |
91 | """Construct vhost BLK controller. | |
92 | Args: | |
93 | ctrlr: controller name | |
94 | dev_name: device name to add to controller | |
95 | cpumask: cpu mask for this controller | |
96 | readonly: set controller as read-only | |
97 | """ | |
98 | params = { | |
99 | 'ctrlr': ctrlr, | |
100 | 'dev_name': dev_name, | |
101 | } | |
102 | if cpumask: | |
103 | params['cpumask'] = cpumask | |
104 | if readonly: | |
105 | params['readonly'] = readonly | |
106 | return client.call('construct_vhost_blk_controller', params) | |
107 | ||
108 | ||
109 | def get_vhost_controllers(client, name=None): | |
110 | """Get information about configured vhost controllers. | |
111 | ||
112 | Args: | |
113 | name: controller name to query (optional; if omitted, query all controllers) | |
114 | ||
115 | Returns: | |
116 | List of vhost controllers. | |
117 | """ | |
118 | params = {} | |
119 | if name: | |
120 | params['name'] = name | |
121 | return client.call('get_vhost_controllers', params) | |
122 | ||
123 | ||
124 | def remove_vhost_controller(client, ctrlr): | |
125 | """Remove vhost controller from configuration. | |
126 | Args: | |
127 | ctrlr: controller name to remove | |
128 | """ | |
129 | params = {'ctrlr': ctrlr} | |
130 | return client.call('remove_vhost_controller', params) | |
131 | ||
132 | ||
133 | def construct_virtio_dev(client, name, trtype, traddr, dev_type, vq_count=None, vq_size=None): | |
134 | """Construct new virtio device using provided | |
135 | transport type and device type. | |
136 | Args: | |
137 | name: name base for new created bdevs | |
138 | trtype: virtio target transport type: pci or user | |
139 | traddr: transport type specific target address: e.g. UNIX | |
140 | domain socket path or BDF | |
141 | dev_type: device type: blk or scsi | |
142 | vq_count: number of virtual queues to be used | |
143 | vq_size: size of each queue | |
144 | """ | |
145 | params = { | |
146 | 'name': name, | |
147 | 'trtype': trtype, | |
148 | 'traddr': traddr, | |
149 | 'dev_type': dev_type | |
150 | } | |
151 | if vq_count: | |
152 | params['vq_count'] = vq_count | |
153 | if vq_size: | |
154 | params['vq_size'] = vq_size | |
155 | return client.call('construct_virtio_dev', params) | |
156 | ||
157 | ||
11fdf7f2 TL |
158 | def remove_virtio_bdev(client, name): |
159 | """Remove a Virtio device | |
160 | This will delete all bdevs exposed by this device. | |
161 | Args: | |
162 | name: virtio device name | |
163 | """ | |
164 | params = {'name': name} | |
165 | return client.call('remove_virtio_bdev', params) | |
166 | ||
167 | ||
168 | def get_virtio_scsi_devs(client): | |
169 | """Get list of virtio scsi devices.""" | |
170 | return client.call('get_virtio_scsi_devs') |