Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SRIOV: add new test case of dma_translation for vIOMMU #5937

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

meinaLi
Copy link
Contributor

@meinaLi meinaLi commented Oct 11, 2024

Automate new dma_translation attribute for vIOMMU:
VIRT-302220 - [vIOMMU][intel] Start VM with intel iommu and dma_translation attribute

@meinaLi
Copy link
Contributor Author

meinaLi commented Oct 11, 2024

# avocado run --vt-type libvirt --test-runner=runner --vt-machine-type q35 vIOMMU.iommu_device_settings..intel
JOB ID     : 758b6911ec2381a2f01846ed9ab84c0bae470a4f
JOB LOG    : /var/log/avocado/job-results/job-2024-10-10T22.41-758b691/job.log
 (01/16) type_specific.io-github-autotest-libvirt.vIOMMU.iommu_device_settings.e1000e.virtio:PASS (40.62 s)
 (02/16) type_specific.io-github-autotest-libvirt.vIOMMU.iommu_device_settings.e1000e.intel: PASS (165.87 s)
 (03/16) type_specific.io-github-autotest-libvirt.vIOMMU.iommu_device_settings.rtl8139.virtio: PASS (41.68 s)
......
 (16/16) type_specific.io-github-autotest-libvirt.vIOMMU.iommu_device_settings.pcie_root_port_from_expander_bus.intel: PASS (276.34 s)
Not opening readers, lock_server_running not locked
Not opening readers, lock_server_running not locked
RESULTS    : PASS 16 | ERROR 0 | FAIL 0 | SKIP 0 | WARN 0 | INTERRUPT 0 | CANCEL 0
JOB HTML   : /var/log/avocado/job-results/job-2024-10-10T22.41-758b691/results.html
JOB TIME   : 1900.18 s

# avocado run --vt-type libvirt --test-runner=runner --vt-machine-type q35 vIOMMU.attach_iommu_device..intel
JOB ID     : bb1c851cd27ddcfecb9357d64bf30ba07b033cb3
JOB LOG    : /var/log/avocado/job-results/job-2024-10-10T23.28-bb1c851/job.log
 (1/4) type_specific.io-github-autotest-libvirt.vIOMMU.attach_iommu_device.cold_plug.virtio: PASS (8.14 s)
 (2/4) type_specific.io-github-autotest-libvirt.vIOMMU.attach_iommu_device.cold_plug.intel: PASS (8.45 s)
 (3/4) type_specific.io-github-autotest-libvirt.vIOMMU.attach_iommu_device.hot_plug.virtio: PASS (28.88 s)
 (4/4) type_specific.io-github-autotest-libvirt.vIOMMU.attach_iommu_device.hot_plug.intel: PASS (37.56 s)
RESULTS    : PASS 4 | ERROR 0 | FAIL 0 | SKIP 0 | WARN 0 | INTERRUPT 0 | CANCEL 0
JOB HTML   : /var/log/avocado/job-results/job-2024-10-10T23.28-bb1c851/results.html
JOB TIME   : 84.85 s

@@ -33,6 +33,8 @@ def run(test, params, env):
vmxml.features = features
vmxml.sync()
err_msg = ''
if libvirt_version.version_compare(10, 7, 0) and iommu_dict['model'] == 'intel':
iommu_dict['driver']['dma_translation'] = 'on'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dma_translation is new feature, so maybe create separate case under intel variant of ./libvirt/tests/cfg/sriov/vIOMMU/attach_iommu_device.cfg , otherwise it is easy to ignore this feature if still under previous test case.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've considered whether we need to add a new case. But after the evaluation I gave up because:

  1. Keep the same attributes strategy as before in plan.
  2. This new attribute is not so important because before it was enabled default.
    Certainly it can also reduce our debug workloads.

Copy link
Contributor

@chunfuwen chunfuwen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@meinaLi
Copy link
Contributor Author

meinaLi commented Oct 23, 2024

@Yingshun Could you help review this PR? Thanks.

Copy link
Contributor

@Yingshun Yingshun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As discussed offline, it's better to add it to intel iommu cases or create a new one.

@meinaLi meinaLi force-pushed the viommu branch 2 times, most recently from 2c4386a to c718500 Compare October 31, 2024 06:09
@meinaLi meinaLi changed the title SRIOV: add new test scenarios for vIOMMU SRIOV: add new test case of dma_translation for vIOMMU Oct 31, 2024
@meinaLi
Copy link
Contributor Author

meinaLi commented Oct 31, 2024

# avocado run --vt-type libvirt --test-runner=runner --vt-machine-type q35 vIOMMU.intel_iommu_with_dma_translation
JOB ID     : d23c0f2bac019be9d0c4153cb80a230cb4250c40
JOB LOG    : /var/lib/avocado/job-results/job-2024-10-31T01.29-d23c0f2/job.log
 (1/3) type_specific.io-github-autotest-libvirt.vIOMMU.intel_iommu_with_dma_translation.enable_dma_translation: PASS (209.04 s)
 (2/3) type_specific.io-github-autotest-libvirt.vIOMMU.intel_iommu_with_dma_translation.disable_dma_translation: PASS (208.03 s)
 (3/3) type_specific.io-github-autotest-libvirt.vIOMMU.intel_iommu_with_dma_translation.disable_dma_translation_with_more_vcpus: PASS (841.30 s)
Not opening readers, lock_server_running not locked
Not opening readers, lock_server_running not locked
RESULTS    : PASS 3 | ERROR 0 | FAIL 0 | SKIP 0 | WARN 0 | INTERRUPT 0 | CANCEL 0
JOB HTML   : /var/lib/avocado/job-results/job-2024-10-31T01.29-d23c0f2/results.html
JOB TIME   : 1259.86 s

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)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's covered in viommu_base.VIOMMUTest(), plz remove it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed it now.

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'}}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's better to move this line to the end of this file and use the variant 'dma_translation' to show the iommu settings for each tests:
iommu_dict = {'model': 'intel', 'driver': {'intremap': 'on', 'caching_mode': 'on', 'iotlb': 'on', 'dma_translation': 'dma_translation'}}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it can also be at the end of this file.

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)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's only used for L27-29, I think it can be moved into the if statement.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved it now.

vmxml.vcpu = int(guest_vcpus)
vmxml.sync()
test.log.info("TEST STEP2: Start the guest.")
virsh.start(vm_name, debug=True)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's better to use vm.start which will raise exceptions if the startup fails.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed to use vm.start().

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)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we expect the timeout to be so long? 6000s is too long in my opinion, what do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because when we start guest with 256 vCPUs, it may take long time to login the guest. Based on this scenario, I extended the timeout.

Comment on lines 40 to 43
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.")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's better to log the outputs of above 2 shell commands - 'dmesg | xxx'

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated now.

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))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

type(o) to 'o'?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, just a mistake in my debugging. I forgot to restore it before.

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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants