MCPcopy Create free account
hub / github.com/containers/common / New

Function New

pkg/cgroups/cgroups.go:392–415  ·  view source on GitHub ↗

New creates a new cgroup control

(path string, resources *spec.LinuxResources)

Source from the content-addressed store, hash-verified

390
391// New creates a new cgroup control
392func New(path string, resources *spec.LinuxResources) (*CgroupControl, error) {
393 cgroup2, err := IsCgroup2UnifiedMode()
394 if err != nil {
395 return nil, err
396 }
397 control := &CgroupControl{
398 cgroup2: cgroup2,
399 path: path,
400 }
401
402 if !cgroup2 {
403 controllers, err := getAvailableControllers(handlers, false)
404 if err != nil {
405 return nil, err
406 }
407 control.additionalControllers = controllers
408 }
409
410 if err := control.initialize(); err != nil {
411 return nil, err
412 }
413
414 return control, nil
415}
416
417// NewSystemd creates a new cgroup control
418func NewSystemd(path string) (*CgroupControl, error) {

Callers 1

TestCreatedFunction · 0.70

Calls 3

initializeMethod · 0.95
getAvailableControllersFunction · 0.85
IsCgroup2UnifiedModeFunction · 0.70

Tested by 1

TestCreatedFunction · 0.56