From patchwork Tue Dec 17 12:15:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Huth X-Patchwork-Id: 13911694 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 4A7ACE77184 for ; Tue, 17 Dec 2024 12:17:15 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tNWVA-0000wM-Il; Tue, 17 Dec 2024 07:16:36 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tNWV4-0000vP-4l for qemu-devel@nongnu.org; Tue, 17 Dec 2024 07:16:30 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tNWUy-0007wB-G7 for qemu-devel@nongnu.org; Tue, 17 Dec 2024 07:16:29 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1734437780; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=vGPFuF0s7/iQk3ev3K9OkipcorVBDhCojDwHRiwy9pM=; b=b2/5a0mRQEndKhzZXugDJ7mKGUM0v38StdtEMxKw+esF6dof4F3CKjH7n4KEHUzpeAV8dz 85RxHKQerGczf7gFAYzLqRw/dKQP3dVhGzwRKP17BOJzCDF5fFYewtvjBomZ1HF3k3FbA6 PhhqXXt0yekpdKDj2mDe1vylrE7GDxA= Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-203-bNWI4xwpM52vt-qLLCWPKQ-1; Tue, 17 Dec 2024 07:16:16 -0500 X-MC-Unique: bNWI4xwpM52vt-qLLCWPKQ-1 X-Mimecast-MFC-AGG-ID: bNWI4xwpM52vt-qLLCWPKQ Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 6E2A31955F2D; Tue, 17 Dec 2024 12:16:15 +0000 (UTC) Received: from thuth-p1g4.redhat.com (unknown [10.39.194.49]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id DB1E71955F54; Tue, 17 Dec 2024 12:16:10 +0000 (UTC) From: Thomas Huth To: qemu-devel@nongnu.org, "Michael S. Tsirkin" Cc: =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , =?utf-8?q?P?= =?utf-8?q?hilippe_Mathieu-Daud=C3=A9?= , =?utf-8?q?C?= =?utf-8?q?=C3=A9dric_Le_Goater?= , Eric Auger , =?utf-8?q?Cl=C3=A9ment_Mathieu--Drif?= , Yi Liu , Jason Wang , Thomas Huth Subject: [PATCH v3 1/2] tests/functional: Add a helper function for retrieving the hostfwd port Date: Tue, 17 Dec 2024 13:15:49 +0100 Message-ID: <20241217121550.141072-2-thuth@redhat.com> In-Reply-To: <20241217121550.141072-1-thuth@redhat.com> References: <20241217121550.141072-1-thuth@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 Received-SPF: pass client-ip=170.10.129.124; envelope-from=thuth@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-1.116, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org It's just a wrapper around get_info_usernet_hostfwd_port from the qemu module that is also calling the right monitor command for retrieving the information from QEMU. Signed-off-by: Thomas Huth --- tests/functional/qemu_test/utils.py | 7 +++++++ tests/functional/test_info_usernet.py | 8 +++----- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/tests/functional/qemu_test/utils.py b/tests/functional/qemu_test/utils.py index 43853b4366..e7c8de8165 100644 --- a/tests/functional/qemu_test/utils.py +++ b/tests/functional/qemu_test/utils.py @@ -10,6 +10,13 @@ import os +from qemu.utils import get_info_usernet_hostfwd_port + + +def get_usernet_hostfwd_port(vm): + res = vm.cmd('human-monitor-command', command_line='info usernet') + return get_info_usernet_hostfwd_port(res) + """ Round up to next power of 2 """ diff --git a/tests/functional/test_info_usernet.py b/tests/functional/test_info_usernet.py index cd37524d94..e8cbc37eed 100755 --- a/tests/functional/test_info_usernet.py +++ b/tests/functional/test_info_usernet.py @@ -11,8 +11,7 @@ # later. See the COPYING file in the top-level directory. from qemu_test import QemuSystemTest - -from qemu.utils import get_info_usernet_hostfwd_port +from qemu_test.utils import get_usernet_hostfwd_port class InfoUsernet(QemuSystemTest): @@ -22,9 +21,8 @@ def test_hostfwd(self): self.set_machine('none') self.vm.add_args('-netdev', 'user,id=vnet,hostfwd=:127.0.0.1:0-:22') self.vm.launch() - res = self.vm.cmd('human-monitor-command', - command_line='info usernet') - port = get_info_usernet_hostfwd_port(res) + + port = get_usernet_hostfwd_port(self.vm) self.assertIsNotNone(port, ('"info usernet" output content does not seem to ' 'contain the redirected port')) From patchwork Tue Dec 17 12:15:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Huth X-Patchwork-Id: 13911695 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 25603E7717F for ; Tue, 17 Dec 2024 12:17:28 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tNWVb-00012G-Nn; Tue, 17 Dec 2024 07:17:03 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tNWVI-0000zp-LJ for qemu-devel@nongnu.org; Tue, 17 Dec 2024 07:16:46 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tNWVD-0007yX-2N for qemu-devel@nongnu.org; Tue, 17 Dec 2024 07:16:44 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1734437794; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Ml/3c4PFNwDpohMXetaxAQF8giJqtmv2vbcP98mwUnE=; b=YmzTymoWF8u1MOFaiaIEyGsSCjqPnMWsil+3FPByVJmKLuVX6KanrZoVyUMon10ljGuqmL D4faREi+n9cy7eklbKtC3qBV05GVmNoad1BZCedVidjn4Dq8b+QJa8tIWxag2uRrsHawKE jDiYgJb6Qh0BPq6Wg+K6PY+qG18gdh4= Received: from mx-prod-mc-02.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-164-L9m_Aw5oPSyCGWOcYuY9vA-1; Tue, 17 Dec 2024 07:16:27 -0500 X-MC-Unique: L9m_Aw5oPSyCGWOcYuY9vA-1 X-Mimecast-MFC-AGG-ID: L9m_Aw5oPSyCGWOcYuY9vA Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id E96D91956058; Tue, 17 Dec 2024 12:16:20 +0000 (UTC) Received: from thuth-p1g4.redhat.com (unknown [10.39.194.49]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 2A74B1955F41; Tue, 17 Dec 2024 12:16:15 +0000 (UTC) From: Thomas Huth To: qemu-devel@nongnu.org, "Michael S. Tsirkin" Cc: =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , =?utf-8?q?P?= =?utf-8?q?hilippe_Mathieu-Daud=C3=A9?= , =?utf-8?q?C?= =?utf-8?q?=C3=A9dric_Le_Goater?= , Eric Auger , =?utf-8?q?Cl=C3=A9ment_Mathieu--Drif?= , Yi Liu , Jason Wang , Thomas Huth Subject: [PATCH v3 2/2] tests/functional: Convert the intel_iommu avocado test Date: Tue, 17 Dec 2024 13:15:50 +0100 Message-ID: <20241217121550.141072-3-thuth@redhat.com> In-Reply-To: <20241217121550.141072-1-thuth@redhat.com> References: <20241217121550.141072-1-thuth@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 Received-SPF: pass client-ip=170.10.133.124; envelope-from=thuth@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-1.116, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, T_SPF_TEMPERROR=0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Convert the intel_iommu test to the new functional framework. This test needs some changes since we neither support the old 'LinuxTest' class in the functional framework yet, nor a way to use SSH for running commands in the guest. So we now directly download a Fedora kernel and initrd and set up the serial console for executing the commands and for looking for the results. Instead of configuring the cloud image via cloud-init, we now simply mount the file system manually from an initrd rescue shell. While the old test was exercising the network with a "dnf install" command (which is not the best option for the CI since this depends on third party servers), the new code is now setting up a little HTTP server in the guest and transfers a file from the guest to the host instead. The test should now run much faster and more reliable (since we don't depend on the third party servers for "dnf install" anymore), so we can also drop the @skipUnless decorator now. Signed-off-by: Thomas Huth --- MAINTAINERS | 1 + tests/functional/meson.build | 2 + .../test_intel_iommu.py} | 191 +++++++++++------- 3 files changed, 125 insertions(+), 69 deletions(-) rename tests/{avocado/intel_iommu.py => functional/test_intel_iommu.py} (26%) mode change 100644 => 100755 diff --git a/MAINTAINERS b/MAINTAINERS index a800b766d3..79df59d05c 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -3682,6 +3682,7 @@ S: Supported F: hw/i386/intel_iommu.c F: hw/i386/intel_iommu_internal.h F: include/hw/i386/intel_iommu.h +F: tests/functional/test_intel_iommu.py AMD-Vi Emulation S: Orphan diff --git a/tests/functional/meson.build b/tests/functional/meson.build index fb13d67e7f..054c5f85fb 100644 --- a/tests/functional/meson.build +++ b/tests/functional/meson.build @@ -31,6 +31,7 @@ test_timeouts = { 'arm_raspi2' : 120, 'arm_tuxrun' : 240, 'arm_sx1' : 360, + 'intel_iommu': 300, 'mips_malta' : 120, 'netdev_ethtool' : 180, 'ppc_40p' : 240, @@ -248,6 +249,7 @@ tests_x86_64_system_quick = [ tests_x86_64_system_thorough = [ 'acpi_bits', + 'intel_iommu', 'linux_initrd', 'multiprocess', 'netdev_ethtool', diff --git a/tests/avocado/intel_iommu.py b/tests/functional/test_intel_iommu.py old mode 100644 new mode 100755 similarity index 26% rename from tests/avocado/intel_iommu.py rename to tests/functional/test_intel_iommu.py index 992583fa7d..a9e8f82ab5 --- a/tests/avocado/intel_iommu.py +++ b/tests/functional/test_intel_iommu.py @@ -1,3 +1,5 @@ +#!/usr/bin/env python3 +# # INTEL_IOMMU Functional tests # # Copyright (c) 2021 Red Hat, Inc. @@ -7,116 +9,167 @@ # # This work is licensed under the terms of the GNU GPL, version 2 or # later. See the COPYING file in the top-level directory. -import os - -from avocado import skipUnless -from avocado_qemu.linuxtest import LinuxTest - -@skipUnless(os.getenv('QEMU_TEST_FLAKY_TESTS'), 'Test is unstable on GitLab') -class IntelIOMMU(LinuxTest): - """ - :avocado: tags=arch:x86_64 - :avocado: tags=distro:fedora - :avocado: tags=distro_version:31 - :avocado: tags=machine:q35 - :avocado: tags=accel:kvm - :avocado: tags=intel_iommu - :avocado: tags=flaky - """ +import hashlib +import urllib.request + +from qemu_test import LinuxKernelTest, Asset, exec_command_and_wait_for_pattern +from qemu_test.utils import get_usernet_hostfwd_port + + +class IntelIOMMU(LinuxKernelTest): + + ASSET_KERNEL = Asset( + ('https://archives.fedoraproject.org/pub/archive/fedora/linux/releases' + '/31/Server/x86_64/os/images/pxeboot/vmlinuz'), + 'd4738d03dbbe083ca610d0821d0a8f1488bebbdccef54ce33e3adb35fda00129') + + ASSET_INITRD = Asset( + ('https://archives.fedoraproject.org/pub/archive/fedora/linux/releases' + '/31/Server/x86_64/os/images/pxeboot/initrd.img'), + '277cd6c7adf77c7e63d73bbb2cded8ef9e2d3a2f100000e92ff1f8396513cd8b') + + ASSET_DISKIMAGE = Asset( + ('https://archives.fedoraproject.org/pub/archive/fedora/linux/releases' + '/31/Cloud/x86_64/images/Fedora-Cloud-Base-31-1.9.x86_64.qcow2'), + 'e3c1b309d9203604922d6e255c2c5d098a309c2d46215d8fc026954f3c5c27a0') + + DEFAULT_KERNEL_PARAMS = ('root=/dev/vda1 console=ttyS0 net.ifnames=0 ' + 'quiet rd.rescue ') + GUEST_PORT = 8080 IOMMU_ADDON = ',iommu_platform=on,disable-modern=off,disable-legacy=on' kernel_path = None initrd_path = None kernel_params = None - def set_up_boot(self): - path = self.download_boot() + def add_common_args(self, path): + self.vm.add_args('-drive', f'file={path},if=none,id=drv0,snapshot=on') self.vm.add_args('-device', 'virtio-blk-pci,bus=pcie.0,' + 'drive=drv0,id=virtio-disk0,bootindex=1,' 'werror=stop,rerror=stop' + self.IOMMU_ADDON) self.vm.add_args('-device', 'virtio-gpu-pci' + self.IOMMU_ADDON) - self.vm.add_args('-drive', - 'file=%s,if=none,cache=writethrough,id=drv0' % path) - def setUp(self): - super(IntelIOMMU, self).setUp(None, 'virtio-net-pci' + self.IOMMU_ADDON) + self.vm.add_args('-netdev', + 'user,id=n1,hostfwd=tcp:127.0.0.1:0-:%d' % + self.GUEST_PORT) + self.vm.add_args('-device', + 'virtio-net-pci,netdev=n1' + self.IOMMU_ADDON) - def add_common_args(self): self.vm.add_args('-device', 'virtio-rng-pci,rng=rng0') self.vm.add_args('-object', 'rng-random,id=rng0,filename=/dev/urandom') - - def common_vm_setup(self, custom_kernel=None): - self.require_accelerator("kvm") - self.add_common_args() + self.vm.add_args("-m", "1G") self.vm.add_args("-accel", "kvm") - if custom_kernel is None: - return + def common_vm_setup(self): + self.set_machine('q35') + self.require_accelerator("kvm") + self.require_netdev('user') - kernel_url = self.distro.pxeboot_url + 'vmlinuz' - kernel_hash = '5b6f6876e1b5bda314f93893271da0d5777b1f3c' - initrd_url = self.distro.pxeboot_url + 'initrd.img' - initrd_hash = 'dd0340a1b39bd28f88532babd4581c67649ec5b1' - self.kernel_path = self.fetch_asset(kernel_url, asset_hash=kernel_hash) - self.initrd_path = self.fetch_asset(initrd_url, asset_hash=initrd_hash) + self.kernel_path = self.ASSET_KERNEL.fetch() + self.initrd_path = self.ASSET_INITRD.fetch() + image_path = self.ASSET_DISKIMAGE.fetch() + self.add_common_args(image_path) + self.kernel_params = self.DEFAULT_KERNEL_PARAMS def run_and_check(self): if self.kernel_path: self.vm.add_args('-kernel', self.kernel_path, '-append', self.kernel_params, '-initrd', self.initrd_path) - self.launch_and_wait() - self.ssh_command('cat /proc/cmdline') - self.ssh_command('dmesg | grep -e DMAR -e IOMMU') - self.ssh_command('find /sys/kernel/iommu_groups/ -type l') - self.ssh_command('dnf -y install numactl-devel') + self.vm.set_console() + self.vm.launch() + self.wait_for_console_pattern('Entering emergency mode.') + prompt = '# ' + self.wait_for_console_pattern(prompt) + + # Copy a file (checked later), umount afterwards to drop disk cache: + exec_command_and_wait_for_pattern(self, 'mount /dev/vda1 /sysroot', + prompt) + filename = '/boot/initramfs-5.3.7-301.fc31.x86_64.img' + exec_command_and_wait_for_pattern(self, (f'cp /sysroot{filename}' + ' /sysroot/root/data'), + prompt) + exec_command_and_wait_for_pattern(self, 'umount /sysroot', prompt) + + # Switch from initrd to the cloud image filesystem: + exec_command_and_wait_for_pattern(self, 'mount /dev/vda1 /sysroot', + prompt) + exec_command_and_wait_for_pattern(self, + ('for d in dev proc sys run ; do ' + 'mount -o bind /$d /sysroot/$d ; done'), prompt) + exec_command_and_wait_for_pattern(self, 'chroot /sysroot', prompt) + + # Checking for IOMMU enablement: + self.log.info("Checking whether IOMMU has been enabled...") + exec_command_and_wait_for_pattern(self, 'cat /proc/cmdline', + 'intel_iommu=on') + self.wait_for_console_pattern(prompt) + exec_command_and_wait_for_pattern(self, 'dmesg | grep DMAR:', + 'IOMMU enabled') + self.wait_for_console_pattern(prompt) + exec_command_and_wait_for_pattern(self, + 'find /sys/kernel/iommu_groups/ -type l', + 'devices/0000:00:') + self.wait_for_console_pattern(prompt) + + # Check hard disk device via sha256sum: + self.log.info("Checking hard disk...") + hashsum = '0dc7472f879be70b2f3daae279e3ae47175ffe249691e7d97f47222b65b8a720' + exec_command_and_wait_for_pattern(self, 'sha256sum ' + filename, + hashsum) + self.wait_for_console_pattern(prompt) + exec_command_and_wait_for_pattern(self, 'sha256sum /root/data', + hashsum) + self.wait_for_console_pattern(prompt) + + # Check virtio-net via HTTP: + exec_command_and_wait_for_pattern(self, 'dhclient eth0', prompt) + exec_command_and_wait_for_pattern(self, + f'python3 -m http.server {self.GUEST_PORT} & sleep 1', + f'Serving HTTP on 0.0.0.0 port {self.GUEST_PORT}') + hl = hashlib.sha256() + hostport = get_usernet_hostfwd_port(self.vm) + url = f'http://localhost:{hostport}{filename}' + self.log.info(f'Downloading {url} ...') + with urllib.request.urlopen(url) as response: + while True: + chunk = response.read(1 << 20) + if not chunk: + break + hl.update(chunk) + + digest = hl.hexdigest() + self.log.info(f'sha256sum of download is {digest}.') + self.assertEqual(digest, hashsum) def test_intel_iommu(self): - """ - :avocado: tags=intel_iommu_intremap - """ - - self.common_vm_setup(True) + self.common_vm_setup() self.vm.add_args('-device', 'intel-iommu,intremap=on') self.vm.add_args('-machine', 'kernel_irqchip=split') - - self.kernel_params = (self.distro.default_kernel_params + - ' quiet intel_iommu=on') + self.kernel_params += 'intel_iommu=on' self.run_and_check() def test_intel_iommu_strict(self): - """ - :avocado: tags=intel_iommu_strict - """ - - self.common_vm_setup(True) + self.common_vm_setup() self.vm.add_args('-device', 'intel-iommu,intremap=on') self.vm.add_args('-machine', 'kernel_irqchip=split') - self.kernel_params = (self.distro.default_kernel_params + - ' quiet intel_iommu=on,strict') + self.kernel_params += 'intel_iommu=on,strict' self.run_and_check() def test_intel_iommu_strict_cm(self): - """ - :avocado: tags=intel_iommu_strict_cm - """ - - self.common_vm_setup(True) + self.common_vm_setup() self.vm.add_args('-device', 'intel-iommu,intremap=on,caching-mode=on') self.vm.add_args('-machine', 'kernel_irqchip=split') - self.kernel_params = (self.distro.default_kernel_params + - ' quiet intel_iommu=on,strict') + self.kernel_params += 'intel_iommu=on,strict' self.run_and_check() def test_intel_iommu_pt(self): - """ - :avocado: tags=intel_iommu_pt - """ - - self.common_vm_setup(True) + self.common_vm_setup() self.vm.add_args('-device', 'intel-iommu,intremap=on') self.vm.add_args('-machine', 'kernel_irqchip=split') - self.kernel_params = (self.distro.default_kernel_params + - ' quiet intel_iommu=on iommu=pt') + self.kernel_params += 'intel_iommu=on iommu=pt' self.run_and_check() + +if __name__ == '__main__': + LinuxKernelTest.main()