@samitouri / QOSamiQemu / commits / fbf4fa1091

tests/docker: improve handling of docker probes

The docker.py script has logic to guess the container command and detects one of * docker * sudo -n docker * podman but the "docker.py probe" command then throws away the detected argv and prints a slightly different argv based solely on the detected argv[0]. The result is that 'probe' will print * docker * sudo docker * podman which means that if sudo was detected & the result of 'probe' were used directly, it would end up prompting for password interaction every time. The 'configure' script, however, runs 'probe' and then throws away the printed argv again, reporting only 'podman' or 'docker', which is used to set the $(RUNC) variable for tests/docker/Makefile.include which is in turn used to pass --engine to docker.py. So the docker.py command will re-detect the need for 'sudo -n' and use it correctly The problem with this is that some commands in Makefile.include do not call docker.py at all, they invoke $(RUNC) directly. Since configure threw away the 'sudo' command prefix Makefile.in won't be adding either 'sudo' or 'sudo -n', it'll just run plain 'docker' which is wrong. This commit sanitizes things so that the 'docker.py probe' prints out the exact detected ARGV, and configure fully preserves this ARGV when setting $(RUNC). Since "$(RUNC)" is no longer just a bare engine name, however, we must now also set the $(CONTAINER_ENGINE) variable for Makefile.include so it can pass something sane to the --engine arg for docker.py Reviewed-by: Thomas Huth <thuth@redhat.com> Signed-off-by: Daniel P. Berrangé <berrange@redhat.com> Message-ID: <20260210163556.713841-2-berrange@redhat.com> Signed-off-by: Thomas Huth <thuth@redhat.com>

Daniel P. Berrangé committed Feb 10, 2026 at 16:35 UTC fbf4fa1091046fd58f60281134d904e2fb377752
3 files changed +11 -20
configure
+7 -12
@@ -1319,17 +1319,11 @@ fi
1319 ##########################################
1320 # functions to probe cross compilers
1321
1322 -container="no"
1323 -runc=""
1322 +runc="no"
1323 if test $use_containers = "yes" && (has "docker" || has "podman"); then
1325 - case $($python "$source_path"/tests/docker/docker.py --engine "$container_engine" probe) in
1326 - *docker) container=docker ;;
1327 - podman) container=podman ;;
1328 - no) container=no ;;
1329 - esac
1330 - if test "$container" != "no"; then
1331 - docker_py="$python $source_path/tests/docker/docker.py --engine $container"
1332 - runc=$container
1324 + runc=$($python "$source_path"/tests/docker/docker.py --engine "$container_engine" probe)
1325 + if test "$runc" != "no"; then
1326 + docker_py="$python $source_path/tests/docker/docker.py --engine $container_engine"
1327 fi
1328 fi
1329
@@ -1449,7 +1443,7 @@ probe_target_compiler() {
1443 esac
1444
1445 for host in $container_hosts; do
1452 - test "$container" != no || continue
1446 + test "$runc" != no || continue
1447 test "$host" = "$cpu" || continue
1448 case $target_arch in
1449 # debian-all-test-cross architectures
@@ -1771,8 +1765,9 @@ echo all: >> $config_host_mak
1765 echo "SRC_PATH=$source_path" >> $config_host_mak
1766 echo "TARGET_DIRS=$target_list" >> $config_host_mak
1767 echo "GDB=$gdb_bin" >> $config_host_mak
1774 -if test "$container" != no; then
1768 +if test "$runc" != no; then
1769 echo "RUNC=$runc" >> $config_host_mak
1770 + echo "CONTAINER_ENGINE=$container_engine" >> $config_host_mak
1771 fi
1772 echo "SUBDIRS=$subdirs" >> $config_host_mak
1773 if test "$rust" != disabled; then
tests/docker/Makefile.include
+3 -2
@@ -16,8 +16,9 @@ DOCKER_DEFAULT_REGISTRY := registry.gitlab.com/qemu-project/qemu
16 endif
17 DOCKER_REGISTRY := $(if $(REGISTRY),$(REGISTRY),$(DOCKER_DEFAULT_REGISTRY))
18
19 -RUNC ?= $(if $(shell command -v docker), docker, podman)
20 -DOCKER_SCRIPT=$(SRC_PATH)/tests/docker/docker.py --engine $(RUNC)
19 +CONTAINER_ENGINE = auto
20 +DOCKER_SCRIPT=$(SRC_PATH)/tests/docker/docker.py --engine $(CONTAINER_ENGINE)
21 +RUNC ?= $(shell $(DOCKER_SCRIPT) probe)
22
23 CUR_TIME := $(shell date +%Y-%m-%d-%H.%M.%S.$$$$)
24 DOCKER_SRC_COPY := $(BUILD_DIR)/docker-src.$(CUR_TIME)
tests/docker/docker.py
+1 -6
@@ -618,12 +618,7 @@ class ProbeCommand(SubCommand):
618 def run(self, args, argv):
619 try:
620 docker = Docker()
621 - if docker._command[0] == "docker":
622 - print("docker")
623 - elif docker._command[0] == "sudo":
624 - print("sudo docker")
625 - elif docker._command[0] == "podman":
626 - print("podman")
621 + print(" ".join(docker._command))
622 except Exception:
623 print("no")
624