]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
cmd/lxc-checkconfig: list cgroup namespaces and rename confusing ns_cgroup entry 3893/head
authorChristian Brauner <christian.brauner@ubuntu.com>
Thu, 1 Jul 2021 11:39:46 +0000 (13:39 +0200)
committerChristian Brauner <christian.brauner@ubuntu.com>
Thu, 1 Jul 2021 11:40:18 +0000 (13:40 +0200)
Link: https://discuss.linuxcontainers.org/t/cgroup-namespace-required-in-lxc-checkconfig-and-config-cgroup-ns
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
src/lxc/cmd/lxc-checkconfig.in

index 367f85de07e16affce2ba5a526b77b045bbf91bd..0953b76688dbebcfd6e49b7605949d48d05627c7 100755 (executable)
@@ -24,11 +24,8 @@ is_set() {
     return $?
 }
 
-is_enabled() {
-    mandatory=$2
-
-    is_set $1
-    RES=$?
+show_enabled() {
+    RES=$1
     RET=1
     if [ $RES -eq 0 ]; then
         $SETCOLOR_SUCCESS && echo -n "enabled" && $SETCOLOR_NORMAL
@@ -43,6 +40,23 @@ is_enabled() {
     return $RET
 }
 
+is_enabled() {
+    mandatory=$2
+
+    is_set $1
+    show_enabled $?
+}
+
+has_cgroup_ns() {
+    mandatory=no
+
+    if [ -f "/proc/self/ns/cgroup" ]; then
+           show_enabled 0
+    else
+           show_enabled 1
+    fi
+}
+
 is_probed() {
     lsmod | grep $1 > /dev/null
     if [ $? -eq 0 ]; then
@@ -144,6 +158,9 @@ echo "--- Control groups ---"
 echo -n "Cgroups: " && is_enabled CONFIG_CGROUPS
 echo
 
+echo -n "Cgroup namespace: " && has_cgroup_ns
+echo
+
 print_cgroups() {
   # print all mountpoints for cgroup filesystems
   awk '$1 !~ /#/ && $3 == mp { print $2; } ; END { exit(0); } '  "mp=$1" "$2" ;
@@ -179,7 +196,7 @@ if [ -f $CGROUP_MNT_PATH/cgroup.clone_children ]; then
     echo -n "Cgroup v1 clone_children flag: " &&
     $SETCOLOR_SUCCESS && echo "enabled" && $SETCOLOR_NORMAL
 else
-    echo -n "Cgroup namespace: " && is_enabled CONFIG_CGROUP_NS yes
+    echo -n "Cgroup ns_cgroup: " && is_enabled CONFIG_CGROUP_NS yes
     echo
 fi