Skip to contentSkip to conversation

slirp4netns: Require tun kernel module

PATCH In review Andrei Gherzan 2 participants 7 messages Jul 11, 2022

lore
Share & tools
lore
#0 lore raw

PATCH 1/3 slirp4netns: Require tun kernel module

From: Andrei Gherzan <[email protected]>

slirp4netns uses a TAP device to connect to the internet in an unprivileged way. Without the required kernel support (TAP/TUN), slirp4netns will fail at runtime.

---
 recipes-networking/slirp4netns/slirp4netns_git.bb | 2 ++
 1 file changed, 2 insertions(+)
recipes-networking/slirp4netns/slirp4netns_git.bb +2 -0
index a63871c..4bf25b8 100644
@@ -18,4 +18,6 @@ DEPENDS = "glib-2.0 libcap libseccomp libslirp"
 
 S = "${WORKDIR}/git"
 
+RDEPENDS:${PN} += "kernel-module-tun"
+
 inherit autotools pkgconfig
Signature · 1 line
2.25.1
#1 lore raw

PATCH 2/3 podman: Silence docker emulation warnings

From: Andrei Gherzan <[email protected]>

Podman can run in via a docker symlink emulating docker commands. By default this generates a runtime warning. This change silences it via the provided interface.

---
 recipes-containers/podman/podman_git.bb | 4 ++++
 1 file changed, 4 insertions(+)
recipes-containers/podman/podman_git.bb +4 -0
index 547bc4e..961cd18 100644
@@ -93,6 +93,10 @@ do_install() {
 	if ${@bb.utils.contains('PACKAGECONFIG', 'docker', 'true', 'false', d)}; then
 		oe_runmake install.docker DESTDIR="${D}"
 	fi
+
+	# Silence docker emulation warnings.
+	mkdir -p ${D}/etc/containers
+	touch ${D}/etc/containers/nodocker
 }
 
 FILES:${PN} += " \
Signature · 1 line
2.25.1
#2 lore raw

PATCH 3/3 podman: Add support for rootless mode

In reply to Andrei Gherzan

From: Andrei Gherzan <[email protected]>

---
 docs/00-INDEX                                     |  3 +++
 docs/podman.txt                                   | 15 +++++++++++++++
 docs/podman.txt.license                           |  3 +++
 .../podman/podman/00-podman-rootless.conf         |  6 ++++++
 recipes-containers/podman/podman_git.bb           | 15 ++++++++++++++-
 5 files changed, 41 insertions(+), 1 deletion(-)
 create mode 100644 docs/podman.txt
 create mode 100644 docs/podman.txt.license
 create mode 100644 recipes-containers/podman/podman/00-podman-rootless.conf
docs/00-INDEX +3 -0
index 5aa1b3c..6659fbe 100644
@@ -11,5 +11,8 @@ alphabetical order as well.
 openvswitch.txt
 	- example on how to setup openvswitch with qemu/kvm.
 
+podman.txt
+	- documentation on podman container engine integration.
+
 xvisor.txt
 	- example on how to setup Xvisor for RISC-V QEMU.
docs/podman.txt new file +15 -0
new file mode 100644
index 0000000..9f35501
@@ -0,0 +1,15 @@
+Podman
+======
+
+Rootless mode
+-------------
+
+Podman is a daemonless container engine that has as one of its features the
+ability to run in rootless mode. This requires a set of configurations and
+additional components. The OE/Yocto integration configures podman with this
+support enabled by default. This can be changed via configuration files
+(distro, local.conf, etc.) or bbaappends using the `PODMAN_ROOTLESS` variable.
+
+To disable rootless support set the variable to '0':
+
+PODMAN_ROOTLESS = "0"
docs/podman.txt.license new file +3 -0
new file mode 100644
index 0000000..940435e
@@ -0,0 +1,3 @@
+SPDX-FileCopyrightText: Huawei Inc.
+
+SPDX-License-Identifier: Apache-2.0
recipes-containers/podman/podman/00-podman-rootless.conf new file +6 -0
new file mode 100644
index 0000000..2aca663
@@ -0,0 +1,6 @@
+# SPDX-FileCopyrightText: Huawei Inc.
+#
+# SPDX-License-Identifier: Apache-2.0
+
+# User namespaces are required for rootless containers.
+user.max_user_namespaces	= 15000
recipes-containers/podman/podman_git.bb +14 -1
index 961cd18..2680f40 100644
@@ -6,6 +6,10 @@ DESCRIPTION = "Podman is a daemonless container engine for developing, \
     `alias docker=podman`. \
     "
 
