2020-05-04 20:46:48 +00:00
|
|
|
// +build linux
|
|
|
|
|
|
|
|
package fs2
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/opencontainers/runc/libcontainer/cgroups/fscommon"
|
|
|
|
"github.com/opencontainers/runc/libcontainer/configs"
|
|
|
|
)
|
|
|
|
|
2020-08-10 17:43:49 +00:00
|
|
|
func isCpusetSet(cgroup *configs.Cgroup) bool {
|
|
|
|
return cgroup.Resources.CpusetCpus != "" || cgroup.Resources.CpusetMems != ""
|
|
|
|
}
|
|
|
|
|
2020-05-04 20:46:48 +00:00
|
|
|
func setCpuset(dirPath string, cgroup *configs.Cgroup) error {
|
2020-08-10 17:43:49 +00:00
|
|
|
if !isCpusetSet(cgroup) {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2020-05-04 20:46:48 +00:00
|
|
|
if cgroup.Resources.CpusetCpus != "" {
|
|
|
|
if err := fscommon.WriteFile(dirPath, "cpuset.cpus", cgroup.Resources.CpusetCpus); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if cgroup.Resources.CpusetMems != "" {
|
|
|
|
if err := fscommon.WriteFile(dirPath, "cpuset.mems", cgroup.Resources.CpusetMems); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|