From patchwork Wed Nov 30 12:15:07 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bertrand Marquis X-Patchwork-Id: 13059757 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 141B3C352A1 for ; Wed, 30 Nov 2022 12:16:03 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.449846.706841 (Exim 4.92) (envelope-from ) id 1p0M0F-0005h0-3Y; Wed, 30 Nov 2022 12:15:51 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 449846.706841; Wed, 30 Nov 2022 12:15:51 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1p0M0F-0005gq-0E; Wed, 30 Nov 2022 12:15:51 +0000 Received: by outflank-mailman (input) for mailman id 449846; Wed, 30 Nov 2022 12:15:49 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1p0M0D-0005Ok-FF for xen-devel@lists.xenproject.org; Wed, 30 Nov 2022 12:15:49 +0000 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by se1-gles-flk1.inumbo.com (Halon) with ESMTP id b6834992-70a8-11ed-8fd2-01056ac49cbb; Wed, 30 Nov 2022 13:15:44 +0100 (CET) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id B1039D6E; Wed, 30 Nov 2022 04:15:54 -0800 (PST) Received: from e109506.cambridge.arm.com (e109506.cambridge.arm.com [10.1.199.62]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 533EF3F73D; Wed, 30 Nov 2022 04:15:47 -0800 (PST) X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: b6834992-70a8-11ed-8fd2-01056ac49cbb From: Bertrand Marquis To: xen-devel@lists.xenproject.org Cc: michal.orzel@amd.com, Doug Goldstein , Stefano Stabellini Subject: [PATCH v5 1/3] automation: Create Yocto docker images Date: Wed, 30 Nov 2022 12:15:07 +0000 Message-Id: <18861c0c9c547959900532e38df11b2d67f0a1cc.1669810269.git.bertrand.marquis@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 Add containers suitable to run yocto kirkstone build based on ubuntu 22.04. It contains all packages required by Yocto and a checkout of the layers required to build Xen with Yocto. Add a generic docker image template to be used to automatically generate docker files for different configurations: - specific yocto version - different targets (qemu arm, arm64 and x86) - different host platforms (x86 or arm64) During a call to 'make all', only the images for the host platform we run it on in the CI is generated. If needed, images for an other host platform can be generated manually by calling the right make target (see make help). Add a build script to build and run xen on qemu using Yocto. The script supports arm32, arm64 and x86_64 and checks that dom0 is properly booting. At this stage this does not run any guest on top of dom0. The script is to be executed in one of the docker images to build and run a system using a Xen source tree. Signed-off-by: Bertrand Marquis --- Changes in v5: - typo fixes - add INTERMEDIATE to remove intermediate dockerfile - use container architecture - use full words in foreach loops - fix shellcheck findings in build-yocto.sh - rebase on sstabellini next branch Changes in v4: - Rework the system to have one dockerfile template from which make will generate the required dockerfiles for the wanted configuration - add support for different host architectures - Merge the generation system into one single dockerfile - Merge patches 1 and 2 in a single patch - Introduce CONTAINERS_EXTRA to have extra containers not built by default (for those not used by CI but useful to users) Changes in v3: - limit number of jobs in yocto by default to 8 and add --num-jobs option to the script to set a custom number of jobs - do not copy anymore the build-yocto.sh script inside the main image so that the current one in the repository is used when running Changes in v2: - add a --dump-log command line option to build-yocto.sh script to dump the logs if an error occurs. Changes in v1: - add --image command line argument to build-yocto.sh to allow building something different than xen-image-minimal. - modify dockerfile to have one layer per line and make it easier to add other. I kept the for loop to keep the number of docker steps lower - update commit message to warn that no guest are tested. - fix build-yocto script to properly return with an error if expect script ends up in timeout or EOF. --- automation/build/Makefile | 14 +- automation/build/yocto/build-yocto.sh | 351 +++++++++++++++++++++ automation/build/yocto/yocto.dockerfile.in | 114 +++++++ automation/build/yocto/yocto.inc | 42 +++ 4 files changed, 519 insertions(+), 2 deletions(-) create mode 100755 automation/build/yocto/build-yocto.sh create mode 100644 automation/build/yocto/yocto.dockerfile.in create mode 100644 automation/build/yocto/yocto.inc diff --git a/automation/build/Makefile b/automation/build/Makefile index a4b2b85178cf..72a5335baec1 100644 --- a/automation/build/Makefile +++ b/automation/build/Makefile @@ -1,13 +1,18 @@ # the base of where these containers will appear REGISTRY := registry.gitlab.com/xen-project/xen -CONTAINERS = $(subst .dockerfile,,$(wildcard */*.dockerfile)) +CONTAINERS = $(filter-out yocto/%,$(subst .dockerfile,,$(wildcard */*.dockerfile))) +CONTAINERS_EXTRA = DOCKER_CMD ?= docker +include yocto/yocto.inc + help: @echo "Builds containers for building Xen based on different distros" @echo "To build one run 'make DISTRO/VERSION'. Available containers:" @$(foreach file,$(sort $(CONTAINERS)),echo ${file};) + @echo "Extra containers (not built using make all):" + @$(foreach file,$(sort $(CONTAINERS_EXTRA)),echo ${file};) @echo "To push container builds, set the env var PUSH" %: %.dockerfile ## Builds containers @@ -16,5 +21,10 @@ help: $(DOCKER_CMD) push $(REGISTRY)/$(@D):$(@F); \ fi -.PHONY: all +.PHONY: all clean all: $(CONTAINERS) + +# Remove generated dockerfiles for yocto +clean: + rm -f yocto/*.dockerfiles + diff --git a/automation/build/yocto/build-yocto.sh b/automation/build/yocto/build-yocto.sh new file mode 100755 index 000000000000..f42fdf72d964 --- /dev/null +++ b/automation/build/yocto/build-yocto.sh @@ -0,0 +1,351 @@ +#!/bin/bash +# +# Yocto meta virtualization build and run script +# +# This script is building Yocto xen-image-minimal for qemu targets and run +# them using runqemu inside yocto to check that dom0 is booting properly. +# The build is using a local xen source tree so that specific patches can be +# tested. +# In order to optimize the build time, a build cache is used so that only xen +# packages and its dependencies are rebuilt (qemu and final image mainly). +# +# get command error even when piped. +set -o pipefail + +# Directories +YOCTODIR="$HOME/yocto-layers" +CACHEDIR="$HOME/yocto-cache" +LOGDIR="$HOME/logs" +XENDIR="$HOME/xen" +BUILDDIR="$HOME/build" + +# what yocto bsp we support +TARGET_SUPPORTED="qemuarm qemuarm64 qemux86-64" +VERBOSE="n" +TARGETLIST="" +BUILDJOBS="8" + +# actions to do +do_clean="n" +do_build="y" +do_run="y" +do_localsrc="n" +do_dump="n" +build_result=0 + +# layers to include in the project +build_layerlist="poky/meta poky/meta-poky poky/meta-yocto-bsp \ + meta-openembedded/meta-oe meta-openembedded/meta-python \ + meta-openembedded/meta-filesystems \ + meta-openembedded/meta-networking meta-virtualization" + +# yocto image to build +build_image="xen-image-minimal" + +function print_progress() { + echo -n "$(date +%T) $*" +} + +function run_task() { + local task_name="$1" + local task_target="$2" + + task_log="${task_name//project_}-${task_target}" + + mkdir -p "${LOGDIR}" + print_progress + echo -n "${task_name//project_} ${task_target}: " + if [ "${VERBOSE}" = "n" ]; then + "$@" > "${LOGDIR}/${task_log}.log" 2>&1 + else + "$@" 2>&1 | tee "${LOGDIR}/${task_log}.log" + fi + + if [ ${?} -ne 0 ]; then + echo "Error" + build_result=$((build_result+1)) + if [ "${do_dump}" = "y" ]; then + echo + echo "############ LOGS-START ############" + cat "${LOGDIR}/${task_log}.log" + echo "############ LOGS-END ############" + echo + fi + return 1 + else + echo "OK" + return 0 + fi +} + +function project_create() { + target="${1:?}" + destdir="${BUILDDIR}/${target}" + + ( + # init yocto project + source "${YOCTODIR}/poky/oe-init-build-env" "${destdir}" + + # add needed layers + for layer in ${build_layerlist}; do + bitbake-layers add-layer "${YOCTODIR}/${layer}" || exit 1 + done + ) || return 1 + + # customize project configuration + cat <> "${destdir}/conf/local.conf" +# Yocto BSP +MACHINE = "${target}" + +# Use local cache to reuse previous builds results +SSTATE_DIR = "${CACHEDIR}/sstate-cache" +DL_DIR = "${CACHEDIR}/downloads" + +# Enable xen and virtualization +DISTRO_FEATURES = " virtualization xen ipv4" + +# Speed up run by not generating ssh host keys +IMAGE_INSTALL:append:pn-xen-image-minimal = " ssh-pregen-hostkeys" + +# Save some disk space +INHERIT += "rm_work" + +# Reduce number of jobs +BB_NUMBER_THREADS="${BUILDJOBS}" + +EOF + + if [ "${do_localsrc}" = "y" ]; then + XENVERS=$(grep -e "^XEN_REL" \ + "${YOCTODIR}"/meta-virtualization/recipes-extended/xen/xen_*.bb \ + 2> /dev/null | tr -d ' ' | tr -d '?' | tr -d '"' \ + | sed -e "s/.*=//" | sort -V | tail -n 1) + + XENBASE=$(dirname "$(realpath -m "${XENDIR}")") + XENSUB=$(basename "$(realpath -m "${XENDIR}")") + + cat <> "${destdir}/conf/local.conf" +# Use local sources for xen and xen-tools +FILESEXTRAPATHS:prepend:pn-xen := "${XENBASE}:" +FILESEXTRAPATHS:prepend:pn-xen-tools := "${XENBASE}:" + +SRC_URI:pn-xen = "file://${XENSUB}/;subdir=local-xen/" +SRC_URI:pn-xen-tools = "file://${XENSUB}/;subdir=local-xen/" + +PREFERRED_VERSION:pn-xen = "${XENVERS}%" +PREFERRED_VERSION:pn-xen-tools = "${XENVERS}%" + +S:pn-xen = "\${WORKDIR}/local-xen/${XENSUB}" +S:pn-xen-tools = "\${WORKDIR}/local-xen/${XENSUB}" + +SRCREV:pn-xen = "\${AUTOREV}" +SRCREV:pn-xen-tools = "\${AUTOREV}" + +SRCPV:pn-xen = "1" +SRCPV:pn-xen-tools = "1" + +# Disable all QA errors as the recipe is not up to date with changes in Xen +# when we use local sources +ERROR_QA:pn-xen = "arch" +ERROR_QA:pn-xen-tools = "arch" + +EOF + fi +} + +function project_build() { + target="${1:?}" + destdir="${BUILDDIR}/${target}" + + ( + source "${YOCTODIR}/poky/oe-init-build-env" "${destdir}" + + bitbake "${build_image}" || exit 1 + ) || return 1 +} + +function project_clean() { + target="${1:?}" + destdir="${BUILDDIR}/${target}" + + rm -rf "${destdir}" +} + +function project_run() { + target="${1:?}" + destdir="${BUILDDIR}/${target}" + ( + source "${YOCTODIR}/poky/oe-init-build-env" "${destdir}" > /dev/null 2>&1 + + /usr/bin/expect < $$@ + +endef + +$(eval $(foreach version,$(YOCTO_VERSION),\ + $(foreach target,$(YOCTO_TARGETS),\ + $(foreach arch,$(YOCTO_ARCHS),\ + $(call GEN_DOCKER,$(version),$(target),$(arch),$(if $(filter amd64,$(arch)),,-$(arch))))))) From patchwork Wed Nov 30 12:15:08 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bertrand Marquis X-Patchwork-Id: 13059758 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 79504C433FE for ; Wed, 30 Nov 2022 12:16:04 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.449848.706863 (Exim 4.92) (envelope-from ) id 1p0M0H-0006E6-Kr; Wed, 30 Nov 2022 12:15:53 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 449848.706863; Wed, 30 Nov 2022 12:15:53 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1p0M0H-0006Dr-HN; Wed, 30 Nov 2022 12:15:53 +0000 Received: by outflank-mailman (input) for mailman id 449848; Wed, 30 Nov 2022 12:15:52 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1p0M0G-0005h2-8z for xen-devel@lists.xenproject.org; Wed, 30 Nov 2022 12:15:52 +0000 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by se1-gles-sth1.inumbo.com (Halon) with ESMTP id b9e5904a-70a8-11ed-91b6-6bf2151ebd3b; Wed, 30 Nov 2022 13:15:50 +0100 (CET) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 932D21042; Wed, 30 Nov 2022 04:15:55 -0800 (PST) Received: from e109506.cambridge.arm.com (e109506.cambridge.arm.com [10.1.199.62]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 51D583F73D; Wed, 30 Nov 2022 04:15:48 -0800 (PST) X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: b9e5904a-70a8-11ed-91b6-6bf2151ebd3b From: Bertrand Marquis To: xen-devel@lists.xenproject.org Cc: michal.orzel@amd.com, Doug Goldstein , Stefano Stabellini Subject: [PATCH v5 2/3] automation: Add a clean rule for containers Date: Wed, 30 Nov 2022 12:15:08 +0000 Message-Id: X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 Add make clean support to remove the containers from the local docker registry. make clean- must be called to remove an image: make clean-yocto/kirkstone-qemuarm: remove yocto kirkstone for qemuarm image Signed-off-by: Bertrand Marquis Reviewed-by: Michal Orzel --- Changes in v5: - remove cleaning of all images using make clean Changes in v4: - also generate clean rule for CONTAINERS_EXTRA Changes in v3: - none Changes in v2: - none Changes in v1: - patch added --- automation/build/Makefile | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/automation/build/Makefile b/automation/build/Makefile index 72a5335baec1..4cbb1365f94e 100644 --- a/automation/build/Makefile +++ b/automation/build/Makefile @@ -28,3 +28,13 @@ all: $(CONTAINERS) clean: rm -f yocto/*.dockerfiles +define CLEAN_RULE +.PHONY: clean-$(1) +clean-$(1): +ifneq ($$(shell docker image ls -q $(REGISTRY)/$(subst /,:,$(1))),) + docker image rm $(REGISTRY)/$(subst /,:,$(1)) +endif + +endef + +$(eval $(foreach img,$(CONTAINERS) $(CONTAINERS_EXTRA),$(call CLEAN_RULE,$(img)))) From patchwork Wed Nov 30 12:15:09 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bertrand Marquis X-Patchwork-Id: 13059756 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id DC9E6C433FE for ; Wed, 30 Nov 2022 12:16:01 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.449847.706852 (Exim 4.92) (envelope-from ) id 1p0M0G-0005xO-C7; Wed, 30 Nov 2022 12:15:52 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 449847.706852; Wed, 30 Nov 2022 12:15:52 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1p0M0G-0005xD-97; Wed, 30 Nov 2022 12:15:52 +0000 Received: by outflank-mailman (input) for mailman id 449847; Wed, 30 Nov 2022 12:15:51 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1p0M0F-0005h2-Gx for xen-devel@lists.xenproject.org; Wed, 30 Nov 2022 12:15:51 +0000 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by se1-gles-sth1.inumbo.com (Halon) with ESMTP id ba6cb99f-70a8-11ed-91b6-6bf2151ebd3b; Wed, 30 Nov 2022 13:15:50 +0100 (CET) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 75BCB12FC; Wed, 30 Nov 2022 04:15:56 -0800 (PST) Received: from e109506.cambridge.arm.com (e109506.cambridge.arm.com [10.1.199.62]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 348A93F73D; Wed, 30 Nov 2022 04:15:49 -0800 (PST) X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: ba6cb99f-70a8-11ed-91b6-6bf2151ebd3b From: Bertrand Marquis To: xen-devel@lists.xenproject.org Cc: michal.orzel@amd.com, Doug Goldstein , Stefano Stabellini Subject: [PATCH v5 3/3] automation: Add CI test jobs for Yocto Date: Wed, 30 Nov 2022 12:15:09 +0000 Message-Id: X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 From: Michal Orzel Populate test jobs for Yocto based tests using the provided containers. Due to the size restrictions, it is currently not possible to split the build and run tasks, therefore everything is done in a single step. Test jobs for the supported Yocto targets are generic to avoid the necessity to add new ones after each Yocto release. The only thing required to be changed after updating the containers is the variable YOCTO_VERSION stored in a .yocto-test template. Signed-off-by: Michal Orzel --- Changes in v5: - none Changes in v4: - add .yocto-test for arm64 and x86 - make yocto jobs use arm64 version Changes in v3: - patch added --- automation/gitlab-ci/test.yaml | 43 ++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/automation/gitlab-ci/test.yaml b/automation/gitlab-ci/test.yaml index c7e0078e04f1..6ce2fd63eee6 100644 --- a/automation/gitlab-ci/test.yaml +++ b/automation/gitlab-ci/test.yaml @@ -54,6 +54,33 @@ tags: - x86_64 +.yocto-test: + extends: .test-jobs-common + script: + - ./automation/build/yocto/build-yocto.sh -v --log-dir=./logs --xen-dir=`pwd` ${YOCTO_BOARD} + variables: + YOCTO_VERSION: kirkstone + CONTAINER: yocto:${YOCTO_VERSION}-${YOCTO_BOARD}-${YOCTO_HOST} + artifacts: + paths: + - 'logs/*' + when: always + needs: [] + +.yocto-test-arm64: + extends: .yocto-test + variables: + YOCTO_HOST: arm64v8 + tags: + - arm64 + +.yocto-test-x86-64: + extends: .yocto-test + variables: + YOCTO_HOST: amd64 + tags: + - x86_64 + # Test jobs build-each-commit-gcc: extends: .test-jobs-common @@ -188,3 +215,19 @@ qemu-smoke-x86-64-clang-pvh: - ./automation/scripts/qemu-smoke-x86-64.sh pvh 2>&1 | tee ${LOGFILE} needs: - debian-unstable-clang-debug + +# Yocto test jobs +yocto-qemuarm64: + extends: .yocto-test-arm64 + variables: + YOCTO_BOARD: qemuarm64 + +yocto-qemuarm: + extends: .yocto-test-arm64 + variables: + YOCTO_BOARD: qemuarm + +yocto-qemux86-64: + extends: .yocto-test-arm64 + variables: + YOCTO_BOARD: qemux86-64