+# podman can run in rootless mode with the help of additional components:
+# https://github.com/containers/podman/blob/main/docs/tutorials/rootless_tutorial.md
+PODMAN_ROOTLESS ?= "1"
+
 inherit features_check
 REQUIRED_DISTRO_FEATURES ?= "seccomp ipv6"
 
@@ -21,6 +25,7 @@ SRCREV = "cedbbfa543651a13055a1fe093a4d0a2a28ccdfd"
 SRC_URI = " \
     git://github.com/containers/libpod.git;branch=v4.1;protocol=https \
     file://0001-Rename-BUILDFLAGS-to-GOBUILDFLAGS.patch;patchdir=src/import \
+    ${@bb.utils.contains('PODMAN_ROOTLESS', '1', 'file://00-podman-rootless.conf', '', d)} \
 "
 
 LICENSE = "Apache-2.0"
@@ -97,6 +102,11 @@ do_install() {
 	# Silence docker emulation warnings.
 	mkdir -p ${D}/etc/containers
 	touch ${D}/etc/containers/nodocker
+
+	if [ "${PODMAN_ROOTLESS}" = "1" ]; then
+		install -d "${D}${sysconfdir}/sysctl.d"
+		install -m 0644 "${WORKDIR}/00-podman-rootless.conf" "${D}${sysconfdir}/sysctl.d"
+	fi
 }
 
 FILES:${PN} += " \
@@ -112,6 +122,9 @@ SYSTEMD_SERVICE:${PN} = "podman.service podman.socket"
 # that busybox is configured with nsenter
 VIRTUAL-RUNTIME_base-utils-nsenter ?= "util-linux-nsenter"
 
-RDEPENDS:${PN} += "conmon virtual-runc iptables cni skopeo ${VIRTUAL-RUNTIME_base-utils-nsenter}"
+RDEPENDS:${PN} += "\
+	conmon virtual-runc iptables cni skopeo ${VIRTUAL-RUNTIME_base-utils-nsenter} \
+	${@bb.utils.contains('PODMAN_ROOTLESS', '1', 'fuse-overlayfs slirp4netns', '', d)} \
+"
 RRECOMMENDS:${PN} += "slirp4netns kernel-module-xt-masquerade kernel-module-xt-comment"
 RCONFLICTS:${PN} = "${@bb.utils.contains('PACKAGECONFIG', 'docker', 'docker', '', d)}"
Signature · 1 line
2.25.1
#3 lore raw

Re: [meta-virtualization][PATCH 3/3] podman: Add support for rootless mode

Quoted 55 lines · Andrei Gherzan

From: Andrei Gherzan <[email protected]>

---
 docs/00-INDEX                                     |  3 +++
 docs/podman.txt                                   | 15 +++++++++++++++
 docs/podman.txt.license                           |  3 +++
 .../podman/podman/00-podman-rootless.conf         |  6 ++++++
 recipes-containers/podman/podman_git.bb           | 15 ++++++++++++++-
 5 files changed, 41 insertions(+), 1 deletion(-)
 create mode 100644 docs/podman.txt
 create mode 100644 docs/podman.txt.license
 create mode 100644 recipes-containers/podman/podman/00-podman-rootless.conf
docs/00-INDEX +3 -0
index 5aa1b3c..6659fbe 100644
@@ -11,5 +11,8 @@ alphabetical order as well.
 openvswitch.txt
        - example on how to setup openvswitch with qemu/kvm.
 
+podman.txt
+       - documentation on podman container engine integration.
+
 xvisor.txt
        - example on how to setup Xvisor for RISC-V QEMU.
