-
Notifications
You must be signed in to change notification settings - Fork 168
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5937 from meinaLi/viommu
SRIOV: add new test case of dma_translation for vIOMMU
- Loading branch information
Showing
2 changed files
with
64 additions
and
0 deletions.
There are no files selected for viewing
17 changes: 17 additions & 0 deletions
17
libvirt/tests/cfg/sriov/vIOMMU/intel_iommu_with_dma_translation.cfg
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
- vIOMMU.intel_iommu_with_dma_translation: | ||
type = intel_iommu_with_dma_translation | ||
start_vm = "yes" | ||
enable_guest_iommu = "yes" | ||
func_supported_since_libvirt_ver = (10, 7, 0) | ||
only q35 | ||
variants: | ||
- enable_dma_translation: | ||
dma_translation = "on" | ||
- disable_dma_translation: | ||
dma_translation = "off" | ||
- disable_dma_translation_with_more_vcpus: | ||
with_more_vcpus = "yes" | ||
dma_translation = "off" | ||
eim_dict = {'eim': 'on'} | ||
guest_vcpus = 256 | ||
iommu_dict = {'model': 'intel', 'driver': {'intremap': 'on', 'caching_mode': 'on', 'iotlb': 'on', 'dma_translation': '${dma_translation}'}} |
47 changes: 47 additions & 0 deletions
47
libvirt/tests/src/sriov/vIOMMU/intel_iommu_with_dma_translation.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
from virttest import virsh | ||
from virttest.libvirt_xml import vm_xml | ||
|
||
from provider.viommu import viommu_base | ||
|
||
|
||
def run(test, params, env): | ||
""" | ||
Start vm with Intel iommu and dma_translation attribute. | ||
""" | ||
vm_name = params.get("main_vm", "avocado-vt-vm1") | ||
vm = env.get_vm(vm_name) | ||
dma_translation = params.get("dma_translation") | ||
guest_vcpus = params.get("guest_vcpus") | ||
eim_dict = eval(params.get("eim_dict", "{}")) | ||
iommu_dict = eval(params.get("iommu_dict", "{}")) | ||
with_more_vcpus = "yes" == params.get("with_more_vcpus", "no") | ||
test_obj = viommu_base.VIOMMUTest(vm, test, params) | ||
|
||
try: | ||
iommu_dict['driver'].update(eim_dict) | ||
test.log.info("TEST STEP1: Prepare guest xml with intel iommu device.") | ||
test_obj.setup_iommu_test(iommu_dict=iommu_dict) | ||
if with_more_vcpus: | ||
vmxml = vm_xml.VMXML.new_from_dumpxml(vm_name) | ||
vmxml.vcpu = int(guest_vcpus) | ||
vmxml.sync() | ||
test.log.info("TEST STEP2: Start the guest.") | ||
vm.start() | ||
test.log.debug("The current guest xml ls: %s", | ||
virsh.dumpxml(vm_name).stdout_text) | ||
test.log.info("TEST STEP3: Check the message for iommu group and DMA.") | ||
vm.cleanup_serial_console() | ||
vm.create_serial_console() | ||
vm_session = vm.wait_for_serial_login(timeout=1000) | ||
dma_status, dma_o = vm_session.cmd_status_output("dmesg | grep -i 'Not attempting DMA translation'") | ||
iommu_status, iommu_o = vm_session.cmd_status_output("dmesg | grep -i 'Adding to iommu group'") | ||
if dma_translation == "on" and (not dma_status or iommu_status): | ||
test.fail("Can't get expected dma message %s when enabling dma_translation." % dma_o) | ||
if dma_translation == "off" and (dma_status or not iommu_status): | ||
test.fail("Can't get expected iommu message %s when disabling dma_translation." % iommu_o) | ||
if with_more_vcpus: | ||
s, o = vm_session.cmd_status_output("cat /proc/cpuinfo | grep processor| wc -l") | ||
if int(o) != int(guest_vcpus): | ||
test.fail("Can't get expected vCPU number, the actual number is %s" % o) | ||
finally: | ||
test_obj.teardown_iommu_test() |