Skip to content

Commit

Permalink
qcontainer.py: add new support to the parameter
Browse files Browse the repository at this point in the history
qdevices.py: add new support to the parameter

Add new support to the parameter: iothread_vqs_mapping.

Signed-off-by: Houqi (Nick) Zuo <[email protected]>
  • Loading branch information
nickzhq committed Oct 23, 2023
1 parent 6ce0d7b commit b0dbb65
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 7 deletions.
24 changes: 17 additions & 7 deletions virttest/qemu_devices/qcontainer.py
Original file line number Diff line number Diff line change
Expand Up @@ -1704,7 +1704,8 @@ def images_define_by_variables(self, name, filename, pci_bus, index=None,
image_throttle_group=None,
image_auto_readonly=None,
image_discard=None,
image_copy_on_read=None):
image_copy_on_read=None,
image_iothread_vqs_mapping=None):
"""
Creates related devices by variables
:note: To skip the argument use None, to disable it use False
Expand Down Expand Up @@ -1749,6 +1750,8 @@ def images_define_by_variables(self, name, filename, pci_bus, index=None,
:param image_auto_readonly: auto-read-only option in BlockdevOptions
:param image_discard: discard option in BlockdevOptions
:param image_copy_on_read: if support copy-on-read filter
:param image_iothread_vqs_mapping: the mapping between iothread
and virt-queues
"""
def _get_access_tls_creds(image_access):
"""Get all tls-creds objects of the image and its backing images"""
Expand Down Expand Up @@ -2018,11 +2021,12 @@ def define_hbas(qtype, atype, bus, unit, port, qbus, pci_bus, iothread,
if arch.ARCH in ('ppc64', 'ppc64le'):
_ = define_hbas('SCSI', 'spapr-vscsi', None, None, None,
qdevices.QSCSIBus, None, iothread,
addr_spec=[64, 32])
addr_spec=[64, 32], num_queues=num_queues)
else:
_ = define_hbas('SCSI', 'lsi53c895a', None, None, None,
qdevices.QSCSIBus, pci_bus, iothread,
addr_spec=[8, 16384])
addr_spec=[8, 16384],
num_queues=num_queues)
devices.extend(_[0])
elif fmt == "ide":
if bus:
Expand All @@ -2033,13 +2037,14 @@ def define_hbas(qtype, atype, bus, unit, port, qbus, pci_bus, iothread,
elif fmt == "ahci":
devs, bus, dev_parent = define_hbas('IDE', 'ahci', bus, unit, port,
qdevices.QAHCIBus, pci_bus,
iothread)
iothread,
num_queues=num_queues)
devices.extend(devs)
elif fmt.startswith('scsi-'):
if not scsi_hba:
scsi_hba = "virtio-scsi-pci"
if scsi_hba != "virtio-scsi-pci":
num_queues = None
# if scsi_hba != "virtio-scsi-pci":
# num_queues = None
addr_spec = None
if scsi_hba == 'lsi53c895a':
addr_spec = [8, 16384]
Expand Down Expand Up @@ -2436,6 +2441,9 @@ def define_hbas(qtype, atype, bus, unit, port, qbus, pci_bus, iothread,
if 'serial' in options:
devices[-1].set_param('serial', serial)
devices[-2].set_param('serial', None) # remove serial from drive
if image_iothread_vqs_mapping:
devices[-1].set_param('iothread_vqs_mapping',
image_iothread_vqs_mapping)
if blk_extra_params:
blk_extra_params = (_.split('=', 1) for _ in
blk_extra_params.split(',') if _)
Expand Down Expand Up @@ -2577,7 +2585,9 @@ def images_define_by_params(self, name, image_params, media=None,
image_params.get(
"image_discard"),
image_params.get(
"image_copy_on_read"))
"image_copy_on_read"),
image_params.get(
"image_iothread_vqs_mapping"))

def serials_define_by_variables(self, serial_id, serial_type, chardev_id,
bus_type=None, serial_name=None,
Expand Down
14 changes: 14 additions & 0 deletions virttest/qemu_devices/qdevices.py
Original file line number Diff line number Diff line change
Expand Up @@ -1211,6 +1211,20 @@ def _cmdline_json(self):
elif key in ("requested-size", "label-size"):
command_dict[key] = int(utils_numeric.normalize_data_size(val,
"B"))
# handle the special key(iothread_vq_mapping)
# This key may have many structures of value: x:0,1,2 y:3 or x y z
elif key in ("iothread_vqs_mapping"):
command_dict[key] = []
for item in val.split(" "):
temp = item.split(":")
k = temp[0]
mapping = {"iothread": k}

v = temp[-1] if len(temp) > 1 else None
if v:
v = [int(_) for _ in v.split(",")]
mapping["vqs"] = v
command_dict[key].append(mapping)
else:
command_dict[key] = val

Expand Down

0 comments on commit b0dbb65

Please sign in to comment.