docs/podman.txt new file +15 -0
new file mode 100644
index 0000000..9f35501
@@ -0,0 +1,15 @@
+Podman
+======
+
+Rootless mode
+-------------
+
+Podman is a daemonless container engine that has as one of its features the
+ability to run in rootless mode. This requires a set of configurations and
+additional components. The OE/Yocto integration configures podman with this
+support enabled by default. This can be changed via configuration files
+(distro, local.conf, etc.) or bbaappends using the `PODMAN_ROOTLESS` variable.
+
+To disable rootless support set the variable to '0':
+
+PODMAN_ROOTLESS = "0"
docs/podman.txt.license new file +0 -0
new file mode 100644
index 0000000..940435e

docs/podman.txt.license line 3

Quoted 3 lines
docs/podman.txt.license new file +3 -0
@@ -0,0 +1,3 @@
+SPDX-FileCopyrightText: Huawei Inc.
+
+SPDX-License-Identifier: Apache-2.0

I haven't been following along closely enough to the copyright thread that Richard started, but these jumped out at me.

Aren't most of the .conf files considered MIT (i.e. part of the meta data / recipe space) ? And are we putting copyright's in conf files and .txt files now ? I'm definitely not an expert (at all!!) but that doesn't seem quite right to me, when they are configuration files that follow standard practices for the packages we are integrating.

Quoted 17 lines
recipes-containers/podman/podman/00-podman-rootless.conf new file +6 -0
new file mode 100644
index 0000000..2aca663
@@ -0,0 +1,6 @@
+# SPDX-FileCopyrightText: Huawei Inc.
+#
+# SPDX-License-Identifier: Apache-2.0
+
+# User namespaces are required for rootless containers.
+user.max_user_namespaces       = 15000
recipes-containers/podman/podman_git.bb +0 -0
index 961cd18..2680f40 100644

recipes-containers/podman/podman_git.bb DESCRIPTION = "Podman is a daemonless container engine for developing, \ · line 11

Quoted 6 lines
recipes-containers/podman/podman_git.bb +3 -0
@@ -6,6 +6,10 @@ DESCRIPTION = "Podman is a daemonless container engine for developing, \
     `alias docker=podman`. \
     "
 
+# podman can run in rootless mode with the help of additional components:
+# https://github.com/containers/podman/blob/main/docs/tutorials/rootless_tutorial.md
+PODMAN_ROOTLESS ?= "1"

Isn't there a way to do this with PACKAGECONFIG ? We could just as easily check for the option in that, and then we have a place for extra rdepends, etc,as required.

Bruce

Quoted 39 lines
recipes-containers/podman/podman_git.bb +11 -2
+
 inherit features_check
 REQUIRED_DISTRO_FEATURES ?= "seccomp ipv6"
 
@@ -21,6 +25,7 @@ SRCREV = "cedbbfa543651a13055a1fe093a4d0a2a28ccdfd"
 SRC_URI = " \
     git://github.com/containers/libpod.git;branch=v4.1;protocol=https \
     file://0001-Rename-BUILDFLAGS-to-GOBUILDFLAGS.patch;patchdir=src/import \
+    ${@bb.utils.contains('PODMAN_ROOTLESS', '1', 'file://00-podman-rootless.conf', '', d)} \
 "
 
 LICENSE = "Apache-2.0"
@@ -97,6 +102,11 @@ do_install() {
        # Silence docker emulation warnings.
        mkdir -p ${D}/etc/containers
        touch ${D}/etc/containers/nodocker
+
+       if [ "${PODMAN_ROOTLESS}" = "1" ]; then
+               install -d "${D}${sysconfdir}/sysctl.d"
+               install -m 0644 "${WORKDIR}/00-podman-rootless.conf" "${D}${sysconfdir}/sysctl.d"
+       fi
 }
 
 FILES:${PN} += " \
@@ -112,6 +122,9 @@ SYSTEMD_SERVICE:${PN} = "podman.service podman.socket"
 # that busybox is configured with nsenter
 VIRTUAL-RUNTIME_base-utils-nsenter ?= "util-linux-nsenter"
 
