Skip to content

Commit

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

Signed-off-by: Wenkang Ji <[email protected]>
  • Loading branch information
heywji committed Jan 2, 2025
1 parent 80ca89f commit 083211b
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion virttest/qemu_vm.py
Original file line number Diff line number Diff line change
Expand Up @@ -740,11 +740,24 @@ def add_nic(
dev.parent_bus = pci_bus
dev.set_param("addr", pci_addr)
if nic_extra_params:
nic_extra_params_type = dict(eval(self.params.get("nic_extra_params_type", {})))
print(nic_extra_params_type)
nic_extra_params = (
_.split("=", 1) for _ in nic_extra_params.split(",") if _
)
print(nic_extra_params)
for key, val in nic_extra_params:
dev.set_param(key, val)
value_type = nic_extra_params_type.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 083211b

Please sign in to comment.