[PULL 11/12] tests: increase timeout per instance of bios-tables-test
From: Igor Mammedov CI often fails 'cross-i686-tci' job due to runner slowness Log shows that test almost complete, with a few remaining when bios-tables-test timeout hits: 19/270 qemu:qtest+qtest-aarch64 / qtest-aarch64/bios-tables-test TIMEOUT610.02s killed by signal 15 SIGTERM ... stderr: TAP parsing error: Too few tests run (expected 8, got 7) At the same time overall job running time is only ~30 out of 1hr allowed. Increase bios-tables-test instance timeout on 5min as a fix for slow CI runners. Signed-off-by: Igor Mammedov Message-ID: <20240716125930.620861-1-imamm...@redhat.com> Acked-by: Michael S. Tsirkin Signed-off-by: Thomas Huth --- tests/qtest/meson.build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/qtest/meson.build b/tests/qtest/meson.build index 6508bfb1a2..ff9200f882 100644 --- a/tests/qtest/meson.build +++ b/tests/qtest/meson.build @@ -1,6 +1,6 @@ slow_qtests = { 'aspeed_smc-test': 360, - 'bios-tables-test' : 610, + 'bios-tables-test' : 910, 'cdrom-test' : 610, 'device-introspect-test' : 720, 'migration-test' : 480, -- 2.45.2
[PULL 09/12] hw: Fix crash that happens when introspecting scsi-block on older machine types
"make check SPEED=slow" is currently failing the device-introspect-test on older machine types since introspecting "scsi-block" is causing an abort: $ ./qemu-system-x86_64 -M pc-q35-8.0 -monitor stdio QEMU 9.0.50 monitor - type 'help' for more information (qemu) device_add scsi-block,help Unexpected error in object_property_find_err() at ../../devel/qemu/qom/object.c:1357: can't apply global scsi-disk-base.migrate-emulated-scsi-request=false: Property 'scsi-block.migrate-emulated-scsi-request' not found Aborted (core dumped) The problem is that the compat code tries to change the "migrate-emulated-scsi-request" property for all devices that are derived from "scsi-block", but the property has only been added to "scsi-hd" and "scsi-cd" via the DEFINE_SCSI_DISK_PROPERTIES macro. Thus let's fix the problem by only changing the property on the devices that really have this property. Fixes: b4912afa5f ("scsi-disk: Fix crash for VM configured with USB CDROM after live migration") Message-ID: <20240703090904.909720-1-th...@redhat.com> Acked-by: Hyman Huang Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Thomas Huth --- hw/core/machine.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/hw/core/machine.c b/hw/core/machine.c index bc38cad7f2..8a878f84d7 100644 --- a/hw/core/machine.c +++ b/hw/core/machine.c @@ -36,7 +36,8 @@ GlobalProperty hw_compat_9_0[] = { {"arm-cpu", "backcompat-cntfrq", "true" }, -{"scsi-disk-base", "migrate-emulated-scsi-request", "false" }, +{ "scsi-hd", "migrate-emulated-scsi-request", "false" }, +{ "scsi-cd", "migrate-emulated-scsi-request", "false" }, {"vfio-pci", "skip-vsc-check", "false" }, { "virtio-pci", "x-pcie-pm-no-soft-reset", "off" }, {"sd-card", "spec_version", "2" }, -- 2.45.2
[PULL 08/12] tests/avocado/machine_aspeed.py: Increase timeout for TPM test
From: Cédric Le Goater On some runners, test_arm_ast2600_evb_buildroot_tpm can take longer than 90s to complete. Increase timeout for these. Reported-by: Thomas Huth Signed-off-by: Cédric Le Goater Message-ID: <20240722085547.90650-1-...@redhat.com> Signed-off-by: Thomas Huth --- tests/avocado/machine_aspeed.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/avocado/machine_aspeed.py b/tests/avocado/machine_aspeed.py index 29e6b388a9..f8e263d37e 100644 --- a/tests/avocado/machine_aspeed.py +++ b/tests/avocado/machine_aspeed.py @@ -87,7 +87,7 @@ def test_ast1030_zephyros_1_07(self): class AST2x00Machine(QemuSystemTest): -timeout = 90 +timeout = 180 def wait_for_console_pattern(self, success_message, vm=None): wait_for_console_pattern(self, success_message, -- 2.45.2
[PULL 12/12] target/s390x: filter deprecated properties based on model expansion type
From: Collin Walling Currently, there is no way to execute the query-cpu-model-expansion command to retrieve a comprehenisve list of deprecated properties, as the result is dependent per-model. To enable this, the expansion output is modified as such: When reporting a "full" CPU model, show the *entire* list of deprecated properties regardless if they are supported on the model. A full expansion outputs all known CPU model properties anyway, so it makes sense to report all deprecated properties here too. This allows management apps to query a single model (e.g. host) to acquire the full list of deprecated properties. Additionally, when reporting a "static" CPU model, the command will only show deprecated properties that are a subset of the model's *enabled* properties. This is more accurate than how the query was handled before, which blindly reported deprecated properties that were never otherwise introduced for certain models. Acked-by: David Hildenbrand Suggested-by: Jiri Denemark Signed-off-by: Collin Walling Message-ID: <20240719181741.35146-1-wall...@linux.ibm.com> Signed-off-by: Thomas Huth --- qapi/machine-target.json | 5 +++-- target/s390x/cpu_models_sysemu.c | 16 +--- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/qapi/machine-target.json b/qapi/machine-target.json index 7edb876b5c..a552e2b0ce 100644 --- a/qapi/machine-target.json +++ b/qapi/machine-target.json @@ -21,8 +21,9 @@ # @props: a dictionary of QOM properties to be applied # # @deprecated-props: a list of properties that are flagged as deprecated -# by the CPU vendor. These props are a subset of the full model's -# definition list of properties. (since 9.1) +# by the CPU vendor. These properties are either a subset of the +# properties enabled on the CPU model, or a set of properties +# deprecated across all models for the architecture. # # Since: 2.8 ## diff --git a/target/s390x/cpu_models_sysemu.c b/target/s390x/cpu_models_sysemu.c index 977fbc6522..94dd798b4c 100644 --- a/target/s390x/cpu_models_sysemu.c +++ b/target/s390x/cpu_models_sysemu.c @@ -174,11 +174,15 @@ static void cpu_info_from_model(CpuModelInfo *info, const S390CPUModel *model, bool delta_changes) { QDict *qdict = qdict_new(); -S390FeatBitmap bitmap; +S390FeatBitmap bitmap, deprecated; /* always fallback to the static base model */ info->name = g_strdup_printf("%s-base", model->def->name); +/* features flagged as deprecated */ +bitmap_zero(deprecated, S390_FEAT_MAX); +s390_get_deprecated_features(deprecated); + if (delta_changes) { /* features deleted from the base feature set */ bitmap_andnot(bitmap, model->def->base_feat, model->features, @@ -193,6 +197,9 @@ static void cpu_info_from_model(CpuModelInfo *info, const S390CPUModel *model, if (!bitmap_empty(bitmap, S390_FEAT_MAX)) { s390_feat_bitmap_to_ascii(bitmap, qdict, qdict_add_enabled_feat); } + +/* deprecated features that are a subset of the model's enabled features */ +bitmap_and(deprecated, deprecated, model->features, S390_FEAT_MAX); } else { /* expand all features */ s390_feat_bitmap_to_ascii(model->features, qdict, @@ -207,12 +214,7 @@ static void cpu_info_from_model(CpuModelInfo *info, const S390CPUModel *model, info->props = QOBJECT(qdict); } -/* features flagged as deprecated */ -bitmap_zero(bitmap, S390_FEAT_MAX); -s390_get_deprecated_features(bitmap); - -bitmap_and(bitmap, bitmap, model->def->full_feat, S390_FEAT_MAX); -s390_feat_bitmap_to_ascii(bitmap, >deprecated_props, list_add_feat); +s390_feat_bitmap_to_ascii(deprecated, >deprecated_props, list_add_feat); info->has_deprecated_props = !!info->deprecated_props; } -- 2.45.2
[PULL 07/12] tests/avocado: Remove the remainders of the virtiofs_submounts test
The virtiofs_submounts test has been removed in commit 5da7701e2a ("virtiofsd: Remove test"), so we don't need this files anymore. Message-ID: <20240718173125.489901-1-th...@redhat.com> Signed-off-by: Thomas Huth --- .../virtiofs_submounts.py.data/cleanup.sh | 46 -- .../guest-cleanup.sh | 30 .../virtiofs_submounts.py.data/guest.sh | 138 -- .../virtiofs_submounts.py.data/host.sh| 127 4 files changed, 341 deletions(-) delete mode 100644 tests/avocado/virtiofs_submounts.py.data/cleanup.sh delete mode 100644 tests/avocado/virtiofs_submounts.py.data/guest-cleanup.sh delete mode 100644 tests/avocado/virtiofs_submounts.py.data/guest.sh delete mode 100644 tests/avocado/virtiofs_submounts.py.data/host.sh diff --git a/tests/avocado/virtiofs_submounts.py.data/cleanup.sh b/tests/avocado/virtiofs_submounts.py.data/cleanup.sh deleted file mode 100644 index 2a6579a0fe..00 --- a/tests/avocado/virtiofs_submounts.py.data/cleanup.sh +++ /dev/null @@ -1,46 +0,0 @@ -#!/bin/bash - -function print_usage() -{ -if [ -n "$2" ]; then -echo "Error: $2" -echo -fi -echo "Usage: $1 " -} - -scratch_dir=$1 -if [ -z "$scratch_dir" ]; then -print_usage "$0" 'Scratch dir not given' >&2 -exit 1 -fi - -cd "$scratch_dir/share" || exit 1 -mps=(mnt*) -mp_i=0 -for mp in "${mps[@]}"; do -mp_i=$((mp_i + 1)) -printf "Unmounting %i/%i...\r" "$mp_i" "${#mps[@]}" - -sudo umount -R "$mp" -rm -rf "$mp" -done -echo - -rm some-file -cd .. -rmdir share - -imgs=(fs*.img) -img_i=0 -for img in "${imgs[@]}"; do -img_i=$((img_i + 1)) -printf "Detaching and deleting %i/%i...\r" "$img_i" "${#imgs[@]}" - -dev=$(losetup -j "$img" | sed -e 's/:.*//') -sudo losetup -d "$dev" -rm -f "$img" -done -echo - -echo 'Done.' diff --git a/tests/avocado/virtiofs_submounts.py.data/guest-cleanup.sh b/tests/avocado/virtiofs_submounts.py.data/guest-cleanup.sh deleted file mode 100644 index 729cb2d1a5..00 --- a/tests/avocado/virtiofs_submounts.py.data/guest-cleanup.sh +++ /dev/null @@ -1,30 +0,0 @@ -#!/bin/bash - -function print_usage() -{ -if [ -n "$2" ]; then -echo "Error: $2" -echo -fi -echo "Usage: $1 " -} - -scratch_dir=$1 -if [ -z "$scratch_dir" ]; then -print_usage "$0" 'Scratch dir not given' >&2 -exit 1 -fi - -cd "$scratch_dir/share" || exit 1 - -mps=(mnt*) -mp_i=0 -for mp in "${mps[@]}"; do -mp_i=$((mp_i + 1)) -printf "Unmounting %i/%i...\r" "$mp_i" "${#mps[@]}" - -sudo umount -R "$mp" -done -echo - -echo 'Done.' diff --git a/tests/avocado/virtiofs_submounts.py.data/guest.sh b/tests/avocado/virtiofs_submounts.py.data/guest.sh deleted file mode 100644 index 59ba40fde1..00 --- a/tests/avocado/virtiofs_submounts.py.data/guest.sh +++ /dev/null @@ -1,138 +0,0 @@ -#!/bin/bash - -function print_usage() -{ -if [ -n "$2" ]; then -echo "Error: $2" -echo -fi -echo "Usage: $1 " -echo '(The shared directory is the "share" directory in the scratch' \ - 'directory)' -} - -shared_dir=$1 -if [ -z "$shared_dir" ]; then -print_usage "$0" 'Shared dir not given' >&2 -exit 1 -fi - -cd "$shared_dir" - -# FIXME: This should not be necessary, but it is. In order for all -# submounts to be proper mount points, we need to visit them. -# (Before we visit them, they will not be auto-mounted, and so just -# appear as normal directories, with the catch that their st_ino will -# be the st_ino of the filesystem they host, while the st_dev will -# still be the st_dev of the parent.) -# `find` does not work, because it will refuse to touch the mount -# points as long as they are not mounted; their st_dev being shared -# with the parent and st_ino just being the root node's inode ID -# will practically ensure that this node exists elsewhere on the -# filesystem, and `find` is required to recognize loops and not to -# follow them. -# Thus, we have to manually visit all nodes first. - -mnt_i=0 - -function recursively_visit() -{ -pushd "$1" >/dev/null -for entry in *; do -if [[ "$entry" == mnt* ]]; then -mnt_i=$((mnt_i + 1)) -printf "Triggering auto-mount $mnt_i...\r" -fi - -if [ -d "$entry" ]; then -recursively_visit "$entry" -fi -done -popd >/dev/null -} - -recursively_visit . -echo - - -if [ -n "$(find -name not-mounted)" ]; then -echo "Error: not-mounted files vi
[PULL 10/12] qtest/fuzz: make range overlap check more readable
From: Yao Xingtao use ranges_overlap() instead of open-coding the overlap check to improve the readability of the code. Signed-off-by: Yao Xingtao Reviewed-by: Philippe Mathieu-Daudé Tested-by: Philippe Mathieu-Daudé Reviewed-by: Alexander Bulekov Message-ID: <20240722040742.11513-8-yaoxt.f...@fujitsu.com> Signed-off-by: Thomas Huth --- tests/qtest/fuzz/generic_fuzz.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/qtest/fuzz/generic_fuzz.c b/tests/qtest/fuzz/generic_fuzz.c index ec842e03c5..d107a496da 100644 --- a/tests/qtest/fuzz/generic_fuzz.c +++ b/tests/qtest/fuzz/generic_fuzz.c @@ -11,6 +11,7 @@ */ #include "qemu/osdep.h" +#include "qemu/range.h" #include @@ -211,7 +212,7 @@ void fuzz_dma_read_cb(size_t addr, size_t len, MemoryRegion *mr) i < dma_regions->len && (avoid_double_fetches || qtest_log_enabled); ++i) { region = g_array_index(dma_regions, address_range, i); -if (addr < region.addr + region.size && addr + len > region.addr) { +if (ranges_overlap(addr, len, region.addr, region.size)) { double_fetch = true; if (addr < region.addr && avoid_double_fetches) { -- 2.45.2
[PULL 06/12] tests/avocado/mem-addr-space-check: Remove unused "import signal"
The "signal" module is not used here, so we can remove this import statement. Message-ID: <20240719095408.33298-1-th...@redhat.com> Reviewed-by: Daniel P. Berrangé Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Thomas Huth --- tests/avocado/mem-addr-space-check.py | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/avocado/mem-addr-space-check.py b/tests/avocado/mem-addr-space-check.py index 85541ea051..d3974599f4 100644 --- a/tests/avocado/mem-addr-space-check.py +++ b/tests/avocado/mem-addr-space-check.py @@ -9,7 +9,6 @@ # SPDX-License-Identifier: GPL-2.0-or-later from avocado_qemu import QemuSystemTest -import signal import time class MemAddrCheck(QemuSystemTest): -- 2.45.2
[PULL 05/12] tests/avocado: Move LinuxTest related code into a separate file
Only some few tests are using the LinuxTest class. Move the related code into a separate file so that this does not pollute the main namespace. Message-ID: <20240719095031.32814-1-th...@redhat.com> Reviewed-by: Daniel P. Berrangé Reviewed-by: Philippe Mathieu-Daudé Tested-by: Philippe Mathieu-Daudé Signed-off-by: Thomas Huth --- tests/avocado/avocado_qemu/__init__.py | 239 +- tests/avocado/avocado_qemu/linuxtest.py | 253 tests/avocado/boot_linux.py | 3 +- tests/avocado/hotplug_blk.py| 2 +- tests/avocado/hotplug_cpu.py| 2 +- tests/avocado/intel_iommu.py| 2 +- tests/avocado/replay_linux.py | 2 +- tests/avocado/smmu.py | 3 +- 8 files changed, 262 insertions(+), 244 deletions(-) create mode 100644 tests/avocado/avocado_qemu/linuxtest.py diff --git a/tests/avocado/avocado_qemu/__init__.py b/tests/avocado/avocado_qemu/__init__.py index 304c428168..a3da2a96bb 100644 --- a/tests/avocado/avocado_qemu/__init__.py +++ b/tests/avocado/avocado_qemu/__init__.py @@ -10,7 +10,6 @@ import logging import os -import shutil import subprocess import sys import tempfile @@ -18,7 +17,7 @@ import uuid import avocado -from avocado.utils import cloudinit, datadrainer, process, ssh, vmimage +from avocado.utils import ssh from avocado.utils.path import find_command from qemu.machine import QEMUMachine @@ -32,14 +31,6 @@ #: and build tree, it will not be accurate. BUILD_DIR = os.path.dirname(os.path.dirname(os.path.dirname(os.path.dirname(__file__ -if os.path.islink(os.path.dirname(os.path.dirname(__file__))): -# The link to the avocado tests dir in the source code directory -lnk = os.path.dirname(os.path.dirname(__file__)) -#: The QEMU root source directory -SOURCE_DIR = os.path.dirname(os.path.dirname(os.readlink(lnk))) -else: -SOURCE_DIR = BUILD_DIR - def has_cmd(name, args=None): """ @@ -451,231 +442,3 @@ def ssh_command_output_contains(self, cmd, exp): break else: self.fail('"%s" output does not contain "%s"' % (cmd, exp)) - -class LinuxDistro: -"""Represents a Linux distribution - -Holds information of known distros. -""" -#: A collection of known distros and their respective image checksum -KNOWN_DISTROS = { -'fedora': { -'31': { -'x86_64': -{'checksum': ('e3c1b309d9203604922d6e255c2c5d09' - '8a309c2d46215d8fc026954f3c5c27a0'), - 'pxeboot_url': ('https://archives.fedoraproject.org/' - 'pub/archive/fedora/linux/releases/31/' - 'Everything/x86_64/os/images/pxeboot/'), - 'kernel_params': ('root=UUID=b1438b9b-2cab-4065-a99a-' - '08a96687f73c ro no_timer_check ' - 'net.ifnames=0 console=tty1 ' - 'console=ttyS0,115200n8'), -}, -'aarch64': -{'checksum': ('1e18d9c0cf734940c4b5d5ec592facae' - 'd2af0ad0329383d5639c997fdf16fe49'), -'pxeboot_url': 'https://archives.fedoraproject.org/' - 'pub/archive/fedora/linux/releases/31/' - 'Everything/aarch64/os/images/pxeboot/', -'kernel_params': ('root=UUID=b6950a44-9f3c-4076-a9c2-' - '355e8475b0a7 ro earlyprintk=pl011,0x900' - ' ignore_loglevel no_timer_check' - ' printk.time=1 rd_NO_PLYMOUTH' - ' console=ttyAMA0'), -}, -'ppc64': -{'checksum': ('7c3528b85a3df4b2306e892199a9e1e4' - '3f991c506f2cc390dc4efa2026ad2f58')}, -'s390x': -{'checksum': ('4caaab5a434fd4d1079149a072fdc789' - '1e354f834d355069ca982fdcaf5a122d')}, -}, -'32': { -'aarch64': -{'checksum': ('b367755c664a2d7a26955bbfff985855' - 'adfa2ca15e908baf15b4b176d68d3967'), -'pxeboot_url': ('http://dl.fedoraproject.org/pub/fedora/linux/' -'releases/32/Server/aarch64/os/images/' -'pxeboot/'), -'kernel_params': ('root=UUID=3df75b65-be8d-4db4-8655-' - '14d95c0e90c5 ro no_timer_check net.ifnames=0' - ' console=tty1 console=ttyS0,115200n8'), -}, -}, -'33': { -'aar
[PULL 04/12] tests/avocado: Allow overwriting AVOCADO_SHOW env variable
From: Philippe Mathieu-Daudé The 'app' level logging is useful, but sometimes we want more, for example QEMU leverages the 'console' logging. Allow overwriting AVOCADO_SHOW from environment, i.e.: $ make check-avocado AVOCADO_SHOW='app,console' Signed-off-by: Philippe Mathieu-Daudé Message-ID: <20240719180211.48073-1-phi...@linaro.org> Signed-off-by: Thomas Huth --- tests/Makefile.include | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Makefile.include b/tests/Makefile.include index d39d5dd6a4..6618bfed70 100644 --- a/tests/Makefile.include +++ b/tests/Makefile.include @@ -97,7 +97,7 @@ endif # Controls the output generated by Avocado when running tests. # Any number of command separated loggers are accepted. For more # information please refer to "avocado --help". -AVOCADO_SHOW=app +AVOCADO_SHOW?=app ifndef AVOCADO_TAGS AVOCADO_CMDLINE_TAGS=$(patsubst %-softmmu,-t arch:%, \ $(filter %-softmmu,$(TARGETS))) -- 2.45.2
[PULL 02/12] tests/avocado/boot_xen.py: unify tags
From: Cleber Rosa Because all tests share the same tags, it's possible to have all of them at the class level. Signed-off-by: Cleber Rosa Reviewed-by: Philippe Mathieu-Daudé Message-ID: <20231208190911.102879-10-cr...@redhat.com> Signed-off-by: Thomas Huth --- tests/avocado/boot_xen.py | 26 +- 1 file changed, 5 insertions(+), 21 deletions(-) diff --git a/tests/avocado/boot_xen.py b/tests/avocado/boot_xen.py index f80cbcb8fb..f4b63c1ef2 100644 --- a/tests/avocado/boot_xen.py +++ b/tests/avocado/boot_xen.py @@ -20,6 +20,11 @@ class BootXen(LinuxKernelTest): """ Boots a Xen hypervisor with a Linux DomU kernel. + +:avocado: tags=arch:aarch64 +:avocado: tags=accel:tcg +:avocado: tags=cpu:cortex-a57 +:avocado: tags=machine:virt """ timeout = 90 @@ -60,13 +65,6 @@ def launch_xen(self, xen_path): wait_for_console_pattern(self, console_pattern, "Panic on CPU 0:") def test_arm64_xen_411_and_dom0(self): -""" -:avocado: tags=arch:aarch64 -:avocado: tags=accel:tcg -:avocado: tags=cpu:cortex-a57 -:avocado: tags=machine:virt -""" - # archive of file from https://deb.debian.org/debian/pool/main/x/xen/ xen_url = ('https://fileserver.linaro.org/s/JSsewXGZ6mqxPr5/' 'download?path=%2F=' @@ -78,13 +76,6 @@ def test_arm64_xen_411_and_dom0(self): self.launch_xen(xen_path) def test_arm64_xen_414_and_dom0(self): -""" -:avocado: tags=arch:aarch64 -:avocado: tags=accel:tcg -:avocado: tags=cpu:cortex-a57 -:avocado: tags=machine:virt -""" - # archive of file from https://deb.debian.org/debian/pool/main/x/xen/ xen_url = ('https://fileserver.linaro.org/s/JSsewXGZ6mqxPr5/' 'download?path=%2F=' @@ -96,13 +87,6 @@ def test_arm64_xen_414_and_dom0(self): self.launch_xen(xen_path) def test_arm64_xen_415_and_dom0(self): -""" -:avocado: tags=arch:aarch64 -:avocado: tags=accel:tcg -:avocado: tags=cpu:cortex-a57 -:avocado: tags=machine:virt -""" - xen_url = ('https://fileserver.linaro.org/' 's/JSsewXGZ6mqxPr5/download' '?path=%2F=xen-upstream-4.15-unstable.deb') -- 2.45.2
[PULL 03/12] tests/avocado/boot_xen.py: use class attribute
From: Cleber Rosa Rather than defining a single use variable, let's just use the class attribute directly. Signed-off-by: Cleber Rosa Reviewed-by: Philippe Mathieu-Daudé Message-ID: <20231208190911.102879-11-cr...@redhat.com> Signed-off-by: Thomas Huth --- tests/avocado/boot_xen.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/avocado/boot_xen.py b/tests/avocado/boot_xen.py index f4b63c1ef2..f29bc58b9e 100644 --- a/tests/avocado/boot_xen.py +++ b/tests/avocado/boot_xen.py @@ -50,11 +50,10 @@ def launch_xen(self, xen_path): self.vm.set_console() -xen_command_line = self.XEN_COMMON_COMMAND_LINE self.vm.add_args('-machine', 'virtualization=on', '-m', '768', '-kernel', xen_path, - '-append', xen_command_line, + '-append', self.XEN_COMMON_COMMAND_LINE, '-device', 'guest-loader,addr=0x4700,kernel=%s,bootargs=console=hvc0' % (kernel_path)) -- 2.45.2
[PULL 00/12] QTests, Avocado and s390x fixes for 9.1 softfreeze
Hi Richard! The following changes since commit a7ddb48bd1363c8bcdf42776d320289c42191f01: Merge tag 'pull-aspeed-20240721' of https://github.com/legoater/qemu into staging (2024-07-22 07:52:05 +1000) are available in the Git repository at: https://gitlab.com/thuth/qemu.git tags/pull-request-2024-07-22 for you to fetch changes up to eed0e8ffa38f0695c0519508f6e4f5a3297cbd67: target/s390x: filter deprecated properties based on model expansion type (2024-07-22 13:56:11 +0200) * Minor clean-ups and fixes for the qtests and Avocado tests * Fix crash that happens when introspecting scsi-block on older machine types * s390x: filter deprecated properties based on model expansion type Cleber Rosa (3): tests/avocado/boot_xen.py: merge base classes tests/avocado/boot_xen.py: unify tags tests/avocado/boot_xen.py: use class attribute Collin L. Walling (1): target/s390x: filter deprecated properties based on model expansion type Cédric Le Goater (1): tests/avocado/machine_aspeed.py: Increase timeout for TPM test Igor Mammedov (1): tests: increase timeout per instance of bios-tables-test Philippe Mathieu-Daudé (1): tests/avocado: Allow overwriting AVOCADO_SHOW env variable Thomas Huth (4): tests/avocado: Move LinuxTest related code into a separate file tests/avocado/mem-addr-space-check: Remove unused "import signal" tests/avocado: Remove the remainders of the virtiofs_submounts test hw: Fix crash that happens when introspecting scsi-block on older machine types Yao Xingtao (1): qtest/fuzz: make range overlap check more readable qapi/machine-target.json | 5 +- hw/core/machine.c | 3 +- target/s390x/cpu_models_sysemu.c | 16 +- tests/qtest/fuzz/generic_fuzz.c| 3 +- tests/Makefile.include | 2 +- tests/avocado/avocado_qemu/__init__.py | 239 +-- tests/avocado/avocado_qemu/linuxtest.py| 253 + tests/avocado/boot_linux.py| 3 +- tests/avocado/boot_xen.py | 34 +-- tests/avocado/hotplug_blk.py | 2 +- tests/avocado/hotplug_cpu.py | 2 +- tests/avocado/intel_iommu.py | 2 +- tests/avocado/machine_aspeed.py| 2 +- tests/avocado/mem-addr-space-check.py | 1 - tests/avocado/replay_linux.py | 2 +- tests/avocado/smmu.py | 3 +- .../avocado/virtiofs_submounts.py.data/cleanup.sh | 46 .../virtiofs_submounts.py.data/guest-cleanup.sh| 30 --- tests/avocado/virtiofs_submounts.py.data/guest.sh | 138 --- tests/avocado/virtiofs_submounts.py.data/host.sh | 127 --- tests/qtest/meson.build| 2 +- 21 files changed, 288 insertions(+), 627 deletions(-) create mode 100644 tests/avocado/avocado_qemu/linuxtest.py delete mode 100644 tests/avocado/virtiofs_submounts.py.data/cleanup.sh delete mode 100644 tests/avocado/virtiofs_submounts.py.data/guest-cleanup.sh delete mode 100644 tests/avocado/virtiofs_submounts.py.data/guest.sh delete mode 100644 tests/avocado/virtiofs_submounts.py.data/host.sh
[PULL 01/12] tests/avocado/boot_xen.py: merge base classes
From: Cleber Rosa While it's a good practice to have reusable base classes, in this specific case there's no other user of the BootXenBase class. By unifying the class used in this test, we can improve readability and have the opportunity to add some future improvements in a clearer fashion. Signed-off-by: Cleber Rosa Message-ID: <20231208190911.102879-9-cr...@redhat.com> Signed-off-by: Thomas Huth --- tests/avocado/boot_xen.py | 5 + 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/tests/avocado/boot_xen.py b/tests/avocado/boot_xen.py index fc2faeedb5..f80cbcb8fb 100644 --- a/tests/avocado/boot_xen.py +++ b/tests/avocado/boot_xen.py @@ -17,7 +17,7 @@ from boot_linux_console import LinuxKernelTest -class BootXenBase(LinuxKernelTest): +class BootXen(LinuxKernelTest): """ Boots a Xen hypervisor with a Linux DomU kernel. """ @@ -59,9 +59,6 @@ def launch_xen(self, xen_path): console_pattern = 'VFS: Cannot open root device' wait_for_console_pattern(self, console_pattern, "Panic on CPU 0:") - -class BootXen(BootXenBase): - def test_arm64_xen_411_and_dom0(self): """ :avocado: tags=arch:aarch64 -- 2.45.2
Re: [RFC PATCH v4 1/2] target/riscv: Add RISC-V CSR qtest support
On 03/07/2024 10.19, Ivan Klokov wrote: The RISC-V architecture supports the creation of custom CSR-mapped devices. It would be convenient to test them in the same way as MMIO-mapped devices. To do this, a new call has been added to read/write CSR registers. Signed-off-by: Ivan Klokov --- target/riscv/cpu.c | 17 ++ target/riscv/cpu.h | 3 +++ target/riscv/csr.c | 53 +- tests/qtest/libqtest.c | 27 + tests/qtest/libqtest.h | 14 +++ 5 files changed, 113 insertions(+), 1 deletion(-) ... diff --git a/target/riscv/cpu.h b/target/riscv/cpu.h index 6fe0d712b4..6d4bbec53c 100644 --- a/target/riscv/cpu.h +++ b/target/riscv/cpu.h @@ -32,6 +32,8 @@ #include "cpu_cfg.h" #include "qapi/qapi-types-common.h" #include "cpu-qom.h" +#include "qemu/cutils.h" +#include "sysemu/qtest.h" Why do you need these include statements here? typedef struct CPUArchState CPURISCVState; @@ -813,6 +815,7 @@ bool riscv_cpu_accelerator_compatible(RISCVCPU *cpu); /* CSR function table */ extern riscv_csr_operations csr_ops[CSR_TABLE_SIZE]; +bool csr_qtest_callback(CharBackend *chr, gchar **words); extern const bool valid_vm_1_10_32[], valid_vm_1_10_64[]; diff --git a/target/riscv/csr.c b/target/riscv/csr.c index 58ef7079dc..f4f5128c9c 100644 --- a/target/riscv/csr.c +++ b/target/riscv/csr.c @@ -29,7 +29,7 @@ #include "sysemu/cpu-timers.h" #include "qemu/guest-random.h" #include "qapi/error.h" - +#include "tests/qtest/libqtest.h" Code in target/ should never include code from tests/ ... if you really need this, you likely did something wrong...? Thomas /* CSR function table public API */ void riscv_get_csr_ops(int csrno, riscv_csr_operations *ops) @@ -4549,6 +4549,57 @@ static RISCVException write_jvt(CPURISCVState *env, int csrno, return RISCV_EXCP_NONE; } +#if !defined(CONFIG_USER_ONLY) +static uint64_t csr_call(char *cmd, uint64_t cpu_num, int csrno, +uint64_t *val) +{ +RISCVCPU *cpu = RISCV_CPU(cpu_by_arch_id(cpu_num)); +CPURISCVState *env = >env; + +int ret = RISCV_EXCP_NONE; +if (strcmp(cmd, "get_csr") == 0) { +ret = riscv_csrrw(env, csrno, (target_ulong *)val, 0, 0); + +} else if (strcmp(cmd, "set_csr") == 0) { +ret = riscv_csrrw(env, csrno, NULL, *(target_ulong *)val, MAKE_64BIT_MASK(0, TARGET_LONG_BITS)); +} + +if (ret == RISCV_EXCP_NONE) { +ret = 0; +} else { +g_assert_not_reached(); +} + +return ret; +} + +bool csr_qtest_callback(CharBackend *chr, gchar **words) +{ +if (strcmp(words[0], "csr") == 0) { + +uint64_t res, cpu; + +uint64_t val; +int rc, csr; + +rc = qemu_strtou64(words[2], NULL, 0, ); +g_assert(rc == 0); +rc = qemu_strtoi(words[3], NULL, 0, ); +g_assert(rc == 0); +rc = qemu_strtou64(words[4], NULL, 0, ); +g_assert(rc == 0); +res = csr_call(words[1], cpu, csr, ); + +qtest_send_prefix(chr); +qtest_sendf(chr, "OK %"PRIx64" "TARGET_FMT_lx"\n", res, (target_ulong)val); + +return true; +} + +return false; +} +#endif + /* * Control and Status Register function table * riscv_csr_operations::predicate() must be provided for an implemented CSR diff --git a/tests/qtest/libqtest.c b/tests/qtest/libqtest.c index c7f6897d78..f8c3ff15a9 100644 --- a/tests/qtest/libqtest.c +++ b/tests/qtest/libqtest.c @@ -1205,6 +1205,33 @@ uint64_t qtest_rtas_call(QTestState *s, const char *name, return 0; } +static void qtest_rsp_csr(QTestState *s, uint64_t *val) +{ +gchar **args; +uint64_t ret; +int rc; + +args = qtest_rsp_args(s, 3); + +rc = qemu_strtou64(args[1], NULL, 16, ); +g_assert(rc == 0); +rc = qemu_strtou64(args[2], NULL, 16, val); +g_assert(rc == 0); + +g_strfreev(args); +} + +uint64_t qtest_csr_call(QTestState *s, const char *name, + uint64_t cpu, int csr, + uint64_t *val) +{ +qtest_sendf(s, "csr %s 0x%"PRIx64" %d 0x%"PRIx64"\n", +name, cpu, csr, *val); + +qtest_rsp_csr(s, val); +return 0; +} + void qtest_add_func(const char *str, void (*fn)(void)) { gchar *path = g_strdup_printf("/%s/%s", qtest_get_arch(), str); diff --git a/tests/qtest/libqtest.h b/tests/qtest/libqtest.h index c261b7e0b3..7b547e5e2c 100644 --- a/tests/qtest/libqtest.h +++ b/tests/qtest/libqtest.h @@ -577,6 +577,20 @@ uint64_t qtest_rtas_call(QTestState *s, const char *name, uint32_t nargs, uint64_t args, uint32_t nret, uint64_t ret); +/** + * qtest_csr_call: + * @s: #QTestState instance to op
Re: [RFC PATCH v4 2/2] tests/qtest: QTest example for RISC-V CSR register
On 03/07/2024 10.19, Ivan Klokov wrote: Added demo for reading CSR register from qtest environment. Signed-off-by: Ivan Klokov --- tests/qtest/meson.build | 2 + tests/qtest/riscv-csr-test.c | 86 2 files changed, 88 insertions(+) create mode 100644 tests/qtest/riscv-csr-test.c diff --git a/tests/qtest/meson.build b/tests/qtest/meson.build index 12792948ff..45d651da99 100644 --- a/tests/qtest/meson.build +++ b/tests/qtest/meson.build @@ -259,6 +259,8 @@ qtests_s390x = \ qtests_riscv32 = \ (config_all_devices.has_key('CONFIG_SIFIVE_E_AON') ? ['sifive-e-aon-watchdog-test'] : []) +qtests_riscv32 += ['riscv-csr-test'] Could you please add it directly to the qtests_riscv32 list above intead of using a separate += line here? qos_test_ss = ss.source_set() qos_test_ss.add( 'ac97-test.c', diff --git a/tests/qtest/riscv-csr-test.c b/tests/qtest/riscv-csr-test.c new file mode 100644 index 00..e9af9ca724 --- /dev/null +++ b/tests/qtest/riscv-csr-test.c @@ -0,0 +1,86 @@ +/* + * QTest testcase for RISC-V CSRs + * + * Copyright (c) 2024 Syntacore. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. + */ + +#include "qemu/osdep.h" +#include "libqtest-single.h" +#include "libqtest.h" + +static uint64_t qcsr_call(QTestState *qts, const char *name, uint64_t cpu, + int csrno, uint64_t *val) +{ +uint64_t res = 0; + +res = qtest_csr_call(qts, name, cpu, csrno, val); + +return res; +} Could you please get rid of this useless qcsr_call() wrapper and call qtest_csr_call() everywhere instead? +static int qcsr_get_csr(QTestState *qts, uint64_t cpu, +int csrno, uint64_t *val) Bad indentation, please align "int csrno" with QTestState. +{ +int res; + +res = qcsr_call(qts, "get_csr", cpu, csrno, val); + +return res; +} + +static int qcsr_set_csr(QTestState *qts, uint64_t cpu, +int csrno, uint64_t *val) dito. +{ +int res; + +res = qcsr_call(qts, "set_csr", cpu, csrno, val); + +return res; +} + +static void run_test_csr(void) +{ + Please remove the empty line above. +uint64_t res; +uint64_t val = 0; + +res = qcsr_call(global_qtest, "get_csr", 0, 0xf11, ); + +g_assert_cmpint(res, ==, 0); +g_assert_cmpint(val, ==, 0x100); + +val = 0xff; +res = qcsr_call(global_qtest, "set_csr", 0, 0x342, ); + +g_assert_cmpint(res, ==, 0); + +val = 0; +res = qcsr_call(global_qtest, "get_csr", 0, 0x342, ); + +g_assert_cmpint(res, ==, 0); +g_assert_cmpint(val, ==, 0xff); + +qtest_quit(global_qtest); Having qtest_quit here, while qtest_start is in the main function, looks really ugly and will likely cause trouble when extending the test later. Please clean it up: Use qts = qtest_init() at the beginning of this function instead of calling qtest_start() in main(). Then you can get rid of global_qtest completely and also drop the #include "libtest-single.h" statement at the beginning of the function. Thanks, Thomas +} + +int main(int argc, char **argv) +{ +g_test_init(, , NULL); + +qtest_add_func("/cpu/csr", run_test_csr); + +qtest_start("-machine virt -cpu any,mvendorid=0x100"); + +return g_test_run(); + +}
Re: [PATCH] tests/avocado/machine_aspeed.py: Increase timeout for TPM test
On 22/07/2024 10.55, Cédric Le Goater wrote: On some runners, test_arm_ast2600_evb_buildroot_tpm can take longer than 90s to complete. Increase timeout for these. Reported-by: Thomas Huth Signed-off-by: Cédric Le Goater --- tests/avocado/machine_aspeed.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/avocado/machine_aspeed.py b/tests/avocado/machine_aspeed.py index 29e6b388a9fd..f8e263d37ea9 100644 --- a/tests/avocado/machine_aspeed.py +++ b/tests/avocado/machine_aspeed.py @@ -87,7 +87,7 @@ def test_ast1030_zephyros_1_07(self): class AST2x00Machine(QemuSystemTest): -timeout = 90 +timeout = 180 def wait_for_console_pattern(self, success_message, vm=None): wait_for_console_pattern(self, success_message, Reviewed-by: Thomas Huth Thanks, I'll queue it!
Re: [PATCH] tests: increase timeout per instance of bios-tables-test
On 16/07/2024 14.59, Igor Mammedov wrote: CI often fails 'cross-i686-tci' job due to runner slowness Log shows that test almost complete, with a few remaining when bios-tables-test timeout hits: 19/270 qemu:qtest+qtest-aarch64 / qtest-aarch64/bios-tables-test TIMEOUT610.02s killed by signal 15 SIGTERM ... stderr: TAP parsing error: Too few tests run (expected 8, got 7) At the same time overall job running time is only ~30 out of 1hr allowed. Increase bios-tables-test instance timeout on 5min as a fix for slow CI runners. Signed-off-by: Igor Mammedov --- tests/qtest/meson.build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) Since we're entering the freeze period this week, I'm going to pick up this patch for my next pull request in the hope that it will help to get this job green again during the freeze period. But in the long run, it would be really good if someone familiar with the bios-tables-test could analyze why the run time increased so much in recent times for this test and provide a better fix for the problem. Thanks, Thomas
Re: [PULL 06/27] iotests/{024, 271}: add testcases for qemu-img rebase
On 31/10/2023 19.58, Kevin Wolf wrote: From: Andrey Drobyshev As the previous commit changes the logic of "qemu-img rebase" (it's using write alignment now), let's add a couple more test cases which would ensure it works correctly. In particular, the following scenarios: 024: add test case for rebase within one backing chain when the overlay cluster size > backings cluster size; 271: add test case for rebase images that contain subclusters. Check that no extra allocations are being made. Signed-off-by: Andrey Drobyshev Reviewed-by: Hanna Czenczek Message-ID: <20230919165804.439110-7-andrey.drobys...@virtuozzo.com> Reviewed-by: Kevin Wolf Signed-off-by: Kevin Wolf --- tests/qemu-iotests/024 | 60 ++ tests/qemu-iotests/024.out | 43 + tests/qemu-iotests/271 | 66 ++ tests/qemu-iotests/271.out | 42 4 files changed, 211 insertions(+) Hi! Seems like this patch now breaks the iotests when running with -qed : $ ./check -qed 024 QEMU -- ".../qemu-build/qemu-system-x86_64" -nodefaults -display none -accel qtest QEMU_IMG -- ".../qemu-build/qemu-img" QEMU_IO -- ".../qemu-build/qemu-io" --cache writeback --aio threads -f qed QEMU_NBD -- ".../qemu-build/qemu-nbd" IMGFMT-- qed IMGPROTO -- file PLATFORM -- Linux/x86_64 thuth-p1g4 6.9.9-200.fc40.x86_64 TEST_DIR -- .../qemu-build/tests/qemu-iotests/scratch SOCK_DIR -- /tmp/qemu-iotests-b84qth8b GDB_OPTIONS -- VALGRIND_QEMU -- PRINT_QEMU_OUTPUT -- 024 fail [09:14:06] [09:14:09] 2.9s output mismatch (see .../qemu-build/tests/qemu-iotests/scratch/qed-file-024/024.out.bad) --- .../qemu/tests/qemu-iotests/024.out +++ .../qemu-build/tests/qemu-iotests/scratch/qed-file-024/024.out.bad @@ -214,7 +214,6 @@ virtual size: 384 KiB (393216 bytes) cluster_size: 131072 backing file: TEST_DIR/subdir/t.IMGFMT.base_old -backing file format: IMGFMT Fill backing files with data Failures: 024 Failed 1 of 1 iotests Could you please have a look at it? Thanks, Thomas
Re: [PATCH] tests/avocado: Move common Avocado tags to class
On 19/07/2024 17.13, Philippe Mathieu-Daudé wrote: When Avocado tags apply to all tests in a class, we can define them once in the class: they will be applied to all test methods. Signed-off-by: Philippe Mathieu-Daudé --- tests/avocado/boot_linux.py | 2 +- tests/avocado/boot_xen.py | 17 + tests/avocado/machine_aarch64_virt.py | 10 -- 3 files changed, 6 insertions(+), 23 deletions(-) diff --git a/tests/avocado/boot_linux.py b/tests/avocado/boot_linux.py index cdce4cbcba..df6cf209ef 100644 --- a/tests/avocado/boot_linux.py +++ b/tests/avocado/boot_linux.py @@ -64,12 +64,12 @@ def test_pc_q35_kvm(self): class BootLinuxAarch64(LinuxTest): """ :avocado: tags=arch:aarch64 -:avocado: tags=machine:virt """ timeout = 720 def test_virt_kvm(self): """ +:avocado: tags=machine:virt :avocado: tags=accel:kvm :avocado: tags=cpu:host """ This change seems to contradict your patch description? Thomas
Re: [PATCH v2] target/s390x: filter deprecated properties based on model expansion type
On 18/07/2024 20.22, Collin Walling wrote: On 7/18/24 9:39 AM, Markus Armbruster wrote: Collin Walling writes: As s390 CPU models progress and deprecated properties are dropped outright, it will be cumbersome for management apps to query the host for a comprehensive list of deprecated properties that will need to be disabled on older models. To remedy this, the query-cpu-model-expansion output now behaves by filtering deprecated properties based on the expansion type instead of filtering based off of the model's full set of features: When reporting a static CPU model, only show deprecated properties that are a subset of the model's enabled features. When reporting a full CPU model, show the entire list of deprecated properties regardless if they are supported on the model. Suggested-by: Jiri Denemark Signed-off-by: Collin Walling --- Changelog: v2 - Changed commit message - Added documentation reflecting this change - Made code changes that more accurately filter the deprecated properties based on expansion type. This change makes it so that the deprecated-properties reported for a static model expansion are a subset of the model's properties instead of the model's full-definition properties. For example: Previously, the z900 static model would report 'bpb' in the list of deprecated-properties. However, this prop is *not* a part of the model's feature set, leading to some inaccuracy (albeit harmless). Now, this feature will not show during a static expansion. It will, however, show up in a full expansion (along with the rest of the list: 'csske', 'te', 'cte'). @David, I've elected to respectully forgo adding your ack-by on this iteration since I have changed the code (and therefore the behavior) between this version and the previous in case you do not agree with these adjustments. --- qapi/machine-target.json | 8 ++-- target/s390x/cpu_models_sysemu.c | 16 +--- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/qapi/machine-target.json b/qapi/machine-target.json index a8d9ec87f5..d151504f25 100644 --- a/qapi/machine-target.json +++ b/qapi/machine-target.json @@ -21,8 +21,12 @@ # @props: a dictionary of QOM properties to be applied # # @deprecated-props: a list of properties that are flagged as deprecated -# by the CPU vendor. These props are a subset of the full model's -# definition list of properties. (since 9.1) +# by the CPU vendor. (since 9.1). +# +# .. note:: Since 9.1, the list of deprecated props were always a subset +#of the model's full-definition list of properites. Now, this list is +#populated with the model's enabled property set when delta changes +#are applied. All deprecated properties are reported otherwise. I'm confused. "Since 9.1, the list of deprecated props were ..." and "Now, this list is" sounds like you're explaining behavior before and after a change. What change? Since only released behavior matters, and @deprecated-props is new, there is no old behavior to document, isn't it? I admittedly had some difficulty articulating the change introduced by this patch. The @deprecated-props array, as well as a way for s390x to populate it, was introduced in release 9.1. Prior to this patch, the deprecated-props list was filtered by the CPU model's full feature set. I attempted to explain this with: "Since 9.1, the list of deprecated props were always a subset of the model's full-definition list of properties." Version 9.1 has not been released yet (see https://wiki.qemu.org/Planning/9.1), so I agree with Markus, this sounds confusing/wrong to me, too. Thomas
[PATCH] tests/avocado/mem-addr-space-check: Remove unused "import signal"
The "signal" module is not used here, so we can remove this import statement. Signed-off-by: Thomas Huth --- tests/avocado/mem-addr-space-check.py | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/avocado/mem-addr-space-check.py b/tests/avocado/mem-addr-space-check.py index 85541ea051..d3974599f4 100644 --- a/tests/avocado/mem-addr-space-check.py +++ b/tests/avocado/mem-addr-space-check.py @@ -9,7 +9,6 @@ # SPDX-License-Identifier: GPL-2.0-or-later from avocado_qemu import QemuSystemTest -import signal import time class MemAddrCheck(QemuSystemTest): -- 2.45.2
[PATCH] tests/avocado: Move LinuxTest related code into a separate file
Only some few tests are using the LinuxTest class. Move the related code into a separate file so that this does not pollute the main namespace. Signed-off-by: Thomas Huth --- tests/avocado/avocado_qemu/__init__.py | 239 +- tests/avocado/avocado_qemu/linuxtest.py | 253 tests/avocado/boot_linux.py | 3 +- tests/avocado/hotplug_blk.py| 2 +- tests/avocado/hotplug_cpu.py| 2 +- tests/avocado/intel_iommu.py| 2 +- tests/avocado/replay_linux.py | 2 +- tests/avocado/smmu.py | 3 +- 8 files changed, 262 insertions(+), 244 deletions(-) create mode 100644 tests/avocado/avocado_qemu/linuxtest.py diff --git a/tests/avocado/avocado_qemu/__init__.py b/tests/avocado/avocado_qemu/__init__.py index 304c428168..a3da2a96bb 100644 --- a/tests/avocado/avocado_qemu/__init__.py +++ b/tests/avocado/avocado_qemu/__init__.py @@ -10,7 +10,6 @@ import logging import os -import shutil import subprocess import sys import tempfile @@ -18,7 +17,7 @@ import uuid import avocado -from avocado.utils import cloudinit, datadrainer, process, ssh, vmimage +from avocado.utils import ssh from avocado.utils.path import find_command from qemu.machine import QEMUMachine @@ -32,14 +31,6 @@ #: and build tree, it will not be accurate. BUILD_DIR = os.path.dirname(os.path.dirname(os.path.dirname(os.path.dirname(__file__ -if os.path.islink(os.path.dirname(os.path.dirname(__file__))): -# The link to the avocado tests dir in the source code directory -lnk = os.path.dirname(os.path.dirname(__file__)) -#: The QEMU root source directory -SOURCE_DIR = os.path.dirname(os.path.dirname(os.readlink(lnk))) -else: -SOURCE_DIR = BUILD_DIR - def has_cmd(name, args=None): """ @@ -451,231 +442,3 @@ def ssh_command_output_contains(self, cmd, exp): break else: self.fail('"%s" output does not contain "%s"' % (cmd, exp)) - -class LinuxDistro: -"""Represents a Linux distribution - -Holds information of known distros. -""" -#: A collection of known distros and their respective image checksum -KNOWN_DISTROS = { -'fedora': { -'31': { -'x86_64': -{'checksum': ('e3c1b309d9203604922d6e255c2c5d09' - '8a309c2d46215d8fc026954f3c5c27a0'), - 'pxeboot_url': ('https://archives.fedoraproject.org/' - 'pub/archive/fedora/linux/releases/31/' - 'Everything/x86_64/os/images/pxeboot/'), - 'kernel_params': ('root=UUID=b1438b9b-2cab-4065-a99a-' - '08a96687f73c ro no_timer_check ' - 'net.ifnames=0 console=tty1 ' - 'console=ttyS0,115200n8'), -}, -'aarch64': -{'checksum': ('1e18d9c0cf734940c4b5d5ec592facae' - 'd2af0ad0329383d5639c997fdf16fe49'), -'pxeboot_url': 'https://archives.fedoraproject.org/' - 'pub/archive/fedora/linux/releases/31/' - 'Everything/aarch64/os/images/pxeboot/', -'kernel_params': ('root=UUID=b6950a44-9f3c-4076-a9c2-' - '355e8475b0a7 ro earlyprintk=pl011,0x900' - ' ignore_loglevel no_timer_check' - ' printk.time=1 rd_NO_PLYMOUTH' - ' console=ttyAMA0'), -}, -'ppc64': -{'checksum': ('7c3528b85a3df4b2306e892199a9e1e4' - '3f991c506f2cc390dc4efa2026ad2f58')}, -'s390x': -{'checksum': ('4caaab5a434fd4d1079149a072fdc789' - '1e354f834d355069ca982fdcaf5a122d')}, -}, -'32': { -'aarch64': -{'checksum': ('b367755c664a2d7a26955bbfff985855' - 'adfa2ca15e908baf15b4b176d68d3967'), -'pxeboot_url': ('http://dl.fedoraproject.org/pub/fedora/linux/' -'releases/32/Server/aarch64/os/images/' -'pxeboot/'), -'kernel_params': ('root=UUID=3df75b65-be8d-4db4-8655-' - '14d95c0e90c5 ro no_timer_check net.ifnames=0' - ' console=tty1 console=ttyS0,115200n8'), -}, -}, -'33': { -'aarch64': -{'checksum': ('e7f75cdfd523fe5ac2ca9eeece68edc1' - 'a81f386a17f969c1d1c7c87031008a6b'), -'pxeboot_url': ('http://dl.fedoraproject.org/pub/fedora/lin
[PATCH v6 2/4] docs/interop/firmware.json: add new enum FirmwareArchitecture
Only a small subset of all architectures supported by qemu make use of firmware files. Introduce and use a new enum to represent this. This also removes the dependency to machine.json from the global qapi definitions. Claim "Since: 3.0" for the new enum, because that's correct for most of its members, and the members are what matters in the interface. Suggested-by: Daniel P. Berrangé Reviewed-by: Daniel P. Berrangé Signed-off-by: Thomas Weißschuh --- docs/interop/firmware.json | 28 ++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/docs/interop/firmware.json b/docs/interop/firmware.json index d5d4c17f230b..ae4179994479 100644 --- a/docs/interop/firmware.json +++ b/docs/interop/firmware.json @@ -14,7 +14,10 @@ # = Firmware ## -{ 'include' : 'machine.json' } +{ 'pragma': { +'member-name-exceptions': [ +'FirmwareArchitecture' # x86_64 +] } } ## # @FirmwareOSInterface: @@ -59,6 +62,27 @@ { 'enum' : 'FirmwareDevice', 'data' : [ 'flash', 'kernel', 'memory' ] } +## +# @FirmwareArchitecture: +# +# Enumeration of architectures for which Qemu uses additional +# firmware files. +# +# @aarch64: 64-bit Arm. +# +# @arm: 32-bit Arm. +# +# @i386: 32-bit x86. +# +# @loongarch64: 64-bit LoongArch. (since: 7.1) +# +# @x86_64: 64-bit x86. +# +# Since: 3.0 +## +{ 'enum' : 'FirmwareArchitecture', + 'data' : [ 'aarch64', 'arm', 'i386', 'loongarch64', 'x86_64' ] } + ## # @FirmwareTarget: # @@ -80,7 +104,7 @@ # Since: 3.0 ## { 'struct' : 'FirmwareTarget', - 'data' : { 'architecture' : 'SysEmuTarget', + 'data' : { 'architecture' : 'FirmwareArchitecture', 'machines' : [ 'str' ] } } ## -- 2.45.2
[PATCH v6 0/4] docs/interop/firmware.json: scripts/qapi-gen.py compatibility
docs/interop/firmware.json is currently not usable with qapi-gen.py due to various non-functional issues. Fix those issue to provide compatibility. Kashyap, I stuck with the original wording for image format docs, as I personally prefer them a bit. Signed-off-by: Thomas Weißschuh --- Changes in v6: - Style cleanups - Improve the comment for qcow2 - Document the new enums as Since: 3.0 (7.1 for the loongarch64 arch) - Link to v5: https://lore.kernel.org/r/20240718-qapi-firmware-json-v5-0-0dba12d7a...@linutronix.de Changes in v5: - Add Reviewed-by from Daniel - Add patch to drop Example section - Link to v4: https://lore.kernel.org/r/20240718-qapi-firmware-json-v4-0-449ce672d...@linutronix.de Changes in v4: - Update "since" to 9.1 - Add comment to 'member-name-exceptions' - Document enum members and drop 'documentation-exceptions' - Link to v3: https://lore.kernel.org/r/20240311-qapi-firmware-json-v3-0-ceea6e35e...@linutronix.de Changes in v3: - Drop already picked up patches - Drop include of pragma.json - Introduce new enums FirmwareFormat and FirmwareArchitecture - Link to v2: https://lore.kernel.org/r/20240307-qapi-firmware-json-v2-0-3b29eabb9...@linutronix.de Changes in v2: - Add review tag from Philippe - Add Fixes tag (Philippe) - Add testcase (Philippe) - Link to v1: https://lore.kernel.org/r/20240306-qapi-firmware-json-v1-0-619f7122a...@linutronix.de --- Thomas Weißschuh (4): docs/interop/firmware.json: add new enum FirmwareFormat docs/interop/firmware.json: add new enum FirmwareArchitecture docs/interop/firmware.json: convert "Example" section docs: add test for firmware.json QAPI docs/interop/firmware.json | 47 +- docs/meson.build | 5 + 2 files changed, 47 insertions(+), 5 deletions(-) --- base-commit: 23fa74974d8c96bc95cbecc0d4e2d90f984939f6 change-id: 20240306-qapi-firmware-json-6fb1213936dd Best regards, -- Thomas Weißschuh
[PATCH v6 4/4] docs: add test for firmware.json QAPI
To make sure that the QAPI description stays valid, add a testcase. Suggested-by: Philippe Mathieu-Daudé Link: https://lore.kernel.org/qemu-devel/d9ce0234-4beb-4b90-b14c-76810d3b8...@linaro.org/ Reviewed-by: Daniel P. Berrangé Signed-off-by: Thomas Weißschuh --- docs/meson.build | 5 + 1 file changed, 5 insertions(+) diff --git a/docs/meson.build b/docs/meson.build index 9040f860ae1a..bcca45a342a3 100644 --- a/docs/meson.build +++ b/docs/meson.build @@ -99,3 +99,8 @@ if build_docs alias_target('html', sphinxdocs) alias_target('man', sphinxmans) endif + +test('QAPI firmware.json regression tests', python, + args: [qapi_gen.full_path(), '-o', meson.current_build_dir() / 'qapi', +meson.current_source_dir() / 'interop/firmware.json'], + env: test_env, suite: ['qapi-schema', 'qapi-interop']) -- 2.45.2
[PATCH v6 1/4] docs/interop/firmware.json: add new enum FirmwareFormat
Only a small subset of all blockdev drivers make sense for firmware images. Introduce and use a new enum to represent this. This also reduces the dependency on firmware.json from the global qapi definitions. Claim "Since: 3.0" for the new enum, because that's correct for its members, and the members are what matters in the interface. Suggested-by: Daniel P. Berrangé Reviewed-by: Daniel P. Berrangé Signed-off-by: Thomas Weißschuh --- docs/interop/firmware.json | 17 +++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/docs/interop/firmware.json b/docs/interop/firmware.json index 54a1fc6c1041..d5d4c17f230b 100644 --- a/docs/interop/firmware.json +++ b/docs/interop/firmware.json @@ -15,7 +15,6 @@ ## { 'include' : 'machine.json' } -{ 'include' : 'block-core.json' } ## # @FirmwareOSInterface: @@ -200,6 +199,20 @@ 'enrolled-keys', 'requires-smm', 'secure-boot', 'verbose-dynamic', 'verbose-static' ] } +## +# @FirmwareFormat: +# +# Formats that are supported for firmware images. +# +# @raw: Raw disk image format. +# +# @qcow2: The QCOW2 image format. +# +# Since: 3.0 +## +{ 'enum': 'FirmwareFormat', + 'data': [ 'raw', 'qcow2' ] } + ## # @FirmwareFlashFile: # @@ -219,7 +232,7 @@ ## { 'struct' : 'FirmwareFlashFile', 'data' : { 'filename' : 'str', - 'format' : 'BlockdevDriver' } } + 'format' : 'FirmwareFormat' } } ## -- 2.45.2
[PATCH v6 3/4] docs/interop/firmware.json: convert "Example" section
Since commit 3c5f6114d9ff ("qapi: remove "Example" doc section") the "Example" section is not valid anymore. It has been replaced by the "qmp-example" directive. This was not detected earlier as firmware.json was not validated. As this validation is about to be added, adapt firmware.json. Reviewed-by: Markus Armbruster Signed-off-by: Thomas Weißschuh --- docs/interop/firmware.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/interop/firmware.json b/docs/interop/firmware.json index ae4179994479..57f55f6c5455 100644 --- a/docs/interop/firmware.json +++ b/docs/interop/firmware.json @@ -470,7 +470,7 @@ # # Since: 3.0 # -# Examples: +# .. qmp-example:: # # { # "description": "SeaBIOS", -- 2.45.2
[PATCH] tests/avocado: Remove the remainders of the virtiofs_submounts test
The virtiofs_submounts test has been removed in commit 5da7701e2a ("virtiofsd: Remove test"), so we don't need this files anymore. Signed-off-by: Thomas Huth --- .../virtiofs_submounts.py.data/cleanup.sh | 46 -- .../guest-cleanup.sh | 30 .../virtiofs_submounts.py.data/guest.sh | 138 -- .../virtiofs_submounts.py.data/host.sh| 127 4 files changed, 341 deletions(-) delete mode 100644 tests/avocado/virtiofs_submounts.py.data/cleanup.sh delete mode 100644 tests/avocado/virtiofs_submounts.py.data/guest-cleanup.sh delete mode 100644 tests/avocado/virtiofs_submounts.py.data/guest.sh delete mode 100644 tests/avocado/virtiofs_submounts.py.data/host.sh diff --git a/tests/avocado/virtiofs_submounts.py.data/cleanup.sh b/tests/avocado/virtiofs_submounts.py.data/cleanup.sh deleted file mode 100644 index 2a6579a0fe..00 --- a/tests/avocado/virtiofs_submounts.py.data/cleanup.sh +++ /dev/null @@ -1,46 +0,0 @@ -#!/bin/bash - -function print_usage() -{ -if [ -n "$2" ]; then -echo "Error: $2" -echo -fi -echo "Usage: $1 " -} - -scratch_dir=$1 -if [ -z "$scratch_dir" ]; then -print_usage "$0" 'Scratch dir not given' >&2 -exit 1 -fi - -cd "$scratch_dir/share" || exit 1 -mps=(mnt*) -mp_i=0 -for mp in "${mps[@]}"; do -mp_i=$((mp_i + 1)) -printf "Unmounting %i/%i...\r" "$mp_i" "${#mps[@]}" - -sudo umount -R "$mp" -rm -rf "$mp" -done -echo - -rm some-file -cd .. -rmdir share - -imgs=(fs*.img) -img_i=0 -for img in "${imgs[@]}"; do -img_i=$((img_i + 1)) -printf "Detaching and deleting %i/%i...\r" "$img_i" "${#imgs[@]}" - -dev=$(losetup -j "$img" | sed -e 's/:.*//') -sudo losetup -d "$dev" -rm -f "$img" -done -echo - -echo 'Done.' diff --git a/tests/avocado/virtiofs_submounts.py.data/guest-cleanup.sh b/tests/avocado/virtiofs_submounts.py.data/guest-cleanup.sh deleted file mode 100644 index 729cb2d1a5..00 --- a/tests/avocado/virtiofs_submounts.py.data/guest-cleanup.sh +++ /dev/null @@ -1,30 +0,0 @@ -#!/bin/bash - -function print_usage() -{ -if [ -n "$2" ]; then -echo "Error: $2" -echo -fi -echo "Usage: $1 " -} - -scratch_dir=$1 -if [ -z "$scratch_dir" ]; then -print_usage "$0" 'Scratch dir not given' >&2 -exit 1 -fi - -cd "$scratch_dir/share" || exit 1 - -mps=(mnt*) -mp_i=0 -for mp in "${mps[@]}"; do -mp_i=$((mp_i + 1)) -printf "Unmounting %i/%i...\r" "$mp_i" "${#mps[@]}" - -sudo umount -R "$mp" -done -echo - -echo 'Done.' diff --git a/tests/avocado/virtiofs_submounts.py.data/guest.sh b/tests/avocado/virtiofs_submounts.py.data/guest.sh deleted file mode 100644 index 59ba40fde1..00 --- a/tests/avocado/virtiofs_submounts.py.data/guest.sh +++ /dev/null @@ -1,138 +0,0 @@ -#!/bin/bash - -function print_usage() -{ -if [ -n "$2" ]; then -echo "Error: $2" -echo -fi -echo "Usage: $1 " -echo '(The shared directory is the "share" directory in the scratch' \ - 'directory)' -} - -shared_dir=$1 -if [ -z "$shared_dir" ]; then -print_usage "$0" 'Shared dir not given' >&2 -exit 1 -fi - -cd "$shared_dir" - -# FIXME: This should not be necessary, but it is. In order for all -# submounts to be proper mount points, we need to visit them. -# (Before we visit them, they will not be auto-mounted, and so just -# appear as normal directories, with the catch that their st_ino will -# be the st_ino of the filesystem they host, while the st_dev will -# still be the st_dev of the parent.) -# `find` does not work, because it will refuse to touch the mount -# points as long as they are not mounted; their st_dev being shared -# with the parent and st_ino just being the root node's inode ID -# will practically ensure that this node exists elsewhere on the -# filesystem, and `find` is required to recognize loops and not to -# follow them. -# Thus, we have to manually visit all nodes first. - -mnt_i=0 - -function recursively_visit() -{ -pushd "$1" >/dev/null -for entry in *; do -if [[ "$entry" == mnt* ]]; then -mnt_i=$((mnt_i + 1)) -printf "Triggering auto-mount $mnt_i...\r" -fi - -if [ -d "$entry" ]; then -recursively_visit "$entry" -fi -done -popd >/dev/null -} - -recursively_visit . -echo - - -if [ -n "$(find -name not-mounted)" ]; then -echo "Error: not-mounted files visible on mount points:" >&2 -find -name not-
[PATCH] guest-agent: document allow-rpcs in config file section
While the `allow-rpcs` option is documented in the CLI options section, it was missing in the section about the configuration file syntax. And while it's mentioned that "the list of keys follows the command line options", having `block-rpcs` there but not `allow-rpcs` seems like being a potential source of confusion; and as it's cheap to add let's just do so. Signed-off-by: Thomas Lamprecht --- docs/interop/qemu-ga.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/interop/qemu-ga.rst b/docs/interop/qemu-ga.rst index 72fb75a6f5..dd4245ece8 100644 --- a/docs/interop/qemu-ga.rst +++ b/docs/interop/qemu-ga.rst @@ -131,6 +131,7 @@ fsfreeze-hook string statedir string verboseboolean block-rpcs string list +allow-rpcs string list = === See also -- 2.39.2
Re: [PATCH v5 2/4] docs/interop/firmware.json: add new enum FirmwareArchitecture
On Thu, Jul 18, 2024 at 03:18:07PM GMT, Markus Armbruster wrote: > Thomas Weißschuh writes: > > > Only a small subset of all architectures supported by qemu make use of > > firmware files. Introduce and use a new enum to represent this. > > > > This also removes the dependency to machine.json from the global qapi > > definitions. > > > > Suggested-by: Daniel P. Berrangé > > Reviewed-by: Daniel P. Berrangé > > Signed-off-by: Thomas Weißschuh > > --- > > docs/interop/firmware.json | 29 +++-- > > 1 file changed, 27 insertions(+), 2 deletions(-) > > > > diff --git a/docs/interop/firmware.json b/docs/interop/firmware.json > > index a26fe81bf2fe..2eb0be11d595 100644 > > --- a/docs/interop/firmware.json > > +++ b/docs/interop/firmware.json > > @@ -14,7 +14,10 @@ > > # = Firmware > > ## > > > > -{ 'include' : 'machine.json' } > > +{ 'pragma': { > > +'member-name-exceptions': [ > > +'FirmwareArchitecture' # x86_64 > > +] } } > > > > ## > > # @FirmwareOSInterface: > > @@ -59,6 +62,28 @@ > > { 'enum' : 'FirmwareDevice', > >'data' : [ 'flash', 'kernel', 'memory' ] } > > > > +## > > +# @FirmwareArchitecture: > > +# > > +# Enumerations of architectures for which Qemu uses additional firmware > > files. > > docs/devel/qapi-code-gen.rst section "Documentation markup": > > For legibility, wrap text paragraphs so every line is at most 70 > characters long. > > > +# The values are a subset of the enum SysEmuTarget. Ack. > Will consumers of firmware.json care for this? Most probably not. > Or is it just a reminder for developers to keep the two enums in sync? I guess so. Should I drop it? > > > +# > > +# @aarch64: 64-bit Arm. > > +# > > +# @arm: 32-bit Arm. > > +# > > +# @i386: 32-bit x86. > > +# > > +# @loongarch64: 64-bit LoongArch. > > +# > > +# @x86_64: 64-bit x86. > > +# > > +# Since: 9.1 > > The enum type is indeed since 9.1, but its members are since 3.0, and > that's what matters. Except for @loongarch, which is since 7.1.0 (not > documented in qapi/machine.json; I'll fix that). > > > +## > > +{ 'enum' : 'FirmwareArchitecture', > > + 'data' : [ 'aarch64', 'arm', 'i386', 'loongarch64', 'x86_64' ] } > > + > > + > > Drop one blank line, please. Ack. > > > ## > > # @FirmwareTarget: > > # > > @@ -80,7 +105,7 @@ > > # Since: 3.0 > > ## > > { 'struct' : 'FirmwareTarget', > > - 'data' : { 'architecture' : 'SysEmuTarget', > > + 'data' : { 'architecture' : 'FirmwareArchitecture', > > 'machines' : [ 'str' ] } } > > > > ## >
Re: [PATCH v5 1/4] docs/interop/firmware.json: add new enum FirmwareFormat
On Thu, Jul 18, 2024 at 03:09:37PM GMT, Markus Armbruster wrote: > Thomas Weißschuh writes: > > > Only a small subset of all blockdev drivers make sense for firmware > > images. Introduce and use a new enum to represent this. > > > > This also reduces the dependency on firmware.json from the global qapi > > definitions. > > > > Suggested-by: Daniel P. Berrangé > > Reviewed-by: Daniel P. Berrangé > > Signed-off-by: Thomas Weißschuh > > --- > > docs/interop/firmware.json | 17 +++-- > > 1 file changed, 15 insertions(+), 2 deletions(-) > > > > diff --git a/docs/interop/firmware.json b/docs/interop/firmware.json > > index 54a1fc6c1041..a26fe81bf2fe 100644 > > --- a/docs/interop/firmware.json > > +++ b/docs/interop/firmware.json > > @@ -15,7 +15,6 @@ > > ## > > > > { 'include' : 'machine.json' } > > -{ 'include' : 'block-core.json' } > > > > ## > > # @FirmwareOSInterface: > > @@ -200,6 +199,20 @@ > > 'enrolled-keys', 'requires-smm', 'secure-boot', > > 'verbose-dynamic', 'verbose-static' ] } > > > > +## > > +# @FirmwareFormat: > > +# > > +# Formats that are supported for firmware images. > > +# > > +# @raw: Raw disk image format. > > +# > > +# @qcow2: QEMU image format. > > It's not the only QEMU image format... Maybe "The QCOW2 image format." > Almost tautological, but I don't have better ideas. I used the wording from qemu-img(1). If you prefer "The QCOW2 image format", I'll switch to that. > > +# > > +# Since: 9.1 > > The enum type is indeed since 9.1, but its two members are since 3.0, > and that's what matters. Ack. So I change the Since: of the whole enum? And not on the individual members? > > +## > > +{ 'enum': 'FirmwareFormat', > > + 'data': [ 'raw', 'qcow2' ] } > > + > > ## > > # @FirmwareFlashFile: > > # > > @@ -219,7 +232,7 @@ > > ## > > { 'struct' : 'FirmwareFlashFile', > >'data' : { 'filename' : 'str', > > - 'format' : 'BlockdevDriver' } } > > + 'format' : 'FirmwareFormat' } } > > > > > > ## >
[PATCH v5 0/4] docs/interop/firmware.json: scripts/qapi-gen.py compatibility
docs/interop/firmware.json is currently not usable with qapi-gen.py due to various non-functional issues. Fix those issue to provide compatibility. Sorry for the quick resend, but the series got broken by the just-merged pull "pull-qapi-2024-07-17" which made the newly introduced patch 3 necessary. Signed-off-by: Thomas Weißschuh --- Changes in v5: - Add Reviewed-by from Daniel - Add patch to drop Example section - Link to v4: https://lore.kernel.org/r/20240718-qapi-firmware-json-v4-0-449ce672d...@linutronix.de Changes in v4: - Update "since" to 9.1 - Add comment to 'member-name-exceptions' - Document enum members and drop 'documentation-exceptions' - Link to v3: https://lore.kernel.org/r/20240311-qapi-firmware-json-v3-0-ceea6e35e...@linutronix.de Changes in v3: - Drop already picked up patches - Drop include of pragma.json - Introduce new enums FirmwareFormat and FirmwareArchitecture - Link to v2: https://lore.kernel.org/r/20240307-qapi-firmware-json-v2-0-3b29eabb9...@linutronix.de Changes in v2: - Add review tag from Philippe - Add Fixes tag (Philippe) - Add testcase (Philippe) - Link to v1: https://lore.kernel.org/r/20240306-qapi-firmware-json-v1-0-619f7122a...@linutronix.de --- Thomas Weißschuh (4): docs/interop/firmware.json: add new enum FirmwareFormat docs/interop/firmware.json: add new enum FirmwareArchitecture docs/interop/firmware.json: convert "Example" section docs: add test for firmware.json QAPI docs/interop/firmware.json | 48 +- docs/meson.build | 5 + 2 files changed, 48 insertions(+), 5 deletions(-) --- base-commit: d74ec4d7dda6322bcc51d1b13ccbd993d3574795 change-id: 20240306-qapi-firmware-json-6fb1213936dd Best regards, -- Thomas Weißschuh
[PATCH v5 2/4] docs/interop/firmware.json: add new enum FirmwareArchitecture
Only a small subset of all architectures supported by qemu make use of firmware files. Introduce and use a new enum to represent this. This also removes the dependency to machine.json from the global qapi definitions. Suggested-by: Daniel P. Berrangé Reviewed-by: Daniel P. Berrangé Signed-off-by: Thomas Weißschuh --- docs/interop/firmware.json | 29 +++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/docs/interop/firmware.json b/docs/interop/firmware.json index a26fe81bf2fe..2eb0be11d595 100644 --- a/docs/interop/firmware.json +++ b/docs/interop/firmware.json @@ -14,7 +14,10 @@ # = Firmware ## -{ 'include' : 'machine.json' } +{ 'pragma': { +'member-name-exceptions': [ +'FirmwareArchitecture' # x86_64 +] } } ## # @FirmwareOSInterface: @@ -59,6 +62,28 @@ { 'enum' : 'FirmwareDevice', 'data' : [ 'flash', 'kernel', 'memory' ] } +## +# @FirmwareArchitecture: +# +# Enumerations of architectures for which Qemu uses additional firmware files. +# The values are a subset of the enum SysEmuTarget. +# +# @aarch64: 64-bit Arm. +# +# @arm: 32-bit Arm. +# +# @i386: 32-bit x86. +# +# @loongarch64: 64-bit LoongArch. +# +# @x86_64: 64-bit x86. +# +# Since: 9.1 +## +{ 'enum' : 'FirmwareArchitecture', + 'data' : [ 'aarch64', 'arm', 'i386', 'loongarch64', 'x86_64' ] } + + ## # @FirmwareTarget: # @@ -80,7 +105,7 @@ # Since: 3.0 ## { 'struct' : 'FirmwareTarget', - 'data' : { 'architecture' : 'SysEmuTarget', + 'data' : { 'architecture' : 'FirmwareArchitecture', 'machines' : [ 'str' ] } } ## -- 2.45.2
[PATCH v5 3/4] docs/interop/firmware.json: convert "Example" section
Since commit 3c5f6114d9ff ("qapi: remove "Example" doc section") the "Example" section is not valid anymore. It has been replaced by the "qmp-example" role. This was not detected earlier as firmware.json was not validated. As this validation is about to be added, adapt firmware.json. Signed-off-by: Thomas Weißschuh --- docs/interop/firmware.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/interop/firmware.json b/docs/interop/firmware.json index 2eb0be11d595..eea82eef3a07 100644 --- a/docs/interop/firmware.json +++ b/docs/interop/firmware.json @@ -471,7 +471,7 @@ # # Since: 3.0 # -# Examples: +# .. qmp-example:: # # { # "description": "SeaBIOS", -- 2.45.2
[PATCH v5 4/4] docs: add test for firmware.json QAPI
To make sure that the QAPI description stays valid add a testcase. Suggested-by: Philippe Mathieu-Daudé Link: https://lore.kernel.org/qemu-devel/d9ce0234-4beb-4b90-b14c-76810d3b8...@linaro.org/ Reviewed-by: Daniel P. Berrangé Signed-off-by: Thomas Weißschuh --- docs/meson.build | 5 + 1 file changed, 5 insertions(+) diff --git a/docs/meson.build b/docs/meson.build index 9040f860ae1a..bcca45a342a3 100644 --- a/docs/meson.build +++ b/docs/meson.build @@ -99,3 +99,8 @@ if build_docs alias_target('html', sphinxdocs) alias_target('man', sphinxmans) endif + +test('QAPI firmware.json regression tests', python, + args: [qapi_gen.full_path(), '-o', meson.current_build_dir() / 'qapi', +meson.current_source_dir() / 'interop/firmware.json'], + env: test_env, suite: ['qapi-schema', 'qapi-interop']) -- 2.45.2
[PATCH v5 1/4] docs/interop/firmware.json: add new enum FirmwareFormat
Only a small subset of all blockdev drivers make sense for firmware images. Introduce and use a new enum to represent this. This also reduces the dependency on firmware.json from the global qapi definitions. Suggested-by: Daniel P. Berrangé Reviewed-by: Daniel P. Berrangé Signed-off-by: Thomas Weißschuh --- docs/interop/firmware.json | 17 +++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/docs/interop/firmware.json b/docs/interop/firmware.json index 54a1fc6c1041..a26fe81bf2fe 100644 --- a/docs/interop/firmware.json +++ b/docs/interop/firmware.json @@ -15,7 +15,6 @@ ## { 'include' : 'machine.json' } -{ 'include' : 'block-core.json' } ## # @FirmwareOSInterface: @@ -200,6 +199,20 @@ 'enrolled-keys', 'requires-smm', 'secure-boot', 'verbose-dynamic', 'verbose-static' ] } +## +# @FirmwareFormat: +# +# Formats that are supported for firmware images. +# +# @raw: Raw disk image format. +# +# @qcow2: QEMU image format. +# +# Since: 9.1 +## +{ 'enum': 'FirmwareFormat', + 'data': [ 'raw', 'qcow2' ] } + ## # @FirmwareFlashFile: # @@ -219,7 +232,7 @@ ## { 'struct' : 'FirmwareFlashFile', 'data' : { 'filename' : 'str', - 'format' : 'BlockdevDriver' } } + 'format' : 'FirmwareFormat' } } ## -- 2.45.2
Re: [PATCH 1/2] ci: add gtk-vnc to the deps
On 18/07/2024 11.41, Daniel P. Berrangé wrote: The gtk-vnc package is used by the vnc-display-test qtest program. Technically only gvnc is needed, but since we already pull in the gtk3 dep, it is harmless to depend on gtk-vnc. Signed-off-by: Daniel P. Berrangé --- tests/lcitool/projects/qemu.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/lcitool/projects/qemu.yml b/tests/lcitool/projects/qemu.yml index 0c85784259..252e871f80 100644 --- a/tests/lcitool/projects/qemu.yml +++ b/tests/lcitool/projects/qemu.yml @@ -32,6 +32,7 @@ packages: - glusterfs - gnutls - gtk3 + - gtk-vnc - hostname - json-c - libaio Reviewed-by: Thomas Huth IIRC Alex has a patch in his queue already to refresh the docker images, maybe he could include this change there, too...?
[PATCH v4 3/3] docs: add test for firmware.json QAPI
To make sure that the QAPI description stays valid add a testcase. Suggested-by: Philippe Mathieu-Daudé Link: https://lore.kernel.org/qemu-devel/d9ce0234-4beb-4b90-b14c-76810d3b8...@linaro.org/ Signed-off-by: Thomas Weißschuh --- docs/meson.build | 5 + 1 file changed, 5 insertions(+) diff --git a/docs/meson.build b/docs/meson.build index 9040f860ae1a..bcca45a342a3 100644 --- a/docs/meson.build +++ b/docs/meson.build @@ -99,3 +99,8 @@ if build_docs alias_target('html', sphinxdocs) alias_target('man', sphinxmans) endif + +test('QAPI firmware.json regression tests', python, + args: [qapi_gen.full_path(), '-o', meson.current_build_dir() / 'qapi', +meson.current_source_dir() / 'interop/firmware.json'], + env: test_env, suite: ['qapi-schema', 'qapi-interop']) -- 2.45.2
[PATCH v4 0/3] docs/interop/firmware.json: scripts/qapi-gen.py compatibility
docs/interop/firmware.json is currently not usable with qapi-gen.py due to various non-functional issues. Fix those issue to provide compatibility. In v3 there was an open question about @file vs. @raw, but given that the existing descriptors in pc-bios/descriptors/ are already using @raw it seems clear the we have to keep it. Signed-off-by: Thomas Weißschuh --- Changes in v4: - Update "since" to 9.1 - Add comment to 'member-name-exceptions' - Document enum members and drop 'documentation-exceptions' - Link to v3: https://lore.kernel.org/r/20240311-qapi-firmware-json-v3-0-ceea6e35e...@linutronix.de Changes in v3: - Drop already picked up patches - Drop include of pragma.json - Introduce new enums FirmwareFormat and FirmwareArchitecture - Link to v2: https://lore.kernel.org/r/20240307-qapi-firmware-json-v2-0-3b29eabb9...@linutronix.de Changes in v2: - Add review tag from Philippe - Add Fixes tag (Philippe) - Add testcase (Philippe) - Link to v1: https://lore.kernel.org/r/20240306-qapi-firmware-json-v1-0-619f7122a...@linutronix.de --- Thomas Weißschuh (3): docs/interop/firmware.json: add new enum FirmwareFormat docs/interop/firmware.json: add new enum FirmwareArchitecture docs: add test for firmware.json QAPI docs/interop/firmware.json | 46 ++ docs/meson.build | 5 + 2 files changed, 47 insertions(+), 4 deletions(-) --- base-commit: 58ee924b97d1c0898555647a31820c5a20d55a73 change-id: 20240306-qapi-firmware-json-6fb1213936dd Best regards, -- Thomas Weißschuh
[PATCH v4 1/3] docs/interop/firmware.json: add new enum FirmwareFormat
Only a small subset of all blockdev drivers make sense for firmware images. Introduce and use a new enum to represent this. This also reduces the dependency on firmware.json from the global qapi definitions. Suggested-by: Daniel P. Berrangé Signed-off-by: Thomas Weißschuh --- docs/interop/firmware.json | 17 +++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/docs/interop/firmware.json b/docs/interop/firmware.json index 54a1fc6c1041..a26fe81bf2fe 100644 --- a/docs/interop/firmware.json +++ b/docs/interop/firmware.json @@ -15,7 +15,6 @@ ## { 'include' : 'machine.json' } -{ 'include' : 'block-core.json' } ## # @FirmwareOSInterface: @@ -200,6 +199,20 @@ 'enrolled-keys', 'requires-smm', 'secure-boot', 'verbose-dynamic', 'verbose-static' ] } +## +# @FirmwareFormat: +# +# Formats that are supported for firmware images. +# +# @raw: Raw disk image format. +# +# @qcow2: QEMU image format. +# +# Since: 9.1 +## +{ 'enum': 'FirmwareFormat', + 'data': [ 'raw', 'qcow2' ] } + ## # @FirmwareFlashFile: # @@ -219,7 +232,7 @@ ## { 'struct' : 'FirmwareFlashFile', 'data' : { 'filename' : 'str', - 'format' : 'BlockdevDriver' } } + 'format' : 'FirmwareFormat' } } ## -- 2.45.2
[PATCH v4 2/3] docs/interop/firmware.json: add new enum FirmwareArchitecture
Only a small subset of all architectures supported by qemu make use of firmware files. Introduce and use a new enum to represent this. This also removes the dependency to machine.json from the global qapi definitions. Suggested-by: Daniel P. Berrangé Signed-off-by: Thomas Weißschuh --- docs/interop/firmware.json | 29 +++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/docs/interop/firmware.json b/docs/interop/firmware.json index a26fe81bf2fe..2eb0be11d595 100644 --- a/docs/interop/firmware.json +++ b/docs/interop/firmware.json @@ -14,7 +14,10 @@ # = Firmware ## -{ 'include' : 'machine.json' } +{ 'pragma': { +'member-name-exceptions': [ +'FirmwareArchitecture' # x86_64 +] } } ## # @FirmwareOSInterface: @@ -59,6 +62,28 @@ { 'enum' : 'FirmwareDevice', 'data' : [ 'flash', 'kernel', 'memory' ] } +## +# @FirmwareArchitecture: +# +# Enumerations of architectures for which Qemu uses additional firmware files. +# The values are a subset of the enum SysEmuTarget. +# +# @aarch64: 64-bit Arm. +# +# @arm: 32-bit Arm. +# +# @i386: 32-bit x86. +# +# @loongarch64: 64-bit LoongArch. +# +# @x86_64: 64-bit x86. +# +# Since: 9.1 +## +{ 'enum' : 'FirmwareArchitecture', + 'data' : [ 'aarch64', 'arm', 'i386', 'loongarch64', 'x86_64' ] } + + ## # @FirmwareTarget: # @@ -80,7 +105,7 @@ # Since: 3.0 ## { 'struct' : 'FirmwareTarget', - 'data' : { 'architecture' : 'SysEmuTarget', + 'data' : { 'architecture' : 'FirmwareArchitecture', 'machines' : [ 'str' ] } } ## -- 2.45.2
Re: [PATCH 04/11] tests/functional: Add python-based tests to the meson build system
On 16/07/2024 17.15, Fabiano Rosas wrote: Thomas Huth writes: Integrate the new python-based test framework with the meson build system. Since these tests now require the pycotap module, make sure that it gets installed in the venv. The changes to the meson.build files are partly based on an earlier patch by Ani Sinha (but heavily modified by Thomas Huth e.g. to use pycotap for running the tests instead). Signed-off-by: Thomas Huth Just one touch-up below. Reviewed-by: Fabiano Rosas --- pythondeps.toml | 3 +- tests/Makefile.include | 18 - tests/functional/meson.build | 75 tests/meson.build| 1 + 4 files changed, 95 insertions(+), 2 deletions(-) create mode 100644 tests/functional/meson.build diff --git a/pythondeps.toml b/pythondeps.toml index f6e590fdd8..c018b4d74a 100644 --- a/pythondeps.toml +++ b/pythondeps.toml @@ -26,9 +26,10 @@ meson = { accepted = ">=1.1.0", installed = "1.2.3", canary = "meson" } sphinx = { accepted = ">=3.4.3", installed = "5.3.0", canary = "sphinx-build" } sphinx_rtd_theme = { accepted = ">=0.5", installed = "1.1.1" } -[avocado] +[tests] # Note that qemu.git/python/ is always implicitly installed. # Prefer an LTS version when updating the accepted versions of # avocado-framework, for example right now the limit is 92.x. avocado-framework = { accepted = "(>=88.1, <93.0)", installed = "88.1", canary = "avocado" } pycdlib = { accepted = ">=1.11.0" } +pycotap = { accepted = ">=1.1.0" } diff --git a/tests/Makefile.include b/tests/Makefile.include index d39d5dd6a4..2bdf607977 100644 --- a/tests/Makefile.include +++ b/tests/Makefile.include @@ -9,6 +9,8 @@ check-help: @echo "Individual test suites:" @echo " $(MAKE) check-qtest-TARGET Run qtest tests for given target" @echo " $(MAKE) check-qtestRun qtest tests" + @echo " $(MAKE) check-functional Run python-based functional tests" + @echo " $(MAKE) check-functional-TARG Run functional tests for a given target" @echo " $(MAKE) check-unit Run qobject tests" @echo " $(MAKE) check-qapi-schema Run QAPI schema tests" @echo " $(MAKE) check-blockRun block tests" @@ -111,7 +113,7 @@ quiet-venv-pip = $(quiet-@)$(call quiet-command-run, \ $(TESTS_VENV_TOKEN): $(SRC_PATH)/pythondeps.toml $(call quiet-venv-pip,install -e "$(SRC_PATH)/python/") - $(MKVENV_ENSUREGROUP) $< avocado + $(MKVENV_ENSUREGROUP) $< tests $(call quiet-command, touch $@) $(TESTS_RESULTS_DIR): @@ -152,6 +154,20 @@ check-acceptance-deprecated-warning: check-acceptance: check-acceptance-deprecated-warning | check-avocado +# Make sure that pycotap is installed before running any functional tests: +ifneq ($(filter check-func%,$(MAKECMDGOALS))$(filter check,$(MAKECMDGOALS)),) +do-meson-check: check-venv +endif + +FUNCTIONAL_TARGETS=$(patsubst %-softmmu,check-functional-%, $(filter %-softmmu,$(TARGETS))) +.PHONY: $(FUNCTIONAL_TARGETS) +$(FUNCTIONAL_TARGETS): + @make SPEED=thorough $(subst -functional,-func,$@) + +.PHONY: check-functional +check-functional: + @make SPEED=thorough check-func check-func-quick I think these^ two should use $(MAKE) instead: make[1]: warning: jobserver unavailable: using -j1. Add '+' to parent make rule. Right, thanks! I'll change it in the next version. Thomas
Re: [PATCH v1 00/11] Convert avocado tests to normal Python unittests
On 17/07/2024 10.37, Daniel P. Berrangé wrote: On Wed, Jul 17, 2024 at 10:04:19AM +0200, Thomas Huth wrote: On 16/07/2024 19.03, Thomas Huth wrote: On 16/07/2024 18.51, Daniel P. Berrangé wrote: On Tue, Jul 16, 2024 at 01:26:03PM +0200, Thomas Huth wrote: ... So instead of trying to update the python-based test suite in QEMU to a newer version of Avocado, we should maybe try to better integrate it with the meson test runner instead. Indeed most tests work quite nicely without the Avocado framework already, as you can see with this patch series - it does not convert all tests, just a subset so far, but this already proves that many tests only need small modifi- cations to work without Avocado. ... Now if you want to try out these patches: Apply the patches, then recompile and then run: make check-functional You can also run single targets e.g. with: make check-functional-ppc You can also run the tests without any test runner now by setting the PYTHONPATH environment variable to the "python" folder of your source tree, and by specifying the build directory via QEMU_BUILD_ROOT (if autodetection fails) and by specifying the QEMU binary via QEMU_TEST_QEMU_BINARY. For example: export PYTHONPATH=$HOME/qemu/python export QEMU_TEST_QEMU_BINARY=qemu-system-x86_64 export PYTHONPATH=$HOME/qemu/build ~/qemu/tests/functional/test_virtio_version.py For the whole series as is Tested-by: Daniel P. Berrangé as it does what you claim it does here when I tried it. Thanks! The logs of the tests can be found in the build directory under tests/functional/ - console log and general logs will be put in separate files there. As an example, one dir name appears to be: __main__.MemAddrCheck.test_phybits_ok_pentium_pae I'd rather prefer it if the dir name matched the test script file name - in this case test_mem_addr_space.py, as I don't want to have to lookup which class names were defined inside each test script. We could drop the "test_" prefix from the method name too IOW, could we make this dir name be: test_mem_addr_space.phybits_ok_pentium_pae I can try to change that, indeed ... but the boilerplate code will increase a little bit, I guess, since I cannot simply rely on the unittest.id() function in that case anymore... After looking at this for a while, I think it's maybe best to ditch the idea of making the .py files directly runnable and run the tests via a simple pycotap runner instead. Then you get proper module names: I'd really not want to loose that. To me, eliminating the test harness entirely when debugging is the single biggest improvement of this new approach, especially when I want to 'strace' the test without extraneous processes. $ pyvenv/bin/python3 -m pycotap test_virtio_version TAP version 13 ok 1 test_virtio_version.VirtioVersionCheck.test_conventional_devs ok 2 test_virtio_version.VirtioVersionCheck.test_modern_only_devs 1.. With the following change, you get the same output with direct execution, by making argv look the same as you'd get when running your pycotap example. diff --git a/tests/functional/qemu_test/__init__.py b/tests/functional/qemu_test/__init__.py index cc49fd4c94..3a3e65252d 100644 --- a/tests/functional/qemu_test/__init__.py +++ b/tests/functional/qemu_test/__init__.py @@ -266,7 +266,10 @@ def fetch_asset(self, url, asset_hash): def main(): tr = pycotap.TAPTestRunner(message_log = pycotap.LogMode.LogToError, test_output_log = pycotap.LogMode.LogToError) -unittest.main(testRunner = tr) +import sys +import os.path +path = os.path.basename(sys.argv[0])[:-3] +unittest.main(module = None, testRunner = tr, argv=["__dummy__", path]) Sweet, thank you very much, looks like this will do the job! Thomas
Re: [PATCH v1 00/11] Convert avocado tests to normal Python unittests
On 16/07/2024 19.03, Thomas Huth wrote: On 16/07/2024 18.51, Daniel P. Berrangé wrote: On Tue, Jul 16, 2024 at 01:26:03PM +0200, Thomas Huth wrote: ... So instead of trying to update the python-based test suite in QEMU to a newer version of Avocado, we should maybe try to better integrate it with the meson test runner instead. Indeed most tests work quite nicely without the Avocado framework already, as you can see with this patch series - it does not convert all tests, just a subset so far, but this already proves that many tests only need small modifi- cations to work without Avocado. ... Now if you want to try out these patches: Apply the patches, then recompile and then run: make check-functional You can also run single targets e.g. with: make check-functional-ppc You can also run the tests without any test runner now by setting the PYTHONPATH environment variable to the "python" folder of your source tree, and by specifying the build directory via QEMU_BUILD_ROOT (if autodetection fails) and by specifying the QEMU binary via QEMU_TEST_QEMU_BINARY. For example: export PYTHONPATH=$HOME/qemu/python export QEMU_TEST_QEMU_BINARY=qemu-system-x86_64 export PYTHONPATH=$HOME/qemu/build ~/qemu/tests/functional/test_virtio_version.py For the whole series as is Tested-by: Daniel P. Berrangé as it does what you claim it does here when I tried it. Thanks! The logs of the tests can be found in the build directory under tests/functional/ - console log and general logs will be put in separate files there. As an example, one dir name appears to be: __main__.MemAddrCheck.test_phybits_ok_pentium_pae I'd rather prefer it if the dir name matched the test script file name - in this case test_mem_addr_space.py, as I don't want to have to lookup which class names were defined inside each test script. We could drop the "test_" prefix from the method name too IOW, could we make this dir name be: test_mem_addr_space.phybits_ok_pentium_pae I can try to change that, indeed ... but the boilerplate code will increase a little bit, I guess, since I cannot simply rely on the unittest.id() function in that case anymore... After looking at this for a while, I think it's maybe best to ditch the idea of making the .py files directly runnable and run the tests via a simple pycotap runner instead. Then you get proper module names: $ pyvenv/bin/python3 -m pycotap test_virtio_version TAP version 13 ok 1 test_virtio_version.VirtioVersionCheck.test_conventional_devs ok 2 test_virtio_version.VirtioVersionCheck.test_modern_only_devs 1..2 Thomas
Re: [RFC PATCH 0/8] Convert avocado tests to normal Python unittests
On 16/07/2024 20.03, Paolo Bonzini wrote: Il mar 16 lug 2024, 18:45 John Snow <mailto:js...@redhat.com>> ha scritto: My only ask is that we keep the tests running in the custom venv environment we set up at build time Yes, they do, however pytest should also be added to pythondeps.toml if we go this way. If we move to pytest, it's possible we can eliminate that funkiness, which would be a win. There is the pycotap dependency to produce TAP from pytest, but that's probably something small enough to be vendored. The next version is only depending on pycotap now. I'm installing it in the venv there that we also install when running the old avocado tests. Not sure whether that's the best solution, though. Would it be OK to have it in python/wheels/ instead? And also it depends on what the dependencies would be for the assets framework. > I'm also not so sure about recreating all of the framework that pulls vm images on demand, that sounds like it'd be a lot of work, but maybe I'm wrong about that. Yep, that's the part that I am a bit more doubtful about. As I'm mentioned elsewhere, the tests that really have a hard dependency on the Avocado framework are only the tests that use the cloud-init images via the LinuxTest class. That's currently onle these files: - boot_linux.py - hotplug_blk.py - hotplug_cpu.py - intel_iommu.py - replay_linux.py - smmu.py I assume we could continue using avocado.utils for the cloud-init stuff there, and just run them via the meson test runner, too. I'll give it a try when I get some spare time. Thomas
Re: [RFC PATCH 0/8] Convert avocado tests to normal Python unittests
On 16/07/2024 18.45, John Snow wrote: On Thu, Jul 11, 2024, 7:55 AM Thomas Huth <mailto:th...@redhat.com>> wrote: ... - I haven't looked into logging yet ... this still needs some work so that you could e.g. inspect the console output of the guests somewhere FWIW: This is now done in the next version of the patch series: https://lore.kernel.org/qemu-devel/20240716112614.1755692-10-th...@redhat.com/ This has spilled the most developer blood of any other problem with the Python-based tests. Be very careful here. Apart from 1:1 copying the functions from one __init__.py file to the other, and from setting up the logger so that it writes its output to a file, I didn't have to change anything. It currently simply seems to work. I still have a prototype for replacing QMPMachine with an asyncio variant that should have more robust logging features, but I put it on the back-burner. Avocado tests are the primary user of the QMP Machine interface I hate the very most, a multi-threaded buffer-reader that works only by the grace of god. If you do go down this path, I may want to take the opportunity to abolish that interface once and for all. > I think simplifying the console buffering will help ease debuggability. Feel free to do improvements on top! I think it should be easier now when there are no more complicated mixtures with the avocado test runner. What's your thoughts? Is it worth to continue with this approach? Or shall I rather forget about it and wait for the Avocado version update? I'm personally ambivalent on avocado; I use it for the python self-tests as dogfooding but I can likely switch back over to plain pytest if that's the direction we head. I don't think I use any crazy features except some asyncio helpers i advocated for. I'm not sure what pytest's asyncio support looks like, but I have to imagine as the premier testing framework that it has *something* for me to use. There's no more pytest harness in the next iteration of the patch series, just the need for pycotap for TAP output. Console logging is completely independent of the test runner, I'll simply do normal logging to files there. My only ask is that we keep the tests running in the custom venv environment we set up at build time. We have some funky post-hoc initialization of avocado that allows us to use internet packages post-config for testing purposes. If we move to pytest, it's possible we can eliminate that funkiness, which would be a win. I still need a way for making sure that pycotap is installed, though, so the venv is still there. I'm also not so sure about recreating all of the framework that pulls vm images on demand, that sounds like it'd be a lot of work, but maybe I'm wrong about that. It likely does not make sense to rewrite the tests that use these cloud-init images (i.e. the ones that depend on the LinuxTest class). But we could likely simply continue to use avocado.utils for these, without using the avocado test runner. Tacit ACK from me on this project in general, provided we are still using the configure venv. Thanks, Thomas
Re: [PATCH] tests: increase timeout per instance of bios-tables-test
On 16/07/2024 15.06, Michael S. Tsirkin wrote: On Tue, Jul 16, 2024 at 02:59:30PM +0200, Igor Mammedov wrote: CI often fails 'cross-i686-tci' job due to runner slowness Log shows that test almost complete, with a few remaining when bios-tables-test timeout hits: 19/270 qemu:qtest+qtest-aarch64 / qtest-aarch64/bios-tables-test TIMEOUT610.02s killed by signal 15 SIGTERM ... stderr: TAP parsing error: Too few tests run (expected 8, got 7) At the same time overall job running time is only ~30 out of 1hr allowed. Increase bios-tables-test instance timeout on 5min as a fix for slow CI runners. Signed-off-by: Igor Mammedov We can't just keep increasing the timeout. The issue is checking wall time on a busy host, isn't it? Let's check CPU time instead. The timeout setting comes from meson, not sure whether you can switch that easily to use CPU time instead of wall time? Anyway, if the bios-tables-test is getting more and more complex, it's maybe not such a good idea to run it in a job that is using TCI ... Maybe it's best to remove aarch64-softmmu from the cross-i686-tci job? Thomas
Re: [PATCH v1 00/11] Convert avocado tests to normal Python unittests
On 16/07/2024 18.51, Daniel P. Berrangé wrote: On Tue, Jul 16, 2024 at 01:26:03PM +0200, Thomas Huth wrote: ... So instead of trying to update the python-based test suite in QEMU to a newer version of Avocado, we should maybe try to better integrate it with the meson test runner instead. Indeed most tests work quite nicely without the Avocado framework already, as you can see with this patch series - it does not convert all tests, just a subset so far, but this already proves that many tests only need small modifi- cations to work without Avocado. ... Now if you want to try out these patches: Apply the patches, then recompile and then run: make check-functional You can also run single targets e.g. with: make check-functional-ppc You can also run the tests without any test runner now by setting the PYTHONPATH environment variable to the "python" folder of your source tree, and by specifying the build directory via QEMU_BUILD_ROOT (if autodetection fails) and by specifying the QEMU binary via QEMU_TEST_QEMU_BINARY. For example: export PYTHONPATH=$HOME/qemu/python export QEMU_TEST_QEMU_BINARY=qemu-system-x86_64 export PYTHONPATH=$HOME/qemu/build ~/qemu/tests/functional/test_virtio_version.py For the whole series as is Tested-by: Daniel P. Berrangé as it does what you claim it does here when I tried it. Thanks! The logs of the tests can be found in the build directory under tests/functional/ - console log and general logs will be put in separate files there. As an example, one dir name appears to be: __main__.MemAddrCheck.test_phybits_ok_pentium_pae I'd rather prefer it if the dir name matched the test script file name - in this case test_mem_addr_space.py, as I don't want to have to lookup which class names were defined inside each test script. We could drop the "test_" prefix from the method name too IOW, could we make this dir name be: test_mem_addr_space.phybits_ok_pentium_pae I can try to change that, indeed ... but the boilerplate code will increase a little bit, I guess, since I cannot simply rely on the unittest.id() function in that case anymore... Thomas
[PATCH 08/11] tests/functional: Convert some avocado tests that needed avocado.utils.archive
Instead of using the "archive" module from avocado.utils, switch these tests to use the new wrapper function that is based on the "tarfile" module instead. Signed-off-by: Thomas Huth --- MAINTAINERS | 6 ++--- tests/functional/meson.build | 6 + .../test_arm_canona1100.py} | 21 +--- .../test_ppc_bamboo.py} | 23 - .../test_sparc64_sun4u.py}| 25 +++ 5 files changed, 46 insertions(+), 35 deletions(-) rename tests/{avocado/machine_arm_canona1100.py => functional/test_arm_canona1100.py} (71%) mode change 100644 => 100755 rename tests/{avocado/ppc_bamboo.py => functional/test_ppc_bamboo.py} (75%) mode change 100644 => 100755 rename tests/{avocado/machine_sparc64_sun4u.py => functional/test_sparc64_sun4u.py} (60%) mode change 100644 => 100755 diff --git a/MAINTAINERS b/MAINTAINERS index 533e22b548..025227954c 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -730,7 +730,7 @@ S: Odd Fixes F: include/hw/arm/digic.h F: hw/*/digic* F: include/hw/*/digic* -F: tests/avocado/machine_arm_canona1100.py +F: tests/functional/test_arm_canona1100.py F: docs/system/arm/digic.rst Goldfish RTC @@ -1425,7 +1425,7 @@ L: qemu-...@nongnu.org S: Orphan F: hw/ppc/ppc440_bamboo.c F: hw/pci-host/ppc4xx_pci.c -F: tests/avocado/ppc_bamboo.py +F: tests/functional/test_ppc_bamboo.py e500 L: qemu-...@nongnu.org @@ -1711,7 +1711,7 @@ F: include/hw/pci-host/sabre.h F: hw/pci-bridge/simba.c F: include/hw/pci-bridge/simba.h F: pc-bios/openbios-sparc64 -F: tests/avocado/machine_sparc64_sun4u.py +F: tests/functional/test_sparc64_sun4u.py Sun4v M: Artyom Tarasenko diff --git a/tests/functional/meson.build b/tests/functional/meson.build index 947f9ac74f..c8fc9f6c07 100644 --- a/tests/functional/meson.build +++ b/tests/functional/meson.build @@ -22,6 +22,7 @@ tests_generic = [ ] tests_arm_thorough = [ + 'arm_canona1100', 'arm_n8x0', ] @@ -43,6 +44,11 @@ tests_ppc_quick = [ tests_ppc_thorough = [ 'ppc_405', + 'ppc_bamboo', +] + +tests_sparc64_thorough = [ + 'sparc64_sun4u', ] tests_x86_64_quick = [ diff --git a/tests/avocado/machine_arm_canona1100.py b/tests/functional/test_arm_canona1100.py old mode 100644 new mode 100755 similarity index 71% rename from tests/avocado/machine_arm_canona1100.py rename to tests/functional/test_arm_canona1100.py index a42d8b0f2b..de6169f2af --- a/tests/avocado/machine_arm_canona1100.py +++ b/tests/functional/test_arm_canona1100.py @@ -1,3 +1,5 @@ +#!/usr/bin/env python3 +# # Functional test that boots the canon-a1100 machine with firmware # # Copyright (c) 2020 Red Hat, Inc. @@ -8,9 +10,9 @@ # This work is licensed under the terms of the GNU GPL, version 2 or # later. See the COPYING file in the top-level directory. -from avocado_qemu import QemuSystemTest -from avocado_qemu import wait_for_console_pattern -from avocado.utils import archive +from qemu_test import QemuSystemTest +from qemu_test import wait_for_console_pattern +from qemu_test.utils import archive_extract class CanonA1100Machine(QemuSystemTest): """Boots the barebox firmware and checks that the console is operational""" @@ -18,18 +20,19 @@ class CanonA1100Machine(QemuSystemTest): timeout = 90 def test_arm_canona1100(self): -""" -:avocado: tags=arch:arm -:avocado: tags=machine:canon-a1100 -:avocado: tags=device:pflash_cfi02 -""" +self.set_machine('canon-a1100') + tar_url = ('https://qemu-advcal.gitlab.io' '/qac-best-of-multiarch/download/day18.tar.xz') tar_hash = '068b5fc4242b29381acee94713509f8a876e9db6' file_path = self.fetch_asset(tar_url, asset_hash=tar_hash) -archive.extract(file_path, self.workdir) +archive_extract(file_path, dest_dir=self.workdir, +member="day18/barebox.canon-a1100.bin") self.vm.set_console() self.vm.add_args('-bios', self.workdir + '/day18/barebox.canon-a1100.bin') self.vm.launch() wait_for_console_pattern(self, 'running /env/bin/init') + +if __name__ == '__main__': +QemuSystemTest.main() diff --git a/tests/avocado/ppc_bamboo.py b/tests/functional/test_ppc_bamboo.py old mode 100644 new mode 100755 similarity index 75% rename from tests/avocado/ppc_bamboo.py rename to tests/functional/test_ppc_bamboo.py index a81be3d608..652b31e95a --- a/tests/avocado/ppc_bamboo.py +++ b/tests/functional/test_ppc_bamboo.py @@ -1,3 +1,5 @@ +#!/usr/bin/env python3 +# # Test that Linux kernel boots on the ppc bamboo board and check the console # # Copyright (c) 2021 Red Hat @@ -5,30 +7,24 @@ # This work is licensed under the terms of the GNU GPL, version 2 or # later. See the COPYING file in
[PATCH 05/11] tests/functional: Implement fetch_asset() method for downloading assets
In the new python test framework, we cannot use the fetch_asset() function from Avocado anymore, so we have to provide our own implementation now instead. Thus add such a function based on the urllib python module for this purpose. Signed-off-by: Thomas Huth --- tests/functional/qemu_test/__init__.py | 36 ++ 1 file changed, 36 insertions(+) diff --git a/tests/functional/qemu_test/__init__.py b/tests/functional/qemu_test/__init__.py index e73705d40a..77c3b14d34 100644 --- a/tests/functional/qemu_test/__init__.py +++ b/tests/functional/qemu_test/__init__.py @@ -11,6 +11,8 @@ # 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 hashlib +import urllib.request import logging import os import pycotap @@ -23,6 +25,7 @@ import unittest from pathlib import Path +from shutil import copyfileobj from qemu.machine import QEMUMachine from qemu.utils import (get_info_usernet_hostfwd_port, kvm_available, tcg_available) @@ -215,6 +218,39 @@ def setUp(self, bin_prefix): if not os.path.exists(self.workdir): os.makedirs(self.workdir) +def check_hash(self, file_name, expected_hash): +if not expected_hash: +return True +if len(expected_hash) == 40: +sum_prog = 'sha1sum' +elif len(expected_hash) == 64: +sum_prog = 'sha256sum' +elif len(expected_hash) == 128: +sum_prog = 'sha512sum' +else: +raise Exception("unknown hash type") +checksum = subprocess.check_output([sum_prog, file_name]).split()[0] +return expected_hash == checksum.decode("utf-8") + +def fetch_asset(self, url, asset_hash): +cache_dir = os.path.expanduser("~/.cache/qemu/download") +if not os.path.exists(cache_dir): +os.makedirs(cache_dir) +fname = os.path.join(cache_dir, + hashlib.sha256(url.encode("utf-8")).hexdigest()) +if os.path.exists(fname) and self.check_hash(fname, asset_hash): +return fname +self.log.info("Downloading %s to %s...", url, fname) +dl_fname = fname + ".download" +with urllib.request.urlopen(url) as src: +with open(dl_fname, "wb+") as dst: +copyfileobj(src, dst) +if not self.check_hash(dl_fname, asset_hash): +os.remove(dl_fname) +raise Exception("Hash of " + url + " does not match") +os.rename(dl_fname, fname) +return fname + def main(): tr = pycotap.TAPTestRunner(message_log = pycotap.LogMode.LogToError, test_output_log = pycotap.LogMode.LogToError) -- 2.45.2
[PATCH 01/11] tests/functional: Add base classes for the upcoming pytest-based tests
The file is mostly a copy of the tests/avocado/avocado_qemu/__init__.py file with some adjustments to get rid of the Avocado dependencies (i.e. we also have to drop the LinuxSSHMixIn and LinuxTest for now). The emulator binary and build directory are now passed via environment variables that will be set via meson.build later. Signed-off-by: Thomas Huth --- tests/functional/qemu_test/__init__.py | 326 + 1 file changed, 326 insertions(+) create mode 100644 tests/functional/qemu_test/__init__.py diff --git a/tests/functional/qemu_test/__init__.py b/tests/functional/qemu_test/__init__.py new file mode 100644 index 00..e73705d40a --- /dev/null +++ b/tests/functional/qemu_test/__init__.py @@ -0,0 +1,326 @@ +# Test class and utilities for functional tests +# +# Copyright 2018, 2024 Red Hat, Inc. +# +# Original Author (Avocado-based tests): +# Cleber Rosa +# +# Adaption for standalone version: +# Thomas Huth +# +# 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 logging +import os +import pycotap +import shutil +import subprocess +import sys +import tempfile +import time +import uuid +import unittest + +from pathlib import Path +from qemu.machine import QEMUMachine +from qemu.utils import (get_info_usernet_hostfwd_port, kvm_available, +tcg_available) + +def _source_dir(): +# Determine top-level directory of the QEMU sources +return Path(__file__).parent.parent.parent.parent + +def _build_dir(): +root = os.getenv('QEMU_BUILD_ROOT') +if root is not None: +return Path(root) +# Makefile.mtest only exists in build dir, so if it is available, use CWD +if os.path.exists('Makefile.mtest'): +return Path(os.getcwd()) + +root = os.path.join(_source_dir(), 'build') +if os.path.exists(root): +return Path(root) + +raise Exception("Cannot identify build dir, set QEMU_BUILD_ROOT") + +def has_cmd(name, args=None): +""" +This function is for use in a @skipUnless decorator, e.g.: + +@skipUnless(*has_cmd('sudo -n', ('sudo', '-n', 'true'))) +def test_something_that_needs_sudo(self): +... +""" + +if args is None: +args = ('which', name) + +try: +_, stderr, exitcode = run_cmd(args) +except Exception as e: +exitcode = -1 +stderr = str(e) + +if exitcode != 0: +cmd_line = ' '.join(args) +err = f'{name} required, but "{cmd_line}" failed: {stderr.strip()}' +return (False, err) +else: +return (True, '') + +def has_cmds(*cmds): +""" +This function is for use in a @skipUnless decorator and +allows checking for the availability of multiple commands, e.g.: + +@skipUnless(*has_cmds(('cmd1', ('cmd1', '--some-parameter')), + 'cmd2', 'cmd3')) +def test_something_that_needs_cmd1_and_cmd2(self): +... +""" + +for cmd in cmds: +if isinstance(cmd, str): +cmd = (cmd,) + +ok, errstr = has_cmd(*cmd) +if not ok: +return (False, errstr) + +return (True, '') + +def run_cmd(args): +subp = subprocess.Popen(args, +stdout=subprocess.PIPE, +stderr=subprocess.PIPE, +universal_newlines=True) +stdout, stderr = subp.communicate() +ret = subp.returncode + +return (stdout, stderr, ret) + +def is_readable_executable_file(path): +return os.path.isfile(path) and os.access(path, os.R_OK | os.X_OK) + +def _console_interaction(test, success_message, failure_message, + send_string, keep_sending=False, vm=None): +assert not keep_sending or send_string +if vm is None: +vm = test.vm +console = vm.console_file +console_logger = logging.getLogger('console') +while True: +if send_string: +vm.console_socket.sendall(send_string.encode()) +if not keep_sending: +send_string = None # send only once +try: +msg = console.readline().decode().strip() +except UnicodeDecodeError: +msg = None +if not msg: +continue +console_logger.debug(msg) +if success_message is None or success_message in msg: +break +if failure_message and failure_message in msg: +console.close() +fail = 'Failure message found in console: "%s". Expected: "%s"' % \ +(failure_message, success_message) +test.fail(fail) + +def interrupt_interactive_console_until_pattern(test, success_message, +failure_message=None, +inte
[PATCH 07/11] tests/functional: Add a function for extracting files from an archive
Some Avocado-based tests use the "archive" module from avocado.utils to extract files from an archive. To be able to use these tests without Avocado, we have to provide our own function for extracting files. Fortunately, there is already the tarfile module that will provide us with this functionality, so let's just add a nice wrapper function around that. Signed-off-by: Thomas Huth --- tests/functional/qemu_test/utils.py | 21 + 1 file changed, 21 insertions(+) create mode 100644 tests/functional/qemu_test/utils.py diff --git a/tests/functional/qemu_test/utils.py b/tests/functional/qemu_test/utils.py new file mode 100644 index 00..4eb5e5d5e5 --- /dev/null +++ b/tests/functional/qemu_test/utils.py @@ -0,0 +1,21 @@ +# Utilities for python-based QEMU tests +# +# Copyright 2024 Red Hat, Inc. +# +# Authors: +# Thomas Huth +# +# 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 tarfile + +def archive_extract(archive, dest_dir, member=None): +with tarfile.open(archive) as tf: +if hasattr(tarfile, 'data_filter'): +tf.extraction_filter = getattr(tarfile, 'data_filter', + (lambda member, path: member)) +if member: +tf.extract(member=member, path=dest_dir) +else: +tf.extractall(path=dest_dir) -- 2.45.2
[PATCH 03/11] tests/functional: Convert avocado tests that just need a small adjustment
These simple tests can be converted to stand-alone tests quite easily, e.g. by just setting the machine to 'none' now manually or by adding "-cpu" command line parameters, since we don't support the corresponding avocado tags in the new python test framework. Signed-off-by: Thomas Huth --- .../test_info_usernet.py} | 11 ++- .../test_ppc_74xx.py} | 74 --- .../version.py => functional/test_version.py} | 13 ++-- 3 files changed, 47 insertions(+), 51 deletions(-) rename tests/{avocado/info_usernet.py => functional/test_info_usernet.py} (87%) mode change 100644 => 100755 rename tests/{avocado/ppc_74xx.py => functional/test_ppc_74xx.py} (74%) mode change 100644 => 100755 rename tests/{avocado/version.py => functional/test_version.py} (78%) mode change 100644 => 100755 diff --git a/tests/avocado/info_usernet.py b/tests/functional/test_info_usernet.py old mode 100644 new mode 100755 similarity index 87% rename from tests/avocado/info_usernet.py rename to tests/functional/test_info_usernet.py index e1aa7a6e0a..ded973253a --- a/tests/avocado/info_usernet.py +++ b/tests/functional/test_info_usernet.py @@ -1,3 +1,5 @@ +#!/usr/bin/env python3 +# # Test for the hmp command "info usernet" # # Copyright (c) 2021 Red Hat, Inc. @@ -8,18 +10,16 @@ # This work is licensed under the terms of the GNU GPL, version 2 or # later. See the COPYING file in the top-level directory. -from avocado_qemu import QemuSystemTest +from qemu_test import QemuSystemTest from qemu.utils import get_info_usernet_hostfwd_port class InfoUsernet(QemuSystemTest): -""" -:avocado: tags=machine:none -""" def test_hostfwd(self): self.require_netdev('user') +self.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', @@ -31,3 +31,6 @@ def test_hostfwd(self): self.assertGreater(port, 0, ('Found a redirected port that is not greater than' ' zero')) + +if __name__ == '__main__': +QemuSystemTest.main() diff --git a/tests/avocado/ppc_74xx.py b/tests/functional/test_ppc_74xx.py old mode 100644 new mode 100755 similarity index 74% rename from tests/avocado/ppc_74xx.py rename to tests/functional/test_ppc_74xx.py index f54757c243..5386016f26 --- a/tests/avocado/ppc_74xx.py +++ b/tests/functional/test_ppc_74xx.py @@ -1,3 +1,5 @@ +#!/usr/bin/env python3 +# # Smoke tests for 74xx cpus (aka G4). # # Copyright (c) 2021, IBM Corp. @@ -5,132 +7,120 @@ # This work is licensed under the terms of the GNU GPL, version 2 or # later. See the COPYING file in the top-level directory. -from avocado_qemu import QemuSystemTest -from avocado_qemu import wait_for_console_pattern +from qemu_test import QemuSystemTest +from qemu_test import wait_for_console_pattern class ppc74xxCpu(QemuSystemTest): -""" -:avocado: tags=arch:ppc -:avocado: tags=accel:tcg -""" + timeout = 5 def test_ppc_7400(self): -""" -:avocado: tags=cpu:7400 -""" self.require_accelerator("tcg") +self.set_machine('g3beige') self.vm.set_console() +self.vm.add_args('-cpu', '7400') self.vm.launch() wait_for_console_pattern(self, '>> OpenBIOS') wait_for_console_pattern(self, '>> CPU type PowerPC,G4') def test_ppc_7410(self): -""" -:avocado: tags=cpu:7410 -""" self.require_accelerator("tcg") +self.set_machine('g3beige') self.vm.set_console() +self.vm.add_args('-cpu', '7410') self.vm.launch() wait_for_console_pattern(self, '>> OpenBIOS') wait_for_console_pattern(self, '>> CPU type PowerPC,74xx') def test_ppc_7441(self): -""" -:avocado: tags=cpu:7441 -""" self.require_accelerator("tcg") +self.set_machine('g3beige') self.vm.set_console() +self.vm.add_args('-cpu', '7441') self.vm.launch() wait_for_console_pattern(self, '>> OpenBIOS') wait_for_console_pattern(self, '>> CPU type PowerPC,G4') def test_ppc_7445(self): -""" -:avocado: tags=cpu:7445 -""" self.require_accelerator("tcg") +self.set_machine('g3beige') self.vm.set_console() +self.vm.add_args('-cpu', '7445') self.vm.launch() wait_for_console_pattern(self, '>> OpenBIOS') wait_for_console_pattern(self, '>> CPU type PowerPC,G4') def
[PATCH 11/11] gitlab-ci: Add "check-functional" to the build tests
Now that we converted many tests from the "check-avocado" test suite to the "check-functional" test suite, we should make sure that these also get tested in the CI. Signed-off-by: Thomas Huth --- .gitlab-ci.d/buildtest-template.yml | 3 +- .gitlab-ci.d/buildtest.yml | 60 ++--- 2 files changed, 32 insertions(+), 31 deletions(-) diff --git a/.gitlab-ci.d/buildtest-template.yml b/.gitlab-ci.d/buildtest-template.yml index 8f7ebfaed8..54cae74a8e 100644 --- a/.gitlab-ci.d/buildtest-template.yml +++ b/.gitlab-ci.d/buildtest-template.yml @@ -71,7 +71,7 @@ reports: junit: build/meson-logs/testlog.junit.xml -.avocado_test_job_template: +.functional_test_job_template: extends: .common_test_job_template cache: key: "${CI_JOB_NAME}-cache" @@ -98,6 +98,7 @@ du -chs ${CI_PROJECT_DIR}/avocado-cache ; fi - export AVOCADO_ALLOW_UNTRUSTED_CODE=1 +- export QEMU_TEST_ALLOW_UNTRUSTED_CODE=1 after_script: - cd build - du -chs ${CI_PROJECT_DIR}/avocado-cache diff --git a/.gitlab-ci.d/buildtest.yml b/.gitlab-ci.d/buildtest.yml index e3a0758bd9..8b1d61911c 100644 --- a/.gitlab-ci.d/buildtest.yml +++ b/.gitlab-ci.d/buildtest.yml @@ -22,14 +22,14 @@ check-system-alpine: IMAGE: alpine MAKE_CHECK_ARGS: check-unit check-qtest -avocado-system-alpine: - extends: .avocado_test_job_template +functional-system-alpine: + extends: .functional_test_job_template needs: - job: build-system-alpine artifacts: true variables: IMAGE: alpine -MAKE_CHECK_ARGS: check-avocado +MAKE_CHECK_ARGS: check-avocado check-functional AVOCADO_TAGS: arch:avr arch:loongarch64 arch:mips64 arch:mipsel build-system-ubuntu: @@ -53,14 +53,14 @@ check-system-ubuntu: IMAGE: ubuntu2204 MAKE_CHECK_ARGS: check -avocado-system-ubuntu: - extends: .avocado_test_job_template +functional-system-ubuntu: + extends: .functional_test_job_template needs: - job: build-system-ubuntu artifacts: true variables: IMAGE: ubuntu2204 -MAKE_CHECK_ARGS: check-avocado +MAKE_CHECK_ARGS: check-avocado check-functional AVOCADO_TAGS: arch:alpha arch:microblazeel arch:mips64el build-system-debian: @@ -85,14 +85,14 @@ check-system-debian: IMAGE: debian MAKE_CHECK_ARGS: check -avocado-system-debian: - extends: .avocado_test_job_template +functional-system-debian: + extends: .functional_test_job_template needs: - job: build-system-debian artifacts: true variables: IMAGE: debian -MAKE_CHECK_ARGS: check-avocado +MAKE_CHECK_ARGS: check-avocado check-functional AVOCADO_TAGS: arch:arm arch:i386 arch:riscv64 arch:sh4 arch:sparc arch:xtensa crash-test-debian: @@ -129,14 +129,14 @@ check-system-fedora: IMAGE: fedora MAKE_CHECK_ARGS: check -avocado-system-fedora: - extends: .avocado_test_job_template +functional-system-fedora: + extends: .functional_test_job_template needs: - job: build-system-fedora artifacts: true variables: IMAGE: fedora -MAKE_CHECK_ARGS: check-avocado +MAKE_CHECK_ARGS: check-avocado check-functional AVOCADO_TAGS: arch:microblaze arch:mips arch:xtensa arch:m68k arch:riscv32 arch:ppc arch:sparc64 @@ -243,14 +243,14 @@ check-system-centos: IMAGE: centos9 MAKE_CHECK_ARGS: check -avocado-system-centos: - extends: .avocado_test_job_template +functional-system-centos: + extends: .functional_test_job_template needs: - job: build-system-centos artifacts: true variables: IMAGE: centos9 -MAKE_CHECK_ARGS: check-avocado +MAKE_CHECK_ARGS: check-avocado check-functional AVOCADO_TAGS: arch:ppc64 arch:or1k arch:s390x arch:x86_64 arch:rx arch:sh4 @@ -274,14 +274,14 @@ check-system-opensuse: IMAGE: opensuse-leap MAKE_CHECK_ARGS: check -avocado-system-opensuse: - extends: .avocado_test_job_template +functional-system-opensuse: + extends: .functional_test_job_template needs: - job: build-system-opensuse artifacts: true variables: IMAGE: opensuse-leap -MAKE_CHECK_ARGS: check-avocado +MAKE_CHECK_ARGS: check-avocado check-functional AVOCADO_TAGS: arch:s390x arch:x86_64 arch:aarch64 # @@ -302,15 +302,15 @@ build-system-flaky: ppc64-softmmu rx-softmmu s390x-softmmu sh4-softmmu x86_64-softmmu MAKE_CHECK_ARGS: check-build -avocado-system-flaky: - extends: .avocado_test_job_template +functional-system-flaky: + extends: .functional_test_job_template needs: - job: build-system-flaky artifacts: true allow_failure: true variables: IMAGE: debian -MAKE_CHECK_ARGS: check-avocado +MAKE_CHECK_ARGS: check-avocado check-functional QEMU_JOB_OPTIONAL: 1 QEMU_TEST_FLAKY_TESTS: 1 AVOCADO_TAGS: flaky @@ -484,14 +484,14 @@ check-cfi-aarch64: IMAGE: fedora MAKE_CHECK_ARGS: check -avocado-cfi-aarch64: - exten
[PATCH 04/11] tests/functional: Add python-based tests to the meson build system
Integrate the new python-based test framework with the meson build system. Since these tests now require the pycotap module, make sure that it gets installed in the venv. The changes to the meson.build files are partly based on an earlier patch by Ani Sinha (but heavily modified by Thomas Huth e.g. to use pycotap for running the tests instead). Signed-off-by: Thomas Huth --- pythondeps.toml | 3 +- tests/Makefile.include | 18 - tests/functional/meson.build | 75 tests/meson.build| 1 + 4 files changed, 95 insertions(+), 2 deletions(-) create mode 100644 tests/functional/meson.build diff --git a/pythondeps.toml b/pythondeps.toml index f6e590fdd8..c018b4d74a 100644 --- a/pythondeps.toml +++ b/pythondeps.toml @@ -26,9 +26,10 @@ meson = { accepted = ">=1.1.0", installed = "1.2.3", canary = "meson" } sphinx = { accepted = ">=3.4.3", installed = "5.3.0", canary = "sphinx-build" } sphinx_rtd_theme = { accepted = ">=0.5", installed = "1.1.1" } -[avocado] +[tests] # Note that qemu.git/python/ is always implicitly installed. # Prefer an LTS version when updating the accepted versions of # avocado-framework, for example right now the limit is 92.x. avocado-framework = { accepted = "(>=88.1, <93.0)", installed = "88.1", canary = "avocado" } pycdlib = { accepted = ">=1.11.0" } +pycotap = { accepted = ">=1.1.0" } diff --git a/tests/Makefile.include b/tests/Makefile.include index d39d5dd6a4..2bdf607977 100644 --- a/tests/Makefile.include +++ b/tests/Makefile.include @@ -9,6 +9,8 @@ check-help: @echo "Individual test suites:" @echo " $(MAKE) check-qtest-TARGET Run qtest tests for given target" @echo " $(MAKE) check-qtestRun qtest tests" + @echo " $(MAKE) check-functional Run python-based functional tests" + @echo " $(MAKE) check-functional-TARG Run functional tests for a given target" @echo " $(MAKE) check-unit Run qobject tests" @echo " $(MAKE) check-qapi-schema Run QAPI schema tests" @echo " $(MAKE) check-blockRun block tests" @@ -111,7 +113,7 @@ quiet-venv-pip = $(quiet-@)$(call quiet-command-run, \ $(TESTS_VENV_TOKEN): $(SRC_PATH)/pythondeps.toml $(call quiet-venv-pip,install -e "$(SRC_PATH)/python/") - $(MKVENV_ENSUREGROUP) $< avocado + $(MKVENV_ENSUREGROUP) $< tests $(call quiet-command, touch $@) $(TESTS_RESULTS_DIR): @@ -152,6 +154,20 @@ check-acceptance-deprecated-warning: check-acceptance: check-acceptance-deprecated-warning | check-avocado +# Make sure that pycotap is installed before running any functional tests: +ifneq ($(filter check-func%,$(MAKECMDGOALS))$(filter check,$(MAKECMDGOALS)),) +do-meson-check: check-venv +endif + +FUNCTIONAL_TARGETS=$(patsubst %-softmmu,check-functional-%, $(filter %-softmmu,$(TARGETS))) +.PHONY: $(FUNCTIONAL_TARGETS) +$(FUNCTIONAL_TARGETS): + @make SPEED=thorough $(subst -functional,-func,$@) + +.PHONY: check-functional +check-functional: + @make SPEED=thorough check-func check-func-quick + # Consolidated targets .PHONY: check check-clean get-vm-images diff --git a/tests/functional/meson.build b/tests/functional/meson.build new file mode 100644 index 00..11352b5bb5 --- /dev/null +++ b/tests/functional/meson.build @@ -0,0 +1,75 @@ +# QEMU functional tests: +# Tests that are put in the 'quick' category are run by default during +# 'make check'. Everything that should not be run during 'make check' +# (e.g. tests that fetch assets from the internet) should be put into +# the 'thorough' category instead. + +# Most tests run too slow with TCI enabled, so skip the functional tests there +if get_option('tcg_interpreter') + subdir_done() +endif + +# Timeouts for individual tests that can be slow e.g. with debugging enabled +test_timeouts = { + 'ppc_74xx' : 90, +} + +tests_generic = [ + 'empty_cpu_model', + 'info_usernet', + 'version', +] + +tests_ppc_quick = [ + 'ppc_74xx', +] + +tests_x86_64_quick = [ + 'cpu_queries', + 'mem_addr_space', + 'pc_cpu_hotplug_props', + 'virtio_version', +] + +foreach speed : ['quick', 'thorough'] + foreach dir : target_dirs +if not dir.endswith('-softmmu') + continue +endif + +target_base = dir.split('-')[0] +test_emulator = emulators['qemu-system-' + target_base] + +if speed == 'quick' + suites = ['func-quick', 'func-' + target_base] + target_tests = get_variable('tests_' + target_base + '_quick', []) + tests_generic +else + suites = ['func-' + speed, 'func-' + target_base + '-' + speed, speed] + target_tests = get_variable('tests_' + target_base + '_' + speed, []) +
[PATCH 10/11] tests/functional: Convert the s390x avocado tests into standalone tests
These tests use archive.lzma_uncompress() from the Avocado utils, so provide a small helper function for this, based on the standard lzma module from Python instead. And while we're at it, replace the MD5 hashes in the topology test with proper SHA256 hashes, since MD5 should not be used anymore nowadays. Signed-off-by: Thomas Huth --- MAINTAINERS | 4 +- tests/functional/meson.build | 6 ++ tests/functional/qemu_test/utils.py | 7 ++ .../test_s390x_ccw_virtio.py} | 32 - .../test_s390x_topology.py} | 70 +++ 5 files changed, 52 insertions(+), 67 deletions(-) rename tests/{avocado/machine_s390_ccw_virtio.py => functional/test_s390x_ccw_virtio.py} (95%) mode change 100644 => 100755 rename tests/{avocado/s390_topology.py => functional/test_s390x_topology.py} (90%) mode change 100644 => 100755 diff --git a/MAINTAINERS b/MAINTAINERS index 025227954c..cbefb6fb81 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -1739,7 +1739,7 @@ S: Supported F: hw/s390x/ F: include/hw/s390x/ F: configs/devices/s390x-softmmu/default.mak -F: tests/avocado/machine_s390_ccw_virtio.py +F: tests/functional/test_s390x_ccw_virtio.py T: git https://github.com/borntraeger/qemu.git s390-next L: qemu-s3...@nongnu.org @@ -1802,7 +1802,7 @@ F: hw/s390x/cpu-topology.c F: target/s390x/kvm/stsi-topology.c F: docs/devel/s390-cpu-topology.rst F: docs/system/s390x/cpu-topology.rst -F: tests/avocado/s390_topology.py +F: tests/functional/test_s390x_topology.py X86 Machines diff --git a/tests/functional/meson.build b/tests/functional/meson.build index c8fc9f6c07..f6de9af8a2 100644 --- a/tests/functional/meson.build +++ b/tests/functional/meson.build @@ -13,6 +13,7 @@ endif test_timeouts = { 'netdev_ethtool' : 180, 'ppc_74xx' : 90, + 's390x_ccw_virtio' : 180, } tests_generic = [ @@ -47,6 +48,11 @@ tests_ppc_thorough = [ 'ppc_bamboo', ] +tests_s390x_thorough = [ + 's390x_ccw_virtio', + 's390x_topology', +] + tests_sparc64_thorough = [ 'sparc64_sun4u', ] diff --git a/tests/functional/qemu_test/utils.py b/tests/functional/qemu_test/utils.py index 4eb5e5d5e5..8115d9d1da 100644 --- a/tests/functional/qemu_test/utils.py +++ b/tests/functional/qemu_test/utils.py @@ -8,6 +8,8 @@ # 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 lzma +import shutil import tarfile def archive_extract(archive, dest_dir, member=None): @@ -19,3 +21,8 @@ def archive_extract(archive, dest_dir, member=None): tf.extract(member=member, path=dest_dir) else: tf.extractall(path=dest_dir) + +def lzma_uncompress(xz_path, output_path): +with lzma.open(xz_path, 'rb') as lzma_in: +with open(output_path, 'wb') as raw_out: +shutil.copyfileobj(lzma_in, raw_out) diff --git a/tests/avocado/machine_s390_ccw_virtio.py b/tests/functional/test_s390x_ccw_virtio.py old mode 100644 new mode 100755 similarity index 95% rename from tests/avocado/machine_s390_ccw_virtio.py rename to tests/functional/test_s390x_ccw_virtio.py index 26e938c9e9..b2cbaacd21 --- a/tests/avocado/machine_s390_ccw_virtio.py +++ b/tests/functional/test_s390x_ccw_virtio.py @@ -1,3 +1,5 @@ +#!/usr/bin/env python3 +# # Functional test that boots an s390x Linux guest with ccw and PCI devices # attached and checks whether the devices are recognized by Linux # @@ -12,11 +14,10 @@ import os import tempfile -from avocado import skipUnless -from avocado_qemu import QemuSystemTest -from avocado_qemu import exec_command_and_wait_for_pattern -from avocado_qemu import wait_for_console_pattern -from avocado.utils import archive +from qemu_test import QemuSystemTest +from qemu_test import exec_command_and_wait_for_pattern +from qemu_test import wait_for_console_pattern +from qemu_test.utils import lzma_uncompress class S390CCWVirtioMachine(QemuSystemTest): KERNEL_COMMON_COMMAND_LINE = 'printk.time=0 ' @@ -41,11 +42,7 @@ def clear_guest_dmesg(self): self.dmesg_clear_count += 1 def test_s390x_devices(self): - -""" -:avocado: tags=arch:s390x -:avocado: tags=machine:s390-ccw-virtio -""" +self.set_machine('s390-ccw-virtio') kernel_url = ('https://snapshot.debian.org/archive/debian/' '20201126T092837Z/dists/buster/main/installer-s390x/' @@ -160,15 +157,7 @@ def test_s390x_devices(self): def test_s390x_fedora(self): - -""" -:avocado: tags=arch:s390x -:avocado: tags=machine:s390-ccw-virtio -:avocado: tags=device:virtio-gpu -:avocado: tags=device:virtio-crypto -:avocado: tags=device:virtio-net -:avocado: tags=flaky -""" +self.set_machine('s390-ccw-virtio')
[PATCH 09/11] tests/functional: Set up logging
Create log files for each test separately, one file that contains the basic logging and one that contains the console output. Signed-off-by: Thomas Huth --- tests/functional/qemu_test/__init__.py | 24 +++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/tests/functional/qemu_test/__init__.py b/tests/functional/qemu_test/__init__.py index 77c3b14d34..cc49fd4c94 100644 --- a/tests/functional/qemu_test/__init__.py +++ b/tests/functional/qemu_test/__init__.py @@ -208,7 +208,7 @@ class QemuBaseTest(unittest.TestCase): BUILD_DIR = _build_dir() workdir = None -log = logging.getLogger('qemu-test') +log = None def setUp(self, bin_prefix): self.assertIsNotNone(self.qemu_bin, 'QEMU_TEST_QEMU_BINARY must be set') @@ -218,6 +218,18 @@ def setUp(self, bin_prefix): if not os.path.exists(self.workdir): os.makedirs(self.workdir) +self.log = logging.getLogger('qemu-test') +self.log.setLevel(logging.DEBUG) +self._log_fh = logging.FileHandler(os.path.join(self.workdir, +'base.log'), mode='w') +self._log_fh.setLevel(logging.DEBUG) +fileFormatter = logging.Formatter('%(asctime)s - %(levelname)s: %(message)s') +self._log_fh.setFormatter(fileFormatter) +self.log.addHandler(self._log_fh) + +def tearDown(self): +self.log.removeHandler(self._log_fh) + def check_hash(self, file_name, expected_hash): if not expected_hash: return True @@ -269,6 +281,15 @@ def setUp(self): super().setUp('qemu-system-') +console_log = logging.getLogger('console') +console_log.setLevel(logging.DEBUG) +self._console_log_fh = logging.FileHandler(os.path.join(self.workdir, + 'console.log'), mode='w') +self._console_log_fh.setLevel(logging.DEBUG) +fileFormatter = logging.Formatter('%(asctime)s: %(message)s') +self._console_log_fh.setFormatter(fileFormatter) +console_log.addHandler(self._console_log_fh) + def set_machine(self, machinename): # TODO: We should use QMP to get the list of available machines if not self._machinehelp: @@ -359,4 +380,5 @@ def set_vm_arg(self, arg, value): def tearDown(self): for vm in self._vms.values(): vm.shutdown() +logging.getLogger('console').removeHandler(self._console_log_fh) super().tearDown() -- 2.45.2
[PATCH 02/11] tests/functional: Convert simple avocado tests into standalone python tests
These test are rather simple and don't need any modifications apart from adjusting the "from avocado_qemu" line. To ease debugging, make the files executable and add a shebang line and Python '__main__' handling, too, so that these tests can now be run by executing them directly. Signed-off-by: Thomas Huth --- .../test_cpu_queries.py} | 7 ++- .../test_empty_cpu_model.py} | 7 ++- .../test_mem_addr_space.py} | 53 +++ .../test_pc_cpu_hotplug_props.py} | 11 ++-- .../test_virtio_version.py} | 8 +-- 5 files changed, 29 insertions(+), 57 deletions(-) rename tests/{avocado/cpu_queries.py => functional/test_cpu_queries.py} (89%) mode change 100644 => 100755 rename tests/{avocado/empty_cpu_model.py => functional/test_empty_cpu_model.py} (84%) mode change 100644 => 100755 rename tests/{avocado/mem-addr-space-check.py => functional/test_mem_addr_space.py} (92%) mode change 100644 => 100755 rename tests/{avocado/pc_cpu_hotplug_props.py => functional/test_pc_cpu_hotplug_props.py} (90%) mode change 100644 => 100755 rename tests/{avocado/virtio_version.py => functional/test_virtio_version.py} (98%) mode change 100644 => 100755 diff --git a/tests/avocado/cpu_queries.py b/tests/functional/test_cpu_queries.py old mode 100644 new mode 100755 similarity index 89% rename from tests/avocado/cpu_queries.py rename to tests/functional/test_cpu_queries.py index d3faa14720..97dd600c01 --- a/tests/avocado/cpu_queries.py +++ b/tests/functional/test_cpu_queries.py @@ -1,3 +1,5 @@ +#!/usr/bin/env python3 +# # Sanity check of query-cpu-* results # # Copyright (c) 2019 Red Hat, Inc. @@ -8,7 +10,7 @@ # This work is licensed under the terms of the GNU GPL, version 2 or # later. See the COPYING file in the top-level directory. -from avocado_qemu import QemuSystemTest +from qemu_test import QemuSystemTest class QueryCPUModelExpansion(QemuSystemTest): """ @@ -33,3 +35,6 @@ def test(self): e = self.vm.cmd('query-cpu-model-expansion', model=model, type='full') self.assertEqual(e['model']['name'], c['name']) + +if __name__ == '__main__': +QemuSystemTest.main() diff --git a/tests/avocado/empty_cpu_model.py b/tests/functional/test_empty_cpu_model.py old mode 100644 new mode 100755 similarity index 84% rename from tests/avocado/empty_cpu_model.py rename to tests/functional/test_empty_cpu_model.py index d906ef3d3c..0081b06d85 --- a/tests/avocado/empty_cpu_model.py +++ b/tests/functional/test_empty_cpu_model.py @@ -1,3 +1,5 @@ +#!/usr/bin/env python3 +# # Check for crash when using empty -cpu option # # Copyright (c) 2019 Red Hat, Inc. @@ -7,7 +9,7 @@ # # This work is licensed under the terms of the GNU GPL, version 2 or # later. See the COPYING file in the top-level directory. -from avocado_qemu import QemuSystemTest +from qemu_test import QemuSystemTest class EmptyCPUModel(QemuSystemTest): def test(self): @@ -17,3 +19,6 @@ def test(self): self.vm.wait() self.assertEqual(self.vm.exitcode(), 1, "QEMU exit code should be 1") self.assertRegex(self.vm.get_log(), r'-cpu option cannot be empty') + +if __name__ == '__main__': +QemuSystemTest.main() diff --git a/tests/avocado/mem-addr-space-check.py b/tests/functional/test_mem_addr_space.py old mode 100644 new mode 100755 similarity index 92% rename from tests/avocado/mem-addr-space-check.py rename to tests/functional/test_mem_addr_space.py index 85541ea051..bb0cf062ca --- a/tests/avocado/mem-addr-space-check.py +++ b/tests/functional/test_mem_addr_space.py @@ -1,3 +1,5 @@ +#!/usr/bin/env python3 +# # Check for crash when using memory beyond the available guest processor # address space. # @@ -8,8 +10,7 @@ # # SPDX-License-Identifier: GPL-2.0-or-later -from avocado_qemu import QemuSystemTest -import signal +from qemu_test import QemuSystemTest import time class MemAddrCheck(QemuSystemTest): @@ -23,9 +24,6 @@ class MemAddrCheck(QemuSystemTest): # for all 32-bit cases, pci64_hole_size is 0. def test_phybits_low_pse36(self): """ -:avocado: tags=machine:q35 -:avocado: tags=arch:x86_64 - With pse36 feature ON, a processor has 36 bits of addressing. So it can access up to a maximum of 64GiB of memory. Memory hotplug region begins at 4 GiB boundary when "above_4g_mem_size" is 0 (this would be true when @@ -53,9 +51,6 @@ def test_phybits_low_pse36(self): def test_phybits_low_pae(self): """ -:avocado: tags=machine:q35 -:avocado: tags=arch:x86_64 - With pae feature ON, a processor has 36 bits of addressing. So it can access up to a maximum of 64GiB of memory. Rest is the same as the case with pse36 above. @@ -73,9 +68,6 @@ def test_ph
[PATCH 06/11] tests/functional: Convert some tests that download files via fetch_asset()
Now that we've got a working fetch_asset() function, we can convert some Avocado tests that use this function for downloading their required files. Signed-off-by: Thomas Huth --- MAINTAINERS | 12 +++ tests/functional/meson.build | 25 +++ .../test_arm_n8x0.py} | 25 +++ .../test_avr_mega2560.py} | 11 --- .../test_loongarch64_virt.py} | 16 ++ .../test_mips64el_loongson3v.py} | 26 +++ .../test_netdev_ethtool.py} | 32 ++- .../ppc_405.py => functional/test_ppc_405.py} | 19 ++- 8 files changed, 89 insertions(+), 77 deletions(-) rename tests/{avocado/machine_arm_n8x0.py => functional/test_arm_n8x0.py} (71%) mode change 100644 => 100755 rename tests/{avocado/machine_avr6.py => functional/test_avr_mega2560.py} (90%) mode change 100644 => 100755 rename tests/{avocado/machine_loongarch.py => functional/test_loongarch64_virt.py} (89%) mode change 100644 => 100755 rename tests/{avocado/machine_mips_loongson3v.py => functional/test_mips64el_loongson3v.py} (55%) mode change 100644 => 100755 rename tests/{avocado/netdev-ethtool.py => functional/test_netdev_ethtool.py} (81%) mode change 100644 => 100755 rename tests/{avocado/ppc_405.py => functional/test_ppc_405.py} (73%) mode change 100644 => 100755 diff --git a/MAINTAINERS b/MAINTAINERS index 7d9811458c..533e22b548 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -221,7 +221,7 @@ S: Maintained F: docs/system/target-avr.rst F: gdb-xml/avr-cpu.xml F: target/avr/ -F: tests/avocado/machine_avr6.py +F: tests/functional/test_avr_mega2560.py CRIS TCG CPUs M: Edgar E. Iglesias @@ -264,7 +264,7 @@ M: Song Gao S: Maintained F: target/loongarch/ F: tests/tcg/loongarch64/ -F: tests/avocado/machine_loongarch.py +F: tests/functional/test_loongarch64_virt.py M68K TCG CPUs M: Laurent Vivier @@ -883,7 +883,7 @@ F: include/hw/display/blizzard.h F: include/hw/input/lm832x.h F: include/hw/input/tsc2xxx.h F: include/hw/misc/cbus.h -F: tests/avocado/machine_arm_n8x0.py +F: tests/functional/test_arm_n8x0.py F: docs/system/arm/nseries.rst Palm @@ -1392,7 +1392,7 @@ F: hw/mips/loongson3_bootp.h F: hw/mips/loongson3_virt.c F: include/hw/intc/loongson_ipi.h F: include/hw/intc/loongson_liointc.h -F: tests/avocado/machine_mips_loongson3v.py +F: tests/functional/test_mips64el_loongson3v.py Boston M: Paul Burton @@ -1418,7 +1418,7 @@ PowerPC Machines L: qemu-...@nongnu.org S: Orphan F: hw/ppc/ppc405* -F: tests/avocado/ppc_405.py +F: tests/functional/test_ppc_405.py Bamboo L: qemu-...@nongnu.org @@ -2483,7 +2483,7 @@ R: Sriram Yagnaraman S: Maintained F: docs/system/devices/igb.rst F: hw/net/igb* -F: tests/avocado/netdev-ethtool.py +F: tests/functional/test_netdev_ethtool.py F: tests/qtest/igb-test.c F: tests/qtest/libqos/igb.c diff --git a/tests/functional/meson.build b/tests/functional/meson.build index 11352b5bb5..947f9ac74f 100644 --- a/tests/functional/meson.build +++ b/tests/functional/meson.build @@ -11,6 +11,7 @@ endif # Timeouts for individual tests that can be slow e.g. with debugging enabled test_timeouts = { + 'netdev_ethtool' : 180, 'ppc_74xx' : 90, } @@ -20,10 +21,30 @@ tests_generic = [ 'version', ] +tests_arm_thorough = [ + 'arm_n8x0', +] + +tests_avr_thorough = [ + 'avr_mega2560', +] + +tests_loongarch64_thorough = [ + 'loongarch64_virt', +] + +tests_mips64el_thorough = [ + 'mips64el_loongson3v', +] + tests_ppc_quick = [ 'ppc_74xx', ] +tests_ppc_thorough = [ + 'ppc_405', +] + tests_x86_64_quick = [ 'cpu_queries', 'mem_addr_space', @@ -31,6 +52,10 @@ tests_x86_64_quick = [ 'virtio_version', ] +tests_x86_64_thorough = [ + 'netdev_ethtool', +] + foreach speed : ['quick', 'thorough'] foreach dir : target_dirs if not dir.endswith('-softmmu') diff --git a/tests/avocado/machine_arm_n8x0.py b/tests/functional/test_arm_n8x0.py old mode 100644 new mode 100755 similarity index 71% rename from tests/avocado/machine_arm_n8x0.py rename to tests/functional/test_arm_n8x0.py index 12e9a6803b..d451c80a73 --- a/tests/avocado/machine_arm_n8x0.py +++ b/tests/functional/test_arm_n8x0.py @@ -1,3 +1,5 @@ +#!/usr/bin/env python3 +# # Functional test that boots a Linux kernel and checks the console # # Copyright (c) 2020 Red Hat, Inc. @@ -10,9 +12,9 @@ import os -from avocado import skipUnless -from avocado_qemu import QemuSystemTest -from avocado_qemu import wait_for_console_pattern +from unittest import skipUnless +from qemu_test import QemuSystemTest +from qemu_test import wait_for_console_pattern class N8x0Machine(QemuSystemTest): """Boots the Linux kernel and checks that the console is operational""" @@ -32,18 +34,15 @@ def __do_test_n8x0(self): self.vm.launch()
[PATCH v1 00/11] Convert avocado tests to normal Python unittests
The Avocado v88 that we use in QEMU is already on a life support system: It is not supported by upstream anymore, and with the latest versions of Python, it won't work anymore since it depends on the "imp" module that has been removed in Python 3.12. There have been several attempts to update the test suite in QEMU to a newer version of Avocado, but so far no attempt has successfully been merged yet. Additionally, the whole "make check" test suite in QEMU is using the meson test runner nowadays, so running the python-based tests via the Avocodo test runner looks and feels quite like an oddball, requiring the users to deal with the knowledge of multiple test runners in parallel (e.g. the timeout settings work completely differently). So instead of trying to update the python-based test suite in QEMU to a newer version of Avocado, we should maybe try to better integrate it with the meson test runner instead. Indeed most tests work quite nicely without the Avocado framework already, as you can see with this patch series - it does not convert all tests, just a subset so far, but this already proves that many tests only need small modifi- cations to work without Avocado. Only tests that use the LinuxTest / LinuxDistro and LinuxSSHMixIn classes (e.g. based on cloud-init images or using SSH) really depend on the Avocado framework, so we'd need a solution for those if we want to continue using them. One solution might be to simply use the required functions from avocado.utils for these tests, and still run them via the meson test runner instead, but that needs some further investigation that will be done later. Now if you want to try out these patches: Apply the patches, then recompile and then run: make check-functional You can also run single targets e.g. with: make check-functional-ppc You can also run the tests without any test runner now by setting the PYTHONPATH environment variable to the "python" folder of your source tree, and by specifying the build directory via QEMU_BUILD_ROOT (if autodetection fails) and by specifying the QEMU binary via QEMU_TEST_QEMU_BINARY. For example: export PYTHONPATH=$HOME/qemu/python export QEMU_TEST_QEMU_BINARY=qemu-system-x86_64 export PYTHONPATH=$HOME/qemu/build ~/qemu/tests/functional/test_virtio_version.py The logs of the tests can be found in the build directory under tests/functional/ - console log and general logs will be put in separate files there. Still to be done: Update the documentation for this new test framework. RFC -> v1: - Now using pycotap for running the tests instead of "pytest" - Change the name from "tests/pytest" to "tests/functional" accordingly - Make it possible to run the tests directly - Use Python's urllib instead of wget for downloading - Lots of makefile / meson integration improvements - Converted more tests - Update MAINTAINERS file accordingly - Added a patch to run check-functional in the gitlab-CI - ... lots of other changes I forgot about ... in fact, I changed so many things that I also did not dare to pick up the Reviewed-bys from the RFC Thomas Huth (11): tests/functional: Add base classes for the upcoming pytest-based tests tests/functional: Convert simple avocado tests into standalone python tests tests/functional: Convert avocado tests that just need a small adjustment tests/functional: Add python-based tests to the meson build system tests/functional: Implement fetch_asset() method for downloading assets tests/functional: Convert some tests that download files via fetch_asset() tests/functional: Add a function for extracting files from an archive tests/functional: Convert some avocado tests that needed avocado.utils.archive tests/functional: Set up logging tests/functional: Convert the s390x avocado tests into standalone tests gitlab-ci: Add "check-functional" to the build tests MAINTAINERS | 22 +- .gitlab-ci.d/buildtest-template.yml | 3 +- .gitlab-ci.d/buildtest.yml| 60 +-- pythondeps.toml | 3 +- tests/Makefile.include| 18 +- tests/functional/meson.build | 112 + tests/functional/qemu_test/__init__.py| 384 ++ tests/functional/qemu_test/utils.py | 28 ++ .../test_arm_canona1100.py} | 21 +- .../test_arm_n8x0.py} | 25 +- .../test_avr_mega2560.py} | 11 +- .../test_cpu_queries.py} | 7 +- .../test_empty_cpu_model.py} | 7 +- .../test_info_usernet.py} | 11 +- .../test_loongarch64_virt.py} | 16 +- .../test_mem_addr_space.py} | 53 +-- .../test_mips64el_loongson3v.py} | 26 +- .../test_netdev_ethtool.py} | 32 +
Re: FreeBSD update required for CI?
On 16/07/2024 01.00, Richard Henderson wrote: Hi guys, CI currently failing FreeBSD: https://gitlab.com/qemu-project/qemu/-/jobs/7347517439 pkg: No packages available to install matching 'py39-pillow' have been found in the repositories pkg: No packages available to install matching 'py39-pip' have been found in the repositories pkg: No packages available to install matching 'py39-sphinx' have been found in the repositories pkg: No packages available to install matching 'py39-sphinx_rtd_theme' have been found in the repositories pkg: No packages available to install matching 'py39-yaml' have been found in the repositories Has FreeBSD ports updated to something beyond python 3.9, and we need an update to match? Yes, we discussed it in IRC yesterday: Python has been updated there, we need to update lcitool to the latest version to get the fix for it. Alex is planning to provide a patch. Thomas
Re: [RFC PATCH 4/8] tests/pytest: add pytest to the meson build system
On 12/07/2024 13.47, Daniel P. Berrangé wrote: On Fri, Jul 12, 2024 at 12:14:45PM +0200, Thomas Huth wrote: On 12/07/2024 11.01, Daniel P. Berrangé wrote: On Thu, Jul 11, 2024 at 01:55:42PM +0200, Thomas Huth wrote: From: Ani Sinha Integrate the pytest framework with the meson build system. This will make meson run all the pytests under the pytest directory. Lets add a note about the compelling benefit of this new approach With this change, each functional test becomes subject to an individual execution timeout, defaulting to 60 seconds, but overridable per-test. The avocado runner uses timeouts, too, so it's not really an additional benefit that we get here. For CI purposes we'll need to add 'python3-pytest' to tests/lcitool/projects/qemu.yml, and re-generate the the dockerfiles. Some of the other non-gitlab CI integrations probably need manual additions of pytest packages. I'm currently rather looking into getting rid of pytest and to use pycotap instead: Using the TAP protocol for running the tests, you get a much nicer output from the meson test runner, which can then count the subtests and properly report SKIPs for tests that have not been run. I've just looked at pycotap and IIUC, there's no command line tool equivalent to '/usr/bin/pytest' at all. Each test case is expected to provide a stub for "__main__" to invoke the tests. With pycotap 1.3.0 you could run tests through "python -m pycotap ...", too. But for playing nicely with meson, I'd like to set message_log and test_output_log to LogMode.LogToError instead of using their default value, so I need my own wrapper code anyway. As such each individual test is directly executable. This meshes nicely with what I'd suggested as changes in patch 1, and eliminating the intermediate runner process is a nice further simplification. So I'll be interested to see your next version using pycotap. I'll try to post it as soon as I have something at least in a somewhat more proper shape than the RFC ;-) Thomas
Re: [RFC PATCH 4/8] tests/pytest: add pytest to the meson build system
On 12/07/2024 12.26, Daniel P. Berrangé wrote: On Fri, Jul 12, 2024 at 12:14:45PM +0200, Thomas Huth wrote: On 12/07/2024 11.01, Daniel P. Berrangé wrote: On Thu, Jul 11, 2024 at 01:55:42PM +0200, Thomas Huth wrote: From: Ani Sinha Integrate the pytest framework with the meson build system. This will make meson run all the pytests under the pytest directory. Lets add a note about the compelling benefit of this new approach With this change, each functional test becomes subject to an individual execution timeout, defaulting to 60 seconds, but overridable per-test. The avocado runner uses timeouts, too, so it's not really an additional benefit that we get here. At the meson level though, we can't put an overall cap on the execution time, as there's only 1 huge test visible, and thus the meson timeout multiplier also won't get honoured IIUC. For CI purposes we'll need to add 'python3-pytest' to tests/lcitool/projects/qemu.yml, and re-generate the the dockerfiles. Some of the other non-gitlab CI integrations probably need manual additions of pytest packages. I'm currently rather looking into getting rid of pytest and to use pycotap instead: Using the TAP protocol for running the tests, you get a much nicer output from the meson test runner, which can then count the subtests and properly report SKIPs for tests that have not been run. diff --git a/tests/Makefile.include b/tests/Makefile.include index d39d5dd6a4..68151717d7 100644 --- a/tests/Makefile.include +++ b/tests/Makefile.include @@ -3,12 +3,14 @@ .PHONY: check-help check-help: @echo "Regression testing targets:" - @echo " $(MAKE) check Run block, qapi-schema, unit, softfloat, qtest and decodetree tests" + @echo " $(MAKE) check Run block, qapi-schema, unit, softfloat, qtest, pytest and decodetree tests" @echo " $(MAKE) bench Run speed tests" @echo @echo "Individual test suites:" @echo " $(MAKE) check-qtest-TARGET Run qtest tests for given target" @echo " $(MAKE) check-qtestRun qtest tests" + @echo " $(MAKE) check-pytest Run pytest tests" + @echo " $(MAKE) check-pytest-TARGETRun pytest for a given target" Or name it after the type of test rather than harness ? eg check-functional / check-functional-TARGET For that matter perhaps also for the dir name ? tests/functional/*.py I almost expected that discussion again ... (see https://lists.gnu.org/archive/html/qemu-devel/2021-05/msg06553.html ) ... last time we couldn't really agree on such a name and decided to go with the name of the framework... I agree that "pytest" is likely not the best name here, especially if switching to the pycotap test runner instead of using the "pytest" program, but "functional" might trigger the same discussion again as last time ... should it rather be "functional" or "validation" or "integration" etc.? IMHO you can just make an executive decision and pick one of those three. None of them are terrible, any would be a valid choice. Ok, I think I'll go with "functional" since that still seems to be the best fit to me. Thomas
Re: [RFC PATCH 7/8] tests/pytest: Add a function for extracting files from an archive
On 12/07/2024 11.14, Daniel P. Berrangé wrote: On Thu, Jul 11, 2024 at 01:55:45PM +0200, Thomas Huth wrote: Some Avocado-based tests use the "archive" module from avocado.utils to extract files from an archive. To be able to use these tests without Avocado, we have to provide our own function for extracting files. Fortunately, there is already the tarfile module that will provide us with this functionality, so let's just add a nice wrapper function around that. Signed-off-by: Thomas Huth --- tests/pytest/qemu_pytest/utils.py | 21 + 1 file changed, 21 insertions(+) create mode 100644 tests/pytest/qemu_pytest/utils.py diff --git a/tests/pytest/qemu_pytest/utils.py b/tests/pytest/qemu_pytest/utils.py new file mode 100644 index 00..4eb5e5d5e5 --- /dev/null +++ b/tests/pytest/qemu_pytest/utils.py @@ -0,0 +1,21 @@ +# Utilities for python-based QEMU tests +# +# Copyright 2024 Red Hat, Inc. +# +# Authors: +# Thomas Huth +# +# 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 tarfile + +def archive_extract(archive, dest_dir, member=None): +with tarfile.open(archive) as tf: +if hasattr(tarfile, 'data_filter'): Not convinced this is still needed. The python docs don't say anything about 'data_filter' being introduced after 3.0, so can likely assume it always exists. According to https://docs.python.org/3/library/tarfile.html : "Extraction filters were added to Python 3.12, but may be backported to older versions as security updates. To check whether the feature is available, use e.g. hasattr(tarfile, 'data_filter') rather than checking the Python version." And it seems to be missing in Python 3.7, indeed: https://docs.python.org/3.7/library/tarfile.html So as long as we still support this old version, I think I've got to keep this check. Thomas
Re: [RFC PATCH 4/8] tests/pytest: add pytest to the meson build system
On 12/07/2024 11.01, Daniel P. Berrangé wrote: On Thu, Jul 11, 2024 at 01:55:42PM +0200, Thomas Huth wrote: From: Ani Sinha Integrate the pytest framework with the meson build system. This will make meson run all the pytests under the pytest directory. Lets add a note about the compelling benefit of this new approach With this change, each functional test becomes subject to an individual execution timeout, defaulting to 60 seconds, but overridable per-test. The avocado runner uses timeouts, too, so it's not really an additional benefit that we get here. For CI purposes we'll need to add 'python3-pytest' to tests/lcitool/projects/qemu.yml, and re-generate the the dockerfiles. Some of the other non-gitlab CI integrations probably need manual additions of pytest packages. I'm currently rather looking into getting rid of pytest and to use pycotap instead: Using the TAP protocol for running the tests, you get a much nicer output from the meson test runner, which can then count the subtests and properly report SKIPs for tests that have not been run. diff --git a/tests/Makefile.include b/tests/Makefile.include index d39d5dd6a4..68151717d7 100644 --- a/tests/Makefile.include +++ b/tests/Makefile.include @@ -3,12 +3,14 @@ .PHONY: check-help check-help: @echo "Regression testing targets:" - @echo " $(MAKE) check Run block, qapi-schema, unit, softfloat, qtest and decodetree tests" + @echo " $(MAKE) check Run block, qapi-schema, unit, softfloat, qtest, pytest and decodetree tests" @echo " $(MAKE) bench Run speed tests" @echo @echo "Individual test suites:" @echo " $(MAKE) check-qtest-TARGET Run qtest tests for given target" @echo " $(MAKE) check-qtestRun qtest tests" + @echo " $(MAKE) check-pytest Run pytest tests" + @echo " $(MAKE) check-pytest-TARGETRun pytest for a given target" Or name it after the type of test rather than harness ? eg check-functional / check-functional-TARGET For that matter perhaps also for the dir name ? tests/functional/*.py I almost expected that discussion again ... (see https://lists.gnu.org/archive/html/qemu-devel/2021-05/msg06553.html ) ... last time we couldn't really agree on such a name and decided to go with the name of the framework... I agree that "pytest" is likely not the best name here, especially if switching to the pycotap test runner instead of using the "pytest" program, but "functional" might trigger the same discussion again as last time ... should it rather be "functional" or "validation" or "integration" etc.? Maybe best if we come up with a new fictional name for the "new" test framework... something like "pyqe" - PYthon-based Qemu test Environment"? ... could be considered as a play on the word "pike", too, i.e. something that makes sure that not everything gets in ... ? WDYT? Thomas
Re: [RFC PATCH 5/8] tests_pytest: Implement fetch_asset() method for downloading assets
On 12/07/2024 11.09, Daniel P. Berrangé wrote: On Thu, Jul 11, 2024 at 01:55:43PM +0200, Thomas Huth wrote: In the pytests, we cannot use the fetch_asset() function from Avocado anymore, so we have to provide our own implementation now instead. Thus add such a function based on the _download_with_cache() function from tests/vm/basevm.py for this purpose. Signed-off-by: Thomas Huth --- tests/pytest/qemu_pytest/__init__.py | 40 1 file changed, 29 insertions(+), 11 deletions(-) diff --git a/tests/pytest/qemu_pytest/__init__.py b/tests/pytest/qemu_pytest/__init__.py index e3ed32e3de..73d80b3828 100644 --- a/tests/pytest/qemu_pytest/__init__.py +++ b/tests/pytest/qemu_pytest/__init__.py @@ -11,6 +11,7 @@ # 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 hashlib import logging import os import shutil @@ -201,17 +202,34 @@ def setUp(self, bin_prefix): self.assertIsNotNone(SOURCE_DIR,'PYTEST_SOURCE_ROOT must be set') self.assertIsNotNone(self.qemu_bin, 'PYTEST_QEMU_BINARY must be set') -def fetch_asset(self, name, -asset_hash, algorithm=None, -locations=None, expire=None, -find_only=False, cancel_on_missing=True): -return super().fetch_asset(name, -asset_hash=asset_hash, -algorithm=algorithm, -locations=locations, -expire=expire, -find_only=find_only, -cancel_on_missing=cancel_on_missing) +def check_hash(self, file_name, expected_hash): +if not expected_hash: +return True +if len(expected_hash) == 32: +sum_prog = 'md5sum' +elif len(expected_hash) == 40: +sum_prog = 'sha1sum' +elif len(expected_hash) == 64: +sum_prog = 'sha256sum' +elif len(expected_hash) == 128: +sum_prog = 'sha512sum' +else: +raise Exception("unknown hash type") Why shouldn't we just standardize on sha256 as we convert each test to pytest ? sha512 is overkill, and md5/sha1 shouldn't really be used anymore. I mainly added that for minimizing the changes that I need to do on the existing tests. Updating all the hashsums there is certainly some additional work... If you want to help, feel free to send patches for the existing avocado tests to update the md5 and sha1 sums there! +checksum = subprocess.check_output([sum_prog, file_name]).split()[0] +return expected_hash == checksum.decode("utf-8") + +def fetch_asset(self, url, asset_hash): +cache_dir = os.path.expanduser("~/.cache/qemu/download") +if not os.path.exists(cache_dir): +os.makedirs(cache_dir) +fname = os.path.join(cache_dir, + hashlib.sha1(url.encode("utf-8")).hexdigest()) +if os.path.exists(fname) and self.check_hash(fname, asset_hash): +return fname +logging.debug("Downloading %s to %s...", url, fname) +subprocess.check_call(["wget", "-c", url, "-O", fname + ".download"]) +os.rename(fname + ".download", fname) +return fname To avoid a dep on an external command that may not be installed, I think we could replace wget with native python code: import urllib ... Yes, I came across urllib after I sent out the patches, too, sounds like the right way to go. We should also update tests/vm/basevm.py accordingly! Thomas
Re: [RFC PATCH 5/8] tests_pytest: Implement fetch_asset() method for downloading assets
On 11/07/2024 23.35, Richard Henderson wrote: On 7/11/24 12:23, Alex Bennée wrote: Richard Henderson writes: On 7/11/24 09:45, Richard Henderson wrote: On 7/11/24 04:55, Thomas Huth wrote: + def fetch_asset(self, url, asset_hash): + cache_dir = os.path.expanduser("~/.cache/qemu/download") + if not os.path.exists(cache_dir): + os.makedirs(cache_dir) + fname = os.path.join(cache_dir, + hashlib.sha1(url.encode("utf-8")).hexdigest()) + if os.path.exists(fname) and self.check_hash(fname, asset_hash): + return fname + logging.debug("Downloading %s to %s...", url, fname) + subprocess.check_call(["wget", "-c", url, "-O", fname + ".download"]) + os.rename(fname + ".download", fname) + return fname Download failure via exception? Check hash on downloaded asset? I would prefer to see assets, particularly downloading, handled in a separate pass from tests. And I assume cachable? The cache is already handled here. But downloading after cache miss is non-optional, may not fail, and is accounted against the meson test timeout. Unless someone has a really good idea how to implement that download before running the tests, I think we can start by simply giving enough headroom in the initial timeout settings. We can then hopefully easily fine-tune later - since this time the framework is under our control, so we don't have to sync in a cumbersome way with the avocado test runner any more. Thomas
Re: [RFC PATCH 5/8] tests_pytest: Implement fetch_asset() method for downloading assets
On 11/07/2024 20.49, Richard Henderson wrote: On 7/11/24 09:45, Richard Henderson wrote: On 7/11/24 04:55, Thomas Huth wrote: + def fetch_asset(self, url, asset_hash): + cache_dir = os.path.expanduser("~/.cache/qemu/download") + if not os.path.exists(cache_dir): + os.makedirs(cache_dir) + fname = os.path.join(cache_dir, + hashlib.sha1(url.encode("utf-8")).hexdigest()) + if os.path.exists(fname) and self.check_hash(fname, asset_hash): + return fname + logging.debug("Downloading %s to %s...", url, fname) + subprocess.check_call(["wget", "-c", url, "-O", fname + ".download"]) + os.rename(fname + ".download", fname) + return fname Download failure via exception? Check hash on downloaded asset? I would prefer to see assets, particularly downloading, handled in a separate pass from tests. (1) Asset download should not count against test timeout. (2) Running tests while disconnected should skip unavailable assets. Sounds good, but honestly, that's above my primitive python-fu. I guess that would need some kind of introspection of the tests to retrieve the information what they want to download? Thomas
Re: [RFC PATCH 5/8] tests_pytest: Implement fetch_asset() method for downloading assets
On 11/07/2024 18.45, Richard Henderson wrote: On 7/11/24 04:55, Thomas Huth wrote: + def fetch_asset(self, url, asset_hash): + cache_dir = os.path.expanduser("~/.cache/qemu/download") + if not os.path.exists(cache_dir): + os.makedirs(cache_dir) + fname = os.path.join(cache_dir, + hashlib.sha1(url.encode("utf-8")).hexdigest()) + if os.path.exists(fname) and self.check_hash(fname, asset_hash): + return fname + logging.debug("Downloading %s to %s...", url, fname) + subprocess.check_call(["wget", "-c", url, "-O", fname + ".download"]) + os.rename(fname + ".download", fname) + return fname Download failure via exception? Check hash on downloaded asset? Yes, you're right, I'll add that. But that means it's also missing from _download_with_cache in tests/vm/basevm.py so far... Thomas
Re: [RFC PATCH 0/8] Convert avocado tests to normal Python unittests
On 11/07/2024 16.39, Fabiano Rosas wrote: Thomas Huth writes: ... Things that need further attention though: - All tests that use the LinuxTest / LinuxDistro classes (e.g. based on cloud-init images) really depend on the Avocado framework, thus we'd need a solution for those if we want to continue with this approach - Same for all tests that require the LinuxSSHMixIn class - we'd need to provide a solution for ssh-based tests, too. These two seem to be dependent mostly avocado/utils only. Those could still be used without the whole framework, no? Say we keep importing avocado.utils, but run everything from meson, would that make sense? Yes ... maybe ... I can give it a try to see whether that works. Thomas
Re: Avocado 88.1 vs Python 3.12
On 10/07/2024 01.45, Richard Henderson wrote: On 7/9/24 09:26, Philippe Mathieu-Daudé wrote: On 9/7/24 17:41, Richard Henderson wrote: Hi guys, I have reinstalled my development box to ubuntu 24 (because the Rust support is better than my previous install; ho hum). I thought I had tested everything in a VM before committing, but I missed out on Avocado: AVOCADO Downloading avocado tests VM image for aarch64 Failed to load plugin from module "avocado.plugins.list": ModuleNotFoundError("No module named 'imp'") : If I understand things correctly, the python "imp" package was deprecated, and has been removed before v3.12. This is fixed in upstream avocado as of v93. But we have a hard stop in pythondeps.toml at v92. Remind me what the blocker is to upgrading? IIRC we're waiting for v2 of: https://lore.kernel.org/qemu-devel/20231208190911.102879-1-cr...@redhat.com/ Yes indeed. There are two minor conflicts in rebasing this branch, but otherwise it works. Cleber, do you have time to pick this up again? As an alternative, if nobody has time to work on that Avocado update, we could maybe also try to integrate the python-based tests directly with the meson test runner. A prototype can be found here: https://lore.kernel.org/qemu-devel/2024075546.40859-1-th...@redhat.com/ Thomas
[RFC PATCH 3/8] tests/pytest: Convert info_usernet and version test with small adjustments
These two simple tests can be converted to a pytest quite easily, we just have to set the machine to 'none' now manually since we don't support the avocado tags here yet. Signed-off-by: Thomas Huth --- .../info_usernet.py => pytest/test_info_usernet.py} | 6 ++ tests/{avocado/version.py => pytest/test_version.py} | 8 +++- 2 files changed, 5 insertions(+), 9 deletions(-) rename tests/{avocado/info_usernet.py => pytest/test_info_usernet.py} (91%) rename tests/{avocado/version.py => pytest/test_version.py} (82%) diff --git a/tests/avocado/info_usernet.py b/tests/pytest/test_info_usernet.py similarity index 91% rename from tests/avocado/info_usernet.py rename to tests/pytest/test_info_usernet.py index e1aa7a6e0a..0cc3697c0b 100644 --- a/tests/avocado/info_usernet.py +++ b/tests/pytest/test_info_usernet.py @@ -8,18 +8,16 @@ # This work is licensed under the terms of the GNU GPL, version 2 or # later. See the COPYING file in the top-level directory. -from avocado_qemu import QemuSystemTest +from qemu_pytest import QemuSystemTest from qemu.utils import get_info_usernet_hostfwd_port class InfoUsernet(QemuSystemTest): -""" -:avocado: tags=machine:none -""" def test_hostfwd(self): self.require_netdev('user') +self.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', diff --git a/tests/avocado/version.py b/tests/pytest/test_version.py similarity index 82% rename from tests/avocado/version.py rename to tests/pytest/test_version.py index c6139568a1..2d16b4075d 100644 --- a/tests/avocado/version.py +++ b/tests/pytest/test_version.py @@ -9,15 +9,13 @@ # later. See the COPYING file in the top-level directory. -from avocado_qemu import QemuSystemTest +from qemu_pytest import QemuSystemTest class Version(QemuSystemTest): -""" -:avocado: tags=quick -:avocado: tags=machine:none -""" + def test_qmp_human_info_version(self): +self.machine = 'none' self.vm.add_args('-nodefaults') self.vm.launch() res = self.vm.cmd('human-monitor-command', -- 2.45.2
[RFC PATCH 5/8] tests_pytest: Implement fetch_asset() method for downloading assets
In the pytests, we cannot use the fetch_asset() function from Avocado anymore, so we have to provide our own implementation now instead. Thus add such a function based on the _download_with_cache() function from tests/vm/basevm.py for this purpose. Signed-off-by: Thomas Huth --- tests/pytest/qemu_pytest/__init__.py | 40 1 file changed, 29 insertions(+), 11 deletions(-) diff --git a/tests/pytest/qemu_pytest/__init__.py b/tests/pytest/qemu_pytest/__init__.py index e3ed32e3de..73d80b3828 100644 --- a/tests/pytest/qemu_pytest/__init__.py +++ b/tests/pytest/qemu_pytest/__init__.py @@ -11,6 +11,7 @@ # 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 hashlib import logging import os import shutil @@ -201,17 +202,34 @@ def setUp(self, bin_prefix): self.assertIsNotNone(SOURCE_DIR,'PYTEST_SOURCE_ROOT must be set') self.assertIsNotNone(self.qemu_bin, 'PYTEST_QEMU_BINARY must be set') -def fetch_asset(self, name, -asset_hash, algorithm=None, -locations=None, expire=None, -find_only=False, cancel_on_missing=True): -return super().fetch_asset(name, -asset_hash=asset_hash, -algorithm=algorithm, -locations=locations, -expire=expire, -find_only=find_only, -cancel_on_missing=cancel_on_missing) +def check_hash(self, file_name, expected_hash): +if not expected_hash: +return True +if len(expected_hash) == 32: +sum_prog = 'md5sum' +elif len(expected_hash) == 40: +sum_prog = 'sha1sum' +elif len(expected_hash) == 64: +sum_prog = 'sha256sum' +elif len(expected_hash) == 128: +sum_prog = 'sha512sum' +else: +raise Exception("unknown hash type") +checksum = subprocess.check_output([sum_prog, file_name]).split()[0] +return expected_hash == checksum.decode("utf-8") + +def fetch_asset(self, url, asset_hash): +cache_dir = os.path.expanduser("~/.cache/qemu/download") +if not os.path.exists(cache_dir): +os.makedirs(cache_dir) +fname = os.path.join(cache_dir, + hashlib.sha1(url.encode("utf-8")).hexdigest()) +if os.path.exists(fname) and self.check_hash(fname, asset_hash): +return fname +logging.debug("Downloading %s to %s...", url, fname) +subprocess.check_call(["wget", "-c", url, "-O", fname + ".download"]) +os.rename(fname + ".download", fname) +return fname class QemuSystemTest(QemuBaseTest): -- 2.45.2
[RFC PATCH 4/8] tests/pytest: add pytest to the meson build system
From: Ani Sinha Integrate the pytest framework with the meson build system. This will make meson run all the pytests under the pytest directory. Signed-off-by: Ani Sinha [thuth: Removed the acpi-bits and adjusted for converted avocado tests instead] Signed-off-by: Thomas Huth --- tests/Makefile.include | 4 ++- tests/meson.build| 1 + tests/pytest/meson.build | 53 3 files changed, 57 insertions(+), 1 deletion(-) create mode 100644 tests/pytest/meson.build diff --git a/tests/Makefile.include b/tests/Makefile.include index d39d5dd6a4..68151717d7 100644 --- a/tests/Makefile.include +++ b/tests/Makefile.include @@ -3,12 +3,14 @@ .PHONY: check-help check-help: @echo "Regression testing targets:" - @echo " $(MAKE) check Run block, qapi-schema, unit, softfloat, qtest and decodetree tests" + @echo " $(MAKE) check Run block, qapi-schema, unit, softfloat, qtest, pytest and decodetree tests" @echo " $(MAKE) bench Run speed tests" @echo @echo "Individual test suites:" @echo " $(MAKE) check-qtest-TARGET Run qtest tests for given target" @echo " $(MAKE) check-qtestRun qtest tests" + @echo " $(MAKE) check-pytest Run pytest tests" + @echo " $(MAKE) check-pytest-TARGETRun pytest for a given target" @echo " $(MAKE) check-unit Run qobject tests" @echo " $(MAKE) check-qapi-schema Run QAPI schema tests" @echo " $(MAKE) check-blockRun block tests" diff --git a/tests/meson.build b/tests/meson.build index acb6807094..17510a468e 100644 --- a/tests/meson.build +++ b/tests/meson.build @@ -85,3 +85,4 @@ subdir('unit') subdir('qapi-schema') subdir('qtest') subdir('migration') +subdir('pytest') diff --git a/tests/pytest/meson.build b/tests/pytest/meson.build new file mode 100644 index 00..1486628d45 --- /dev/null +++ b/tests/pytest/meson.build @@ -0,0 +1,53 @@ +slow_pytests = { + 'mem_addr_space' : 90, +} + +pytests_generic = [ + 'empty_cpu_model', + 'info_usernet', + 'version', +] + +pytests_x86_64 = [ + 'cpu_queries', + 'mem_addr_space', + 'virtio_version', +] + +pytest = find_program('pytest', required: false) +if not pytest.found() + message('pytest not available ==> Disabled the qemu-pytests.') + subdir_done() +endif + +foreach dir : target_dirs + if not dir.endswith('-softmmu') +continue + endif + + target_base = dir.split('-')[0] + pytest_emulator = emulators['qemu-system-' + target_base] + target_pytests = get_variable('pytests_' + target_base, []) + pytests_generic + + test_deps = roms + pytest_env = environment() + if have_tools +pytest_env.set('PYTEST_QEMU_IMG', './qemu-img') +test_deps += [qemu_img] + endif + pytest_env.set('PYTEST_QEMU_BINARY', meson.global_build_root() / 'qemu-system-' + target_base) + pytest_env.set('PYTEST_SOURCE_ROOT', meson.project_source_root()) + pytest_env.set('PYTEST_BUILD_ROOT', meson.project_build_root()) + pytest_env.set('PYTHONPATH', meson.project_source_root() / 'python') + + foreach test : target_pytests +test('pytest-@0@/@1@'.format(target_base, test), + pytest, + depends: [test_deps, pytest_emulator, emulator_modules], + env: pytest_env, + args: [meson.current_source_dir() / 'test_' + test + '.py'], + timeout: slow_pytests.get(test, 60), + priority: slow_pytests.get(test, 60), + suite: ['pytest', 'pytest-' + target_base]) + endforeach +endforeach -- 2.45.2
[RFC PATCH 7/8] tests/pytest: Add a function for extracting files from an archive
Some Avocado-based tests use the "archive" module from avocado.utils to extract files from an archive. To be able to use these tests without Avocado, we have to provide our own function for extracting files. Fortunately, there is already the tarfile module that will provide us with this functionality, so let's just add a nice wrapper function around that. Signed-off-by: Thomas Huth --- tests/pytest/qemu_pytest/utils.py | 21 + 1 file changed, 21 insertions(+) create mode 100644 tests/pytest/qemu_pytest/utils.py diff --git a/tests/pytest/qemu_pytest/utils.py b/tests/pytest/qemu_pytest/utils.py new file mode 100644 index 00..4eb5e5d5e5 --- /dev/null +++ b/tests/pytest/qemu_pytest/utils.py @@ -0,0 +1,21 @@ +# Utilities for python-based QEMU tests +# +# Copyright 2024 Red Hat, Inc. +# +# Authors: +# Thomas Huth +# +# 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 tarfile + +def archive_extract(archive, dest_dir, member=None): +with tarfile.open(archive) as tf: +if hasattr(tarfile, 'data_filter'): +tf.extraction_filter = getattr(tarfile, 'data_filter', + (lambda member, path: member)) +if member: +tf.extract(member=member, path=dest_dir) +else: +tf.extractall(path=dest_dir) -- 2.45.2
[RFC PATCH 8/8] tests/pytest: Convert avocado test that needed avocado.utils.archive
Instead of using the "archive" module from avocado.utils, switch these tests to use the new wrapper function that is based on the "tarfile" module instead. Signed-off-by: Thomas Huth --- tests/pytest/meson.build | 5 + .../test_arm_canona1100.py}| 16 +++- .../test_ppc_bamboo.py}| 18 ++ 3 files changed, 18 insertions(+), 21 deletions(-) rename tests/{avocado/machine_arm_canona1100.py => pytest/test_arm_canona1100.py} (74%) rename tests/{avocado/ppc_bamboo.py => pytest/test_ppc_bamboo.py} (75%) diff --git a/tests/pytest/meson.build b/tests/pytest/meson.build index d3607db362..baaacf00cc 100644 --- a/tests/pytest/meson.build +++ b/tests/pytest/meson.build @@ -9,6 +9,7 @@ pytests_generic = [ ] pytests_arm = [ + 'arm_canona1100', 'machine_arm_n8x0', ] @@ -24,6 +25,10 @@ pytests_mips64el = [ 'machine_mips_loongson3v', ] +pytests_ppc = [ + 'ppc_bamboo', +] + pytests_x86_64 = [ 'cpu_queries', 'mem_addr_space', diff --git a/tests/avocado/machine_arm_canona1100.py b/tests/pytest/test_arm_canona1100.py similarity index 74% rename from tests/avocado/machine_arm_canona1100.py rename to tests/pytest/test_arm_canona1100.py index a42d8b0f2b..296df41a06 100644 --- a/tests/avocado/machine_arm_canona1100.py +++ b/tests/pytest/test_arm_canona1100.py @@ -8,9 +8,9 @@ # This work is licensed under the terms of the GNU GPL, version 2 or # later. See the COPYING file in the top-level directory. -from avocado_qemu import QemuSystemTest -from avocado_qemu import wait_for_console_pattern -from avocado.utils import archive +from qemu_pytest import QemuSystemTest +from qemu_pytest import wait_for_console_pattern +from qemu_pytest.utils import archive_extract class CanonA1100Machine(QemuSystemTest): """Boots the barebox firmware and checks that the console is operational""" @@ -18,16 +18,14 @@ class CanonA1100Machine(QemuSystemTest): timeout = 90 def test_arm_canona1100(self): -""" -:avocado: tags=arch:arm -:avocado: tags=machine:canon-a1100 -:avocado: tags=device:pflash_cfi02 -""" +self.machine = 'canon-a1100' + tar_url = ('https://qemu-advcal.gitlab.io' '/qac-best-of-multiarch/download/day18.tar.xz') tar_hash = '068b5fc4242b29381acee94713509f8a876e9db6' file_path = self.fetch_asset(tar_url, asset_hash=tar_hash) -archive.extract(file_path, self.workdir) +archive_extract(file_path, dest_dir=self.workdir, +member="day18/barebox.canon-a1100.bin") self.vm.set_console() self.vm.add_args('-bios', self.workdir + '/day18/barebox.canon-a1100.bin') diff --git a/tests/avocado/ppc_bamboo.py b/tests/pytest/test_ppc_bamboo.py similarity index 75% rename from tests/avocado/ppc_bamboo.py rename to tests/pytest/test_ppc_bamboo.py index a81be3d608..4964dedbfe 100644 --- a/tests/avocado/ppc_bamboo.py +++ b/tests/pytest/test_ppc_bamboo.py @@ -5,30 +5,24 @@ # This work is licensed under the terms of the GNU GPL, version 2 or # later. See the COPYING file in the top-level directory. -from avocado.utils import archive -from avocado_qemu import QemuSystemTest -from avocado_qemu import wait_for_console_pattern -from avocado_qemu import exec_command_and_wait_for_pattern +from qemu_pytest.utils import archive_extract +from qemu_pytest import QemuSystemTest +from qemu_pytest import wait_for_console_pattern +from qemu_pytest import exec_command_and_wait_for_pattern class BambooMachine(QemuSystemTest): timeout = 90 def test_ppc_bamboo(self): -""" -:avocado: tags=arch:ppc -:avocado: tags=machine:bamboo -:avocado: tags=cpu:440epb -:avocado: tags=device:rtl8139 -:avocado: tags=accel:tcg -""" +self.machine = 'bamboo' self.require_accelerator("tcg") self.require_netdev('user') tar_url = ('http://landley.net/aboriginal/downloads/binaries/' 'system-image-powerpc-440fp.tar.gz') tar_hash = '53e5f16414b195b82d2c70272f81c2eedb39bad9' file_path = self.fetch_asset(tar_url, asset_hash=tar_hash) -archive.extract(file_path, self.workdir) +archive_extract(file_path, self.workdir) self.vm.set_console() self.vm.add_args('-kernel', self.workdir + '/system-image-powerpc-440fp/linux', -- 2.45.2
[RFC PATCH 6/8] tests/pytest: Convert some tests that download files via fetch_asset()
Now that we've got a working fetch_asset() function, we can convert some Avocado tests that use this function for downloading their required files. Signed-off-by: Thomas Huth --- tests/pytest/meson.build | 16 +++ .../test_machine_arm_n8x0.py} | 20 +++ .../test_machine_avr6.py} | 7 ++- .../test_machine_loongarch.py}| 11 -- .../test_machine_mips_loongson3v.py} | 19 ++ 5 files changed, 35 insertions(+), 38 deletions(-) rename tests/{avocado/machine_arm_n8x0.py => pytest/test_machine_arm_n8x0.py} (71%) rename tests/{avocado/machine_avr6.py => pytest/test_machine_avr6.py} (91%) rename tests/{avocado/machine_loongarch.py => pytest/test_machine_loongarch.py} (89%) rename tests/{avocado/machine_mips_loongson3v.py => pytest/test_machine_mips_loongson3v.py} (59%) diff --git a/tests/pytest/meson.build b/tests/pytest/meson.build index 1486628d45..d3607db362 100644 --- a/tests/pytest/meson.build +++ b/tests/pytest/meson.build @@ -8,6 +8,22 @@ pytests_generic = [ 'version', ] +pytests_arm = [ + 'machine_arm_n8x0', +] + +pytests_avr = [ + 'machine_avr6', +] + +pytests_loongarch64 = [ + 'machine_loongarch', +] + +pytests_mips64el = [ + 'machine_mips_loongson3v', +] + pytests_x86_64 = [ 'cpu_queries', 'mem_addr_space', diff --git a/tests/avocado/machine_arm_n8x0.py b/tests/pytest/test_machine_arm_n8x0.py similarity index 71% rename from tests/avocado/machine_arm_n8x0.py rename to tests/pytest/test_machine_arm_n8x0.py index 12e9a6803b..082284b975 100644 --- a/tests/avocado/machine_arm_n8x0.py +++ b/tests/pytest/test_machine_arm_n8x0.py @@ -10,9 +10,9 @@ import os -from avocado import skipUnless -from avocado_qemu import QemuSystemTest -from avocado_qemu import wait_for_console_pattern +from unittest import skipUnless +from qemu_pytest import QemuSystemTest +from qemu_pytest import wait_for_console_pattern class N8x0Machine(QemuSystemTest): """Boots the Linux kernel and checks that the console is operational""" @@ -32,18 +32,12 @@ def __do_test_n8x0(self): self.vm.launch() wait_for_console_pattern(self, 'TSC2005 driver initializing') -@skipUnless(os.getenv('AVOCADO_ALLOW_UNTRUSTED_CODE'), 'untrusted code') +@skipUnless(os.getenv('QEMU_TEST_ALLOW_UNTRUSTED_CODE'), 'untrusted code') def test_n800(self): -""" -:avocado: tags=arch:arm -:avocado: tags=machine:n800 -""" +self.machine = 'n800' self.__do_test_n8x0() -@skipUnless(os.getenv('AVOCADO_ALLOW_UNTRUSTED_CODE'), 'untrusted code') +@skipUnless(os.getenv('QEMU_TEST_ALLOW_UNTRUSTED_CODE'), 'untrusted code') def test_n810(self): -""" -:avocado: tags=arch:arm -:avocado: tags=machine:n810 -""" +self.machine = 'n810' self.__do_test_n8x0() diff --git a/tests/avocado/machine_avr6.py b/tests/pytest/test_machine_avr6.py similarity index 91% rename from tests/avocado/machine_avr6.py rename to tests/pytest/test_machine_avr6.py index 5485db79c6..479038a221 100644 --- a/tests/avocado/machine_avr6.py +++ b/tests/pytest/test_machine_avr6.py @@ -19,16 +19,12 @@ import time -from avocado_qemu import QemuSystemTest +from qemu_pytest import QemuSystemTest class AVR6Machine(QemuSystemTest): timeout = 5 def test_freertos(self): -""" -:avocado: tags=arch:avr -:avocado: tags=machine:arduino-mega-2560-v3 -""" """ https://github.com/seharris/qemu-avr-tests/raw/master/free-rtos/Demo/AVR_ATMega2560_GCC/demo.elf constantly prints out 'ABCDEFGHIJKLMNOPQRSTUVWXABCDEFGHIJKLMNOPQRSTUVWX' @@ -39,6 +35,7 @@ def test_freertos(self): rom_hash = '7eb521f511ca8f2622e0a3c5e8dd686efbb911d4' rom_path = self.fetch_asset(rom_url, asset_hash=rom_hash) +self.machine = 'arduino-mega-2560-v3' self.vm.add_args('-bios', rom_path) self.vm.add_args('-nographic') self.vm.launch() diff --git a/tests/avocado/machine_loongarch.py b/tests/pytest/test_machine_loongarch.py similarity index 89% rename from tests/avocado/machine_loongarch.py rename to tests/pytest/test_machine_loongarch.py index 8de308f2d6..3eb68745ac 100644 --- a/tests/avocado/machine_loongarch.py +++ b/tests/pytest/test_machine_loongarch.py @@ -5,9 +5,9 @@ # Copyright (c) 2023 Loongson Technology Corporation Limited # -from avocado_qemu import QemuSystemTest -from avocado_qemu import exec_command_and_wait_for_pattern -from avocado_qemu import wait_for_console_pattern +from qemu_pytest import QemuSystemTest +from qemu_pytest import exec_command_and_wait_for_pattern +from qemu_pytest import wait_for_console_pattern class LoongArchMachine(QemuSystemTe
[RFC PATCH 2/8] tests/pytest: Convert some simple avocado tests into pytests
These test are rather simple and don't need any modifications apart from adjusting the "from avocado_qemu" line. These tests can now be run directly via "pytest" by setting the PYTHONPATH environment variable to the python folder of QEMU and by providing the QEMU binary via the PYTEST_QEMU_BINARY environment variable, and the source and build directories via the PYTEST_SOURCE_ROOTand PYTEST_BUILD_ROOT environment variables. Signed-off-by: Thomas Huth --- tests/{avocado/cpu_queries.py => pytest/test_cpu_queries.py} | 2 +- .../empty_cpu_model.py => pytest/test_empty_cpu_model.py} | 2 +- .../mem-addr-space-check.py => pytest/test_mem_addr_space.py} | 3 +-- .../virtio_version.py => pytest/test_virtio_version.py}| 2 +- 4 files changed, 4 insertions(+), 5 deletions(-) rename tests/{avocado/cpu_queries.py => pytest/test_cpu_queries.py} (96%) rename tests/{avocado/empty_cpu_model.py => pytest/test_empty_cpu_model.py} (94%) rename tests/{avocado/mem-addr-space-check.py => pytest/test_mem_addr_space.py} (99%) rename tests/{avocado/virtio_version.py => pytest/test_virtio_version.py} (99%) diff --git a/tests/avocado/cpu_queries.py b/tests/pytest/test_cpu_queries.py similarity index 96% rename from tests/avocado/cpu_queries.py rename to tests/pytest/test_cpu_queries.py index d3faa14720..b300447121 100644 --- a/tests/avocado/cpu_queries.py +++ b/tests/pytest/test_cpu_queries.py @@ -8,7 +8,7 @@ # This work is licensed under the terms of the GNU GPL, version 2 or # later. See the COPYING file in the top-level directory. -from avocado_qemu import QemuSystemTest +from qemu_pytest import QemuSystemTest class QueryCPUModelExpansion(QemuSystemTest): """ diff --git a/tests/avocado/empty_cpu_model.py b/tests/pytest/test_empty_cpu_model.py similarity index 94% rename from tests/avocado/empty_cpu_model.py rename to tests/pytest/test_empty_cpu_model.py index d906ef3d3c..113740bc82 100644 --- a/tests/avocado/empty_cpu_model.py +++ b/tests/pytest/test_empty_cpu_model.py @@ -7,7 +7,7 @@ # # This work is licensed under the terms of the GNU GPL, version 2 or # later. See the COPYING file in the top-level directory. -from avocado_qemu import QemuSystemTest +from qemu_pytest import QemuSystemTest class EmptyCPUModel(QemuSystemTest): def test(self): diff --git a/tests/avocado/mem-addr-space-check.py b/tests/pytest/test_mem_addr_space.py similarity index 99% rename from tests/avocado/mem-addr-space-check.py rename to tests/pytest/test_mem_addr_space.py index 85541ea051..6ae7ba5e6b 100644 --- a/tests/avocado/mem-addr-space-check.py +++ b/tests/pytest/test_mem_addr_space.py @@ -8,8 +8,7 @@ # # SPDX-License-Identifier: GPL-2.0-or-later -from avocado_qemu import QemuSystemTest -import signal +from qemu_pytest import QemuSystemTest import time class MemAddrCheck(QemuSystemTest): diff --git a/tests/avocado/virtio_version.py b/tests/pytest/test_virtio_version.py similarity index 99% rename from tests/avocado/virtio_version.py rename to tests/pytest/test_virtio_version.py index afe5e828b5..ca3aa806df 100644 --- a/tests/avocado/virtio_version.py +++ b/tests/pytest/test_virtio_version.py @@ -12,7 +12,7 @@ import os from qemu.machine import QEMUMachine -from avocado_qemu import QemuSystemTest +from qemu_pytest import QemuSystemTest # Virtio Device IDs: VIRTIO_NET = 1 -- 2.45.2
[RFC PATCH 1/8] tests/pytest: Add base classes for the upcoming pytest-based tests
The file is a copy of the tests/avocado/avocado_qemu/__init__.py file with some adjustments to get rid of the Avocado dependencies (i.e. we also have to drop the LinuxSSHMixIn and LinuxTest for now). The emulator binary, source and build directory are now passed via environment variables that will be set via meson.build later. Signed-off-by: Thomas Huth --- tests/pytest/qemu_pytest/__init__.py | 344 +++ 1 file changed, 344 insertions(+) create mode 100644 tests/pytest/qemu_pytest/__init__.py diff --git a/tests/pytest/qemu_pytest/__init__.py b/tests/pytest/qemu_pytest/__init__.py new file mode 100644 index 00..e3ed32e3de --- /dev/null +++ b/tests/pytest/qemu_pytest/__init__.py @@ -0,0 +1,344 @@ +# Test class and utilities for functional tests +# +# Copyright 2018, 2024 Red Hat, Inc. +# +# Original Author (Avocado-based tests): +# Cleber Rosa +# +# Adaption for pytest based version: +# Thomas Huth +# +# 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 logging +import os +import shutil +import subprocess +import sys +import tempfile +import time +import uuid +import unittest + +from qemu.machine import QEMUMachine +from qemu.utils import (get_info_usernet_hostfwd_port, kvm_available, +tcg_available) + +BUILD_DIR = os.getenv('PYTEST_BUILD_ROOT') +SOURCE_DIR = os.getenv('PYTEST_SOURCE_ROOT') + +def has_cmd(name, args=None): +""" +This function is for use in a @skipUnless decorator, e.g.: + +@skipUnless(*has_cmd('sudo -n', ('sudo', '-n', 'true'))) +def test_something_that_needs_sudo(self): +... +""" + +if args is None: +args = ('which', name) + +try: +_, stderr, exitcode = run_cmd(args) +except Exception as e: +exitcode = -1 +stderr = str(e) + +if exitcode != 0: +cmd_line = ' '.join(args) +err = f'{name} required, but "{cmd_line}" failed: {stderr.strip()}' +return (False, err) +else: +return (True, '') + +def has_cmds(*cmds): +""" +This function is for use in a @skipUnless decorator and +allows checking for the availability of multiple commands, e.g.: + +@skipUnless(*has_cmds(('cmd1', ('cmd1', '--some-parameter')), + 'cmd2', 'cmd3')) +def test_something_that_needs_cmd1_and_cmd2(self): +... +""" + +for cmd in cmds: +if isinstance(cmd, str): +cmd = (cmd,) + +ok, errstr = has_cmd(*cmd) +if not ok: +return (False, errstr) + +return (True, '') + +def run_cmd(args): +subp = subprocess.Popen(args, +stdout=subprocess.PIPE, +stderr=subprocess.PIPE, +universal_newlines=True) +stdout, stderr = subp.communicate() +ret = subp.returncode + +return (stdout, stderr, ret) + +def is_readable_executable_file(path): +return os.path.isfile(path) and os.access(path, os.R_OK | os.X_OK) + +def _console_interaction(test, success_message, failure_message, + send_string, keep_sending=False, vm=None): +assert not keep_sending or send_string +if vm is None: +vm = test.vm +console = vm.console_file +console_logger = logging.getLogger('console') +while True: +if send_string: +vm.console_socket.sendall(send_string.encode()) +if not keep_sending: +send_string = None # send only once +try: +msg = console.readline().decode().strip() +except UnicodeDecodeError: +msg = None +if not msg: +continue +console_logger.debug(msg) +if success_message is None or success_message in msg: +break +if failure_message and failure_message in msg: +console.close() +fail = 'Failure message found in console: "%s". Expected: "%s"' % \ +(failure_message, success_message) +test.fail(fail) + +def interrupt_interactive_console_until_pattern(test, success_message, +failure_message=None, +interrupt_string='\r'): +""" +Keep sending a string to interrupt a console prompt, while logging the +console output. Typical use case is to break a boot loader prompt, such: + +Press a key within 5 seconds to interrupt boot process. +5 +4 +3 +2 +1 +Booting default image... + +:param test: a test containing a VM that will have its console + read and probed for a success or failure message +:type test: :class:`qemu_pytest.QemuSystemTest` +:p
[RFC PATCH 0/8] Convert avocado tests to normal Python unittests
The Avocado v88 that we use in QEMU is already on a life support system: It is not supported by upstream anymore, and with the latest versions of Python, it won't work anymore since it depends on the "imp" module that has been removed in Python 3.12. There have been several attempts to update the test suite in QEMU to a newer version of Avocado, but so far no attempt has successfully been merged yet. Additionally, the whole "make check" test suite in QEMU is using the meson test runner nowadays, so running the python-based tests via the Avocodo test runner looks and feels quite like an oddball, requiring the users to deal with the knowledge of multiple test runners in parallel. So instead of trying to update the python-based test suite in QEMU to a newer version of Avocado, we should maybe try to better integrate it with the meson test runner instead. Indeed most tests work quite nicely without the Avocado framework already, as you can see with this patch series - it does not convert all tests, just a subset since it is just an RFC so far, but as you can see, many tests only need small modifications to work without Avocado. If you want to try it: Apply the patches, make sure that you have the "pytest" program installed, then recompile and then run: make check-pytest Things that need further attention though: - All tests that use the LinuxTest / LinuxDistro classes (e.g. based on cloud-init images) really depend on the Avocado framework, thus we'd need a solution for those if we want to continue with this approach - Same for all tests that require the LinuxSSHMixIn class - we'd need to provide a solution for ssh-based tests, too. - We lose the way of running tests via the avocado tags this way... single targets can still be tested by running "make check-pytest-arm" for example, but running selected tests by other tags does not work anymore. - I haven't looked into logging yet ... this still needs some work so that you could e.g. inspect the console output of the guests somewhere - I did not work on documentation updates yet (will do that if we agree to continue with this patch series) What's your thoughts? Is it worth to continue with this approach? Or shall I rather forget about it and wait for the Avocado version update? Thomas Ani Sinha (1): tests/pytest: add pytest to the meson build system Thomas Huth (7): tests/pytest: Add base classes for the upcoming pytest-based tests tests/pytest: Convert some simple avocado tests into pytests tests/pytest: Convert info_usernet and version test with small adjustments tests_pytest: Implement fetch_asset() method for downloading assets tests/pytest: Convert some tests that download files via fetch_asset() tests/pytest: Add a function for extracting files from an archive tests/pytest: Convert avocado test that needed avocado.utils.archive tests/Makefile.include| 4 +- tests/meson.build | 1 + tests/pytest/meson.build | 74 tests/pytest/qemu_pytest/__init__.py | 362 ++ tests/pytest/qemu_pytest/utils.py | 21 + .../test_arm_canona1100.py} | 16 +- .../test_cpu_queries.py} | 2 +- .../test_empty_cpu_model.py} | 2 +- .../test_info_usernet.py} | 6 +- .../test_machine_arm_n8x0.py} | 20 +- .../test_machine_avr6.py} | 7 +- .../test_machine_loongarch.py}| 11 +- .../test_machine_mips_loongson3v.py} | 19 +- .../test_mem_addr_space.py} | 3 +- .../test_ppc_bamboo.py} | 18 +- .../version.py => pytest/test_version.py} | 8 +- .../test_virtio_version.py} | 2 +- 17 files changed, 502 insertions(+), 74 deletions(-) create mode 100644 tests/pytest/meson.build create mode 100644 tests/pytest/qemu_pytest/__init__.py create mode 100644 tests/pytest/qemu_pytest/utils.py rename tests/{avocado/machine_arm_canona1100.py => pytest/test_arm_canona1100.py} (74%) rename tests/{avocado/cpu_queries.py => pytest/test_cpu_queries.py} (96%) rename tests/{avocado/empty_cpu_model.py => pytest/test_empty_cpu_model.py} (94%) rename tests/{avocado/info_usernet.py => pytest/test_info_usernet.py} (91%) rename tests/{avocado/machine_arm_n8x0.py => pytest/test_machine_arm_n8x0.py} (71%) rename tests/{avocado/machine_avr6.py => pytest/test_machine_avr6.py} (91%) rename tests/{avocado/machine_loongarch.py => pytest/test_machine_loongarch.py} (89%) rename tests/{avocado/machine_mips_loongson3v.py => pytest/test_machine_mips_loongson3v.py} (59%) rename tests/{avocado/mem-addr-space-check.py => pytest/test_mem_addr_space.py} (99%) rename tests/{avocado/ppc_bamboo.py => pytest/test_ppc_bamboo.py} (75%) rename tests/{a
[PATCH] tests/avocado: Remove the non-working virtio_check_params test
The test has been marked as broken more than 4 years ago, and so far nobody ever cared to fix it. Thus let's simply remove it now ... if somebody ever needs it again, they can restore the file from an older version of QEMU. Signed-off-by: Thomas Huth --- tests/avocado/virtio_check_params.py | 143 --- 1 file changed, 143 deletions(-) delete mode 100644 tests/avocado/virtio_check_params.py diff --git a/tests/avocado/virtio_check_params.py b/tests/avocado/virtio_check_params.py deleted file mode 100644 index 5fe370a179..00 --- a/tests/avocado/virtio_check_params.py +++ /dev/null @@ -1,143 +0,0 @@ -# -# Test virtio-scsi and virtio-blk queue settings for all machine types -# -# Copyright (c) 2019 Virtuozzo International GmbH -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see <http://www.gnu.org/licenses/>. -# - -import sys -import os -import re -import logging - -from qemu.machine import QEMUMachine -from avocado_qemu import QemuSystemTest -from avocado import skip - -#list of machine types and virtqueue properties to test -VIRTIO_SCSI_PROPS = {'seg_max_adjust': 'seg_max_adjust'} -VIRTIO_BLK_PROPS = {'seg_max_adjust': 'seg-max-adjust'} - -DEV_TYPES = {'virtio-scsi-pci': VIRTIO_SCSI_PROPS, - 'virtio-blk-pci': VIRTIO_BLK_PROPS} - -VM_DEV_PARAMS = {'virtio-scsi-pci': ['-device', 'virtio-scsi-pci,id=scsi0'], - 'virtio-blk-pci': ['-device', -'virtio-blk-pci,id=scsi0,drive=drive0', -'-drive', -'driver=null-co,id=drive0,if=none']} - - -class VirtioMaxSegSettingsCheck(QemuSystemTest): -@staticmethod -def make_pattern(props): -pattern_items = [r'{0} = \w+'.format(prop) for prop in props] -return '|'.join(pattern_items) - -def query_virtqueue(self, vm, dev_type_name): -query_ok = False -error = None -props = None - -output = vm.cmd('human-monitor-command', -command_line = 'info qtree') -props_list = DEV_TYPES[dev_type_name].values(); -pattern = self.make_pattern(props_list) -res = re.findall(pattern, output) - -if len(res) != len(props_list): -props_list = set(props_list) -res = set(res) -not_found = props_list.difference(res) -not_found = ', '.join(not_found) -error = '({0}): The following properties not found: {1}'\ - .format(dev_type_name, not_found) -else: -query_ok = True -props = dict() -for prop in res: -p = prop.split(' = ') -props[p[0]] = p[1] -return query_ok, props, error - -def check_mt(self, mt, dev_type_name): -mt['device'] = dev_type_name # Only for the debug() call. -logger = logging.getLogger('machine') -logger.debug(mt) -with QEMUMachine(self.qemu_bin) as vm: -vm.set_machine(mt["name"]) -vm.add_args('-nodefaults') -for s in VM_DEV_PARAMS[dev_type_name]: -vm.add_args(s) -try: -vm.launch() -query_ok, props, error = self.query_virtqueue(vm, dev_type_name) -except: -query_ok = False -error = sys.exc_info()[0] - -if not query_ok: -self.fail('machine type {0}: {1}'.format(mt['name'], error)) - -for prop_name, prop_val in props.items(): -expected_val = mt[prop_name] -self.assertEqual(expected_val, prop_val) - -@staticmethod -def seg_max_adjust_enabled(mt): -# machine types >= 5.0 should have seg_max_adjust = true -# others seg_max_adjust = false -mt = mt.split("-") - -# machine types with one line name and name like pc-x.x -if len(mt) <= 2: -return False - -# machine types like pc--x.x[.x] -ver = mt[2] -ver = ver.split("."); - -# versions >= 5.0 goes with seg_max_adjust enabled -major = int(ver[0]) - -if major >= 5: -return True -return False - -@skip("break multi-arch CI") -def test_machine_types(self): -# collect all machine types except 'none', 'isapc', 'microvm' -wit
[PATCH] tests/avocado: Remove non-working sparc leon3 test
The test has been marked as broken more than 4 years ago, and so far nobody ever cared to fix it. Thus let's simply remove it now ... if somebody ever needs it again, they can restore the file from an older version of QEMU. Signed-off-by: Thomas Huth --- tests/avocado/machine_sparc_leon3.py | 37 1 file changed, 37 deletions(-) delete mode 100644 tests/avocado/machine_sparc_leon3.py diff --git a/tests/avocado/machine_sparc_leon3.py b/tests/avocado/machine_sparc_leon3.py deleted file mode 100644 index e61b223185..00 --- a/tests/avocado/machine_sparc_leon3.py +++ /dev/null @@ -1,37 +0,0 @@ -# Functional test that boots a Leon3 machine and checks its serial console. -# -# Copyright (c) Philippe Mathieu-Daudé -# -# This work is licensed under the terms of the GNU GPL, version 2 or -# later. See the COPYING file in the top-level directory. - -from avocado_qemu import QemuSystemTest -from avocado_qemu import wait_for_console_pattern -from avocado import skip - - -class Leon3Machine(QemuSystemTest): - -timeout = 60 - -@skip("Test currently broken") -# A Window Underflow exception occurs before booting the kernel, -# and QEMU exit calling cpu_abort(), which makes this test to fail. -def test_leon3_helenos_uimage(self): -""" -:avocado: tags=arch:sparc -:avocado: tags=machine:leon3_generic -:avocado: tags=binfmt:uimage -""" -kernel_url = ('http://www.helenos.org/releases/' - 'HelenOS-0.6.0-sparc32-leon3.bin') -kernel_hash = 'a88c9cfdb8430c66650e5290a08765f9bf049a30' -kernel_path = self.fetch_asset(kernel_url, asset_hash=kernel_hash) - -self.vm.set_console() -self.vm.add_args('-kernel', kernel_path) - -self.vm.launch() - -wait_for_console_pattern(self, 'Copyright (c) 2001-2014 HelenOS project') -wait_for_console_pattern(self, 'Booting the kernel ...') -- 2.45.2
Re: [PATCH v3 9/9] tests/qtest: Delete previous boot file
On 08/07/2024 08.55, Akihiko Odaki wrote: A test run may create boot files several times. Delete the previous boot file before creating a new one. Signed-off-by: Akihiko Odaki Reviewed-by: Michael S. Tsirkin --- tests/qtest/migration-test.c | 18 +++--- 1 file changed, 11 insertions(+), 7 deletions(-) Acked-by: Thomas Huth
Re: [PATCH v2 20/40] gitlab: don't bother with KVM for TCI builds
On 05/07/2024 23.44, Philippe Mathieu-Daudé wrote: On 5/7/24 18:49, Thomas Huth wrote: On 05/07/2024 18.34, Philippe Mathieu-Daudé wrote: On 5/7/24 10:40, Alex Bennée wrote: In fact any other accelerator would be pointless as the point is to exercise the TCI accelerator anyway. Signed-off-by: Alex Bennée --- .gitlab-ci.d/buildtest.yml | 2 +- .gitlab-ci.d/crossbuilds.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitlab-ci.d/buildtest.yml b/.gitlab-ci.d/buildtest.yml index 425fc6479b..e3a0758bd9 100644 --- a/.gitlab-ci.d/buildtest.yml +++ b/.gitlab-ci.d/buildtest.yml @@ -635,7 +635,7 @@ build-tci: - TARGETS="aarch64 arm hppa m68k microblaze ppc64 s390x x86_64" - mkdir build - cd build - - ../configure --enable-tcg-interpreter --disable-docs --disable-gtk --disable-vnc + - ../configure --enable-tcg-interpreter --disable-kvm --disable-docs --disable-gtk --disable-vnc Shouldn't we also disable the other accelerators for completeness? No, this is a Linux machine, and there's only TCG and KVM available for Linux. No need to bother with the other accelerators here. I noticed this is Linux. If for some reason the Xen libs get installed, Xen accel will be enabled. Explicit would be: --enable-tcg --enable-tcg-interpreter --disable-kvm --disable-xen But I won't insist. Anyhow Alex sent his pull request. Oh, drat, I somehow only had the hvf and whpx accelerators in mind... You're right, --disable-xen is certainly a good idea here, too: https://gitlab.com/qemu-project/qemu/-/jobs/7281510036#L583 Mind to send a patch on top of the previous one? Thomas
Re: [PATCH v2 20/40] gitlab: don't bother with KVM for TCI builds
On 05/07/2024 18.34, Philippe Mathieu-Daudé wrote: On 5/7/24 10:40, Alex Bennée wrote: In fact any other accelerator would be pointless as the point is to exercise the TCI accelerator anyway. Signed-off-by: Alex Bennée --- .gitlab-ci.d/buildtest.yml | 2 +- .gitlab-ci.d/crossbuilds.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitlab-ci.d/buildtest.yml b/.gitlab-ci.d/buildtest.yml index 425fc6479b..e3a0758bd9 100644 --- a/.gitlab-ci.d/buildtest.yml +++ b/.gitlab-ci.d/buildtest.yml @@ -635,7 +635,7 @@ build-tci: - TARGETS="aarch64 arm hppa m68k microblaze ppc64 s390x x86_64" - mkdir build - cd build - - ../configure --enable-tcg-interpreter --disable-docs --disable-gtk --disable-vnc + - ../configure --enable-tcg-interpreter --disable-kvm --disable-docs --disable-gtk --disable-vnc Shouldn't we also disable the other accelerators for completeness? No, this is a Linux machine, and there's only TCG and KVM available for Linux. No need to bother with the other accelerators here. Thomas
[PATCH] system: Enable the device aliases for or1k, too
Now that we've got a "virt" machine for or1k that supports PCI, too, we can also enable the virtio device aliases like we do on other similar platforms. This will e.g. help to run the iotests with qemu-system-or1k later. While we're at it, sort QEMU_ARCH_LOONGARCH alphabetically into the list. Signed-off-by: Thomas Huth --- system/qdev-monitor.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/system/qdev-monitor.c b/system/qdev-monitor.c index 6af6ef7d66..60c3b6ad96 100644 --- a/system/qdev-monitor.c +++ b/system/qdev-monitor.c @@ -57,10 +57,10 @@ typedef struct QDevAlias /* default virtio transport per architecture */ #define QEMU_ARCH_VIRTIO_PCI (QEMU_ARCH_ALPHA | QEMU_ARCH_ARM | \ QEMU_ARCH_HPPA | QEMU_ARCH_I386 | \ - QEMU_ARCH_MIPS | QEMU_ARCH_PPC | \ + QEMU_ARCH_LOONGARCH | QEMU_ARCH_MIPS | \ + QEMU_ARCH_OPENRISC | QEMU_ARCH_PPC | \ QEMU_ARCH_RISCV | QEMU_ARCH_SH4 | \ - QEMU_ARCH_SPARC | QEMU_ARCH_XTENSA | \ - QEMU_ARCH_LOONGARCH) + QEMU_ARCH_SPARC | QEMU_ARCH_XTENSA) #define QEMU_ARCH_VIRTIO_CCW (QEMU_ARCH_S390X) #define QEMU_ARCH_VIRTIO_MMIO (QEMU_ARCH_M68K) -- 2.45.2
Re: [PATCH v2 20/40] gitlab: don't bother with KVM for TCI builds
On 05/07/2024 10.40, Alex Bennée wrote: In fact any other accelerator would be pointless as the point is to exercise the TCI accelerator anyway. Signed-off-by: Alex Bennée --- .gitlab-ci.d/buildtest.yml | 2 +- .gitlab-ci.d/crossbuilds.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) Reviewed-by: Thomas Huth
Re: [PULL 02/12] tests/qtest/migration-test: enable on s390x with TCG
On 04/07/2024 13.20, Nicholas Piggin wrote: On Tue Jul 2, 2024 at 8:33 PM AEST, Thomas Huth wrote: From: Nicholas Piggin s390x with TCG is more stable now. Enable it. Ah, you did a more complete version of my flic fix that migrates all the state. I didn't see that go by but yeah I suspect that was probably the correct thing to do. Thanks for that. Drat, seems like I forgot to CC: you on that patch, sorry for that, that was by accident and certainly not on purpose :-( Should the s390x flic migrate fix could be got to stable, perhaps? We need a new machine type for enabling the fix, so it does not make much sense on stable, unfortunately. There's some kvm-unit-tests s390x migration tests that can be enabled after the fix too don't forget. Right, I'll try to remember to enable it once QEMU 9.1 has been released. Thomas
Re: [PULL v2 00/88] virtio: features,fixes
On 03/07/2024 21.45, Michael S. Tsirkin wrote: On Wed, Jul 03, 2024 at 08:46:38PM +0200, Thomas Huth wrote: On 03/07/2024 19.01, Richard Henderson wrote: On 7/3/24 09:51, Michael S. Tsirkin wrote: On Wed, Jul 03, 2024 at 09:31:45AM -0700, Richard Henderson wrote: On 7/2/24 13:15, Michael S. Tsirkin wrote: The following changes since commit 1152a0414944f03231f3177207d379d58125890e: Merge tag 'pull-xen-20240701' ofhttps://xenbits.xen.org/git-http/people/aperard/qemu-dm into staging (2024-07-01 09:06:25 -0700) are available in the Git repository at: https://git.kernel.org/pub/scm/virt/kvm/mst/qemu.git tags/for_upstream for you to fetch changes up to 29e45afd8d6abf7a67dab5db0ab1cfbc388daefe: hw/pci: Replace -1 with UINT32_MAX for romsize (2024-07-02 11:27:19 -0400) virtio: features,fixes A bunch of improvements: - vhost dirty log is now only scanned once, not once per device - virtio and vhost now support VIRTIO_F_NOTIFICATION_DATA - cxl gained DCD emulation support - pvpanic gained shutdown support - beginning of patchset for Generic Port Affinity Structure - s3 support - friendlier error messages when boot fails on some illegal configs - for vhost-user, VHOST_USER_SET_LOG_BASE is now only sent once - vhost-user now works on any POSIX system - sr-iov VF setup code has been reworked significantly - new tests, particularly for risc-v ACPI - bugfixes Signed-off-by: Michael S. Tsirkin Fails testing: https://gitlab.com/qemu-project/qemu/-/jobs/7257337667 Could you give me a hint how to trigger this in CI pls? All tests seem to pass when I push it to gitlab. Any special variables to set? In CI, FreeBSD uses travis; I'm not sure what's involved. s/travis/cirrus-ci/ See .gitlab-ci.d/cirrus/README.rst for information how to enable it in your private gitlab repo. I replicated it locally within a FreeBSD VM. It should be reproducible with 'make vm-build-freebsd', but I think that's more difficult to debug after the fact than a full vm. Just use "make vm-build-freebsd DEBUG=1" and you should get a shell prompt for interactive debugging, so that's likely the best way to tackle such issues. HTH, Thomas Well 1st failure had to do with inabilit to find qemu-img. Which I guess should be used from build directory really? After adding that to path for now, it crashes with: ./scripts/archive-source.sh: line 55: meson: command not found Would appreciate some help here. Hmm, you've got to run the command from your build directory, not from the source tree ... maybe that's the problem? Thomas
Re: [PULL v2 00/88] virtio: features,fixes
On 03/07/2024 22.26, Michael S. Tsirkin wrote: On Wed, Jul 03, 2024 at 08:46:38PM +0200, Thomas Huth wrote: On 03/07/2024 19.01, Richard Henderson wrote: On 7/3/24 09:51, Michael S. Tsirkin wrote: On Wed, Jul 03, 2024 at 09:31:45AM -0700, Richard Henderson wrote: On 7/2/24 13:15, Michael S. Tsirkin wrote: The following changes since commit 1152a0414944f03231f3177207d379d58125890e: Merge tag 'pull-xen-20240701' ofhttps://xenbits.xen.org/git-http/people/aperard/qemu-dm into staging (2024-07-01 09:06:25 -0700) are available in the Git repository at: https://git.kernel.org/pub/scm/virt/kvm/mst/qemu.git tags/for_upstream for you to fetch changes up to 29e45afd8d6abf7a67dab5db0ab1cfbc388daefe: hw/pci: Replace -1 with UINT32_MAX for romsize (2024-07-02 11:27:19 -0400) virtio: features,fixes A bunch of improvements: - vhost dirty log is now only scanned once, not once per device - virtio and vhost now support VIRTIO_F_NOTIFICATION_DATA - cxl gained DCD emulation support - pvpanic gained shutdown support - beginning of patchset for Generic Port Affinity Structure - s3 support - friendlier error messages when boot fails on some illegal configs - for vhost-user, VHOST_USER_SET_LOG_BASE is now only sent once - vhost-user now works on any POSIX system - sr-iov VF setup code has been reworked significantly - new tests, particularly for risc-v ACPI - bugfixes Signed-off-by: Michael S. Tsirkin Fails testing: https://gitlab.com/qemu-project/qemu/-/jobs/7257337667 Could you give me a hint how to trigger this in CI pls? All tests seem to pass when I push it to gitlab. Any special variables to set? In CI, FreeBSD uses travis; I'm not sure what's involved. s/travis/cirrus-ci/ See .gitlab-ci.d/cirrus/README.rst for information how to enable it in your private gitlab repo. I replicated it locally within a FreeBSD VM. It should be reproducible with 'make vm-build-freebsd', but I think that's more difficult to debug after the fact than a full vm. Just use "make vm-build-freebsd DEBUG=1" and you should get a shell prompt for interactive debugging, so that's likely the best way to tackle such issues. HTH, Thomas Thanks! As a side, is there some way to persist the stuff fetched over the network so it does not happen each time I re-run make? The download should get cached in ~/.cache/qemu-vm/ ... if that does not work, there is likely another bug in the scripts somewhere... Thomas
Re: [PULL v2 00/88] virtio: features,fixes
On 03/07/2024 19.01, Richard Henderson wrote: On 7/3/24 09:51, Michael S. Tsirkin wrote: On Wed, Jul 03, 2024 at 09:31:45AM -0700, Richard Henderson wrote: On 7/2/24 13:15, Michael S. Tsirkin wrote: The following changes since commit 1152a0414944f03231f3177207d379d58125890e: Merge tag 'pull-xen-20240701' ofhttps://xenbits.xen.org/git-http/people/aperard/qemu-dm into staging (2024-07-01 09:06:25 -0700) are available in the Git repository at: https://git.kernel.org/pub/scm/virt/kvm/mst/qemu.git tags/for_upstream for you to fetch changes up to 29e45afd8d6abf7a67dab5db0ab1cfbc388daefe: hw/pci: Replace -1 with UINT32_MAX for romsize (2024-07-02 11:27:19 -0400) virtio: features,fixes A bunch of improvements: - vhost dirty log is now only scanned once, not once per device - virtio and vhost now support VIRTIO_F_NOTIFICATION_DATA - cxl gained DCD emulation support - pvpanic gained shutdown support - beginning of patchset for Generic Port Affinity Structure - s3 support - friendlier error messages when boot fails on some illegal configs - for vhost-user, VHOST_USER_SET_LOG_BASE is now only sent once - vhost-user now works on any POSIX system - sr-iov VF setup code has been reworked significantly - new tests, particularly for risc-v ACPI - bugfixes Signed-off-by: Michael S. Tsirkin Fails testing: https://gitlab.com/qemu-project/qemu/-/jobs/7257337667 Could you give me a hint how to trigger this in CI pls? All tests seem to pass when I push it to gitlab. Any special variables to set? In CI, FreeBSD uses travis; I'm not sure what's involved. s/travis/cirrus-ci/ See .gitlab-ci.d/cirrus/README.rst for information how to enable it in your private gitlab repo. I replicated it locally within a FreeBSD VM. It should be reproducible with 'make vm-build-freebsd', but I think that's more difficult to debug after the fact than a full vm. Just use "make vm-build-freebsd DEBUG=1" and you should get a shell prompt for interactive debugging, so that's likely the best way to tackle such issues. HTH, Thomas
Re: [PATCH v2 2/2] docs: remove Sphinx 1.x compatibility code
On 03/07/2024 19.52, John Snow wrote: In general, the Use_SSI workaround is no longer needed, and neither is the pre-1.6 logging shim for kerneldoc. Signed-off-by: John Snow Acked-by: Markus Armbruster --- docs/sphinx/hxtool.py| 21 - docs/sphinx/kerneldoc.py | 38 -- docs/sphinx/kernellog.py | 28 docs/sphinx/qapidoc.py | 29 +++-- 4 files changed, 19 insertions(+), 97 deletions(-) delete mode 100644 docs/sphinx/kernellog.py Reviewed-by: Thomas Huth
Re: [PATCH v2 1/2] Python: bump minimum sphinx version to 3.4.3
On 03/07/2024 19.52, John Snow wrote: With RHEL 8 support retired (It's been two years since RHEL9 released), our very oldest build platform version of Sphinx is now 3.4.3; and keeping backwards compatibility for versions as old as v1.6 when using domain extensions is a lot of work we don't need to do. This patch is motivated by my work creating a new QAPI domain, which unlike the dbus documentation, cannot be allowed to regress by creating a "dummy" doc when operating under older sphinx versions. Easier is to raise our minimum version as far as we can push it forwards, reducing my burden in creating cross-compatibility hacks and patches. A sampling of sphinx versions from various distributions, courtesy https://repology.org/project/python:sphinx/versions Alpine 3.16: v4.3.0 (QEMU support ended 2024-05-23) Alpine 3.17: v5.3.0 Alpine 3.18: v6.1.3 Alpine 3.19: v6.2.1 Ubuntu 20.04 LTS: EOL Ubuntu 22.04 LTS: v4.3.2 Ubuntu 22.10: EOL Ubuntu 23.04: EOL Ubuntu 23.10: v5.3.0 Ubuntu 24.04 LTS: v7.2.6 Debian 11: v3.4.3 (QEMU support ends 2024-07-xx) Debian 12: v5.3.0 Fedora 38: EOL Fedora 39: v6.2.1 Fedora 40: v7.2.6 CentOS Stream 8: v1.7.6 (QEMU support ended 2024-05-17) CentOS Stream 9: v3.4.3 OpenSUSE Leap 15.4: EOL OpenSUSE Leap 15.5: 2.3.1, 4.2.0 and 7.2.6 RHEL9 / CentOS Stream 9 becomes the new defining factor in staying at Sphinx 3.4.3 due to downstream offline build requirements that force us to use platform Sphinx instead of newer packages from PyPI. Signed-off-by: John Snow Acked-by: Paolo Bonzini Acked-by: Markus Armbruster --- docs/conf.py| 7 +++ pythondeps.toml | 2 +- 2 files changed, 4 insertions(+), 5 deletions(-) Reviewed-by: Thomas Huth
[PATCH] hw: Fix crash that happens when introspecting scsi-block on older machine types
"make check SPEED=slow" is currently failing the device-introspect-test on older machine types since introspecting "scsi-block" is causing an abort: $ ./qemu-system-x86_64 -M pc-q35-8.0 -monitor stdio QEMU 9.0.50 monitor - type 'help' for more information (qemu) device_add scsi-block,help Unexpected error in object_property_find_err() at ../../devel/qemu/qom/object.c:1357: can't apply global scsi-disk-base.migrate-emulated-scsi-request=false: Property 'scsi-block.migrate-emulated-scsi-request' not found Aborted (core dumped) The problem is that the compat code tries to change the "migrate-emulated-scsi-request" property for all devices that are derived from "scsi-block", but the property has only been added to "scsi-hd" and "scsi-cd" via the DEFINE_SCSI_DISK_PROPERTIES macro. Thus let's fix the problem by only changing the property on the devices that really have this property. Fixes: b4912afa5f ("scsi-disk: Fix crash for VM configured with USB CDROM after live migration") Signed-off-by: Thomas Huth --- hw/core/machine.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/hw/core/machine.c b/hw/core/machine.c index 655d75c21f..60858a8565 100644 --- a/hw/core/machine.c +++ b/hw/core/machine.c @@ -36,7 +36,8 @@ GlobalProperty hw_compat_9_0[] = { {"arm-cpu", "backcompat-cntfrq", "true" }, -{"scsi-disk-base", "migrate-emulated-scsi-request", "false" }, +{"scsi-hd", "migrate-emulated-scsi-request", "false" }, +{"scsi-cd", "migrate-emulated-scsi-request", "false" }, {"vfio-pci", "skip-vsc-check", "false" }, }; const size_t hw_compat_9_0_len = G_N_ELEMENTS(hw_compat_9_0); -- 2.45.2
[PULL 03/12] tests/qtest: Use qtest_add_data_func_full()
From: Akihiko Odaki A test function may not be executed depending on the test command line so it is wrong to free data with a test function. Use qtest_add_data_func_full() to register a function to free data. Signed-off-by: Akihiko Odaki Reviewed-by: Michael S. Tsirkin Message-ID: <20240627-san-v2-10-750bb0946...@daynix.com> Reviewed-by: Thomas Huth Signed-off-by: Thomas Huth --- tests/qtest/device-introspect-test.c | 7 +++ 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/tests/qtest/device-introspect-test.c b/tests/qtest/device-introspect-test.c index 5b0ffe43f5..587da59623 100644 --- a/tests/qtest/device-introspect-test.c +++ b/tests/qtest/device-introspect-test.c @@ -266,7 +266,6 @@ static void test_device_intro_concrete(const void *args) qobject_unref(types); qtest_quit(qts); -g_free((void *)args); } static void test_abstract_interfaces(void) @@ -310,12 +309,12 @@ static void add_machine_test_case(const char *mname) path = g_strdup_printf("device/introspect/concrete/defaults/%s", mname); args = g_strdup_printf("-M %s", mname); -qtest_add_data_func(path, args, test_device_intro_concrete); +qtest_add_data_func_full(path, args, test_device_intro_concrete, g_free); g_free(path); path = g_strdup_printf("device/introspect/concrete/nodefaults/%s", mname); args = g_strdup_printf("-nodefaults -M %s", mname); -qtest_add_data_func(path, args, test_device_intro_concrete); +qtest_add_data_func_full(path, args, test_device_intro_concrete, g_free); g_free(path); } @@ -330,7 +329,7 @@ int main(int argc, char **argv) qtest_add_func("device/introspect/abstract-interfaces", test_abstract_interfaces); if (g_test_quick()) { qtest_add_data_func("device/introspect/concrete/defaults/none", -g_strdup(common_args), test_device_intro_concrete); +common_args, test_device_intro_concrete); } else { qtest_cb_for_every_machine(add_machine_test_case, true); } -- 2.45.2
[PULL 05/12] tests/qtest: Free old machine variable name
From: Akihiko Odaki This fixes LeakSanitizer warnings. Signed-off-by: Akihiko Odaki Reviewed-by: Peter Maydell Reviewed-by: Michael S. Tsirkin Message-ID: <20240627-san-v2-12-750bb0946...@daynix.com> Signed-off-by: Thomas Huth --- tests/qtest/libqtest.c | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/qtest/libqtest.c b/tests/qtest/libqtest.c index ca46b1f8d0..1326e34291 100644 --- a/tests/qtest/libqtest.c +++ b/tests/qtest/libqtest.c @@ -1514,6 +1514,7 @@ static struct MachInfo *qtest_get_machines(const char *var) int idx; if (g_strcmp0(qemu_var, var)) { +g_free(qemu_var); qemu_var = g_strdup(var); /* new qemu, clear the cache */ -- 2.45.2
[PULL 04/12] tests/qtest: Free unused QMP response
From: Akihiko Odaki This fixes LeakSanitizer warnings. Signed-off-by: Akihiko Odaki Reviewed-by: Michael S. Tsirkin Message-ID: <20240627-san-v2-11-750bb0946...@daynix.com> Signed-off-by: Thomas Huth --- tests/qtest/libqtest.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/qtest/libqtest.c b/tests/qtest/libqtest.c index c7f6897d78..ca46b1f8d0 100644 --- a/tests/qtest/libqtest.c +++ b/tests/qtest/libqtest.c @@ -749,6 +749,8 @@ QDict *qtest_qmp_receive(QTestState *s) response, s->eventData)) { /* Stash the event for a later consumption */ s->pending_events = g_list_append(s->pending_events, response); +} else { +qobject_unref(response); } } } -- 2.45.2
[PULL 10/12] tests/avocado: add hotplug_blk test
From: Vladimir Sementsov-Ogievskiy Introduce a test, that checks that plug/unplug of virtio-blk device works. (the test is developed by copying hotplug_cpu.py, so keep original copyright) Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Thomas Huth Message-ID: <20240409065854.366856-1-vsement...@yandex-team.ru> Signed-off-by: Thomas Huth --- tests/avocado/hotplug_blk.py | 69 1 file changed, 69 insertions(+) create mode 100644 tests/avocado/hotplug_blk.py diff --git a/tests/avocado/hotplug_blk.py b/tests/avocado/hotplug_blk.py new file mode 100644 index 00..5dc30f6616 --- /dev/null +++ b/tests/avocado/hotplug_blk.py @@ -0,0 +1,69 @@ +# Functional test that hotplugs a virtio blk disk and checks it on a Linux +# guest +# +# Copyright (c) 2021 Red Hat, Inc. +# Copyright (c) Yandex +# +# 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 time + +from avocado_qemu import LinuxTest + + +class HotPlug(LinuxTest): +def blockdev_add(self) -> None: +self.vm.cmd('blockdev-add', **{ +'driver': 'null-co', +'size': 1073741824, +'node-name': 'disk' +}) + +def assert_vda(self) -> None: +self.ssh_command('test -e /sys/block/vda') + +def assert_no_vda(self) -> None: +with self.assertRaises(AssertionError): +self.assert_vda() + +def plug(self) -> None: +args = { +'driver': 'virtio-blk-pci', +'drive': 'disk', +'id': 'virtio-disk0', +'bus': 'pci.1', +'addr': 1 +} + +self.assert_no_vda() +self.vm.cmd('device_add', args) +try: +self.assert_vda() +except AssertionError: +time.sleep(1) +self.assert_vda() + +def unplug(self) -> None: +self.vm.cmd('device_del', id='virtio-disk0') + +self.vm.event_wait('DEVICE_DELETED', 1.0, + match={'data': {'device': 'virtio-disk0'}}) + +self.assert_no_vda() + +def test(self) -> None: +""" +:avocado: tags=arch:x86_64 +:avocado: tags=machine:q35 +:avocado: tags=accel:kvm +""" +self.require_accelerator('kvm') +self.vm.add_args('-accel', 'kvm') +self.vm.add_args('-device', 'pcie-pci-bridge,id=pci.1,bus=pcie.0') + +self.launch_and_wait() +self.blockdev_add() + +self.plug() +self.unplug() -- 2.45.2
[PULL 09/12] hw/s390x: Attach default virtio-net devices to the /machine/virtual-css-bridge
The initial virtio-net-ccw devices currently do not have a proper parent in the QOM tree, so they show up under /machine/unattached - which is somewhat ugly. Let's attach them to /machine/virtual-css-bridge/virtual-css instead. Message-ID: <20240701200108.154271-1-th...@redhat.com> Reviewed-by: Cédric Le Goater Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Thomas Huth --- hw/s390x/s390-virtio-ccw.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/hw/s390x/s390-virtio-ccw.c b/hw/s390x/s390-virtio-ccw.c index f87ca36264..c1edbd9131 100644 --- a/hw/s390x/s390-virtio-ccw.c +++ b/hw/s390x/s390-virtio-ccw.c @@ -216,8 +216,11 @@ static void s390_init_ipl_dev(const char *kernel_filename, static void s390_create_virtio_net(BusState *bus, const char *name) { DeviceState *dev; +int cnt = 0; while ((dev = qemu_create_nic_device(name, true, "virtio"))) { +g_autofree char *childname = g_strdup_printf("%s[%d]", name, cnt++); +object_property_add_child(OBJECT(bus), childname, OBJECT(dev)); qdev_realize_and_unref(dev, bus, _fatal); } } -- 2.45.2
[PULL 11/12] .travis.yml: Install python3-tomli in all build jobs
Since commit 1f97715c83 ('Revert "python: use vendored tomli"') this package is a hard requirement for compiling QEMU, so install it now in all Travis jobs, too. Message-ID: <20240624094807.182313-1-th...@redhat.com> Acked-by: Alex Bennée Signed-off-by: Thomas Huth --- .travis.yml | 6 ++ 1 file changed, 6 insertions(+) diff --git a/.travis.yml b/.travis.yml index cef0308952..8fc1ae0cf2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -106,6 +106,7 @@ jobs: - libvdeplug-dev - libvte-2.91-dev - ninja-build + - python3-tomli # Tests dependencies - genisoimage env: @@ -141,6 +142,7 @@ jobs: - libvdeplug-dev - libvte-2.91-dev - ninja-build + - python3-tomli # Tests dependencies - genisoimage env: @@ -175,6 +177,7 @@ jobs: - libvdeplug-dev - libvte-2.91-dev - ninja-build + - python3-tomli # Tests dependencies - genisoimage env: @@ -215,6 +218,7 @@ jobs: - libzstd-dev - nettle-dev - ninja-build + - python3-tomli # Tests dependencies - genisoimage env: @@ -231,6 +235,7 @@ jobs: - ninja-build - flex - bison + - python3-tomli env: - TEST_CMD="make check check-tcg V=1" - CONFIG="--disable-containers --disable-system" @@ -263,6 +268,7 @@ jobs: - libvdeplug-dev - libvte-2.91-dev - ninja-build + - python3-tomli env: - TEST_CMD="make check-unit" - CONFIG="--disable-containers --disable-tcg --enable-kvm --disable-tools -- 2.45.2