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. Signed-off-by: Pierrick Bouvier <[email protected]> --- tests/tcg/meson.build | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/tests/tcg/meson.build b/tests/tcg/meson.build index 75f0a52fd22..4cf4865461e 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,15 @@ if get_option('containers') container_command] endif endif + + if docker_supported + 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 +263,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 +278,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 +287,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 -- 2.43.0
