mirror of
https://git.proxmox.com/git/pve-common
synced 2025-05-01 07:07:43 +00:00
cgroup: get mode by checking /sys/fs/cgroup mount point
Since even in pure unified layouts there may be a `name=systemd` v1 cgroup mounted additionally (manually or potentially via systemd-nspawn apparently), we should check what's actually mounted at `/sys/fs/cgroup` rather than whether v1 cgroups exist. Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
This commit is contained in:
parent
2cae54b99d
commit
55b6de7011
@ -86,21 +86,30 @@ sub get_cgroup_controllers() {
|
|||||||
my $CGROUP_MODE = undef;
|
my $CGROUP_MODE = undef;
|
||||||
# Figure out which cgroup mode we're operating under:
|
# Figure out which cgroup mode we're operating under:
|
||||||
#
|
#
|
||||||
# Returns 1 if cgroupv1 controllers exist (hybrid or legacy mode), and 2 in a
|
# For this we check the file system type of `/sys/fs/cgroup` as it may well be possible that some
|
||||||
# cgroupv2-only environment.
|
# additional cgroupv1 mount points have been created by tools such as `systemd-nspawn`, or
|
||||||
|
# manually.
|
||||||
|
#
|
||||||
|
# Returns 1 for what we consider the hybrid layout, 2 for what we consider the unified layout.
|
||||||
#
|
#
|
||||||
# NOTE: To fully support a hybrid layout it is better to use functions like
|
# NOTE: To fully support a hybrid layout it is better to use functions like
|
||||||
# `cpuset_controller_path`.
|
# `cpuset_controller_path` and not rely on this value for anything involving paths.
|
||||||
#
|
#
|
||||||
# This is a function, not a method!
|
# This is a function, not a method!
|
||||||
sub cgroup_mode() {
|
sub cgroup_mode() {
|
||||||
if (!defined($CGROUP_MODE)) {
|
if (!defined($CGROUP_MODE)) {
|
||||||
my ($v1, $v2) = get_cgroup_controllers();
|
my $mounts = PVE::ProcFSTools::parse_proc_mounts();
|
||||||
if (keys %$v1) {
|
for my $entry (@$mounts) {
|
||||||
# hybrid or legacy mode
|
my ($what, $dir, $fstype, $opts) = @$entry;
|
||||||
$CGROUP_MODE = 1;
|
if ($dir eq '/sys/fs/cgroup') {
|
||||||
} elsif ($v2) {
|
if ($fstype eq 'cgroup2') {
|
||||||
$CGROUP_MODE = 2;
|
$CGROUP_MODE = 2;
|
||||||
|
last;
|
||||||
|
} else {
|
||||||
|
$CGROUP_MODE = 1;
|
||||||
|
last;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user