Yocto Gitlab CI
v5 cover Yocto Gitlab CI
This patch series is a first attempt to check if we could use Yocto in gitlab ci to build and run xen on qemu for arm, arm64 and x86.
The first patch is introducing a container template from which container files can be generated for all combinations we want to support (qemu arm, arm64 and x86 targets and hosts x86_64 and arm64).
It is also introducing a generic build script (build-yocto.sh) that is used to create, build and run a Yocto project.
The second patch is adding a way to easily clean locally created containers.
The third patch is introducing some gitlab CI templates and jobs so that we can test a Xen source tree in gitlab-CI using Yocto.
This has been tested on a x86 host machine and on an arm host machine (with mk_dsdt.c fix).
Changes in v5:
- automatic cleanup of generated docker files using INTERMEDIATE
- typo fixes
- rebase on Stefano's next branch
- remove clean rule cleaning all containers
Changes in v4:
- rework the container generation to support multiple hosts
- rework the container generation to use a single template for all docker files (make process is generating the docker files).
Changes in v3:
- limit number of jobs in yocto
- do not copy build script inside container
- add patch from Michal to create gitlab jobs
Changes in v2:
- remove gitignore patch which was merged
- add a --dump-log support in build-yocto.sh script and use it during container creation to see the error logs.
Bertrand Marquis (2):
automation: Create Yocto docker images
automation: Add a clean rule for containers
Michal Orzel (1):
automation: Add CI test jobs for Yocto
automation/build/Makefile | 24 +- automation/build/yocto/build-yocto.sh | 351 +++++++++++++++++++++ automation/build/yocto/yocto.dockerfile.in | 114 +++++++ automation/build/yocto/yocto.inc | 42 +++ automation/gitlab-ci/test.yaml | 43 +++ 5 files changed, 572 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
Signature · 1 line
2.25.1
PATCH v5 3/3 automation: Add CI test jobs for Yocto
From: Michal Orzel <[email protected]>
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.
---
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(+)
automation/gitlab-ci/test.yaml +43 -0
@@ -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
Signature · 1 line
2.25.1
PATCH v5 1/3 automation: Create Yocto docker images
In reply to Bertrand MarquisAdd 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.
---
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
automation/build/Makefile +12 -2
@@ -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 +
automation/build/yocto/build-yocto.sh new file +351 -0
351 lines not on this page · raw message
automation/build/yocto/yocto.dockerfile.in new file +114 -0
114 lines not on this page · raw message
automation/build/yocto/yocto.inc new file +42 -0
42 lines not on this page · raw message
Signature · 1 line
2.25.1
PATCH v5 2/3 automation: Add a clean rule for containers
In reply to Bertrand MarquisAdd make clean support to remove the containers from the local docker registry.
make clean-<image_name> must be called to remove an image:
make clean-yocto/kirkstone-qemuarm: remove yocto kirkstone for qemuarm image
---
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(+)
automation/build/Makefile +10 -0
@@ -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))))
Signature · 1 line
2.25.1
Re: [PATCH v5 3/3] automation: Add CI test jobs for Yocto
In reply to Bertrand MarquisHi Bertrand,
Quoted 50 lines · Bertrand Marquis
From: Michal Orzel <[email protected]>
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_VERSIONstored in a .yocto-test template.Signed-off-by Michal Orzel <[email protected]>---
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(+)automation/gitlab-ci/test.yaml +16
-0@@ -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:
automation/gitlab-ci/test.yaml line 82
Quoted 10 lines
automation/gitlab-ci/test.yaml +10
-0+ YOCTO_HOST: arm64v8 + tags: + - arm64 + +.yocto-test-x86-64: + extends: .yocto-test + variables: + YOCTO_HOST: amd64 + tags: + - x86_64
This hidden job is not used by any yocto test job and as such can be misleading to others working on this file.
So we can either remove it (can be easily reintroduced once we will find more x86 resources) or add a comment explaining why is it here.
Quoted 25 lines
automation/gitlab-ci/test.yaml +17
-1+ # 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 --
Quoted 2 lines
2.25.1
~Michal
Re: [PATCH v5 2/3] automation: Add a clean rule for containers
In reply to Bertrand MarquisHi Bertrand,
Quoted 9 lines · Bertrand Marquis
Add make clean support to remove the containers from the local docker registry.
make clean-<image_name> must be called to remove an image:
make clean-yocto/kirkstone-qemuarm: remove yocto kirkstone for qemuarm imageSigned-off-by Bertrand Marquis <[email protected]>
~Michal
Re: [PATCH v5 1/3] automation: Create Yocto docker images
In reply to Bertrand MarquisHi Bertrand,
I will try to build and run the yocto containers for a test. In the meantime I just spotted one thing.
Quoted 71 lines · Bertrand Marquis
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_64and 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 <[email protected]>---
Changes in v5:
- typo fixes
- add INTERMEDIATE to remove intermediate dockerfile
- use container architecture
- use full words in foreach loops
- fix shellcheck findings inbuild-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
- IntroduceCONTAINERS_EXTRAto 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 thebuild-yocto.shscript 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 tobuild-yocto.shscript to dump the logs if an error occurs.
Changes in v1:
- add --image command line argument tobuild-yocto.shto 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.incautomation/build/Makefile +0
-0
automation/build/Makefile line 8
Quoted 9 lines
automation/build/Makefile +3
-1@@ -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
Because this appears before help, when calling make without any target like:
make -C automation/build
the previous behavior of printing help by default is no longer true (the default target is taken from yocto.inc in this case). Instead we're getting:
make: Entering directory...
rm yocto/kirkstone-qemuarm64.dockerfile
make: Leaving directory...
This include can be easily moved after help to stick to the current behavior and still achieve what we want (i.e. make will still first evaluate include and then call the first target which is help, so CONTAINERS and CONTAINERS_EXTRA will contain correct data).
Quoted 12 lines
automation/build/Makefile +3
-0+ 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); \
automation/build/Makefile help: · line 30
Quoted 10 lines
automation/build/Makefile +6
-1fi -.PHONY: all +.PHONY: all clean all: $(CONTAINERS) + +# Remove generated dockerfiles for yocto +clean: + rm -f yocto/*.dockerfiles +
~Michal
Re: [PATCH v5 1/3] automation: Create Yocto docker images
Hi Michal,
Quoted 6 lines · Michal Orzel
Hi Bertrand,
I will try to build and run the yocto containers for a test. In the meantime I just spotted one thing.
I will wait until tomorrow for a v6 in case you find issues.
Quoted 87 lines · Bertrand Marquis
Quoted 79 lines
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_64and 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 <[email protected]>---
Changes in v5:
- typo fixes
- add INTERMEDIATE to remove intermediate dockerfile
- use container architecture
- use full words in foreach loops
- fix shellcheck findings inbuild-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
- IntroduceCONTAINERS_EXTRAto 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 thebuild-yocto.shscript 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 tobuild-yocto.shscript to dump the logs if an error occurs.
Changes in v1:
- add --image command line argument tobuild-yocto.shto 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.shcreate mode 100644 automation/build/yocto/yocto.dockerfile.in create mode 100644 automation/build/yocto/yocto.incautomation/build/Makefile +0
-0@@ -1,13 +1,18 @@ # the base of where these containers will appearREGISTRY := registry.gitlab.com/xen-project/xen
automation/build/Makefile +2
-1-CONTAINERS = $(subst .dockerfile,,$(wildcard */*.dockerfile)) +CONTAINERS = $(filter-out yocto/%,$(subst .dockerfile,,$(wildcard */*.dockerfile))) +CONTAINERS_EXTRA =
DOCKER_CMD?= dockerQuoted 1 line
+include yocto/yocto.inc
Because this appears before help, when calling make without any target like:
make -C automation/build
the previous behavior of printing help by default is no longer true (the default target is taken from yocto.inc in this case). Instead we're getting:
Quoted 7 lines
make: Entering directory...
rm yocto/kirkstone-qemuarm64.dockerfile
make: Leaving directory...This include can be easily moved after help to stick to the current behavior and still achieve what we want (i.e. make will still first evaluate include and then call the first target which is help, so CONTAINERS and
CONTAINERS_EXTRAwill contain correct data).
Complete right.
I will fix that in v6.
Cheers
Bertrand
Quoted 25 lines
Quoted 13 lines
+
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};)automation/build/Makefile +2
-0+ @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
automation/build/Makefile +0
-0@@ -16,5 +21,10 @@ help: $(DOCKER_CMD) push $(REGISTRY)/$(@D):$(@F); \automation/build/Makefile help: · line 30
Quoted 10 lines
automation/build/Makefile +6
-1fi -.PHONY: all +.PHONY: all clean all: $(CONTAINERS) + +# Remove generated dockerfiles for yocto +clean: + rm -f yocto/*.dockerfiles +~Michal
Re: [PATCH v5 3/3] automation: Add CI test jobs for Yocto
In reply to Michal OrzelHi Michal,
Quoted 59 lines · Michal Orzel
Hi Bertrand,
Quoted 54 lines · Bertrand Marquis
From: Michal Orzel <[email protected]>
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_VERSIONstored in a .yocto-test template.Signed-off-by Michal Orzel <[email protected]>---
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(+)automation/gitlab-ci/test.yaml +20
-0@@ -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 +
Quoted 8 lines
automation/gitlab-ci/test.yaml line 82
Quoted 6 lines
automation/gitlab-ci/test.yaml +6
-0+.yocto-test-x86-64: + extends: .yocto-test + variables: + YOCTO_HOST: amd64 + tags: + - x86_64This hidden job is not used by any yocto test job and as such can be misleading to others working on this file.
So we can either remove it (can be easily reintroduced once we will find more x86 resources) or add a comment explaining why is it here.
If I remove it then there is not reason to have something separated for arm64. I will keep and add the following comment on top:
# This is not used by any test job as we only run Yocto on arm based machines # Keep it here so that someone having x86 hardware can easily add jobs
Would you be ok with that ?
Cheers
Bertrand
Quoted 29 lines
Quoted 26 lines
automation/gitlab-ci/test.yaml +1
-0+ # Test jobsbuild-each-commit-gcc:
extends: .test-jobs-commonautomation/gitlab-ci/test.yaml +16
-1@@ -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 --Quoted 2 lines
2.25.1
~Michal
Re: [PATCH v5 3/3] automation: Add CI test jobs for Yocto
Hi Bertrand,
Quoted 72 lines · Bertrand Marquis
Hi Michal,
Quoted 59 lines · Michal Orzel
Hi Bertrand,
Quoted 54 lines · Bertrand Marquis
From: Michal Orzel <[email protected]>
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_VERSIONstored in a .yocto-test template.Signed-off-by Michal Orzel <[email protected]>---
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(+)automation/gitlab-ci/test.yaml +20
-0@@ -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 +Quoted 8 lines
automation/gitlab-ci/test.yaml line 82
Quoted 6 lines
automation/gitlab-ci/test.yaml +6
-0+.yocto-test-x86-64: + extends: .yocto-test + variables: + YOCTO_HOST: amd64 + tags: + - x86_64This hidden job is not used by any yocto test job and as such can be misleading to others working on this file.
So we can either remove it (can be easily reintroduced once we will find more x86 resources) or add a comment explaining why is it here.
Quoted 6 lines
If I remove it then there is not reason to have something separated for arm64. I will keep and add the following comment on top:
# This is not used by any test job as we only run Yocto on arm based machines # Keep it here so that someone having x86 hardware can easily add jobsWould you be ok with that ?
Yes, sure (+ add comma after end of sentence in multi line comments)
Quoted 4 lines
Cheers
Bertrand
~Michal
Re: [PATCH v5 3/3] automation: Add CI test jobs for Yocto
Hi Michal
Quoted 77 lines · Michal Orzel
Hi Bertrand,
Quoted 72 lines · Bertrand Marquis
Hi Michal,
Quoted 67 lines · Michal Orzel
Hi Bertrand,
Quoted 50 lines · Bertrand Marquis
From: Michal Orzel <[email protected]>
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_VERSIONstored in a .yocto-test template.Signed-off-by Michal Orzel <[email protected]>---
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(+)automation/gitlab-ci/test.yaml +16
-0@@ -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:automation/gitlab-ci/test.yaml line 82
Quoted 10 lines
automation/gitlab-ci/test.yaml +10
-0+ YOCTO_HOST: arm64v8 + tags: + - arm64 + +.yocto-test-x86-64: + extends: .yocto-test + variables: + YOCTO_HOST: amd64 + tags: + - x86_64This hidden job is not used by any yocto test job and as such can be misleading to others working on this file.
So we can either remove it (can be easily reintroduced once we will find more x86 resources) or add a comment explaining why is it here.
Quoted 7 lines
Quoted 6 lines
If I remove it then there is not reason to have something separated for arm64. I will keep and add the following comment on top:
# This is not used by any test job as we only run Yocto on arm based machines # Keep it here so that someone having x86 hardware can easily add jobsWould you be ok with that ?
Yes, sure (+ add comma after end of sentence in multi line comments)
Will do.
Bertrand
Quoted 7 lines
Quoted 5 lines
Cheers
Bertrand~Michal
Re: [PATCH v5 2/3] automation: Add a clean rule for containers
In reply to Bertrand Marquisautomation/build/Makefile all: $(CONTAINERS) · line 34
Quoted 10 lines · Bertrand Marquis
automation/build/Makefile +4
-0@@ -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))),)
Please, don't use "ifneq" in a rule's recipe, especially when running a shell command. That shell command is evaluated every time make parse the makefile, so we are going to run docker image ls 23 times!
Just write the call to docker image ls and evaluate the result in shell. I guess something like:
[ "$(docker image ls -q ...)" ] && docker image rm ...
Cheers,
Signature · 1 line
Anthony PERARD
Re: [PATCH v5 2/3] automation: Add a clean rule for containers
Hi Anthony,
Quoted 18 lines · Anthony PERARD
automation/build/Makefile all: $(CONTAINERS) · line 34
Quoted 10 lines · Bertrand Marquis
automation/build/Makefile +0
-0@@ -28,3 +28,13 @@ all: $(CONTAINERS)clean:
rm -f yocto/*.dockerfilesautomation/build/Makefile +4
-0+define CLEAN_RULE +.PHONY: clean-$(1) +clean-$(1): +ifneq ($$(shell docker image ls -q $(REGISTRY)/$(subst /,:,$(1))),)Please, don't use "ifneq" in a rule's recipe, especially when running a shell command. That shell command is evaluated every time make parse the makefile, so we are going to run
docker image ls23 times!
Quoted 3 lines
Just write the call to
docker image lsand evaluate the result in shell. I guess something like:[ "$(docker image ls -q ...)" ] && docker image rm ...
Very good point, I will fix that in v6.
Cheers
Bertrand
Quoted 6 lines
Cheers,
Signature · 1 line
Anthony PERARD
Re: [PATCH v5 1/3] automation: Create Yocto docker images
In reply to Bertrand Marquisautomation/build/Makefile line 4
Quoted 10 lines · Bertrand Marquis
automation/build/Makefile +1
-1@@ -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)))
Nit: while there, could you use ":=" instead of "=" ? The value of CONTAINERS is always going to be evaluated by make because it's used as a prerequisite of "all", so we can at least tell make to evaluate the value right away.
automation/build/Makefile line 15
Quoted 11 lines
automation/build/Makefile +5
-0+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};)
I wonder why the help syntax uses both ${} and $() for make variables, is it to confuse people? :-)
You can write $(file) instead of ${file}, I think this would be less confusing. I rarely see ${} been used in make, so seen ${} can be confusing. I've learned (relearned?) this alternative syntax only a few weeks ago as it's used by automake or autoconf.
Quoted 4 lines
automation/build/Makefile +0
-0@echo "To push container builds, set the env var PUSH" %: %.dockerfile ## Builds containers
automation/build/Makefile help: · line 29
Quoted 10 lines
automation/build/Makefile +5
-1@@ -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
There's an extra 's', I guess you want to remove "*.dockerfile" instead of "*.dockerfiles".
You could also add those to a .gitignore, even if there are likely to be removed by make.
Cheers,
Signature · 1 line
Anthony PERARD
Re: [PATCH v5 1/3] automation: Create Yocto docker images
Hi Anthony,
Quoted 9 lines · Anthony PERARD
Quoted 6 lines · Bertrand Marquis
automation/build/Makefile +0
-0@@ -1,13 +1,18 @@
Quoted 9 lines
automation/build/Makefile line 4
Quoted 4 lines
automation/build/Makefile +0
-0# the base of where these containers will appearREGISTRY := registry.gitlab.com/xen-project/xen
automation/build/Makefile +1
-1-CONTAINERS = $(subst .dockerfile,,$(wildcard */*.dockerfile)) +CONTAINERS = $(filter-out yocto/%,$(subst .dockerfile,,$(wildcard */*.dockerfile)))Nit: while there, could you use ":=" instead of "=" ? The value of CONTAINERS is always going to be evaluated by make because it's used as a prerequisite of "all", so we can at least tell make to evaluate the value right away.
Will do
Quoted 16 lines
automation/build/Makefile line 15
Quoted 12 lines
+CONTAINERS_EXTRA =
DOCKER_CMD?= dockerautomation/build/Makefile +2
-0+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};)automation/build/Makefile +2
-0+ @echo "Extra containers (not built using make all):" + @$(foreach file,$(sort $(CONTAINERS_EXTRA)),echo ${file};)I wonder why the help syntax uses both ${} and $() for make variables, is it to confuse people? :-)
Quoted 4 lines
You can write $(file) instead of ${file}, I think this would be less confusing. I rarely see ${} been used in make, so seen ${} can be confusing. I've learned (relearned?) this alternative syntax only a few weeks ago as it's used by automake or autoconf.
Definitely a typo, I will fix that in v6 (you have good eyes)
Quoted 8 lines
Quoted 8 lines
@echo "To push container builds, set the env var PUSH"
%: %.dockerfile ## Builds containers
automation/build/Makefile +0
-0@@ -16,5 +21,10 @@ help: $(DOCKER_CMD) push $(REGISTRY)/$(@D):$(@F); \ fi
Quoted 10 lines
automation/build/Makefile help: · line 29
Quoted 7 lines
automation/build/Makefile +5
-1-.PHONY: all +.PHONY: all clean all: $(CONTAINERS) + +# Remove generated dockerfiles for yocto +clean: + rm -f yocto/*.dockerfilesThere's an extra 's', I guess you want to remove "*.dockerfile" instead of "*.dockerfiles".
Ack
Quoted 3 lines
You could also add those to a .gitignore, even if there are likely to be removed by make.
Sure
Thanks for the review
Bertrand
Quoted 6 lines
Cheers,
Signature · 1 line
Anthony PERARD
Re: [PATCH v5 1/3] automation: Create Yocto docker images
In reply to Bertrand MarquisQuoted 583 lines · Bertrand Marquis
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_64and 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 <[email protected]>---
Changes in v5:
- typo fixes
- add INTERMEDIATE to remove intermediate dockerfile
- use container architecture
- use full words in foreach loops
- fix shellcheck findings inbuild-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
- IntroduceCONTAINERS_EXTRAto 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 thebuild-yocto.shscript 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 tobuild-yocto.shscript to dump the logs if an error occurs.
Changes in v1:
- add --image command line argument tobuild-yocto.shto 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.incautomation/build/Makefile +12
-2@@ -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 +automation/build/yocto/build-yocto.sh new file +351
-0@@ -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 <<EOF >> "${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 <<EOF >> "${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 <<EOF +set timeout 100 +spawn bash -c "runqemu serialstdio nographic slirp" + +expect_after { + -re "(.*)\r" { + exp_continue + } + timeout {send_user "ERROR-Timeout!\n"; exit 1} + eof {send_user "ERROR-EOF!\n"; exit 1} +} + +# wait initial login +expect -re ".* login: " +send "root\r" +expect -re "root@.*# " + +EOF + exit $? + ) || return 1 +} + +function help() { + cat <<EOF +Usage: ${0} [TARGET1] [TARGET2] + +This script is build the yocto xen-image-minimal for different qemu targets +and is running it after. +Without any target specified, all supported targets are done. + +Options: + -h, --help Print this help + -v, --verbose Verbose build + --list-target List supported targets + --clean Clean existing project before starting + --no-build Do not build (to run an already built project) + --no-run Do not run + --num-jobs=NUM Define the number of parallel jobs in Yocto. + Default: ${BUILDJOBS} + --dump-log On error, dump the logs on the console + --image=IMG Yocto image or package to build + Default: xen-image-minimal + --xen-dir=DIR path to xen hypervisor source tree + if not provide, normal yocto version of xen is built + Default: ${XENDIR} + --out-dir=DIR directory where to create the projectss + Default: ${BUILDDIR} + --log-dir=DIR directory to store logs + Default: ${LOGDIR} + --cache-dir=DIR directory where to take and store build cache + Default: ${CACHEDIR} + --layer-dir=DIR directory containing the checkout of yocto layers + Default: ${YOCTODIR} +EOF +} + +for OPTION in "$@" +do + case ${OPTION} in + -h|--help) + help + exit 0 + ;; + -v|--verbose) + VERBOSE="y" + ;; + --list-targets) + echo "${TARGET_SUPPORTED}" + exit 0 + ;; + --clean) + do_clean="y" + ;; + --no-build) + do_build="n" + ;; + --no-run) + do_run="n" + ;; + --dump-log) + do_dump="y" + ;; + --num-jobs=*) + BUILDJOBS="${OPTION#*=}" + ;; + --image=*) + build_image="${OPTION#*=}" + ;; + --xen-dir=*) + XENDIR="${OPTION#*=}" + if [ ! -e "${XENDIR}/xen/Makefile" ]; then + echo "No Xen source tree in ${XENDIR}" + exit 1 + fi + do_localsrc="y" + ;; + --out-dir=*) + BUILDDIR="${OPTION#*=}" + ;; + --log-dir=*) + LOGDIR="${OPTION#*=}" + ;; + --cache-dir=*) + CACHEDIR="${OPTION#*=}" + ;; + --layer-dir=*) + YOCTODIR="${OPTION#*=}" + ;; + --*) + echo "Invalid option ${OPTION}" + help + exit 1 + ;; + *) + if echo "${TARGET_SUPPORTED}" | grep -q -w "${OPTION}"; then + TARGETLIST="${TARGETLIST} ${OPTION}" + else + echo "Unsupported target ${OPTION}" + exit 1 + fi + ;; + esac +done + +# if no target is specified build all targets +if [ -z "${TARGETLIST}" ]; then + TARGETLIST="${TARGET_SUPPORTED}" +fi + +mkdir -p "${CACHEDIR}" +mkdir -p "${LOGDIR}" +mkdir -p "${BUILDDIR}" + +# Make sure we have an absolute path +YOCTODIR=$(realpath -m "${YOCTODIR}") +CACHEDIR=$(realpath -m "${CACHEDIR}") +BUILDDIR=$(realpath -m "${BUILDDIR}") +LOGDIR=$(realpath -m "${LOGDIR}") +if [ "${do_localsrc}" = "y" ]; then + XENDIR=$(realpath -m "${XENDIR}") +fi + +# Check that we have all the layers we need +for f in ${build_layerlist}; do + if [ ! -f "${YOCTODIR}/${f}/conf/layer.conf" ]; then + echo "Layer ${f} missing in ${YOCTODIR}" + exit 1 + fi +done + +for f in ${TARGETLIST}; do + if [ "${do_clean}" = "y" ]; then + run_task project_clean "${f}" + fi + if [ ! -f "${BUILDDIR}/${f}/conf/local.conf" ]; then + run_task project_create "${f}" + fi + if [ -f "${BUILDDIR}/${f}/conf/local.conf" ]; then + if [ "${do_build}" = "y" ]; then + run_task project_build "${f}" + fi + if [ "${do_run}" = "y" ]; then + run_task project_run "${f}" + fi + + fi +done + +print_progress "Build Complete (${build_result} errors)" +echo +exit ${build_result} +automation/build/yocto/yocto.dockerfile.in new file +114
-0@@ -0,0 +1,114 @@ +# Docker file to create an environment to build yocto with virtualization +# +# Arguments that can be passed during image creation using --build-arg: +# "host_uid=$(id -u)": to use current user uid for build user in the image +# "host_gid=$(id -g)": to use current user gid for build user in the image +# "ubuntu_version=VERS": to select the ubuntu version number + +# Use standard ubuntu minimal. +ARG ubuntu_version=22.04 +From ##DOCKERPLAT##ubuntu:$ubuntu_version AS base +LABEL maintainer.name="The Xen Project " \ + maintainer.email="[email protected]" + +ENV DEBIAN_FRONTEND=noninteractive + +# Install minimal ubuntu requirements for yocto and other tools we need. +# See https://docs.yoctoproject.org/4.0.1/brief-yoctoprojectqs/index.html#build-host-packages +RUN apt-get update && \ + apt-get --quiet --yes install \ + gawk \ + wget \ + git \ + diffstat \ + unzip \ + texinfo \ + gcc \ + build-essential \ + chrpath \ + socat \ + cpio \ + python3 \ + python3-pip \ + python3-pexpect \ + xz-utils \ + debianutils \ + iputils-ping \ + python3-git \ + python3-jinja2 \ + libegl1-mesa \ + libsdl1.2-dev \ + python3-subunit \ + mesa-common-dev \ + zstd \ + liblz4-tool \ + file \ + vim \ + bison \ + expect \ + locales \ + liblz4-tool \ + zstd \ + openssl \ + libssl3 \ + ca-certificates \ + && \ + apt-get autoremove -y && \ + apt-get clean && \ + rm -rf /var/lib/apt/lists* /tmp/* /var/tmp/* + +# Use bash as shell. +RUN rm /bin/sh && ln -s bash /bin/sh + +# Fix local for yocto. +RUN locale-gen en_US.UTF-8 && update-locale LC_ALL=en_US.UTF-8 \ + LANG=en_US.UTF-8 +ENV LANG en_US.UTF-8 +ENV LC_ALL en_US.UTF-8 + +# Create a user for the build (we don't want to build as root). +ENV USER_NAME docker-build +ARG host_uid=1000 +ARG host_gid=1000 +RUN groupadd -g $host_gid $USER_NAME && \ + useradd -g $host_gid -m -s /bin/bash -u $host_uid $USER_NAME + +# Switch to our user instead of root and start in its home. +USER $USER_NAME +WORKDIR /home/$USER_NAME + +# Create needed directories +RUN mkdir -p /home/$USER_NAME/yocto-layers \ + /home/$USER_NAME/yocto-cache \ + /home/$USER_NAME/logs \ + /home/$USER_NAME/bin \ + /home/$USER_NAME/xen && \ + chown $USER_NAME.$USER_NAME /home/$USER_NAME/* + +# clone yocto repositories we need. +RUN for rep in \ + https://github.com/openembedded/meta-openembedded \ + https://git.yoctoproject.org/poky \ + https://git.yoctoproject.org/meta-virtualization \ + ; do \ + git -C /home/$USER_NAME/yocto-layers \ + clone -b ##YOCTOVERSION## --single-branch $rep; \ + done + +# The builder stage is building an initial cache state that we include in the +# final image. +From base AS builder + +# This step can take one to several hours depending on your download bandwith +# and the speed of your computer. +COPY ./build-yocto.sh / +RUN /build-yocto.sh --dump-log ##YOCTOTARGET## + +From base + +# Only copy the cache status. +COPY --from=builder /home/$USER_NAME/yocto-cache /home/$USER_NAME/yocto-cache/. + +LABEL maintainer.name="The Xen Project " \ + maintainer.email="[email protected]" +automation/build/yocto/yocto.inc new file +0
-0
automation/build/yocto/yocto.inc line 7
Quoted 7 lines
automation/build/yocto/yocto.inc new file +7
-0@@ -0,0 +1,42 @@ +# This makefile generates the docker files for Yocto builds. +# The containers for the current architecture are the one built using make all. +# To build containers for a different architecture, you need to call make for +# the image you want explicitely. +# The containers are named this way: +# YOCTOVERSION-TARGET for x86_64 hosts +# YOCTOVERSION-TARGET-arm64v8 for arm64 hosts
Please add:
# For example you can build an arm64 container with the following command:
# make yocto/kirkstone-qemuarm64-arm64v8
The build of the qemux86-64 container still fails, logs attached. I tested the full gitlab-ci pipeline for qemuarm and qemuarm64 and they both succeeded.
Quoted 47 lines · Bertrand Marquis
This patch series is a first attempt to check if we could use Yocto in gitlab ci to build and run xen on qemu for arm, arm64 and x86.
The first patch is introducing a container template from which container files can be generated for all combinations we want to support (qemu arm, arm64 and x86 targets and hosts
x86_64and arm64).
It is also introducing a generic build script (build-yocto.sh) that is used to create, build and run a Yocto project.The second patch is adding a way to easily clean locally created containers.
The third patch is introducing some gitlab CI templates and jobs so that we can test a Xen source tree in gitlab-CI using Yocto.
This has been tested on a x86 host machine and on an arm host machine (with
mk_dsdt.cfix).Changes in v5:
- automatic cleanup of generated docker files using INTERMEDIATE
- typo fixes
- rebase on Stefano's next branch
- remove clean rule cleaning all containersChanges in v4:
- rework the container generation to support multiple hosts
- rework the container generation to use a single template for all docker files (make process is generating the docker files).Changes in v3:
- limit number of jobs in yocto
- do not copy build script inside container
- add patch from Michal to create gitlab jobsChanges in v2:
- remove gitignore patch which was merged
- add a --dump-log support inbuild-yocto.shscript and use it during container creation to see the error logs.Bertrand Marquis (2):
automation: Create Yocto docker images
automation: Add a clean rule for containersMichal Orzel (1):
automation: Add CI test jobs for Yocto
Quoted 13 lines
automation/build/Makefile | 24 +- automation/build/yocto/build-yocto.sh | 351 +++++++++++++++++++++ automation/build/yocto/yocto.dockerfile.in | 114 +++++++ automation/build/yocto/yocto.inc | 42 +++ automation/gitlab-ci/test.yaml | 43 +++ 5 files changed, 572 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.incSignature · 1 line
2.25.1
| Parsing libxl_types.idl
| In file included from mk_dsdt.c:21:
| /home/docker-build/build/qemux86-64/tmp/work/core2-64-poky-linux/xen-tools/4.16+stableAUTOINC+f265444922-r0/git/tools/libacpi/../../tools/include/xen/arch-x86/xen.h:34: error: "___DEFINE_XEN_GUEST_HANDLE" redefined [-Werror]
| 34 | #define ___DEFINE_XEN_GUEST_HANDLE(name, type) \
| |
| In file included from /home/docker-build/build/qemux86-64/tmp/work/core2-64-poky-linux/xen-tools/4.16+stableAUTOINC+f265444922-r0/git/tools/libacpi/../../tools/include/xen/arch-x86/../xen.h:35,
| from /home/docker-build/build/qemux86-64/tmp/work/core2-64-poky-linux/xen-tools/4.16+stableAUTOINC+f265444922-r0/git/tools/libacpi/../../tools/include/xen/arch-x86/xen.h:27,
| from mk_dsdt.c:21:
| /home/docker-build/build/qemux86-64/tmp/work/core2-64-poky-linux/xen-tools/4.16+stableAUTOINC+f265444922-r0/git/tools/libacpi/../../tools/include/xen/arch-x86/../arch-arm.h:176: note: this is the location of the previous definition
| 176 | #define ___DEFINE_XEN_GUEST_HANDLE(name, type) \
| |
| In file included from mk_dsdt.c:21:
| /home/docker-build/build/qemux86-64/tmp/work/core2-64-poky-linux/xen-tools/4.16+stableAUTOINC+f265444922-r0/git/tools/libacpi/../../tools/include/xen/arch-x86/xen.h:53: error: "__XEN_GUEST_HANDLE" redefined [-Werror]
| 53 | #define __XEN_GUEST_HANDLE(name) __guest_handle_ ## name
| |
| In file included from /home/docker-build/build/qemux86-64/tmp/work/core2-64-poky-linux/xen-tools/4.16+stableAUTOINC+f265444922-r0/git/tools/libacpi/../../tools/include/xen/arch-x86/../xen.h:35,
| from /home/docker-build/build/qemux86-64/tmp/work/core2-64-poky-linux/xen-tools/4.16+stableAUTOINC+f265444922-r0/git/tools/libacpi/../../tools/include/xen/arch-x86/xen.h:27,
| from mk_dsdt.c:21:
| /home/docker-build/build/qemux86-64/tmp/work/core2-64-poky-linux/xen-tools/4.16+stableAUTOINC+f265444922-r0/git/tools/libacpi/../../tools/include/xen/arch-x86/../arch-arm.h:193: note: this is the location of the previous definition
| 193 | #define __XEN_GUEST_HANDLE(name) __guest_handle_64_ ## name
| |
| In file included from mk_dsdt.c:21:
| /home/docker-build/build/qemux86-64/tmp/work/core2-64-poky-linux/xen-tools/4.16+stableAUTOINC+f265444922-r0/git/tools/libacpi/../../tools/include/xen/arch-x86/xen.h:55: error: "XEN_GUEST_HANDLE_PARAM" redefined [-Werror]
| 55 | #define XEN_GUEST_HANDLE_PARAM(name) XEN_GUEST_HANDLE(name)
| |
| In file included from /home/docker-build/build/qemux86-64/tmp/work/core2-64-poky-linux/xen-tools/4.16+stableAUTOINC+f265444922-r0/git/tools/libacpi/../../tools/include/xen/arch-x86/../xen.h:35,
| from /home/docker-build/build/qemux86-64/tmp/work/core2-64-poky-linux/xen-tools/4.16+stableAUTOINC+f265444922-r0/git/tools/libacpi/../../tools/include/xen/arch-x86/xen.h:27,
| from mk_dsdt.c:21:
| /home/docker-build/build/qemux86-64/tmp/work/core2-64-poky-linux/xen-tools/4.16+stableAUTOINC+f265444922-r0/git/tools/libacpi/../../tools/include/xen/arch-x86/../arch-arm.h:195: note: this is the location of the previous definition
| 195 | #define XEN_GUEST_HANDLE_PARAM(name) __guest_handle_ ## name
| |
| In file included from mk_dsdt.c:21:
| /home/docker-build/build/qemux86-64/tmp/work/core2-64-poky-linux/xen-tools/4.16+stableAUTOINC+f265444922-r0/git/tools/libacpi/../../tools/include/xen/arch-x86/xen.h:56: error: "set_xen_guest_handle_raw" redefined [-Werror]
| 56 | #define set_xen_guest_handle_raw(hnd, val) do { (hnd).p = val; } while (0)
| |
| In file included from /home/docker-build/build/qemux86-64/tmp/work/core2-64-poky-linux/xen-tools/4.16+stableAUTOINC+f265444922-r0/git/tools/libacpi/../../tools/include/xen/arch-x86/../xen.h:35,
| from /home/docker-build/build/qemux86-64/tmp/work/core2-64-poky-linux/xen-tools/4.16+stableAUTOINC+f265444922-r0/git/tools/libacpi/../../tools/include/xen/arch-x86/xen.h:27,
| from mk_dsdt.c:21:
| /home/docker-build/build/qemux86-64/tmp/work/core2-64-poky-linux/xen-tools/4.16+stableAUTOINC+f265444922-r0/git/tools/libacpi/../../tools/include/xen/arch-x86/../arch-arm.h:196: note: this is the location of the previous definition
| 196 | #define set_xen_guest_handle_raw(hnd, val) \
| |
| In file included from mk_dsdt.c:21:
| /home/docker-build/build/qemux86-64/tmp/work/core2-64-poky-linux/xen-tools/4.16+stableAUTOINC+f265444922-r0/git/tools/libacpi/../../tools/include/xen/arch-x86/xen.h:77: error: "PRI_xen_pfn" redefined [-Werror]
| 77 | #define PRI_xen_pfn "lx"
| |
| In file included from /home/docker-build/build/qemux86-64/tmp/work/core2-64-poky-linux/xen-tools/4.16+stableAUTOINC+f265444922-r0/git/tools/libacpi/../../tools/include/xen/arch-x86/../xen.h:35,
| from /home/docker-build/build/qemux86-64/tmp/work/core2-64-poky-linux/xen-tools/4.16+stableAUTOINC+f265444922-r0/git/tools/libacpi/../../tools/include/xen/arch-x86/xen.h:27,
| from mk_dsdt.c:21:
| /home/docker-build/build/qemux86-64/tmp/work/core2-64-poky-linux/xen-tools/4.16+stableAUTOINC+f265444922-r0/git/tools/libacpi/../../tools/include/xen/arch-x86/../arch-arm.h:205: note: this is the location of the previous definition
| 205 | #define PRI_xen_pfn PRIx64
| |
| In file included from mk_dsdt.c:21:
| /home/docker-build/build/qemux86-64/tmp/work/core2-64-poky-linux/xen-tools/4.16+stableAUTOINC+f265444922-r0/git/tools/libacpi/../../tools/include/xen/arch-x86/xen.h:78: error: "PRIu_xen_pfn" redefined [-Werror]
| 78 | #define PRIu_xen_pfn "lu"
| |
| In file included from /home/docker-build/build/qemux86-64/tmp/work/core2-64-poky-linux/xen-tools/4.16+stableAUTOINC+f265444922-r0/git/tools/libacpi/../../tools/include/xen/arch-x86/../xen.h:35,
| from /home/docker-build/build/qemux86-64/tmp/work/core2-64-poky-linux/xen-tools/4.16+stableAUTOINC+f265444922-r0/git/tools/libacpi/../../tools/include/xen/arch-x86/xen.h:27,
| from mk_dsdt.c:21:
| /home/docker-build/build/qemux86-64/tmp/work/core2-64-poky-linux/xen-tools/4.16+stableAUTOINC+f265444922-r0/git/tools/libacpi/../../tools/include/xen/arch-x86/../arch-arm.h:206: note: this is the location of the previous definition
| 206 | #define PRIu_xen_pfn PRIu64
| |
| In file included from mk_dsdt.c:21:
| /home/docker-build/build/qemux86-64/tmp/work/core2-64-poky-linux/xen-tools/4.16+stableAUTOINC+f265444922-r0/git/tools/libacpi/../../tools/include/xen/arch-x86/xen.h:117: error: "XEN_LEGACY_MAX_VCPUS" redefined [-Werror]
| 117 | #define XEN_LEGACY_MAX_VCPUS 32
| |
| In file included from /home/docker-build/build/qemux86-64/tmp/work/core2-64-poky-linux/xen-tools/4.16+stableAUTOINC+f265444922-r0/git/tools/libacpi/../../tools/include/xen/arch-x86/../xen.h:35,
| from /home/docker-build/build/qemux86-64/tmp/work/core2-64-poky-linux/xen-tools/4.16+stableAUTOINC+f265444922-r0/git/tools/libacpi/../../tools/include/xen/arch-x86/xen.h:27,
| from mk_dsdt.c:21:
| /home/docker-build/build/qemux86-64/tmp/work/core2-64-poky-linux/xen-tools/4.16+stableAUTOINC+f265444922-r0/git/tools/libacpi/../../tools/include/xen/arch-x86/../arch-arm.h:212: note: this is the location of the previous definition
| 212 | #define XEN_LEGACY_MAX_VCPUS 1
| |
| In file included from mk_dsdt.c:21:
| /home/docker-build/build/qemux86-64/tmp/work/core2-64-poky-linux/xen-tools/4.16+stableAUTOINC+f265444922-r0/git/tools/libacpi/../../tools/include/xen/arch-x86/xen.h:122: error: "PRI_xen_ulong" redefined [-Werror]
| 122 | #define PRI_xen_ulong "lx"
| |
| In file included from /home/docker-build/build/qemux86-64/tmp/work/core2-64-poky-linux/xen-tools/4.16+stableAUTOINC+f265444922-r0/git/tools/libacpi/../../tools/include/xen/arch-x86/../xen.h:35,
| from /home/docker-build/build/qemux86-64/tmp/work/core2-64-poky-linux/xen-tools/4.16+stableAUTOINC+f265444922-r0/git/tools/libacpi/../../tools/include/xen/arch-x86/xen.h:27,
| from mk_dsdt.c:21:
| /home/docker-build/build/qemux86-64/tmp/work/core2-64-poky-linux/xen-tools/4.16+stableAUTOINC+f265444922-r0/git/tools/libacpi/../../tools/include/xen/arch-x86/../arch-arm.h:215: note: this is the location of the previous definition
| 215 | #define PRI_xen_ulong PRIx64
| |
| In file included from mk_dsdt.c:21:
| /home/docker-build/build/qemux86-64/tmp/work/core2-64-poky-linux/xen-tools/4.16+stableAUTOINC+f265444922-r0/git/tools/libacpi/../../tools/include/xen/arch-x86/xen.h:179:8: error: redefinition of ‘struct vcpu_guest_context’
| 179 | struct vcpu_guest_context {
| | ^~~~~~~~~~~~~~~~~~
| In file included from /home/docker-build/build/qemux86-64/tmp/work/core2-64-poky-linux/xen-tools/4.16+stableAUTOINC+f265444922-r0/git/tools/libacpi/../../tools/include/xen/arch-x86/../xen.h:35,
| from /home/docker-build/build/qemux86-64/tmp/work/core2-64-poky-linux/xen-tools/4.16+stableAUTOINC+f265444922-r0/git/tools/libacpi/../../tools/include/xen/arch-x86/xen.h:27,
| from mk_dsdt.c:21:
| /home/docker-build/build/qemux86-64/tmp/work/core2-64-poky-linux/xen-tools/4.16+stableAUTOINC+f265444922-r0/git/tools/libacpi/../../tools/include/xen/arch-x86/../arch-arm.h:293:8: note: originally defined here
| 293 | struct vcpu_guest_context {
| | ^~~~~~~~~~~~~~~~~~
| In file included from mk_dsdt.c:21:
| /home/docker-build/build/qemux86-64/tmp/work/core2-64-poky-linux/xen-tools/4.16+stableAUTOINC+f265444922-r0/git/tools/libacpi/../../tools/include/xen/arch-x86/xen.h:192: error: "_VGCF_online" redefined [-Werror]
| 192 | #define _VGCF_online 5
| |
| In file included from /home/docker-build/build/qemux86-64/tmp/work/core2-64-poky-linux/xen-tools/4.16+stableAUTOINC+f265444922-r0/git/tools/libacpi/../../tools/include/xen/arch-x86/../xen.h:35,
| from /home/docker-build/build/qemux86-64/tmp/work/core2-64-poky-linux/xen-tools/4.16+stableAUTOINC+f265444922-r0/git/tools/libacpi/../../tools/include/xen/arch-x86/xen.h:27,
| from mk_dsdt.c:21:
| /home/docker-build/build/qemux86-64/tmp/work/core2-64-poky-linux/xen-tools/4.16+stableAUTOINC+f265444922-r0/git/tools/libacpi/../../tools/include/xen/arch-x86/../arch-arm.h:294: note: this is the location of the previous definition
| 294 | #define _VGCF_online 0
| |
| In file included from mk_dsdt.c:21:
| /home/docker-build/build/qemux86-64/tmp/work/core2-64-poky-linux/xen-tools/4.16+stableAUTOINC+f265444922-r0/git/tools/libacpi/../../tools/include/xen/arch-x86/xen.h:195:26: error: field ‘user_regs’ has incomplete type
| 195 | struct cpu_user_regs user_regs; /* User-level CPU registers */
| | ^~~~~~~~~
| /home/docker-build/build/qemux86-64/tmp/work/core2-64-poky-linux/xen-tools/4.16+stableAUTOINC+f265444922-r0/git/tools/libacpi/../../tools/include/xen/arch-x86/xen.h:231:35: error: conflicting types for ‘vcpu_guest_context_t’; have ‘struct vcpu_guest_context’
| 231 | typedef struct vcpu_guest_context vcpu_guest_context_t;
| | ^~~~~~~~~~~~~~~~~~~~
| In file included from /home/docker-build/build/qemux86-64/tmp/work/core2-64-poky-linux/xen-tools/4.16+stableAUTOINC+f265444922-r0/git/tools/libacpi/../../tools/include/xen/arch-x86/../xen.h:35,
| from /home/docker-build/build/qemux86-64/tmp/work/core2-64-poky-linux/xen-tools/4.16+stableAUTOINC+f265444922-r0/git/tools/libacpi/../../tools/include/xen/arch-x86/xen.h:27,
| from mk_dsdt.c:21:
| /home/docker-build/build/qemux86-64/tmp/work/core2-64-poky-linux/xen-tools/4.16+stableAUTOINC+f265444922-r0/git/tools/libacpi/../../tools/include/xen/arch-x86/../arch-arm.h:303:35: note: previous declaration of ‘vcpu_guest_context_t’ with type ‘vcpu_guest_context_t’ {aka ‘struct vcpu_guest_context’}
| 303 | typedef struct vcpu_guest_context vcpu_guest_context_t;
| | ^~~~~~~~~~~~~~~~~~~~
| In file included from mk_dsdt.c:21:
| /home/docker-build/build/qemux86-64/tmp/work/core2-64-poky-linux/xen-tools/4.16+stableAUTOINC+f265444922-r0/git/tools/libacpi/../../tools/include/xen/arch-x86/xen.h:35:33: error: conflicting types for ‘__guest_handle_vcpu_guest_context_t’; have ‘struct <anonymous>’
| 35 | typedef struct { type *p; } __guest_handle_ ## name
| | ^~~~~~~~~~~~~~~
| /home/docker-build/build/qemux86-64/tmp/work/core2-64-poky-linux/xen-tools/4.16+stableAUTOINC+f265444922-r0/git/tools/libacpi/../../tools/include/xen/arch-x86/xen.h:50:5: note: in expansion of macro ‘___DEFINE_XEN_GUEST_HANDLE’
| 50 | ___DEFINE_XEN_GUEST_HANDLE(name, type); \
| | ^~~~~~~~~~~~~~~~~~~~~~~~~~
| /home/docker-build/build/qemux86-64/tmp/work/core2-64-poky-linux/xen-tools/4.16+stableAUTOINC+f265444922-r0/git/tools/libacpi/../../tools/include/xen/arch-x86/xen.h:52:41: note: in expansion of macro ‘__DEFINE_XEN_GUEST_HANDLE’
| 52 | #define DEFINE_XEN_GUEST_HANDLE(name) __DEFINE_XEN_GUEST_HANDLE(name, name)
| | ^~~~~~~~~~~~~~~~~~~~~~~~~
| /home/docker-build/build/qemux86-64/tmp/work/core2-64-poky-linux/xen-tools/4.16+stableAUTOINC+f265444922-r0/git/tools/libacpi/../../tools/include/xen/arch-x86/xen.h:232:1: note: in expansion of macro ‘DEFINE_XEN_GUEST_HANDLE’
| 232 | DEFINE_XEN_GUEST_HANDLE(vcpu_guest_context_t);
| | ^~~~~~~~~~~~~~~~~~~~~~~
| In file included from /home/docker-build/build/qemux86-64/tmp/work/core2-64-poky-linux/xen-tools/4.16+stableAUTOINC+f265444922-r0/git/tools/libacpi/../../tools/include/xen/arch-x86/../xen.h:35,
| from /home/docker-build/build/qemux86-64/tmp/work/core2-64-poky-linux/xen-tools/4.16+stableAUTOINC+f265444922-r0/git/tools/libacpi/../../tools/include/xen/arch-x86/xen.h:27,
| from mk_dsdt.c:21:
| /home/docker-build/build/qemux86-64/tmp/work/core2-64-poky-linux/xen-tools/4.16+stableAUTOINC+f265444922-r0/git/tools/libacpi/../../tools/include/xen/arch-x86/../arch-arm.h:178:9: note: previous declaration of ‘__guest_handle_vcpu_guest_context_t’ with type ‘__guest_handle_vcpu_guest_context_t’
| 178 | __guest_handle_ ## name; \
| | ^~~~~~~~~~~~~~~
| /home/docker-build/build/qemux86-64/tmp/work/core2-64-poky-linux/xen-tools/4.16+stableAUTOINC+f265444922-r0/git/tools/libacpi/../../tools/include/xen/arch-x86/../arch-arm.h:190:5: note: in expansion of macro ‘___DEFINE_XEN_GUEST_HANDLE’
| 190 | ___DEFINE_XEN_GUEST_HANDLE(name, type); \
| | ^~~~~~~~~~~~~~~~~~~~~~~~~~
| /home/docker-build/build/qemux86-64/tmp/work/core2-64-poky-linux/xen-tools/4.16+stableAUTOINC+f265444922-r0/git/tools/libacpi/../../tools/include/xen/arch-x86/../arch-arm.h:192:41: note: in expansion of macro ‘__DEFINE_XEN_GUEST_HANDLE’
| 192 | #define DEFINE_XEN_GUEST_HANDLE(name) __DEFINE_XEN_GUEST_HANDLE(name, name)
| | ^~~~~~~~~~~~~~~~~~~~~~~~~
| /home/docker-build/build/qemux86-64/tmp/work/core2-64-poky-linux/xen-tools/4.16+stableAUTOINC+f265444922-r0/git/tools/libacpi/../../tools/include/xen/arch-x86/../arch-arm.h:304:1: note: in expansion of macro ‘DEFINE_XEN_GUEST_HANDLE’
| 304 | DEFINE_XEN_GUEST_HANDLE(vcpu_guest_context_t);
| | ^~~~~~~~~~~~~~~~~~~~~~~
| In file included from mk_dsdt.c:21:
| /home/docker-build/build/qemux86-64/tmp/work/core2-64-poky-linux/xen-tools/4.16+stableAUTOINC+f265444922-r0/git/tools/libacpi/../../tools/include/xen/arch-x86/xen.h:35:33: error: conflicting types for ‘__guest_handle_const_vcpu_guest_context_t’; have ‘struct <anonymous>’
| 35 | typedef struct { type *p; } __guest_handle_ ## name
| | ^~~~~~~~~~~~~~~
| /home/docker-build/build/qemux86-64/tmp/work/core2-64-poky-linux/xen-tools/4.16+stableAUTOINC+f265444922-r0/git/tools/libacpi/../../tools/include/xen/arch-x86/xen.h:51:5: note: in expansion of macro ‘___DEFINE_XEN_GUEST_HANDLE’
| 51 | ___DEFINE_XEN_GUEST_HANDLE(const_##name, const type)
| | ^~~~~~~~~~~~~~~~~~~~~~~~~~
| /home/docker-build/build/qemux86-64/tmp/work/core2-64-poky-linux/xen-tools/4.16+stableAUTOINC+f265444922-r0/git/tools/libacpi/../../tools/include/xen/arch-x86/xen.h:52:41: note: in expansion of macro ‘__DEFINE_XEN_GUEST_HANDLE’
| 52 | #define DEFINE_XEN_GUEST_HANDLE(name) __DEFINE_XEN_GUEST_HANDLE(name, name)
| | ^~~~~~~~~~~~~~~~~~~~~~~~~
| /home/docker-build/build/qemux86-64/tmp/work/core2-64-poky-linux/xen-tools/4.16+stableAUTOINC+f265444922-r0/git/tools/libacpi/../../tools/include/xen/arch-x86/xen.h:232:1: note: in expansion of macro ‘DEFINE_XEN_GUEST_HANDLE’
| 232 | DEFINE_XEN_GUEST_HANDLE(vcpu_guest_context_t);
| | ^~~~~~~~~~~~~~~~~~~~~~~
| In file included from /home/docker-build/build/qemux86-64/tmp/work/core2-64-poky-linux/xen-tools/4.16+stableAUTOINC+f265444922-r0/git/tools/libacpi/../../tools/include/xen/arch-x86/../xen.h:35,
| from /home/docker-build/build/qemux86-64/tmp/work/core2-64-poky-linux/xen-tools/4.16+stableAUTOINC+f265444922-r0/git/tools/libacpi/../../tools/include/xen/arch-x86/xen.h:27,
| from mk_dsdt.c:21:
| /home/docker-build/build/qemux86-64/tmp/work/core2-64-poky-linux/xen-tools/4.16+stableAUTOINC+f265444922-r0/git/tools/libacpi/../../tools/include/xen/arch-x86/../arch-arm.h:178:9: note: previous declaration of ‘__guest_handle_const_vcpu_guest_context_t’ with type ‘__guest_handle_const_vcpu_guest_context_t’
| 178 | __guest_handle_ ## name; \
| | ^~~~~~~~~~~~~~~
| /home/docker-build/build/qemux86-64/tmp/work/core2-64-poky-linux/xen-tools/4.16+stableAUTOINC+f265444922-r0/git/tools/libacpi/../../tools/include/xen/arch-x86/../arch-arm.h:191:5: note: in expansion of macro ‘___DEFINE_XEN_GUEST_HANDLE’
| 191 | ___DEFINE_XEN_GUEST_HANDLE(const_##name, const type)
| | ^~~~~~~~~~~~~~~~~~~~~~~~~~
| /home/docker-build/build/qemux86-64/tmp/work/core2-64-poky-linux/xen-tools/4.16+stableAUTOINC+f265444922-r0/git/tools/libacpi/../../tools/include/xen/arch-x86/../arch-arm.h:192:41: note: in expansion of macro ‘__DEFINE_XEN_GUEST_HANDLE’
| 192 | #define DEFINE_XEN_GUEST_HANDLE(name) __DEFINE_XEN_GUEST_HANDLE(name, name)
| | ^~~~~~~~~~~~~~~~~~~~~~~~~
| /home/docker-build/build/qemux86-64/tmp/work/core2-64-poky-linux/xen-tools/4.16+stableAUTOINC+f265444922-r0/git/tools/libacpi/../../tools/include/xen/arch-x86/../arch-arm.h:304:1: note: in expansion of macro ‘DEFINE_XEN_GUEST_HANDLE’
| 304 | DEFINE_XEN_GUEST_HANDLE(vcpu_guest_context_t);
| | ^~~~~~~~~~~~~~~~~~~~~~~
| In file included from mk_dsdt.c:21:
| /home/docker-build/build/qemux86-64/tmp/work/core2-64-poky-linux/xen-tools/4.16+stableAUTOINC+f265444922-r0/git/tools/libacpi/../../tools/include/xen/arch-x86/xen.h:234:8: error: redefinition of ‘struct arch_shared_info’
| 234 | struct arch_shared_info {
| | ^~~~~~~~~~~~~~~~
| In file included from /home/docker-build/build/qemux86-64/tmp/work/core2-64-poky-linux/xen-tools/4.16+stableAUTOINC+f265444922-r0/git/tools/libacpi/../../tools/include/xen/arch-x86/../xen.h:35,
| from /home/docker-build/build/qemux86-64/tmp/work/core2-64-poky-linux/xen-tools/4.16+stableAUTOINC+f265444922-r0/git/tools/libacpi/../../tools/include/xen/arch-x86/xen.h:27,
| from mk_dsdt.c:21:
| /home/docker-build/build/qemux86-64/tmp/work/core2-64-poky-linux/xen-tools/4.16+stableAUTOINC+f265444922-r0/git/tools/libacpi/../../tools/include/xen/arch-x86/../arch-arm.h:345:8: note: originally defined here
| 345 | struct arch_shared_info {
| | ^~~~~~~~~~~~~~~~
| In file included from mk_dsdt.c:21:
| /home/docker-build/build/qemux86-64/tmp/work/core2-64-poky-linux/xen-tools/4.16+stableAUTOINC+f265444922-r0/git/tools/libacpi/../../tools/include/xen/arch-x86/xen.h:275:33: error: conflicting types for ‘arch_shared_info_t’; have ‘struct arch_shared_info’
| 275 | typedef struct arch_shared_info arch_shared_info_t;
| | ^~~~~~~~~~~~~~~~~~
| In file included from /home/docker-build/build/qemux86-64/tmp/work/core2-64-poky-linux/xen-tools/4.16+stableAUTOINC+f265444922-r0/git/tools/libacpi/../../tools/include/xen/arch-x86/../xen.h:35,
| from /home/docker-build/build/qemux86-64/tmp/work/core2-64-poky-linux/xen-tools/4.16+stableAUTOINC+f265444922-r0/git/tools/libacpi/../../tools/include/xen/arch-x86/xen.h:27,
| from mk_dsdt.c:21:
| /home/docker-build/build/qemux86-64/tmp/work/core2-64-poky-linux/xen-tools/4.16+stableAUTOINC+f265444922-r0/git/tools/libacpi/../../tools/include/xen/arch-x86/../arch-arm.h:347:33: note: previous declaration of ‘arch_shared_info_t’ with type ‘arch_shared_info_t’ {aka ‘struct arch_shared_info’}
| 347 | typedef struct arch_shared_info arch_shared_info_t;
| | ^~~~~~~~~~~~~~~~~~
| In file included from mk_dsdt.c:21:
| /home/docker-build/build/qemux86-64/tmp/work/core2-64-poky-linux/xen-tools/4.16+stableAUTOINC+f265444922-r0/git/tools/libacpi/../../tools/include/xen/arch-x86/xen.h:282:8: error: redefinition of ‘struct xen_arch_domainconfig’
| 282 | struct xen_arch_domainconfig {
| | ^~~~~~~~~~~~~~~~~~~~~
| In file included from /home/docker-build/build/qemux86-64/tmp/work/core2-64-poky-linux/xen-tools/4.16+stableAUTOINC+f265444922-r0/git/tools/libacpi/../../tools/include/xen/arch-x86/../xen.h:35,
| from /home/docker-build/build/qemux86-64/tmp/work/core2-64-poky-linux/xen-tools/4.16+stableAUTOINC+f265444922-r0/git/tools/libacpi/../../tools/include/xen/arch-x86/xen.h:27,
| from mk_dsdt.c:21:
| /home/docker-build/build/qemux86-64/tmp/work/core2-64-poky-linux/xen-tools/4.16+stableAUTOINC+f265444922-r0/git/tools/libacpi/../../tools/include/xen/arch-x86/../arch-arm.h:317:8: note: originally defined here
| 317 | struct xen_arch_domainconfig {
| | ^~~~~~~~~~~~~~~~~~~~~
| cc1: all warnings being treated as errors
| make[7]: *** [Makefile:50: /home/docker-build/build/qemux86-64/tmp/work/core2-64-poky-linux/xen-tools/4.16+stableAUTOINC+f265444922-r0/git/tools/libs/light/mk_dsdt] Error 1
| make[7]: Leaving directory '/home/docker-build/build/qemux86-64/tmp/work/core2-64-poky-linux/xen-tools/4.16+stableAUTOINC+f265444922-r0/git/tools/libacpi'
| make[6]: *** [Makefile:41: acpi] Error 2
| make[6]: *** Waiting for unfinished jobs....
| mv -f _libxl.api-for-check.new _libxl.api-for-check
| mv testidl.c.new testidl.c
| make[6]: Leaving directory '/home/docker-build/build/qemux86-64/tmp/work/core2-64-poky-linux/xen-tools/4.16+stableAUTOINC+f265444922-r0/git/tools/libs/light'
| make[5]: *** [/home/docker-build/build/qemux86-64/tmp/work/core2-64-poky-linux/xen-tools/4.16+stableAUTOINC+f265444922-r0/git/tools/libs/../../tools/Rules.mk:166: subdir-install-light] Error 2
| make[5]: Leaving directory '/home/docker-build/build/qemux86-64/tmp/work/core2-64-poky-linux/xen-tools/4.16+stableAUTOINC+f265444922-r0/git/tools/libs'
| make[4]: *** [/home/docker-build/build/qemux86-64/tmp/work/core2-64-poky-linux/xen-tools/4.16+stableAUTOINC+f265444922-r0/git/tools/libs/../../tools/Rules.mk:161: subdirs-install] Error 2
| make[4]: Leaving directory '/home/docker-build/build/qemux86-64/tmp/work/core2-64-poky-linux/xen-tools/4.16+stableAUTOINC+f265444922-r0/git/tools/libs'
| make[3]: *** [/home/docker-build/build/qemux86-64/tmp/work/core2-64-poky-linux/xen-tools/4.16+stableAUTOINC+f265444922-r0/git/tools/../tools/Rules.mk:166: subdir-install-libs] Error 2
| make[3]: Leaving directory '/home/docker-build/build/qemux86-64/tmp/work/core2-64-poky-linux/xen-tools/4.16+stableAUTOINC+f265444922-r0/git/tools'
| make[2]: *** [/home/docker-build/build/qemux86-64/tmp/work/core2-64-poky-linux/xen-tools/4.16+stableAUTOINC+f265444922-r0/git/tools/../tools/Rules.mk:161: subdirs-install] Error 2
| make[2]: Leaving directory '/home/docker-build/build/qemux86-64/tmp/work/core2-64-poky-linux/xen-tools/4.16+stableAUTOINC+f265444922-r0/git/tools'
| make[1]: *** [Makefile:66: install] Error 2
| make[1]: Leaving directory '/home/docker-build/build/qemux86-64/tmp/work/core2-64-poky-linux/xen-tools/4.16+stableAUTOINC+f265444922-r0/git/tools'
| make: *** [Makefile:140: install-tools] Error 2
| ERROR: oe_runmake failed
| WARNING: /home/docker-build/build/qemux86-64/tmp/work/core2-64-poky-linux/xen-tools/4.16+stableAUTOINC+f265444922-r0/temp/run.do_compile.2461011:201 exit 1 from 'exit 1'
| WARNING: Backtrace (BB generated script):
| #1: bbfatal_log, /home/docker-build/build/qemux86-64/tmp/work/core2-64-poky-linux/xen-tools/4.16+stableAUTOINC+f265444922-r0/temp/run.do_compile.2461011, line 201
| #2: die, /home/docker-build/build/qemux86-64/tmp/work/core2-64-poky-linux/xen-tools/4.16+stableAUTOINC+f265444922-r0/temp/run.do_compile.2461011, line 185
| #3: oe_runmake, /home/docker-build/build/qemux86-64/tmp/work/core2-64-poky-linux/xen-tools/4.16+stableAUTOINC+f265444922-r0/temp/run.do_compile.2461011, line 180
| #4: do_compile, /home/docker-build/build/qemux86-64/tmp/work/core2-64-poky-linux/xen-tools/4.16+stableAUTOINC+f265444922-r0/temp/run.do_compile.2461011, line 174
| #5: main, /home/docker-build/build/qemux86-64/tmp/work/core2-64-poky-linux/xen-tools/4.16+stableAUTOINC+f265444922-r0/temp/run.do_compile.2461011, line 214NOTE: recipe xen-tools-4.16+stableAUTOINC+f265444922-r0: task do_compile: Failed
Re: [PATCH v5 1/3] automation: Create Yocto docker images
In reply to Stefano StabelliniHi Stefano,
Quoted 596 lines · Stefano Stabellini
Quoted 583 lines · Bertrand Marquis
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_64and 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 <[email protected]>---
Changes in v5:
- typo fixes
- add INTERMEDIATE to remove intermediate dockerfile
- use container architecture
- use full words in foreach loops
- fix shellcheck findings inbuild-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
- IntroduceCONTAINERS_EXTRAto 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 thebuild-yocto.shscript 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 tobuild-yocto.shscript to dump the logs if an error occurs.
Changes in v1:
- add --image command line argument tobuild-yocto.shto 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.shcreate mode 100644 automation/build/yocto/yocto.dockerfile.in create mode 100644 automation/build/yocto/yocto.incautomation/build/Makefile +0
-0@@ -1,13 +1,18 @@ # the base of where these containers will appearREGISTRY := registry.gitlab.com/xen-project/xen
automation/build/Makefile +2
-1-CONTAINERS = $(subst .dockerfile,,$(wildcard */*.dockerfile)) +CONTAINERS = $(filter-out yocto/%,$(subst .dockerfile,,$(wildcard */*.dockerfile))) +CONTAINERS_EXTRA =
DOCKER_CMD?= dockerautomation/build/Makefile +2
-0+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};)automation/build/Makefile +2
-0+ @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
automation/build/Makefile +6
-1@@ -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 +automation/build/yocto/build-yocto.sh new file +351
-0@@ -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 <<EOF >> "${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 <<EOF >> "${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 <<EOF +set timeout 100 +spawn bash -c "runqemu serialstdio nographic slirp" + +expect_after { + -re "(.*)\r" { + exp_continue + } + timeout {send_user "ERROR-Timeout!\n"; exit 1} + eof {send_user "ERROR-EOF!\n"; exit 1} +} + +# wait initial login +expect -re ".* login: " +send "root\r" +expect -re "root@.*# " + +EOF + exit $? + ) || return 1 +} + +function help() { + cat <<EOF +Usage: ${0} [TARGET1] [TARGET2] + +This script is build the yocto xen-image-minimal for different qemu targets +and is running it after. +Without any target specified, all supported targets are done. + +Options: + -h, --help Print this help + -v, --verbose Verbose build + --list-target List supported targets + --clean Clean existing project before starting + --no-build Do not build (to run an already built project) + --no-run Do not run + --num-jobs=NUM Define the number of parallel jobs in Yocto. + Default: ${BUILDJOBS} + --dump-log On error, dump the logs on the console + --image=IMG Yocto image or package to build + Default: xen-image-minimal + --xen-dir=DIR path to xen hypervisor source tree + if not provide, normal yocto version of xen is built + Default: ${XENDIR} + --out-dir=DIR directory where to create the projectss + Default: ${BUILDDIR} + --log-dir=DIR directory to store logs + Default: ${LOGDIR} + --cache-dir=DIR directory where to take and store build cache + Default: ${CACHEDIR} + --layer-dir=DIR directory containing the checkout of yocto layers + Default: ${YOCTODIR} +EOF +} + +for OPTION in "$@" +do + case ${OPTION} in + -h|--help) + help + exit 0 + ;; + -v|--verbose) + VERBOSE="y" + ;; + --list-targets) + echo "${TARGET_SUPPORTED}" + exit 0 + ;; + --clean) + do_clean="y" + ;; + --no-build) + do_build="n" + ;; + --no-run) + do_run="n" + ;; + --dump-log) + do_dump="y" + ;; + --num-jobs=*) + BUILDJOBS="${OPTION#*=}" + ;; + --image=*) + build_image="${OPTION#*=}" + ;; + --xen-dir=*) + XENDIR="${OPTION#*=}" + if [ ! -e "${XENDIR}/xen/Makefile" ]; then + echo "No Xen source tree in ${XENDIR}" + exit 1 + fi + do_localsrc="y" + ;; + --out-dir=*) + BUILDDIR="${OPTION#*=}" + ;; + --log-dir=*) + LOGDIR="${OPTION#*=}" + ;; + --cache-dir=*) + CACHEDIR="${OPTION#*=}" + ;; + --layer-dir=*) + YOCTODIR="${OPTION#*=}" + ;; + --*) + echo "Invalid option ${OPTION}" + help + exit 1 + ;; + *) + if echo "${TARGET_SUPPORTED}" | grep -q -w "${OPTION}"; then + TARGETLIST="${TARGETLIST} ${OPTION}" + else + echo "Unsupported target ${OPTION}" + exit 1 + fi + ;; + esac +done + +# if no target is specified build all targets +if [ -z "${TARGETLIST}" ]; then + TARGETLIST="${TARGET_SUPPORTED}" +fi + +mkdir -p "${CACHEDIR}" +mkdir -p "${LOGDIR}" +mkdir -p "${BUILDDIR}" + +# Make sure we have an absolute path +YOCTODIR=$(realpath -m "${YOCTODIR}") +CACHEDIR=$(realpath -m "${CACHEDIR}") +BUILDDIR=$(realpath -m "${BUILDDIR}") +LOGDIR=$(realpath -m "${LOGDIR}") +if [ "${do_localsrc}" = "y" ]; then + XENDIR=$(realpath -m "${XENDIR}") +fi + +# Check that we have all the layers we need +for f in ${build_layerlist}; do + if [ ! -f "${YOCTODIR}/${f}/conf/layer.conf" ]; then + echo "Layer ${f} missing in ${YOCTODIR}" + exit 1 + fi +done + +for f in ${TARGETLIST}; do + if [ "${do_clean}" = "y" ]; then + run_task project_clean "${f}" + fi + if [ ! -f "${BUILDDIR}/${f}/conf/local.conf" ]; then + run_task project_create "${f}" + fi + if [ -f "${BUILDDIR}/${f}/conf/local.conf" ]; then + if [ "${do_build}" = "y" ]; then + run_task project_build "${f}" + fi + if [ "${do_run}" = "y" ]; then + run_task project_run "${f}" + fi + + fi +done + +print_progress "Build Complete (${build_result} errors)" +echo +exit ${build_result} +automation/build/yocto/yocto.dockerfile.in new file +114
-0@@ -0,0 +1,114 @@ +# Docker file to create an environment to build yocto with virtualization +# +# Arguments that can be passed during image creation using --build-arg: +# "host_uid=$(id -u)": to use current user uid for build user in the image +# "host_gid=$(id -g)": to use current user gid for build user in the image +# "ubuntu_version=VERS": to select the ubuntu version number + +# Use standard ubuntu minimal. +ARG ubuntu_version=22.04 +From ##DOCKERPLAT##ubuntu:$ubuntu_version AS base +LABEL maintainer.name="The Xen Project " \ + maintainer.email="[email protected]" + +ENV DEBIAN_FRONTEND=noninteractive + +# Install minimal ubuntu requirements for yocto and other tools we need. +# See https://docs.yoctoproject.org/4.0.1/brief-yoctoprojectqs/index.html#build-host-packages +RUN apt-get update && \ + apt-get --quiet --yes install \ + gawk \ + wget \ + git \ + diffstat \ + unzip \ + texinfo \ + gcc \ + build-essential \ + chrpath \ + socat \ + cpio \ + python3 \ + python3-pip \ + python3-pexpect \ + xz-utils \ + debianutils \ + iputils-ping \ + python3-git \ + python3-jinja2 \ + libegl1-mesa \ + libsdl1.2-dev \ + python3-subunit \ + mesa-common-dev \ + zstd \ + liblz4-tool \ + file \ + vim \ + bison \ + expect \ + locales \ + liblz4-tool \ + zstd \ + openssl \ + libssl3 \ + ca-certificates \ + && \ + apt-get autoremove -y && \ + apt-get clean && \ + rm -rf /var/lib/apt/lists* /tmp/* /var/tmp/* + +# Use bash as shell. +RUN rm /bin/sh && ln -s bash /bin/sh + +# Fix local for yocto. +RUN locale-gen en_US.UTF-8 && update-locale LC_ALL=en_US.UTF-8 \ + LANG=en_US.UTF-8 +ENV LANG en_US.UTF-8 +ENV LC_ALL en_US.UTF-8 + +# Create a user for the build (we don't want to build as root). +ENV USER_NAME docker-build +ARG host_uid=1000 +ARG host_gid=1000 +RUN groupadd -g $host_gid $USER_NAME && \ + useradd -g $host_gid -m -s /bin/bash -u $host_uid $USER_NAME + +# Switch to our user instead of root and start in its home. +USER $USER_NAME +WORKDIR /home/$USER_NAME + +# Create needed directories +RUN mkdir -p /home/$USER_NAME/yocto-layers \ + /home/$USER_NAME/yocto-cache \ + /home/$USER_NAME/logs \ + /home/$USER_NAME/bin \ + /home/$USER_NAME/xen && \ + chown $USER_NAME.$USER_NAME /home/$USER_NAME/* + +# clone yocto repositories we need. +RUN for rep in \ + https://github.com/openembedded/meta-openembedded \ + https://git.yoctoproject.org/poky \ + https://git.yoctoproject.org/meta-virtualization \ + ; do \ + git -C /home/$USER_NAME/yocto-layers \ + clone -b ##YOCTOVERSION## --single-branch $rep; \ + done + +# The builder stage is building an initial cache state that we include in the +# final image. +From base AS builder + +# This step can take one to several hours depending on your download bandwith +# and the speed of your computer. +COPY ./build-yocto.sh / +RUN /build-yocto.sh --dump-log ##YOCTOTARGET## + +From base + +# Only copy the cache status. +COPY --from=builder /home/$USER_NAME/yocto-cache /home/$USER_NAME/yocto-cache/. + +LABEL maintainer.name="The Xen Project " \ + maintainer.email="[email protected]" +automation/build/yocto/yocto.inc new file +0
-0automation/build/yocto/yocto.inc line 7
Quoted 7 lines
automation/build/yocto/yocto.inc new file +7
-0@@ -0,0 +1,42 @@ +# This makefile generates the docker files for Yocto builds. +# The containers for the current architecture are the one built using make all. +# To build containers for a different architecture, you need to call make for +# the image you want explicitely. +# The containers are named this way: +# YOCTOVERSION-TARGET for x86_64 hosts +# YOCTOVERSION-TARGET-arm64v8 for arm64 hostsPlease add:
Quoted 2 lines
# For example you can build an arm64 container with the following command:
# make yocto/kirkstone-qemuarm64-arm64v8
ok
Cheers
Bertrand
Hi Stefano,
Quoted 5 lines · Stefano Stabellini
The build of the qemux86-64 container still fails, logs attached. I tested the full gitlab-ci pipeline for qemuarm and qemuarm64 and they both succeeded.
This is actually because we build 4.16, this was fixed on master. I will enforce to use the latest version of Xen available. I will modify and test that today.
Cheers
Bertrand
Quoted 62 lines · Bertrand Marquis
Quoted 53 lines
This patch series is a first attempt to check if we could use Yocto in gitlab ci to build and run xen on qemu for arm, arm64 and x86.
The first patch is introducing a container template from which container files can be generated for all combinations we want to support (qemu arm, arm64 and x86 targets and hosts
x86_64and arm64).
It is also introducing a generic build script (build-yocto.sh) that is used to create, build and run a Yocto project.The second patch is adding a way to easily clean locally created containers.
The third patch is introducing some gitlab CI templates and jobs so that we can test a Xen source tree in gitlab-CI using Yocto.
This has been tested on a x86 host machine and on an arm host machine (with
mk_dsdt.cfix).Changes in v5:
- automatic cleanup of generated docker files using INTERMEDIATE
- typo fixes
- rebase on Stefano's next branch
- remove clean rule cleaning all containersChanges in v4:
- rework the container generation to support multiple hosts
- rework the container generation to use a single template for all docker files (make process is generating the docker files).Changes in v3:
- limit number of jobs in yocto
- do not copy build script inside container
- add patch from Michal to create gitlab jobsChanges in v2:
- remove gitignore patch which was merged
- add a --dump-log support inbuild-yocto.shscript and use it during container creation to see the error logs.Bertrand Marquis (2):
automation: Create Yocto docker images
automation: Add a clean rule for containersMichal Orzel (1):
automation: Add CI test jobs for Yoctoautomation/build/Makefile | 24 +- automation/build/yocto/build-yocto.sh | 351 +++++++++++++++++++++ automation/build/yocto/yocto.dockerfile.in | 114 +++++++ automation/build/yocto/yocto.inc | 42 +++ automation/gitlab-ci/test.yaml | 43 +++ 5 files changed, 572 insertions(+), 2 deletions(-)Quoted 6 lines
create mode 100755
automation/build/yocto/build-yocto.shcreate mode 100644 automation/build/yocto/yocto.dockerfile.in create mode 100644 automation/build/yocto/yocto.incSignature · 1 line
2.25.1<log.txt>