-
Notifications
You must be signed in to change notification settings - Fork 249
Closed
Description
Lines 155 to 187 in a0ae1c2
| // ToResources converts the oci LinuxResources struct into a | |
| // v2 Resources type for use with this package. | |
| // | |
| // converting cgroups configuration from v1 to v2 | |
| // ref: https://github.com/containers/crun/blob/master/crun.1.md#cgroup-v2 | |
| func ToResources(spec *specs.LinuxResources) *Resources { | |
| var resources Resources | |
| if cpu := spec.CPU; cpu != nil { | |
| resources.CPU = &CPU{ | |
| Cpus: cpu.Cpus, | |
| Mems: cpu.Mems, | |
| } | |
| if shares := cpu.Shares; shares != nil { | |
| convertedWeight := 1 + ((*shares-2)*9999)/262142 | |
| resources.CPU.Weight = &convertedWeight | |
| } | |
| if period := cpu.Period; period != nil { | |
| resources.CPU.Max = NewCPUMax(cpu.Quota, period) | |
| } | |
| } | |
| if mem := spec.Memory; mem != nil { | |
| resources.Memory = &Memory{} | |
| if swap := mem.Swap; swap != nil { | |
| resources.Memory.Swap = swap | |
| } | |
| if l := mem.Limit; l != nil { | |
| resources.Memory.Max = l | |
| } | |
| if l := mem.Reservation; l != nil { | |
| resources.Memory.Low = l | |
| } | |
| } | |
| if hugetlbs := spec.HugepageLimits; hugetlbs != nil { |
Metadata
Metadata
Assignees
Labels
No labels