Commit 1e6efccdfc for qemu.org
commit 1e6efccdfc9c179381babf24c0b4d77d9c7d4907
Author: Pierrick Bouvier <pierrick.bouvier@oss.qualcomm.com>
Date: Wed Sep 23 11:57:20 2026 -0700
tests/tcg/meson.build: force use of linux/amd64 platform for containers
On hosts != x64_64, we detect if host can run amd64 containers (usually
through qemu-user-binfmt). If not, we deactivate container support.
We could technically stop here and force container engine to use this
platform. Since existing base image (docker.io/library/debian:13-slim)
is multi platforms, container engine will enable this variant by
default.
Now the problem is that if user reuses this image for their own
Dockerfiles, they will run into unpleasant surprise that now, their
container engine is using x86_64 variant by default, on any host.
So, in next commit, we'll change base image we use to x86_64 variant,
which has a single platform: linux/amd64. This ensures we don't generate
any unwanted side effect when building our images.
Reviewed-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Link: https://lore.kernel.org/qemu-devel/20260923185725.863311-2-pierrick.bouvier@oss.qualcomm.com
Signed-off-by: Pierrick Bouvier <pierrick.bouvier@oss.qualcomm.com>
diff --git a/tests/tcg/meson.build b/tests/tcg/meson.build
index 7a3f06ddcf..3a6339c2a1 100644
--- a/tests/tcg/meson.build
+++ b/tests/tcg/meson.build
@@ -81,6 +81,7 @@ tcg_tests_summary += {'gdb': gdb}
docker_supported = false
container_command = false
+docker_platform = ['--platform', 'linux/amd64']
if get_option('containers')
if get_option('container_command') != ''
# make sure command is working
@@ -99,6 +100,18 @@ if get_option('containers')
container_command]
endif
endif
+
+ if docker_supported
+ # Check that x86_64 containers can be executed. It implies xthat 86_64
+ # binaries can be executed. On host with a different architecture,
+ # this is usually achieved with qemu-user-binfmt.
+ docker_supported = run_command([docker_wrapper, 'run', '--',
+ docker_platform,
+ 'docker.io/amd64/debian:13-slim',
+ '/bin/true'],
+ check: false).returncode() == 0
+ tcg_tests_summary += {'x86_64 container support': docker_supported}
+ endif
endif
tcg_tests_summary += {'container command': container_command}
if get_option('container_registry') != ''
@@ -253,13 +266,11 @@ foreach target, plan: tcg_tests
target + ' (possible: [' + ', '.join(allowed) + '])')
endif
endforeach
- docker_host_arch_supported = host_machine.cpu_family() in cc_docker_host_arch
dockerfile = files('..'/'docker'/'dockerfiles'/cc_dockerfile + '.docker')
image_name = 'image-' + cc_dockerfile
- has_docker = docker_host_arch_supported and docker_supported
- if cc_dockerfile not in image_targets and has_docker
+ if cc_dockerfile not in image_targets and docker_supported
cmd = [docker_wrapper, 'build', '-f', dockerfile, '-t', 'qemu/' + cc_dockerfile,
- '--add-current-user']
+ docker_platform, '--add-current-user']
if get_option('container_registry') != ''
cmd += ['--registry', get_option('container_registry')]
endif
@@ -270,7 +281,7 @@ foreach target, plan: tcg_tests
image_targets += {cc_dockerfile: t}
endif
- if not has_cc and has_docker
+ if not has_cc and docker_supported
build_test_depends += image_targets[cc_dockerfile]
build_test_depend_files += dockerfile
mount = meson.project_source_root()
@@ -279,6 +290,7 @@ foreach target, plan: tcg_tests
cc = [docker_wrapper, 'run', '--run-as-current-user', '--',
# SELinux blocks modification of host fs by default
'--security-opt', 'label=disable',
+ docker_platform,
'-w', here, '-v', here + ':' + here, '-v', mount,
'qemu/' + cc_dockerfile, plan['cc']]
has_cc = true