-
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.
This PR adds: VIRT-294807 - [vIOMMU] Lifecycle test for vm with iommu device Signed-off-by: Yingshun Cui <[email protected]>
- Loading branch information
Showing
3 changed files
with
141 additions
and
8 deletions.
There are no files selected for viewing
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,41 @@ | ||
- vIOMMU.iommu_device_lifecycle: | ||
type = iommu_device_lifecycle | ||
start_vm = "no" | ||
disk_driver = {'name': 'qemu', 'type': 'qcow2', 'iommu': 'on'} | ||
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: | ||
- e1000e: | ||
no smmuv3 | ||
iface_model = 'e1000e' | ||
iface_dict = {'type_name': 'network', 'model': '${iface_model}', 'source': {'network': 'default'}} | ||
- virtio_muti_devices: | ||
disk_dict = {'target': {'dev': 'vda', 'bus': 'virtio'}, 'device': 'disk', 'driver': ${disk_driver}} | ||
video_dict = {'primary': 'yes', 'model_heads': '1', 'model_type': 'virtio', 'driver': {'iommu': 'on'}} | ||
test_devices = ["Eth", "block", "gpu"] | ||
variants: | ||
- vhost_on: | ||
interface_driver_name = "vhost" | ||
interface_driver = {'driver_attr': {'name': '${interface_driver_name}', 'iommu': 'on'}} | ||
iface_dict = {'type_name': 'network', 'model': 'virtio', 'driver': ${interface_driver}, 'source': {'network': 'default'}} | ||
- hostdev_iface: | ||
only virtio | ||
no save_restore | ||
iface_dict = {'managed': 'yes', 'type_name': 'hostdev', 'hostdev_address': {'type_name': 'pci', 'attrs': vf_pci_addr}} | ||
variants test_scenario: | ||
- save_restore: | ||
- suspend_resume: | ||
- reboot_many_times: | ||
loop_time = 5 |
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,82 @@ | ||
import os | ||
|
||
from virttest import libvirt_version | ||
from virttest import utils_misc | ||
from virttest import virsh | ||
|
||
from virttest.libvirt_xml import vm_xml | ||
from virttest.utils_libvirt import libvirt_vmxml | ||
|
||
from provider.save import save_base | ||
from provider.sriov import sriov_base | ||
from provider.sriov import check_points | ||
|
||
VIRSH_ARGS = {'debug': True, 'ignore_status': False} | ||
|
||
|
||
def run(test, params, env): | ||
""" | ||
Test lifecycle for vm with vIOMMU enabled with different devices. | ||
""" | ||
libvirt_version.is_libvirt_feature_supported(params) | ||
cleanup_ifaces = "yes" == params.get("cleanup_ifaces", "yes") | ||
ping_dest = params.get('ping_dest', "127.0.0.1") | ||
iommu_dict = eval(params.get('iommu_dict', '{}')) | ||
test_scenario = params.get("test_scenario") | ||
|
||
vm_name = params.get("main_vm", "avocado-vt-vm1") | ||
vm = env.get_vm(vm_name) | ||
|
||
rand_id = utils_misc.generate_random_string(3) | ||
save_path = f'/var/tmp/{vm_name}_{rand_id}.save' | ||
test_obj = sriov_base.SRIOVTest(vm, test, params) | ||
try: | ||
test.log.info("TEST_SETUP: Update VM XML.") | ||
test_obj.setup_iommu_test(iommu_dict=iommu_dict, | ||
cleanup_ifaces=cleanup_ifaces) | ||
test_obj.prepare_controller() | ||
for dev in ["disk", "video"]: | ||
dev_dict = eval(params.get('%s_dict' % dev, '{}')) | ||
if dev == "disk": | ||
dev_dict = test_obj.update_disk_addr(dev_dict) | ||
libvirt_vmxml.modify_vm_device( | ||
vm_xml.VMXML.new_from_dumpxml(vm.name), dev, dev_dict) | ||
iface_dict = test_obj.parse_iface_dict() | ||
if cleanup_ifaces: | ||
libvirt_vmxml.modify_vm_device( | ||
vm_xml.VMXML.new_from_dumpxml(vm.name), | ||
"interface", iface_dict) | ||
|
||
test.log.info("TEST_STEP: Start the VM.") | ||
vm.start() | ||
test.log.debug(vm_xml.VMXML.new_from_dumpxml(vm.name)) | ||
if test_scenario == "reboot_many_times": | ||
vm.cleanup_serial_console() | ||
vm.create_serial_console() | ||
for _ in range(int(params.get('loop_time', '5'))): | ||
test.log.info("TEST_STEP: Reboot the VM.") | ||
session = vm.wait_for_serial_login( | ||
timeout=int(params.get('login_timeout'))) | ||
session.sendline(params.get("reboot_command")) | ||
_match, _text = session.read_until_last_line_matches( | ||
[r"[Ll]ogin:\s*$"], timeout=240, internal_timeout=0.5) | ||
session.close() | ||
|
||
session = vm.wait_for_serial_login( | ||
timeout=int(params.get('login_timeout'))) | ||
check_points.check_vm_network_accessed(session, ping_dest=ping_dest) | ||
else: | ||
pid_ping, upsince = save_base.pre_save_setup(vm, serial=True) | ||
if test_scenario == "save_restore": | ||
test.log.info("TEST_STEP: Save and restore the VM.") | ||
virsh.save(vm.name, save_path, **VIRSH_ARGS) | ||
virsh.restore(save_path, **VIRSH_ARGS) | ||
elif test_scenario == "suspend_resume": | ||
test.log.info("TEST_STEP: Suspend and resume the VM.") | ||
virsh.suspend(vm.name, **VIRSH_ARGS) | ||
virsh.resume(vm.name, **VIRSH_ARGS) | ||
save_base.post_save_check(vm, pid_ping, upsince, serial=True) | ||
finally: | ||
test_obj.teardown_iommu_test() | ||
if os.path.exists(save_path): | ||
os.remove(save_path) |
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