-RDEPENDS:${PN} += "conmon virtual-runc iptables cni skopeo ${VIRTUAL-RUNTIME_base-utils-nsenter}"
+RDEPENDS:${PN} += "\
+       conmon virtual-runc iptables cni skopeo ${VIRTUAL-RUNTIME_base-utils-nsenter} \
+       ${@bb.utils.contains('PODMAN_ROOTLESS', '1', 'fuse-overlayfs slirp4netns', '', d)} \
+"
 RRECOMMENDS:${PN} += "slirp4netns kernel-module-xt-masquerade kernel-module-xt-comment"
 RCONFLICTS:${PN} = "${@bb.utils.contains('PACKAGECONFIG', 'docker', 'docker', '', d)}"
--

2.25.1

Quoted 8 lines

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#7423): https://lists.yoctoproject.org/g/meta-virtualization/message/7423
Mute This Topic: https://lists.yoctoproject.org/mt/92309177/1050810
Group Owner: [email protected]
Unsubscribe: https://lists.yoctoproject.org/g/meta-virtualization/unsub [[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-

--
- Thou shalt not follow the NULL pointer, for chaos and madness await thee at its end
- "Use the force Harry" - Gandalf, Star Trek II

#4 lore raw

Re: [meta-virtualization][PATCH 3/3] podman: Add support for rootless mode

Quoted 63 lines · Bruce Ashfield
Quoted 55 lines · Andrei Gherzan

From: Andrei Gherzan <[email protected]>

---
 docs/00-INDEX                                     |  3 +++
 docs/podman.txt                                   | 15 +++++++++++++++
 docs/podman.txt.license                           |  3 +++
 .../podman/podman/00-podman-rootless.conf         |  6 ++++++
 recipes-containers/podman/podman_git.bb           | 15 ++++++++++++++-
 5 files changed, 41 insertions(+), 1 deletion(-)
 create mode 100644 docs/podman.txt
 create mode 100644 docs/podman.txt.license
 create mode 100644 recipes-containers/podman/podman/00-podman-rootless.conf
docs/00-INDEX +3 -0
index 5aa1b3c..6659fbe 100644
@@ -11,5 +11,8 @@ alphabetical order as well.
 openvswitch.txt
        - example on how to setup openvswitch with qemu/kvm.
 
+podman.txt
+       - documentation on podman container engine integration.
+
 xvisor.txt
        - example on how to setup Xvisor for RISC-V QEMU.
docs/podman.txt new file +15 -0
new file mode 100644
index 0000000..9f35501
@@ -0,0 +1,15 @@
+Podman
+======
+
+Rootless mode
+-------------
+
+Podman is a daemonless container engine that has as one of its features the
+ability to run in rootless mode. This requires a set of configurations and
+additional components. The OE/Yocto integration configures podman with this
+support enabled by default. This can be changed via configuration files
+(distro, local.conf, etc.) or bbaappends using the `PODMAN_ROOTLESS` variable.
+
+To disable rootless support set the variable to '0':
+
+PODMAN_ROOTLESS = "0"
docs/podman.txt.license new file +0 -0
new file mode 100644
index 0000000..940435e

docs/podman.txt.license line 3

Quoted 3 lines
docs/podman.txt.license new file +3 -0
@@ -0,0 +1,3 @@
+SPDX-FileCopyrightText: Huawei Inc.
+
+SPDX-License-Identifier: Apache-2.0

I haven't been following along closely enough to the copyright thread that Richard started, but these jumped out at me.

Quoted 5 lines

Aren't most of the .conf files considered MIT (i.e. part of the meta data / recipe space) ? And are we putting copyright's in conf files and .txt files now ? I'm definitely not an expert (at all!!) but that doesn't seem quite right to me, when they are configuration files that follow standard practices for the packages we are integrating.

That is definitely my bad. It should be MIT. I'll re-push with the changed license.

This is following the reuse.software compliance. I've used a separate license file for the txt one so that I don't affect the actual documentation if they get post-processed in any way afterwards - there is no standard for comments in txt files. This is basically saying that given that I don't want to touch file foo, I'll create a foo.license file with the extra SPDX metadata.

