From a65ea52531ac1806007094c7f7e64ab29e3b1ce7 Mon Sep 17 00:00:00 2001 From: Xu Han Date: Fri, 25 Oct 2024 16:23:05 +0800 Subject: [PATCH] qemu_vm: introduce amd-iommu Introduce `amd-iommu` device to guests. Configuration example: ``` vm_iommu_model = amd iommu_$foo = ... iommu_$bar = ... ``` Signed-off-by: Xu Han --- virttest/qemu_vm.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/virttest/qemu_vm.py b/virttest/qemu_vm.py index ec92363a6b..5853dc8766 100644 --- a/virttest/qemu_vm.py +++ b/virttest/qemu_vm.py @@ -1914,6 +1914,17 @@ def __iothread_conflict_check(params): ) devices.insert(dev) + if params.get("vm_iommu_model") == "amd" and devices.has_device("amd-iommu"): + iommu_params = { + "device-iotlb": params.get("iommu_device_iotlb"), + "intremap": params.get("iommu_intremap"), + "pt": params.get("iommu_pt"), + "xtsup": params.get("iommu_xtsup"), + } + dev = QDevice("amd-iommu", iommu_params) + set_cmdline_format_by_cfg(dev, self._get_cmdline_format_cfg(), "iommu_dev") + devices.insert(dev) + # Add device virtio-iommu, it must be added before any virtio devices if params.get_boolean("virtio_iommu") and devices.has_device( "virtio-iommu-pci"