]>
git.proxmox.com Git - pve-container.git/blob - src/PVE/LXC/CGroup.pm
3 # This package should deal with figuring out the right cgroup path for a
4 # container (via the command socket), reading and writing cgroup values, and
5 # handling cgroup v1 & v2 differences.
7 # Note that the long term plan is to have resource manage functions instead of
8 # dealing with cgroup files on the outside.
10 package PVE
::LXC
::CGroup
;
15 use PVE
::LXC
::Command
;
17 use base
('PVE::CGroup');
20 # Get a subdirectory (without the cgroup mount point) for a controller.
22 # If `$controller` is `undef`, get the unified (cgroupv2) path.
24 # Note that in cgroup v2, lxc uses the activated controller names
25 # (`cgroup.controllers` file) as list of controllers for the unified hierarchy,
26 # so this returns a result when a `controller` is provided even when using
27 # a pure cgroupv2 setup.
29 my ($self, $controller, $limiting) = @_;
31 my $entry_name = $controller || 'unified';
32 my $entry = ($self->{controllers
}->{$entry_name} //= {});
34 my $kind = $limiting ?
'limit' : 'ns';
35 my $path = $entry->{$kind};
37 return $path if defined $path;
39 $path = PVE
::LXC
::Command
::get_cgroup_path
(
46 if ($path =~ /\.\./) {
47 die "lxc returned suspicious path: '$path'\n";
49 ($path) = ($path =~ /^(.*)$/s);
51 $entry->{$kind} = $path;