From 49e8565b3df3f43aae57a3850e1b4cd176ef6582 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alex=20Benn=C3=A9e?= Date: Mon, 22 Feb 2021 10:14:50 +0000 Subject: [PATCH 1/7] meson.build: expose TCG cross compiler information in summary MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Blink and you miss the cross TCG compiler stuff so lets display it with the rest of the compiler information. Signed-off-by: Alex Bennée Tested-by: Philippe Mathieu-Daudé Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Richard Henderson Acked-by: Paolo Bonzini Message-Id: <20210222101455.12640-2-alex.bennee@linaro.org> --- meson.build | 18 ++++++++++++++++++ tests/tcg/configure.sh | 8 -------- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/meson.build b/meson.build index 05a67c20d9..f3db83e974 100644 --- a/meson.build +++ b/meson.build @@ -2509,6 +2509,24 @@ endif summary_info += {'strip binaries': get_option('strip')} summary_info += {'sparse': sparse.found() ? sparse.full_path() : false} summary_info += {'mingw32 support': targetos == 'windows'} + +# snarf the cross-compilation information for tests +foreach target: target_dirs + tcg_mak = meson.current_build_dir() / 'tests/tcg' / 'config-' + target + '.mak' + if fs.exists(tcg_mak) + config_cross_tcg = keyval.load(tcg_mak) + target = config_cross_tcg['TARGET_NAME'] + compiler = '' + if 'DOCKER_CROSS_CC_GUEST' in config_cross_tcg + summary_info += {target + ' tests': config_cross_tcg['DOCKER_CROSS_CC_GUEST'] + + ' via ' + config_cross_tcg['DOCKER_IMAGE']} + elif 'CROSS_CC_GUEST' in config_cross_tcg + summary_info += {target + ' tests' + : config_cross_tcg['CROSS_CC_GUEST'] } + endif + endif +endforeach + summary(summary_info, bool_yn: true, section: 'Compilation') # Targets and accelerators diff --git a/tests/tcg/configure.sh b/tests/tcg/configure.sh index 551c02f469..36b8a73a54 100755 --- a/tests/tcg/configure.sh +++ b/tests/tcg/configure.sh @@ -263,11 +263,3 @@ for target in $target_list; do echo "DOCKER_CROSS_CC_GUEST=$container_cross_cc" >> $config_target_mak fi done - -# report container support state -echo "cross containers $container" - -if test -n "$enabled_cross_compilers"; then - echo - echo "NOTE: guest cross-compilers enabled:$enabled_cross_compilers" -fi From 9d66a0eada1cf558cc7fabe1e86131ea68ea7192 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Date: Mon, 22 Feb 2021 10:14:51 +0000 Subject: [PATCH 2/7] docker: Bump Fedora images to release 33 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fedora 33 was released on October 27, 2020. Update all the Fedora 32 images to this new release. Suggested-by: Daniel Berrangé Signed-off-by: Philippe Mathieu-Daudé Signed-off-by: Alex Bennée Reviewed-by: Richard Henderson Message-Id: <20210118181255.314672-1-philmd@redhat.com> Message-Id: <20210222101455.12640-3-alex.bennee@linaro.org> --- tests/docker/dockerfiles/fedora-cris-cross.docker | 2 +- tests/docker/dockerfiles/fedora-i386-cross.docker | 2 +- tests/docker/dockerfiles/fedora-win32-cross.docker | 2 +- tests/docker/dockerfiles/fedora-win64-cross.docker | 2 +- tests/docker/dockerfiles/fedora.docker | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/docker/dockerfiles/fedora-cris-cross.docker b/tests/docker/dockerfiles/fedora-cris-cross.docker index 09e7e449f9..1dfff6e0b9 100644 --- a/tests/docker/dockerfiles/fedora-cris-cross.docker +++ b/tests/docker/dockerfiles/fedora-cris-cross.docker @@ -2,7 +2,7 @@ # Cross compiler for cris system tests # -FROM fedora:30 +FROM fedora:33 ENV PACKAGES gcc-cris-linux-gnu RUN dnf install -y $PACKAGES RUN rpm -q $PACKAGES | sort > /packages.txt diff --git a/tests/docker/dockerfiles/fedora-i386-cross.docker b/tests/docker/dockerfiles/fedora-i386-cross.docker index a6e411291b..966072c08e 100644 --- a/tests/docker/dockerfiles/fedora-i386-cross.docker +++ b/tests/docker/dockerfiles/fedora-i386-cross.docker @@ -1,4 +1,4 @@ -FROM fedora:31 +FROM fedora:33 ENV PACKAGES \ bzip2 \ diffutils \ diff --git a/tests/docker/dockerfiles/fedora-win32-cross.docker b/tests/docker/dockerfiles/fedora-win32-cross.docker index 087df598a0..81b5659e9c 100644 --- a/tests/docker/dockerfiles/fedora-win32-cross.docker +++ b/tests/docker/dockerfiles/fedora-win32-cross.docker @@ -1,4 +1,4 @@ -FROM fedora:32 +FROM fedora:33 # Please keep this list sorted alphabetically ENV PACKAGES \ diff --git a/tests/docker/dockerfiles/fedora-win64-cross.docker b/tests/docker/dockerfiles/fedora-win64-cross.docker index d5d2f5f00d..bcb428e724 100644 --- a/tests/docker/dockerfiles/fedora-win64-cross.docker +++ b/tests/docker/dockerfiles/fedora-win64-cross.docker @@ -1,4 +1,4 @@ -FROM fedora:32 +FROM fedora:33 # Please keep this list sorted alphabetically ENV PACKAGES \ diff --git a/tests/docker/dockerfiles/fedora.docker b/tests/docker/dockerfiles/fedora.docker index 0d7602abbe..915fdc1845 100644 --- a/tests/docker/dockerfiles/fedora.docker +++ b/tests/docker/dockerfiles/fedora.docker @@ -1,4 +1,4 @@ -FROM fedora:32 +FROM fedora:33 # Please keep this list sorted alphabetically ENV PACKAGES \ From d98946450d82d2b46c3cc93e22cee2b189f019b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alex=20Benn=C3=A9e?= Date: Mon, 22 Feb 2021 10:14:52 +0000 Subject: [PATCH 3/7] tests/acceptance: allow a "graceful" failing for virtio-gpu test MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This is a band-aid with a TODO for cases when QEMU doesn't start due to missing VirGL. Longer term we could do with some proper feature probing. Signed-off-by: Alex Bennée Reviewed-by: Marc-André Lureau Reviewed-by: Willian Rampazzo Reviewed-by: Richard Henderson Message-Id: <20210222101455.12640-4-alex.bennee@linaro.org> --- tests/acceptance/virtio-gpu.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tests/acceptance/virtio-gpu.py b/tests/acceptance/virtio-gpu.py index ab1a4c1a71..ab18cddbb7 100644 --- a/tests/acceptance/virtio-gpu.py +++ b/tests/acceptance/virtio-gpu.py @@ -85,7 +85,12 @@ class VirtioGPUx86(Test): "-append", kernel_command_line, ) - self.vm.launch() + try: + self.vm.launch() + except: + # TODO: probably fails because we are missing the VirGL features + self.cancel("VirGL not enabled?") + self.wait_for_console_pattern("as init process") exec_command_and_wait_for_pattern( self, "/usr/sbin/modprobe virtio_gpu", "" From 663a041e1dff50eaa66c8d2b01ade1ac8cd65619 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alex=20Benn=C3=A9e?= Date: Mon, 22 Feb 2021 10:14:53 +0000 Subject: [PATCH 4/7] docs/devel: expand on use of containers to build tests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Expand on the usage of containers for building tests and why we have some that are not used to build QEMU itself. Signed-off-by: Alex Bennée Reviewed-by: Richard Henderson Reviewed-by: Thomas Huth Cc: Thomas Huth Message-Id: <20210222101455.12640-5-alex.bennee@linaro.org> --- docs/devel/testing.rst | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/docs/devel/testing.rst b/docs/devel/testing.rst index 00ce16de48..488d4e3537 100644 --- a/docs/devel/testing.rst +++ b/docs/devel/testing.rst @@ -272,10 +272,10 @@ Note that the following group names have a special meaning: - disabled: Tests in this group are disabled and ignored by check. -.. _docker-ref: +.. _container-ref: -Docker based tests -================== +Container based tests +===================== Introduction ------------ @@ -1001,10 +1001,17 @@ for the architecture in question, for example:: There is also a ``--cross-cc-flags-ARCH`` flag in case additional compiler flags are needed to build for a given target. -If you have the ability to run containers as the user you can also -take advantage of the build systems "Docker" support. It will then use -containers to build any test case for an enabled guest where there is -no system compiler available. See :ref:`docker-ref` for details. +If you have the ability to run containers as the user the build system +will automatically use them where no system compiler is available. For +architectures where we also support building QEMU we will generally +use the same container to build tests. However there are a number of +additional containers defined that have a minimal cross-build +environment that is only suitable for building test cases. Sometimes +we may use a bleeding edge distribution for compiler features needed +for test cases that aren't yet in the LTS distros we support for QEMU +itself. + +See :ref:`container-ref` for more details. Running subset of tests ----------------------- From 9c1f491e02a64882201d20fa8324884baee91fd8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alex=20Benn=C3=A9e?= Date: Mon, 22 Feb 2021 10:14:54 +0000 Subject: [PATCH 5/7] docs/devel: update the container based tests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This section has grown a little stale so clean-up the language and examples for current usage: - refer to containers at the top - mention podman can also be used - add podman prerequisites section - move to using "docker-help" for online help - mention the registry and it's purpose - don't refer to out-of-date min-glib image Signed-off-by: Alex Bennée Reviewed-by: Richard Henderson Reviewed-by: Thomas Huth Message-Id: <20210222101455.12640-6-alex.bennee@linaro.org> --- docs/devel/testing.rst | 63 +++++++++++++++++++++++++++++++----------- 1 file changed, 47 insertions(+), 16 deletions(-) diff --git a/docs/devel/testing.rst b/docs/devel/testing.rst index 488d4e3537..e57260478a 100644 --- a/docs/devel/testing.rst +++ b/docs/devel/testing.rst @@ -280,13 +280,17 @@ Container based tests Introduction ------------ -The Docker testing framework in QEMU utilizes public Docker images to build and -test QEMU in predefined and widely accessible Linux environments. This makes -it possible to expand the test coverage across distros, toolchain flavors and -library versions. +The container testing framework in QEMU utilizes public images to +build and test QEMU in predefined and widely accessible Linux +environments. This makes it possible to expand the test coverage +across distros, toolchain flavors and library versions. The support +was originally written for Docker although we also support Podman as +an alternative container runtime. Although the many of the target +names and scripts are prefixed with "docker" the system will +automatically run on whichever is configured. -Prerequisites -------------- +Docker Prerequisites +-------------------- Install "docker" with the system package manager and start the Docker service on your development machine, then make sure you have the privilege to run @@ -316,26 +320,53 @@ Note that any one of above configurations makes it possible for the user to exploit the whole host with Docker bind mounting or other privileged operations. So only do it on development machines. -Quickstart ----------- +Podman Prerequisites +-------------------- -From source tree, type ``make docker`` to see the help. Testing can be started -without configuring or building QEMU (``configure`` and ``make`` are done in -the container, with parameters defined by the make target): +Install "podman" with the system package manager. .. code:: - make docker-test-build@min-glib + $ sudo dnf install podman + $ podman ps -This will create a container instance using the ``min-glib`` image (the image +The last command should print an empty table, to verify the system is ready. + +Quickstart +---------- + +From source tree, type ``make docker-help`` to see the help. Testing +can be started without configuring or building QEMU (``configure`` and +``make`` are done in the container, with parameters defined by the +make target): + +.. code:: + + make docker-test-build@centos8 + +This will create a container instance using the ``centos8`` image (the image is downloaded and initialized automatically), in which the ``test-build`` job is executed. +Registry +-------- + +The QEMU project has a container registry hosted by GitLab at +``registry.gitlab.com/qemu-project/qemu`` which will automatically be +used to pull in pre-built layers. This avoids unnecessary strain on +the distro archives created by multiple developers running the same +container build steps over and over again. This can be overridden +locally by using the ``NOCACHE`` build option: + +.. code:: + + make docker-image-debian10 NOCACHE=1 + Images ------ -Along with many other images, the ``min-glib`` image is defined in a Dockerfile -in ``tests/docker/dockerfiles/``, called ``min-glib.docker``. ``make docker`` +Along with many other images, the ``centos8`` image is defined in a Dockerfile +in ``tests/docker/dockerfiles/``, called ``centos8.docker``. ``make docker-help`` command will list all the available images. To add a new image, simply create a new ``.docker`` file under the @@ -355,7 +386,7 @@ QEMU. Docker tests are the executables under ``tests/docker`` named library, ``tests/docker/common.rc``, which provides helpers to find the QEMU source and build it. -The full list of tests is printed in the ``make docker`` help. +The full list of tests is printed in the ``make docker-help`` help. Debugging a Docker test failure ------------------------------- From 4583cdadf807c272fe01501b414c570a527e6f41 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alex=20Benn=C3=A9e?= Date: Mon, 22 Feb 2021 10:14:55 +0000 Subject: [PATCH 6/7] docs/devel: add forward reference to check-tcg MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit For completeness reference the check-tcg tests in the container preamble text. Signed-off-by: Alex Bennée Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Richard Henderson Reviewed-by: Thomas Huth Cc: Thomas Huth Message-Id: <20210222101455.12640-7-alex.bennee@linaro.org> --- docs/devel/testing.rst | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/docs/devel/testing.rst b/docs/devel/testing.rst index e57260478a..1434a50cc4 100644 --- a/docs/devel/testing.rst +++ b/docs/devel/testing.rst @@ -289,6 +289,9 @@ an alternative container runtime. Although the many of the target names and scripts are prefixed with "docker" the system will automatically run on whichever is configured. +The container images are also used to augment the generation of tests +for testing TCG. See :ref:`checktcg-ref` for more details. + Docker Prerequisites -------------------- @@ -1011,6 +1014,8 @@ And remove any package you want with:: If you've used ``make check-acceptance``, the Python virtual environment where Avocado is installed will be cleaned up as part of ``make check-clean``. +.. _checktcg-ref: + Testing with "make check-tcg" ============================= From 93a11007681a8051c07834c52d785a2948ff9632 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alex=20Benn=C3=A9e?= Date: Tue, 23 Feb 2021 09:59:31 +0000 Subject: [PATCH 7/7] docs: move CODING_STYLE into the developer documentation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit There is no particular reason to keep this on it's own in the root of the tree. Move it into the rest of the fine developer manual and fixup any links to it. The only tweak I've made is to fix the code-block annotations to mention the language C. Signed-off-by: Alex Bennée Reviewed-by: Claudio Fontana Message-Id: <20210223095931.16908-1-alex.bennee@linaro.org> --- README.rst | 4 +++- docs/devel/index.rst | 1 + CODING_STYLE.rst => docs/devel/style.rst | 6 +++--- scripts/fix-multiline-comments.sh | 2 +- 4 files changed, 8 insertions(+), 5 deletions(-) rename CODING_STYLE.rst => docs/devel/style.rst (99%) diff --git a/README.rst b/README.rst index ce39d89077..91aa1e314c 100644 --- a/README.rst +++ b/README.rst @@ -66,7 +66,9 @@ When submitting patches, one common approach is to use 'git format-patch' and/or 'git send-email' to format & send the mail to the qemu-devel@nongnu.org mailing list. All patches submitted must contain a 'Signed-off-by' line from the author. Patches should follow the -guidelines set out in the CODING_STYLE.rst file. +guidelines set out in the `style section +` of +the Developers Guide. Additional information on submitting patches can be found online via the QEMU website diff --git a/docs/devel/index.rst b/docs/devel/index.rst index 22854e334d..ae664da00c 100644 --- a/docs/devel/index.rst +++ b/docs/devel/index.rst @@ -14,6 +14,7 @@ Contents: :maxdepth: 2 build-system + style kconfig testing fuzzing diff --git a/CODING_STYLE.rst b/docs/devel/style.rst similarity index 99% rename from CODING_STYLE.rst rename to docs/devel/style.rst index 7bf4e39d48..8b0bdb3570 100644 --- a/CODING_STYLE.rst +++ b/docs/devel/style.rst @@ -641,7 +641,7 @@ trace-events style In trace-events files, use a '0x' prefix to specify hex numbers, as in: -.. code-block:: +.. code-block:: c some_trace(unsigned x, uint64_t y) "x 0x%x y 0x" PRIx64 @@ -649,14 +649,14 @@ An exception is made for groups of numbers that are hexadecimal by convention and separated by the symbols '.', '/', ':', or ' ' (such as PCI bus id): -.. code-block:: +.. code-block:: c another_trace(int cssid, int ssid, int dev_num) "bus id: %x.%x.%04x" However, you can use '0x' for such groups if you want. Anyway, be sure that it is obvious that numbers are in hex, ex.: -.. code-block:: +.. code-block:: c data_dump(uint8_t c1, uint8_t c2, uint8_t c3) "bytes (in hex): %02x %02x %02x" diff --git a/scripts/fix-multiline-comments.sh b/scripts/fix-multiline-comments.sh index 93f9b10669..c15a041272 100755 --- a/scripts/fix-multiline-comments.sh +++ b/scripts/fix-multiline-comments.sh @@ -1,6 +1,6 @@ #! /bin/sh # -# Fix multiline comments to match CODING_STYLE +# Fix multiline comments to match docs/devel/style.rst # # Copyright (C) 2018 Red Hat, Inc. #