Skip to content

Instantly share code, notes, and snippets.

@stevenh
Created January 22, 2017 21:28
Show Gist options
  • Save stevenh/f8615eeec21ac53009f6a0dc7b9bfb36 to your computer and use it in GitHub Desktop.
Save stevenh/f8615eeec21ac53009f6a0dc7b9bfb36 to your computer and use it in GitHub Desktop.
sync opencontainers runc/libcontainer with runtime-spec
diff --git a/libcontainer/cgroups/fs/hugetlb.go b/libcontainer/cgroups/fs/hugetlb.go
index 2f97277..b056d02 100644
--- a/libcontainer/cgroups/fs/hugetlb.go
+++ b/libcontainer/cgroups/fs/hugetlb.go
@@ -28,7 +28,7 @@ func (s *HugetlbGroup) Apply(d *cgroupData) error {
func (s *HugetlbGroup) Set(path string, cgroup *configs.Cgroup) error {
for _, hugetlb := range cgroup.Resources.HugetlbLimit {
- if err := writeFile(path, strings.Join([]string{"hugetlb", hugetlb.Pagesize, "limit_in_bytes"}, "."), strconv.FormatUint(hugetlb.Limit, 10)); err != nil {
+ if err := writeFile(path, strings.Join([]string{"hugetlb", hugetlb.Pagesize, "limit_in_bytes"}, "."), strconv.FormatInt(hugetlb.Limit, 10)); err != nil {
return err
}
}
diff --git a/libcontainer/configs/hugepage_limit.go b/libcontainer/configs/hugepage_limit.go
index d302163..0714241 100644
--- a/libcontainer/configs/hugepage_limit.go
+++ b/libcontainer/configs/hugepage_limit.go
@@ -5,5 +5,5 @@ type HugepageLimit struct {
Pagesize string `json:"page_size"`
// usage limit for hugepage.
- Limit uint64 `json:"limit"`
+ Limit int64 `json:"limit"`
}
diff --git a/libcontainer/specconv/spec_linux.go b/libcontainer/specconv/spec_linux.go
index 94afd65..2de983c 100644
--- a/libcontainer/specconv/spec_linux.go
+++ b/libcontainer/specconv/spec_linux.go
@@ -262,10 +262,10 @@ func createCgroupConfig(name string, useSystemdCgroup bool, spec *specs.Spec) (*
Resources: &configs.Resources{},
}
- if spec.Linux != nil && spec.Linux.CgroupsPath != nil {
- myCgroupPath = libcontainerUtils.CleanPath(*spec.Linux.CgroupsPath)
+ if spec.Linux != nil && spec.Linux.CgroupsPath != "" {
+ myCgroupPath = libcontainerUtils.CleanPath(spec.Linux.CgroupsPath)
if useSystemdCgroup {
- myCgroupPath = *spec.Linux.CgroupsPath
+ myCgroupPath = spec.Linux.CgroupsPath
}
}
@@ -306,16 +306,17 @@ func createCgroupConfig(name string, useSystemdCgroup bool, spec *specs.Spec) (*
major = int64(-1)
minor = int64(-1)
)
- if d.Type != nil {
- t = *d.Type
- }
+ if d.Type != "" {
+ t = d.Type
+ }
+
if d.Major != nil {
major = *d.Major
}
if d.Minor != nil {
minor = *d.Minor
}
- if d.Access == nil || *d.Access == "" {
+ if d.Access == "" {
return nil, fmt.Errorf("device access at %d field cannot be empty", i)
}
dt, err := stringToDeviceRune(t)
@@ -326,7 +327,7 @@ func createCgroupConfig(name string, useSystemdCgroup bool, spec *specs.Spec) (*
Type: dt,
Major: major,
Minor: minor,
- Permissions: *d.Access,
+ Permissions: d.Access,
Allow: d.Allow,
}
c.Resources.Devices = append(c.Resources.Devices, dd)
@@ -370,11 +371,11 @@ func createCgroupConfig(name string, useSystemdCgroup bool, spec *specs.Spec) (*
if r.CPU.RealtimePeriod != nil {
c.Resources.CpuRtPeriod = int64(*r.CPU.RealtimePeriod)
}
- if r.CPU.Cpus != nil {
- c.Resources.CpusetCpus = *r.CPU.Cpus
+ if r.CPU.Cpus != "" {
+ c.Resources.CpusetCpus = r.CPU.Cpus
}
- if r.CPU.Mems != nil {
- c.Resources.CpusetMems = *r.CPU.Mems
+ if r.CPU.Mems != "" {
+ c.Resources.CpusetMems = r.CPU.Mems
}
}
if r.Pids != nil {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment