Skip to content

Commit

Permalink
QEMU_VM: Add nic_extra_param_types support
Browse files Browse the repository at this point in the history
Add nic_extra_param_types params support for nic_extra_params to
optimize virtio-net QEMU cmdline type handling.

Signed-off-by: wji <[email protected]>
  • Loading branch information
heywji committed Dec 30, 2024
1 parent 80ca89f commit b6d7689
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions virttest/qemu_vm.py
Original file line number Diff line number Diff line change
Expand Up @@ -740,11 +740,21 @@ def add_nic(
dev.parent_bus = pci_bus
dev.set_param("addr", pci_addr)
if nic_extra_params:
nic_extra_params = (
_.split("=", 1) for _ in nic_extra_params.split(",") if _
)
nic_extra_param_types = self.params.get("nic_extra_param_types", {})
if nic_extra_param_types:
nic_extra_param_types = dict(eval(nic_extra_param_types))
nic_extra_params = (_.split('=', 1) for _ in
nic_extra_params.split(',') if _)
for key, val in nic_extra_params:
dev.set_param(key, val)
value_type = nic_extra_param_types.get(key)
if value_type:
try:
converted_val = value_type(val)
dev.set_param(key, converted_val)
except ValueError as e:
raise ValueError(f"Failed to convert {key}: {val} to {value_type}: {e}")
else:
dev.set_param(key, val)
dev.set_param("bootindex", bootindex)
if "aarch64" in params.get("vm_arch_name", arch.ARCH):
if "rombar" in devices.execute_qemu("-device %s,?" % model):
Expand Down

0 comments on commit b6d7689

Please sign in to comment.