Quoted 20 lines
Quoted 20 lines
recipes-containers/podman/podman/00-podman-rootless.conf new file +6 -0
new file mode 100644
index 0000000..2aca663
@@ -0,0 +1,6 @@
+# SPDX-FileCopyrightText: Huawei Inc.
+#
+# SPDX-License-Identifier: Apache-2.0
+
+# User namespaces are required for rootless containers.
+user.max_user_namespaces       = 15000
recipes-containers/podman/podman_git.bb +0 -0
index 961cd18..2680f40 100644
@@ -6,6 +6,10 @@ DESCRIPTION = "Podman is a daemonless container engine for developing, \
     `alias docker=podman`. \
     "
 
Quoted 7 lines

recipes-containers/podman/podman_git.bb DESCRIPTION = "Podman is a daemonless container engine for developing, \ · line 11

Quoted 3 lines
recipes-containers/podman/podman_git.bb +3 -0
+# podman can run in rootless mode with the help of additional components:
+# https://github.com/containers/podman/blob/main/docs/tutorials/rootless_tutorial.md
+PODMAN_ROOTLESS ?= "1"

Isn't there a way to do this with PACKAGECONFIG ? We could just as easily check for the option in that, and then we have a place for extra rdepends, etc,as required.

Good idea. I like that. I'll change it in the next v.

Andrei

#5 lore raw
In reply to Andrei Gherzan
Quoted 17 lines · Andrei Gherzan

From: Andrei Gherzan <[email protected]>

slirp4netns uses a TAP device to connect to the internet in an unprivileged way. Without the required kernel support (TAP/TUN), slirp4netns will fail at runtime.

---
 recipes-networking/slirp4netns/slirp4netns_git.bb | 2 ++
 1 file changed, 2 insertions(+)
recipes-networking/slirp4netns/slirp4netns_git.bb +0 -0
index a63871c..4bf25b8 100644

recipes-networking/slirp4netns/slirp4netns_git.bb DEPENDS = "glib-2.0 libcap libseccomp libslirp" · line 21

Quoted 4 lines
recipes-networking/slirp4netns/slirp4netns_git.bb +1 -0
@@ -18,4 +18,6 @@ DEPENDS = "glib-2.0 libcap libseccomp libslirp"
 
 S = "${WORKDIR}/git"
 
+RDEPENDS:${PN} += "kernel-module-tun"

This needs to be a RRECOMMENDS, since we can suggest, but not enforce a specific configuration.

Bruce

Quoted 14 lines
recipes-networking/slirp4netns/slirp4netns_git.bb +1 -1
+
 inherit autotools pkgconfig
--

2.25.1

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#7421): https://lists.yoctoproject.org/g/meta-virtualization/message/7421
Mute This Topic: https://lists.yoctoproject.org/mt/92309173/1050810
Group Owner: [email protected]
Unsubscribe: https://lists.yoctoproject.org/g/meta-virtualization/unsub [[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-

Signature · 3 lines
- Thou shalt not follow the NULL pointer, for chaos and madness await
thee at its end
- "Use the force Harry" - Gandalf, Star Trek II
#6 lore raw
Quoted 19 lines · Bruce Ashfield
Quoted 18 lines · Andrei Gherzan

From: Andrei Gherzan <[email protected]>

slirp4netns uses a TAP device to connect to the internet in an unprivileged way. Without the required kernel support (TAP/TUN), slirp4netns will fail at runtime.

---
 recipes-networking/slirp4netns/slirp4netns_git.bb | 2 ++
 1 file changed, 2 insertions(+)
recipes-networking/slirp4netns/slirp4netns_git.bb +0 -0
index a63871c..4bf25b8 100644
@@ -18,4 +18,6 @@ DEPENDS = "glib-2.0 libcap libseccomp libslirp"
 
Quoted 6 lines

recipes-networking/slirp4netns/slirp4netns_git.bb DEPENDS = "glib-2.0 libcap libseccomp libslirp" · line 21

Quoted 3 lines
recipes-networking/slirp4netns/slirp4netns_git.bb +1 -0
 S = "${WORKDIR}/git"
 
+RDEPENDS:${PN} += "kernel-module-tun"

This needs to be a RRECOMMENDS, since we can suggest, but not enforce a specific configuration.

Agreed.

Signature · 2 lines
Andrei Gherzan 
gpg: rsa4096/D4D94F67AD0E9640