-
Notifications
You must be signed in to change notification settings - Fork 186
automate VIRT-303225 - [vIOMMU] virsh reset when booting guest for 10+ times #6249
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| - vIOMMU.iommu_repeated_reset: | ||
| type = iommu_repeated_reset | ||
| ping_dest = '8.8.8.8' | ||
| max_wait_ms = 3000 | ||
| max_repeat = 10 | ||
| str_in_log = False | ||
| log_messages = "virtio: zero sized buffers are not allowed" | ||
| variants: | ||
| - virtio: | ||
| only q35, aarch64 | ||
| func_supported_since_libvirt_ver = (8, 3, 0) | ||
| iommu_dict = {'model': 'virtio'} | ||
| - intel: | ||
| only q35 | ||
| start_vm = "yes" | ||
| enable_guest_iommu = "yes" | ||
| iommu_dict = {'model': 'intel', 'driver': {'intremap': 'on', 'caching_mode': 'on', 'eim': 'on', 'iotlb': 'on', 'aw_bits': '48'}} | ||
| - smmuv3: | ||
| only aarch64 | ||
| func_supported_since_libvirt_ver = (5, 5, 0) | ||
| iommu_dict = {'model': 'smmuv3'} | ||
| variants: | ||
| - scsi_controller: | ||
| controller_dicts = [{'type': 'scsi', 'model': 'virtio-scsi','driver': {'iommu': 'on'}}] | ||
| disk_driver = {'name': 'qemu', 'type': 'qcow2'} | ||
| disk_dict = {'target': {'dev': 'sda', 'bus': 'scsi'}, 'driver': ${disk_driver}} | ||
| cleanup_ifaces = no | ||
| start_vm = "yes" |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,76 @@ | ||
| import os | ||
| from time import sleep | ||
| from random import uniform | ||
|
|
||
| from virttest import virsh | ||
| from virttest.libvirt_xml import vm_xml | ||
| from virttest.utils_libvirt import libvirt_vmxml | ||
| from virttest.utils_test import libvirt | ||
| from virttest import utils_logfile | ||
|
|
||
| from provider.viommu import viommu_base | ||
|
|
||
|
|
||
| def run(test, params, env): | ||
| """ | ||
| Start vm with iommu device and kinds of virtio devices with iommu=on, and | ||
| check network and disk function. | ||
| """ | ||
|
|
||
| def setup_test(): | ||
| utils_logfile.clear_log_file(log_file_name, '/var/log/libvirt/qemu') | ||
| test_obj.setup_iommu_test(iommu_dict=iommu_dict, cleanup_ifaces=False) | ||
| test_obj.prepare_controller() | ||
| test.log.debug("---------------------------------------------------------------------------") | ||
| dev_dict = eval(params.get('disk_dict', '{}')) | ||
| test.log.debug(f"disk_dict: {dev_dict}") | ||
| if dev_dict: | ||
| dev_dict = test_obj.update_disk_addr(dev_dict) | ||
| if dev_dict["target"].get("bus") != "virtio": | ||
| libvirt_vmxml.modify_vm_device( | ||
| vm_xml.VMXML.new_from_dumpxml(vm.name), 'disk', {'driver': None}) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I do not understand what we need to set driver to None when bus is not virtio?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The default guest's xml may contain viommu enabled virtio disk. If we modify it to non-virtio disk in the test, it may report an error because of the extra driver attrs. In order to cover test env with/without viommu virtio disk, we'd better to cleanup the driver setting before the test. |
||
|
|
||
| libvirt_vmxml.modify_vm_device( | ||
| vm_xml.VMXML.new_from_dumpxml(vm.name), 'disk', dev_dict) | ||
|
|
||
| iommu_dict = eval(params.get('iommu_dict', '{}')) | ||
|
|
||
| vm_name = params.get("main_vm", "avocado-vt-vm1") | ||
| log_file_name = f"{vm_name}.log" | ||
| log_file = os.path.join("/var/log/libvirt/qemu", log_file_name) | ||
| vm = env.get_vm(vm_name) | ||
|
|
||
| test_obj = viommu_base.VIOMMUTest(vm, test, params) | ||
|
|
||
| try: | ||
| setup_test() | ||
|
|
||
| test.log.info("TEST_STEP: Start the VM and wait for login.") | ||
| vm.start() | ||
| vm.wait_for_login().close() | ||
| test.log.info("TEST_STEP: Reboot the VM and wait for event 'reboot'") | ||
| virsh.reboot(vm_name, wait_for_event=True, debug=True, ignore_status=False) | ||
| test.log.debug("TEST_STEP: verify user is able to login also after restarts") | ||
| vm.wait_for_login().close() | ||
|
|
||
|
hholoubk marked this conversation as resolved.
|
||
| max_wait_ms = int(params.get('max_wait_ms', 0)) | ||
| max_repeat = int(params.get('max_repeat', 10)) | ||
|
|
||
| for _ in range(max_repeat): | ||
| if max_wait_ms > 0: | ||
| wait_time = uniform(0, max_wait_ms) / 1000 | ||
| test.log.debug(f"waiting before reset {wait_time}s") | ||
| sleep(wait_time) | ||
| virsh.reset(vm_name) | ||
|
|
||
| test.log.debug(vm_xml.VMXML.new_from_dumpxml(vm.name)) | ||
|
|
||
|
hholoubk marked this conversation as resolved.
|
||
| test.log.debug("TEST_STEP: verify user is able to login also after restarts") | ||
| vm.wait_for_login().close() | ||
| log_messages = params.get('log_messages', "") | ||
| str_in_log = (params.get('str_in_log', "False") == "True") | ||
| test.log.debug("TEST_STEP: check log for error messages") | ||
| libvirt.check_logfile(log_messages, log_file, str_in_log) | ||
|
|
||
| finally: | ||
| test_obj.teardown_iommu_test() | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We do not need to update the disk address, instead, we just remove the disk address, then set disk bus to scsi. That will be easier.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the only thing I don't know how to do ... Why is the disk address update worse?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
test_obj.update_disk_addr is a wrapper function to update the disk attrs according to the test cfg and the prepared controller. In this case, it's the easiest way.