Skip to content

Commit

Permalink
checkconfig: Tweak cgroup handling
Browse files Browse the repository at this point in the history
Only run the Cgroup V1 checks if we're not on a fully functional CGroup
V2 system.

Signed-off-by: Stéphane Graber <[email protected]>
  • Loading branch information
stgraber committed Jan 3, 2023
1 parent 3ab0499 commit 3f361da
Showing 1 changed file with 27 additions and 29 deletions.
56 changes: 27 additions & 29 deletions src/lxc/cmd/lxc-checkconfig.in
Original file line number Diff line number Diff line change
Expand Up @@ -161,50 +161,48 @@ fi
echo

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" ;
}

CGROUP_V1_MNTS=$(print_cgroups cgroup /proc/self/mounts)
echo
CGROUP_V2_MNTS=$(print_cgroups cgroup2 /proc/self/mounts)

echo "Cgroup v1 mount points: "
echo "$CGROUP_V1_MNTS"
echo
for mnt in ${CGROUP_V1_MNTS}; do
echo " - ${mnt}"
done

CGROUP_V2_MNTS=$(print_cgroups cgroup2 /proc/self/mounts)
echo "Cgroup v2 mount points: "
echo "$CGROUP_V2_MNTS"
echo

CGROUP_SYSTEMD_MNTPT=$(echo "$CGROUP_V1_MNTS" | grep "/systemd")
if [ -z "$CGROUP_SYSTEMD_MNTPT" ]; then
echo -n "Cgroup v1 systemd controller: "
$SETCOLOR_FAILURE && echo -n "missing" && $SETCOLOR_NORMAL
echo
fi
for mnt in ${CGROUP_V2_MNTS}; do
echo " - ${mnt}"
done

if [ "${CGROUP_V2_MNTS}" != "/sys/fs/cgroup" ]; then
CGROUP_SYSTEMD_MNTPT=$(echo "$CGROUP_V1_MNTS" | grep "/systemd")
if [ -z "$CGROUP_SYSTEMD_MNTPT" ]; then
echo -n "Cgroup v1 systemd controller: "
$SETCOLOR_FAILURE && echo -n "missing" && $SETCOLOR_NORMAL
echo
fi

CGROUP_FREEZER_MNTPT=$(echo "$CGROUP_V1_MNTS" | grep "/freezer")
if [ -z "$CGROUP_FREEZER_MNTPT" ]; then
echo -n "Cgroup v1 freezer controller: "
$SETCOLOR_FAILURE && echo -n "missing" && $SETCOLOR_NORMAL
echo
fi
CGROUP_FREEZER_MNTPT=$(echo "$CGROUP_V1_MNTS" | grep "/freezer")
if [ -z "$CGROUP_FREEZER_MNTPT" ]; then
echo -n "Cgroup v1 freezer controller: "
$SETCOLOR_FAILURE && echo -n "missing" && $SETCOLOR_NORMAL
echo
fi

CGROUP_MNT_PATH=$(echo "$CGROUP_V1_MNTS" | head -n 1)
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 ns_cgroup: " && is_enabled CONFIG_CGROUP_NS yes
echo
CGROUP_MNT_PATH=$(echo "$CGROUP_V1_MNTS" | head -n 1)
if [ -f $CGROUP_MNT_PATH/cgroup.clone_children ]; then
echo -n "Cgroup v1 clone_children flag: " &&
$SETCOLOR_SUCCESS && echo "enabled" && $SETCOLOR_NORMAL
fi
fi

echo -n "Cgroup device: " && is_enabled CONFIG_CGROUP_DEVICE
Expand Down

0 comments on commit 3f361da

Please sign in to comment.