@@ -20,19 +20,10 @@ func (s *CpusetGroup) Set(d *data) error {
20
20
if err != nil {
21
21
return err
22
22
}
23
- if err := s .ensureParent (dir ); err != nil {
24
- return err
25
- }
26
23
27
- // because we are not using d.join we need to place the pid into the procs file
28
- // unlike the other subsystems
29
- if err := writeFile (dir , "cgroup.procs" , strconv .Itoa (d .pid )); err != nil {
30
- return err
31
- }
32
- if err := writeFile (dir , "cpuset.cpus" , d .c .CpusetCpus ); err != nil {
33
- return err
34
- }
24
+ return s .SetDir (dir , d .c .CpusetCpus , d .pid )
35
25
}
26
+
36
27
return nil
37
28
}
38
29
@@ -44,6 +35,24 @@ func (s *CpusetGroup) GetStats(path string, stats *cgroups.Stats) error {
44
35
return nil
45
36
}
46
37
38
+ func (s * CpusetGroup ) SetDir (dir , value string , pid int ) error {
39
+ if err := s .ensureParent (dir ); err != nil {
40
+ return err
41
+ }
42
+
43
+ // because we are not using d.join we need to place the pid into the procs file
44
+ // unlike the other subsystems
45
+ if err := writeFile (dir , "cgroup.procs" , strconv .Itoa (pid )); err != nil {
46
+ return err
47
+ }
48
+
49
+ if err := writeFile (dir , "cpuset.cpus" , value ); err != nil {
50
+ return err
51
+ }
52
+
53
+ return nil
54
+ }
55
+
47
56
func (s * CpusetGroup ) getSubsystemSettings (parent string ) (cpus []byte , mems []byte , err error ) {
48
57
if cpus , err = ioutil .ReadFile (filepath .Join (parent , "cpuset.cpus" )); err != nil {
49
58
return
0 commit comments