From 2bbc8545a463ce90762462adeedd91f9433ecd85 Mon Sep 17 00:00:00 2001 From: Matthieu Baerts Date: Tue, 17 Nov 2026 15:19:51 +0100 Subject: [PATCH 1/2] docker: run: support extra options Some use cases need extra options for 'docker run', e.g. '--network host' to start VMs from the container connected to tap interfaces created on the host: by default, the container has its own network namespace, and QEMU creates new tap interfaces there, not connected to anything. The new DOCKER_EXTRA_ARGS environment variable can be used to pass such options, split on whitespace, e.g. $ DOCKER_EXTRA_ARGS="--network host" docker/selftests/run.sh vng (...) It can be set in the environment of a systemd service, and is then inherited when executing commands via docker/selftests/wrapper.sh. Signed-off-by: Matthieu Baerts --- docker/common/run.sh | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/docker/common/run.sh b/docker/common/run.sh index 8a702874..9455208e 100755 --- a/docker/common/run.sh +++ b/docker/common/run.sh @@ -31,6 +31,12 @@ ARGS=( ) test -t 1 && ARGS+=("-t") +# Extra options for 'docker run', split on whitespace, e.g. '--network host' +if [ -n "${DOCKER_EXTRA_ARGS:-}" ]; then + read -r -a EXTRA_ARGS <<< "${DOCKER_EXTRA_ARGS}" + ARGS+=("${EXTRA_ARGS[@]}") +fi + if [ "${1}" = "--pull" ]; then ARGS+=(--pull always) shift From d514595c544948169ae312e6c319621843a782d5 Mon Sep 17 00:00:00 2001 From: Matthieu Baerts Date: Tue, 17 Nov 2026 15:24:41 +0100 Subject: [PATCH 2/2] docker: selftests: wrapper: drop sudo for 'vng --run' 'sudo' was added to let QEMU create tap interfaces in the network namespace of the container: with rootless Podman, only root in the container has CAP_NET_ADMIN there. But these interfaces are not connected to anything, while tests like the virtio_net ones expect tap interfaces created and wired up on the host. To use them, '--network host' can be passed via DOCKER_EXTRA_ARGS. In this case, QEMU cannot create tap interfaces -- even root in the container has no CAP_NET_ADMIN in the host network namespace -- but it can attach to existing ones owned by the same user. With rootless Podman and 'keep-id', that's the case for the user in the container, not for root, which is mapped to a different UID on the host. So drop 'sudo': the VMs are then started as the same user as on the host, like before using the container. Fixes: b801813 ("docker: selftests: wrapper: run 'vng --run' with sudo") Signed-off-by: Matthieu Baerts --- docker/selftests/wrapper.sh | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/docker/selftests/wrapper.sh b/docker/selftests/wrapper.sh index 80eff143..8519bb0d 100755 --- a/docker/selftests/wrapper.sh +++ b/docker/selftests/wrapper.sh @@ -5,17 +5,4 @@ # after the commands to wrap -- e.g. 'make' and 'vng' -- pointing to this script # in a directory placed at the beginning of $PATH. -cmd=("$(basename "${0}")") - -# 'vng --run' needs root privileges to start some VM in the container -if [ "${cmd[0]}" = "vng" ]; then - for arg in "${@}"; do - [ "${arg}" = "--" ] && break - if [ "${arg}" = "--run" ] || [ "${arg}" = "-r" ]; then - cmd=(sudo "${cmd[@]}") - break - fi - done -fi - -exec "$(dirname "$(realpath "${0}")")/run.sh" "${cmd[@]}" "${@}" +exec "$(dirname "$(realpath "${0}")")/run.sh" "$(basename "${0}")" "${@}"