-
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.
SRIOV: add new test scenarios for vIOMMU
Automate new dma_translation attribute for vIOMMU: VIRT-302220 - [vIOMMU][intel] Start VM with intel iommu and dma_translation attribute Signed-off-by: Meina Li <[email protected]>
- Loading branch information
Showing
2 changed files
with
66 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" | ||
iommu_dict = {'model': 'intel', 'driver': {'intremap': 'on', 'caching_mode': 'on', 'iotlb': 'on', 'dma_translation': '%s'}} | ||
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 |
49 changes: 49 additions & 0 deletions
49
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,49 @@ | ||
from virttest import virsh | ||
from virttest import libvirt_version | ||
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", "{}") % dma_translation) | ||
with_more_vcpus = "yes" == params.get("with_more_vcpus", "no") | ||
test_obj = viommu_base.VIOMMUTest(vm, test, params) | ||
libvirt_version.is_libvirt_feature_supported(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) | ||
vmxml = vm_xml.VMXML.new_from_dumpxml(vm_name) | ||
if with_more_vcpus: | ||
vmxml.vcpu = int(guest_vcpus) | ||
vmxml.sync() | ||
test.log.info("TEST STEP2: Start the guest.") | ||
virsh.start(vm_name, debug=True) | ||
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=6000) | ||
dma_status, _ = vm_session.cmd_status_output("dmesg | grep -i 'Not attempting DMA translation'") | ||
iommu_status, _ = 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 message result when enabling dma_translation.") | ||
if dma_translation == "off" and (dma_status or not iommu_status): | ||
test.fail("Can't get expected message result when disabling dma_translation.") | ||
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" % type(o)) | ||
finally: | ||
test_obj.teardown_iommu_test() |