Skip to content

Commit d564b55

Browse files
authored
Merge pull request #5411 from Yingshun/at_iommu
vIOMMU: Add a case of attach iommu device
2 parents 4fc4554 + 04fe8e3 commit d564b55

File tree

2 files changed

+55
-0
lines changed

2 files changed

+55
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
- vIOMMU.attach_iommu_device:
2+
type = attach_iommu_device
3+
start_vm = "no"
4+
err_msg = "attach of device 'iommu' is not supported"
5+
variants:
6+
- virtio:
7+
only q35, aarch64
8+
func_supported_since_libvirt_ver = (8, 3, 0)
9+
iommu_dict = {'model': 'virtio'}
10+
- intel:
11+
only q35
12+
iommu_dict = {'model': 'intel', 'driver': {'intremap': 'on', 'caching_mode': 'on'}}
13+
- smmuv3:
14+
only aarch64
15+
func_supported_since_libvirt_ver = (5, 5, 0)
16+
iommu_dict = {'model': 'smmuv3'}
17+
variants:
18+
- cold_plug:
19+
attach_option = "--config"
20+
- hot_plug:
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
from virttest import libvirt_version
2+
from virttest import virsh
3+
4+
from virttest.libvirt_xml import vm_xml
5+
from virttest.utils_libvirt import libvirt_vmxml
6+
from virttest.utils_test import libvirt
7+
8+
9+
def run(test, params, env):
10+
"""
11+
Hotplug or coldplug iommu device to guest
12+
"""
13+
libvirt_version.is_libvirt_feature_supported(params)
14+
iommu_dict = eval(params.get('iommu_dict', '{}'))
15+
attach_option = params.get("attach_option", "")
16+
err_msg = params.get("err_msg")
17+
18+
vm_name = params.get("main_vm", "avocado-vt-vm1")
19+
vm = env.get_vm(vm_name)
20+
vmxml = vm_xml.VMXML.new_from_dumpxml(vm_name)
21+
backup_vmxml = vmxml.copy()
22+
try:
23+
if attach_option and vm.is_alive():
24+
vm.destroy()
25+
elif not attach_option and not vm.is_alive():
26+
vm.start()
27+
vm.wait_for_login().close()
28+
29+
iommu_dev = libvirt_vmxml.create_vm_device_by_type('iommu', iommu_dict)
30+
test.log.debug(f"iommu device: {iommu_dev}")
31+
res = virsh.attach_device(vm.name, iommu_dev.xml, debug=True,
32+
flagstr=attach_option)
33+
libvirt.check_result(res, err_msg)
34+
finally:
35+
backup_vmxml.sync()

0 commit comments

Comments
 (0)