|
 |
16d03e |
From 198a2806b0b5522cff1c53bf4671cfee85e45608 Mon Sep 17 00:00:00 2001
|
|
 |
16d03e |
From: Kir Kolyshkin <kolyshkin@gmail.com>
|
|
 |
16d03e |
Date: Tue, 23 Feb 2021 18:25:56 -0800
|
|
 |
16d03e |
Subject: [PATCH 3/5] libct/rootfs/mountCgroupV2: minor refactor
|
|
 |
16d03e |
|
|
 |
16d03e |
1. s/cgroupPath/dest/
|
|
 |
16d03e |
|
|
 |
16d03e |
2. don't hardcode /sys/fs/cgroup
|
|
 |
16d03e |
|
|
 |
16d03e |
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
|
|
 |
16d03e |
---
|
|
 |
16d03e |
libcontainer/rootfs_linux.go | 10 ++++++----
|
|
 |
16d03e |
1 file changed, 6 insertions(+), 4 deletions(-)
|
|
 |
16d03e |
|
|
 |
16d03e |
diff --git a/libcontainer/rootfs_linux.go b/libcontainer/rootfs_linux.go
|
|
 |
16d03e |
index a384abb7e8a5..0f0495b93b3e 100644
|
|
 |
16d03e |
--- a/libcontainer/rootfs_linux.go
|
|
 |
16d03e |
+++ b/libcontainer/rootfs_linux.go
|
|
 |
16d03e |
@@ -17,6 +17,7 @@ import (
|
|
 |
16d03e |
"github.com/moby/sys/mountinfo"
|
|
 |
16d03e |
"github.com/mrunalp/fileutils"
|
|
 |
16d03e |
"github.com/opencontainers/runc/libcontainer/cgroups"
|
|
 |
16d03e |
+ "github.com/opencontainers/runc/libcontainer/cgroups/fs2"
|
|
 |
16d03e |
"github.com/opencontainers/runc/libcontainer/configs"
|
|
 |
16d03e |
"github.com/opencontainers/runc/libcontainer/devices"
|
|
 |
16d03e |
"github.com/opencontainers/runc/libcontainer/system"
|
|
 |
16d03e |
@@ -295,17 +296,18 @@ func mountCgroupV1(m *configs.Mount, c *mountConfig) error {
|
|
 |
16d03e |
}
|
|
 |
16d03e |
|
|
 |
16d03e |
func mountCgroupV2(m *configs.Mount, c *mountConfig) error {
|
|
 |
16d03e |
- cgroupPath, err := securejoin.SecureJoin(c.root, m.Destination)
|
|
 |
16d03e |
+ dest, err := securejoin.SecureJoin(c.root, m.Destination)
|
|
 |
16d03e |
if err != nil {
|
|
 |
16d03e |
return err
|
|
 |
16d03e |
}
|
|
 |
16d03e |
- if err := os.MkdirAll(cgroupPath, 0755); err != nil {
|
|
 |
16d03e |
+ if err := os.MkdirAll(dest, 0755); err != nil {
|
|
 |
16d03e |
return err
|
|
 |
16d03e |
}
|
|
 |
16d03e |
- if err := unix.Mount(m.Source, cgroupPath, "cgroup2", uintptr(m.Flags), m.Data); err != nil {
|
|
 |
16d03e |
+ if err := unix.Mount(m.Source, dest, "cgroup2", uintptr(m.Flags), m.Data); err != nil {
|
|
 |
16d03e |
// when we are in UserNS but CgroupNS is not unshared, we cannot mount cgroup2 (#2158)
|
|
 |
16d03e |
if err == unix.EPERM || err == unix.EBUSY {
|
|
 |
16d03e |
- return unix.Mount("/sys/fs/cgroup", cgroupPath, "", uintptr(m.Flags)|unix.MS_BIND, "")
|
|
 |
16d03e |
+ src := fs2.UnifiedMountpoint
|
|
 |
16d03e |
+ return unix.Mount(src, dest, "", uintptr(m.Flags)|unix.MS_BIND, "")
|
|
 |
16d03e |
}
|
|
 |
16d03e |
return err
|
|
 |
16d03e |
}
|
|
 |
16d03e |
--
|
|
 |
16d03e |
2.31.1
|
|
 |
16d03e |
|