From c1a6bff276ca52ffde472532d92bb5bb122dab3f Mon Sep 17 00:00:00 2001 From: Thomas Huth Date: Thu, 13 Mar 2025 07:35:22 +0100 Subject: [PATCH 1/8] hw/virtio: Also include md stubs in case CONFIG_VIRTIO_PCI is not set MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit For the s390x target, it's possible to build the QEMU binary without CONFIG_VIRTIO_PCI and only have the virtio-mem device via the ccw transport. In that case, QEMU currently fails to link correctly: /usr/bin/ld: libqemu-s390x-softmmu.a.p/hw_s390x_s390-virtio-ccw.c.o: in function `s390_machine_device_pre_plug': ../hw/s390x/s390-virtio-ccw.c:579:(.text+0x1e96): undefined reference to `virtio_md_pci_pre_plug' /usr/bin/ld: libqemu-s390x-softmmu.a.p/hw_s390x_s390-virtio-ccw.c.o: in function `s390_machine_device_plug': ../hw/s390x/s390-virtio-ccw.c:608:(.text+0x21a4): undefined reference to `virtio_md_pci_plug' /usr/bin/ld: libqemu-s390x-softmmu.a.p/hw_s390x_s390-virtio-ccw.c.o: in function `s390_machine_device_unplug_request': ../hw/s390x/s390-virtio-ccw.c:622:(.text+0x2334): undefined reference to `virtio_md_pci_unplug_request' /usr/bin/ld: libqemu-s390x-softmmu.a.p/hw_s390x_s390-virtio-ccw.c.o: in function `s390_machine_device_unplug': ../hw/s390x/s390-virtio-ccw.c:633:(.text+0x2436): undefined reference to `virtio_md_pci_unplug' clang: error: linker command failed with exit code 1 (use -v to see invocation) We also need to include the stubs when CONFIG_VIRTIO_PCI is missing. Fixes: aa910c20ec5 ("s390x: virtio-mem support") Message-ID: <20250313063522.1348288-1-thuth@redhat.com> Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Thomas Huth --- hw/virtio/meson.build | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/hw/virtio/meson.build b/hw/virtio/meson.build index 19b04c4d9c..164f6fd995 100644 --- a/hw/virtio/meson.build +++ b/hw/virtio/meson.build @@ -90,7 +90,8 @@ specific_virtio_ss.add_all(when: 'CONFIG_VIRTIO_PCI', if_true: virtio_pci_ss) system_ss.add_all(when: 'CONFIG_VIRTIO', if_true: system_virtio_ss) system_ss.add(when: 'CONFIG_VIRTIO', if_false: files('vhost-stub.c')) system_ss.add(when: 'CONFIG_VIRTIO', if_false: files('virtio-stub.c')) -system_ss.add(when: 'CONFIG_VIRTIO_MD', if_false: files('virtio-md-stubs.c')) +system_ss.add(when: ['CONFIG_VIRTIO_MD', 'CONFIG_VIRTIO_PCI'], + if_false: files('virtio-md-stubs.c')) system_ss.add(files('virtio-hmp-cmds.c')) From 6d19d095470221684afe065cffd40adebe644d04 Mon Sep 17 00:00:00 2001 From: Niek Linnenbank Date: Sun, 16 Mar 2025 22:02:31 +0100 Subject: [PATCH 2/8] tests/functional/test_arm_orangepi: rename test class to 'OrangePiMachine' MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The test class in this file contains all functional test cases for testing the Orange Pi PC board. It should be given a name matching the Qemu machine it covers. This commit sets the test class name to 'OrangePiMachine'. Signed-off-by: Niek Linnenbank Fixes: 380f7268b7b ("tests/functional: Convert the OrangePi tests to the functional framework") Message-ID: <20250316210232.46298-1-nieklinnenbank@gmail.com> Reviewed-by: Thomas Huth Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Thomas Huth --- tests/functional/test_arm_orangepi.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/functional/test_arm_orangepi.py b/tests/functional/test_arm_orangepi.py index 18ee50216b..28919391e5 100755 --- a/tests/functional/test_arm_orangepi.py +++ b/tests/functional/test_arm_orangepi.py @@ -14,7 +14,7 @@ from qemu_test import wait_for_console_pattern, skipBigDataTest from qemu_test.utils import image_pow2ceil_expand -class BananaPiMachine(LinuxKernelTest): +class OrangePiMachine(LinuxKernelTest): ASSET_DEB = Asset( ('https://apt.armbian.com/pool/main/l/linux-6.6.16/' From 23686dfb763d22d95c05c49382116d77133637b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= Date: Mon, 17 Mar 2025 12:43:00 +0000 Subject: [PATCH 3/8] tests/functional: remove all class level fields MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A number of fields are set at the class level on QemuBaseTest, even though the exact same named field is then set at the object level later in most cases. The 'self.logger' initialization in ACPI bits test needs to be removed since 'self.log' won't exist at that point in the flow. It already initialized 'self.logger' later in the setUp() method, so the __init__ method was redundant. Signed-off-by: Daniel P. Berrangé Message-ID: <20250317124300.84266-1-berrange@redhat.com> Reviewed-by: Thomas Huth Signed-off-by: Thomas Huth --- tests/functional/qemu_test/testcase.py | 6 ------ tests/functional/test_acpi_bits.py | 1 - 2 files changed, 7 deletions(-) diff --git a/tests/functional/qemu_test/testcase.py b/tests/functional/qemu_test/testcase.py index 50d232a7c6..50c401b8c3 100644 --- a/tests/functional/qemu_test/testcase.py +++ b/tests/functional/qemu_test/testcase.py @@ -33,12 +33,6 @@ from .uncompress import uncompress class QemuBaseTest(unittest.TestCase): - arch = None - - workdir = None - log = None - logdir = None - ''' @params compressed: filename, Asset, or file-like object to uncompress @params format: optional compression format (gzip, lzma) diff --git a/tests/functional/test_acpi_bits.py b/tests/functional/test_acpi_bits.py index 20da435687..8e0563a97b 100755 --- a/tests/functional/test_acpi_bits.py +++ b/tests/functional/test_acpi_bits.py @@ -119,7 +119,6 @@ class AcpiBitsTest(QemuSystemTest): #pylint: disable=too-many-instance-attribute self._debugcon_addr = '0x403' self._debugcon_log = 'debugcon-log.txt' - self.logger = self.log def _print_log(self, log): self.logger.info('\nlogs from biosbits follows:') From cef6da5bc9c63871814f544e0af2be22fa60aec3 Mon Sep 17 00:00:00 2001 From: Thomas Huth Date: Tue, 18 Mar 2025 06:54:15 +0100 Subject: [PATCH 4/8] docs/system: Use the meson binary from the pyvenv To avoid problems with the meson installation from the host system, we should always use the meson from our venv instead. Thus use this in the documentation, too. While we're at it, also mention that it has to be run from the build folder (in the igb.rst file; the other two files were already fine). Suggested-by: Niek Linnenbank Message-ID: <20250318055415.16501-1-thuth@redhat.com> Reviewed-by: Akihiko Odaki Reviewed-by: Niek Linnenbank Signed-off-by: Thomas Huth --- docs/system/arm/bananapi_m2u.rst | 2 +- docs/system/arm/orangepi.rst | 2 +- docs/system/devices/igb.rst | 5 +++-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/docs/system/arm/bananapi_m2u.rst b/docs/system/arm/bananapi_m2u.rst index d30db8d04c..6efa222c16 100644 --- a/docs/system/arm/bananapi_m2u.rst +++ b/docs/system/arm/bananapi_m2u.rst @@ -136,4 +136,4 @@ provide the following command: $ cd qemu-build-dir $ QEMU_TEST_ALLOW_LARGE_STORAGE=1 \ - meson test --suite thorough func-arm-arm_bpim2u + pyvenv/bin/meson test --suite thorough func-arm-arm_bpim2u diff --git a/docs/system/arm/orangepi.rst b/docs/system/arm/orangepi.rst index 8b9448ca7b..716062fca9 100644 --- a/docs/system/arm/orangepi.rst +++ b/docs/system/arm/orangepi.rst @@ -262,4 +262,4 @@ provide the following command from the build directory: .. code-block:: bash $ QEMU_TEST_ALLOW_LARGE_STORAGE=1 \ - meson test --suite thorough func-arm-arm_orangepi + pyvenv/bin/meson test --suite thorough func-arm-arm_orangepi diff --git a/docs/system/devices/igb.rst b/docs/system/devices/igb.rst index 9145af5c75..71f31cb116 100644 --- a/docs/system/devices/igb.rst +++ b/docs/system/devices/igb.rst @@ -57,11 +57,12 @@ directory: meson test qtest-x86_64/qos-test ethtool can test register accesses, interrupts, etc. It is automated as an -functional test and can be ran with the following command: +functional test and can be run from the build directory with the following +command: .. code:: shell - meson test --suite thorough func-x86_64-netdev_ethtool + pyvenv/bin/meson test --suite thorough func-x86_64-netdev_ethtool References ========== From a6836b6d49a76b71c43e9571f8bcc6a73b542a77 Mon Sep 17 00:00:00 2001 From: Thomas Huth Date: Tue, 18 Mar 2025 07:14:20 +0100 Subject: [PATCH 5/8] docs/system/arm: Use "functional tests" instead of "integration tests" MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We don't use the term "integration tests" for these kind of tests anymore, it's "functional tests" nowadays. Suggested-by: Niek Linnenbank Message-ID: <20250318061420.20378-1-thuth@redhat.com> Reviewed-by: Peter Maydell Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Niek Linnenbank Signed-off-by: Thomas Huth --- docs/system/arm/bananapi_m2u.rst | 6 +++--- docs/system/arm/orangepi.rst | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/docs/system/arm/bananapi_m2u.rst b/docs/system/arm/bananapi_m2u.rst index 6efa222c16..03cc5618c3 100644 --- a/docs/system/arm/bananapi_m2u.rst +++ b/docs/system/arm/bananapi_m2u.rst @@ -125,10 +125,10 @@ And then boot it. $ qemu-system-arm -M bpim2u -nographic -sd sd.img -Banana Pi M2U integration tests -""""""""""""""""""""""""""""""" +Banana Pi M2U functional tests +"""""""""""""""""""""""""""""" -The Banana Pi M2U machine has several integration tests included. +The Banana Pi M2U machine has several functional tests included. To run the whole set of tests, build QEMU from source and simply provide the following command: diff --git a/docs/system/arm/orangepi.rst b/docs/system/arm/orangepi.rst index 716062fca9..d81f6c3bfd 100644 --- a/docs/system/arm/orangepi.rst +++ b/docs/system/arm/orangepi.rst @@ -252,10 +252,10 @@ and set the following environment variables before booting: Optionally you may save the environment variables to SD card with 'saveenv'. To continue booting simply give the 'boot' command and NetBSD boots. -Orange Pi PC integration tests -"""""""""""""""""""""""""""""" +Orange Pi PC functional tests +""""""""""""""""""""""""""""" -The Orange Pi PC machine has several integration tests included. +The Orange Pi PC machine has several functional tests included. To run the whole set of tests, build QEMU from source and simply provide the following command from the build directory: From bcbd8c0edf712a7d55d9bf020be4b0f21ce3c35c Mon Sep 17 00:00:00 2001 From: Thomas Huth Date: Tue, 18 Mar 2025 10:20:21 +0100 Subject: [PATCH 6/8] docs/devel/testing/functional: Add a section about logging MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We should tell the users where to find the log file. While we're at it, also rename the "Overview" heading to a more accurate "Introduction to writing tests" instead. Reported-by: Aditya Gupta Message-ID: <20250318092021.53719-1-thuth@redhat.com> Reviewed-by: Daniel P. Berrangé Signed-off-by: Thomas Huth --- docs/devel/testing/functional.rst | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/docs/devel/testing/functional.rst b/docs/devel/testing/functional.rst index a9fa45eac1..9bc973392a 100644 --- a/docs/devel/testing/functional.rst +++ b/docs/devel/testing/functional.rst @@ -72,8 +72,26 @@ files around on disk by setting ```QEMU_TEST_KEEP_SCRATCH=1``` as an env variable. Any preserved files will be deleted the next time the test is run without this variable set. -Overview --------- +Logging +------- + +The framework collects log files for each test in the build directory +in the following subfolder:: + + /tests/functional//../ + +There are usually three log files: + +* ``base.log`` contains the generic logging information that is written + by the calls to the logging functions in the test code (e.g. by calling + the ``self.log.info()`` or ``self.log.debug()`` functions). +* ``console.log`` contains the output of the serial console of the guest. +* ``default.log`` contains the output of QEMU. This file could be named + differently if the test chooses to use a different identifier for + the guest VM (e.g. when the test spins up multiple VMs). + +Introduction to writing tests +----------------------------- The ``tests/functional/qemu_test`` directory provides the ``qemu_test`` Python module, containing the ``qemu_test.QemuSystemTest`` class. From 1ddd4d3f6ed39ffd1e0cc03ada36b0766d5be9fb Mon Sep 17 00:00:00 2001 From: Thomas Huth Date: Tue, 18 Mar 2025 18:15:30 +0100 Subject: [PATCH 7/8] tests/functional/test_x86_64_kvm_xen: Remove avocado tags MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit They have been forgotten to be removed when converting the test to the functional framework. Since they are of no use anymore, let's remove them now. Message-ID: <20250318171530.94966-1-thuth@redhat.com> Reviewed-by: Daniel P. Berrangé Signed-off-by: Thomas Huth --- tests/functional/test_x86_64_kvm_xen.py | 28 ------------------------- 1 file changed, 28 deletions(-) diff --git a/tests/functional/test_x86_64_kvm_xen.py b/tests/functional/test_x86_64_kvm_xen.py index 0298c96c2e..3bedef6c98 100755 --- a/tests/functional/test_x86_64_kvm_xen.py +++ b/tests/functional/test_x86_64_kvm_xen.py @@ -80,10 +80,6 @@ class KVMXenGuest(QemuSystemTest): wait_for_console_pattern(self, '#', 'Oops') def test_kvm_xen_guest(self): - """ - :avocado: tags=kvm_xen_guest - """ - self.common_vm_setup() self.kernel_params = (self.KERNEL_DEFAULT + @@ -94,10 +90,6 @@ class KVMXenGuest(QemuSystemTest): 'virtio0-output') def test_kvm_xen_guest_nomsi(self): - """ - :avocado: tags=kvm_xen_guest_nomsi - """ - self.common_vm_setup() self.kernel_params = (self.KERNEL_DEFAULT + @@ -108,10 +100,6 @@ class KVMXenGuest(QemuSystemTest): 'virtio0') def test_kvm_xen_guest_noapic_nomsi(self): - """ - :avocado: tags=kvm_xen_guest_noapic_nomsi - """ - self.common_vm_setup() self.kernel_params = (self.KERNEL_DEFAULT + @@ -122,10 +110,6 @@ class KVMXenGuest(QemuSystemTest): 'virtio0') def test_kvm_xen_guest_vapic(self): - """ - :avocado: tags=kvm_xen_guest_vapic - """ - self.common_vm_setup() self.vm.add_args('-cpu', 'host,+xen-vapic') self.kernel_params = (self.KERNEL_DEFAULT + @@ -140,10 +124,6 @@ class KVMXenGuest(QemuSystemTest): 'virtio0-output') def test_kvm_xen_guest_novector(self): - """ - :avocado: tags=kvm_xen_guest_novector - """ - self.common_vm_setup() self.kernel_params = (self.KERNEL_DEFAULT + ' xen_emul_unplug=ide-disks' + @@ -154,10 +134,6 @@ class KVMXenGuest(QemuSystemTest): 'fasteoi') def test_kvm_xen_guest_novector_nomsi(self): - """ - :avocado: tags=kvm_xen_guest_novector_nomsi - """ - self.common_vm_setup() self.kernel_params = (self.KERNEL_DEFAULT + @@ -169,10 +145,6 @@ class KVMXenGuest(QemuSystemTest): 'IO-APIC') def test_kvm_xen_guest_novector_noapic(self): - """ - :avocado: tags=kvm_xen_guest_novector_noapic - """ - self.common_vm_setup() self.kernel_params = (self.KERNEL_DEFAULT + ' xen_emul_unplug=ide-disks' + From f700abbbeb6ab68a3446d1fb168a934d6f284eb5 Mon Sep 17 00:00:00 2001 From: Thomas Huth Date: Wed, 19 Mar 2025 11:45:45 +0100 Subject: [PATCH 8/8] tests/functional/test_migration: Use "ncat" instead of "nc" in the exec test MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit "nc" can either be GNU netcat, OpenBSD netcat or NMap ncat. At least GNU netcat currently does not work with this test anymore, though the comment in the test says otherwise. GNU netcat seems to be quite unmaintained nowadays, according to its website (https://netcat.sourceforge.net/), the last public release is from 2004, so we should rather avoid that binary. In our CI, we are only using "ncat" in the containers (it's the only flavor that lcitool supports), thus to avoid silent regressions with the other netcats, let's limit this test to "ncat" only now. Reported-by: Matheus Tavares Bernardino Message-ID: <20250319105617.133191-1-thuth@redhat.com> Reviewed-by: Matheus Tavares Bernardino Reviewed-by: Philippe Mathieu-Daudé Acked-by: Fabiano Rosas Signed-off-by: Thomas Huth --- tests/functional/test_migration.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/tests/functional/test_migration.py b/tests/functional/test_migration.py index 44804113cf..181223a69e 100755 --- a/tests/functional/test_migration.py +++ b/tests/functional/test_migration.py @@ -87,13 +87,12 @@ class MigrationTest(QemuSystemTest): dest_uri = 'unix:%s/qemu-test.sock' % socket_path self.do_migrate(dest_uri) - @skipIfMissingCommands('nc') + @skipIfMissingCommands('ncat') def test_migration_with_exec(self): - """The test works for both netcat-traditional and netcat-openbsd packages.""" with Ports() as ports: free_port = self._get_free_port(ports) - dest_uri = 'exec:nc -l localhost %u' % free_port - src_uri = 'exec:nc localhost %u' % free_port + dest_uri = 'exec:ncat -l localhost %u' % free_port + src_uri = 'exec:ncat localhost %u' % free_port self.do_migrate(dest_uri, src_uri) if __name__ == '__main__':