qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH v2 2/5] tests/docker: add podman support


From: Marc-André Lureau
Subject: [Qemu-devel] [PATCH v2 2/5] tests/docker: add podman support
Date: Tue, 9 Jul 2019 23:43:27 +0400

Allow to specify the container engine to run with ENGINE variable.

By default, ENGINE=auto and will select either podman or docker.

With current podman, we have to use a uidmap trick in order to be able
to rw-share the ccache directory with the container user.

With a user 1000, the default mapping is:
1000 (host) -> 0 (container).

So write access to /var/tmp/ccache ends will end with permission
denied error.

With "--uidmap 1000:0:1 --uidmap 0:1:1000", the mapping is:
1000 (host) -> 0 (container, 1st namespace) -> 1000 (container, 2nd namespace).

(the rest is mumbo jumbo to avoid holes in the range of UIDs)

A future podman version may have an option such as --userns-keep-uid.
Thanks to Debarshi Ray for the help!

Cc: Debarshi Ray <address@hidden>
Signed-off-by: Marc-André Lureau <address@hidden>
---
 Makefile                      |  2 +-
 tests/docker/Makefile.include | 17 ++++++++++++++---
 2 files changed, 15 insertions(+), 4 deletions(-)

diff --git a/Makefile b/Makefile
index c63de4e36c..2bcf9bc674 100644
--- a/Makefile
+++ b/Makefile
@@ -1152,7 +1152,7 @@ endif
        @echo  ''
        @echo  'Test targets:'
        @echo  '  check           - Run all tests (check-help for details)'
-       @echo  '  docker          - Help about targets running tests inside 
Docker containers'
+       @echo  '  docker          - Help about targets running tests inside 
containers'
        @echo  '  vm-help         - Help about targets running tests inside VM'
        @echo  ''
        @echo  'Documentation targets:'
diff --git a/tests/docker/Makefile.include b/tests/docker/Makefile.include
index aaf5396b85..0abd2ab0c9 100644
--- a/tests/docker/Makefile.include
+++ b/tests/docker/Makefile.include
@@ -17,7 +17,9 @@ DOCKER_TESTS := $(notdir $(shell \
 
 DOCKER_TOOLS := travis
 
-DOCKER_SCRIPT=$(SRC_PATH)/tests/docker/docker.py
+ENGINE := auto
+
+DOCKER_SCRIPT=$(SRC_PATH)/tests/docker/docker.py --engine $(ENGINE)
 
 TESTS ?= %
 IMAGES ?= %
@@ -146,7 +148,7 @@ $(foreach i,$(filter-out 
$(DOCKER_PARTIAL_IMAGES),$(DOCKER_IMAGES) $(DOCKER_DEPR
 )
 
 docker:
-       @echo 'Build QEMU and run tests inside Docker containers'
+       @echo 'Build QEMU and run tests inside Docker or Podman containers'
        @echo
        @echo 'Available targets:'
        @echo
@@ -193,6 +195,14 @@ endif
        @echo '    EXECUTABLE=<path>    Include executable in image.'
        @echo '    EXTRA_FILES="<path> [... <path>]"'
        @echo '                         Include extra files in image.'
+       @echo '    ENGINE=auto/docker/podman'
+       @echo '                         Specify which container engine to run.'
+
+UID=$(shell id -u)
+UID1=$(shell expr $(UID) + 1)
+ifeq ($(shell $(DOCKER_SCRIPT) probe),podman)
+PODMAN=1
+endif
 
 # This rule if for directly running against an arbitrary docker target.
 # It is called by the expanded docker targets (e.g. make
@@ -212,7 +222,8 @@ docker-run: docker-qemu-src
                        "  COPYING $(EXECUTABLE) to $(IMAGE)"))
        $(call quiet-command,                                           \
                $(DOCKER_SCRIPT) run                                    \
-                       $(if $(NOUSER),,-u $(shell id -u))              \
+                       $(if $(NOUSER),,-u $(UID)                       \
+                               $(if $(PODMAN),--uidmap $(UID):0:1 --uidmap 
0:1:$(UID) --uidmap $(UID1):$(UID1):64536))                 \
                        --security-opt seccomp=unconfined               \
                        $(if $V,,--rm)                                  \
                        $(if $(DEBUG),-ti,)                             \
-- 
2.22.0.214.g8dca754b1e




reply via email to

[Prev in Thread] Current Thread [Next in Thread]