mirror of
https://github.com/containers/podman.git
synced 2025-05-24 18:46:26 +08:00
podman: move MaybeMoveToSubCgroup to utils/
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
This commit is contained in:

committed by
Matthew Heon

parent
b29a52a48a
commit
edfe800271
@ -190,3 +190,23 @@ func MovePauseProcessToScope(pausePidPath string) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// MaybeMoveToSubCgroup moves the current process in a sub cgroup when
|
||||
// it is running in the root cgroup on a system that uses cgroupv2.
|
||||
func MaybeMoveToSubCgroup() error {
|
||||
unifiedMode, err := cgroups.IsCgroup2UnifiedMode()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if !unifiedMode {
|
||||
return nil
|
||||
}
|
||||
cgroup, err := GetOwnCgroup()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if cgroup == "/" {
|
||||
return MoveUnderCgroupSubtree("init")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
Reference in New Issue
Block a user