mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-05-02 13:44:33 +00:00
virtcontainers: resourcecontrol: Add skeleton for Darwin
Cgroups do not exist on Darwin, so use an empty implementation for resourcecontrol for the time being. In the process, ensure that the utilized cgroup handling (ie, isSystemdCgroup) is kept in general file, since we use this to help assess/constrain the container spec we pass to the guest. Fixes: #6051 Signed-off-by: Samuel Ortiz <s.ortiz@apple.com> Signed-off-by: Eric Ernst <eric_ernst@apple.com>
This commit is contained in:
parent
ea06fe3afc
commit
a9626682af
86
src/runtime/pkg/resourcecontrol/cgroups_darwin.go
Normal file
86
src/runtime/pkg/resourcecontrol/cgroups_darwin.go
Normal file
@ -0,0 +1,86 @@
|
|||||||
|
// Copyright (c) 2023 Apple Inc.
|
||||||
|
//
|
||||||
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
|
//
|
||||||
|
|
||||||
|
package resourcecontrol
|
||||||
|
|
||||||
|
import (
|
||||||
|
"errors"
|
||||||
|
|
||||||
|
"github.com/opencontainers/runtime-spec/specs-go"
|
||||||
|
)
|
||||||
|
|
||||||
|
type DarwinResourceController struct{}
|
||||||
|
|
||||||
|
func RenameCgroupPath(path string) (string, error) {
|
||||||
|
return "", errors.New("RenameCgroupPath not supported on Darwin")
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewResourceController(path string, resources *specs.LinuxResources) (ResourceController, error) {
|
||||||
|
return &DarwinResourceController{}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewSandboxResourceController(path string, resources *specs.LinuxResources, sandboxCgroupOnly bool) (ResourceController, error) {
|
||||||
|
return &DarwinResourceController{}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func LoadResourceController(path string) (ResourceController, error) {
|
||||||
|
return &DarwinResourceController{}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *DarwinResourceController) Delete() error {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *DarwinResourceController) Stat() (interface{}, error) {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *DarwinResourceController) AddProcess(pid int, subsystems ...string) error {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *DarwinResourceController) AddThread(pid int, subsystems ...string) error {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *DarwinResourceController) AddTask(pid int, subsystems ...string) error {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *DarwinResourceController) Update(resources *specs.LinuxResources) error {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *DarwinResourceController) MoveTo(path string) error {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *DarwinResourceController) ID() string {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *DarwinResourceController) Parent() string {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *DarwinResourceController) Type() ResourceControllerType {
|
||||||
|
return DarwinResourceControllerType
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *DarwinResourceController) AddDevice(deviceHostPath string) error {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *DarwinResourceController) RemoveDevice(deviceHostPath string) error {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *DarwinResourceController) UpdateCpuSet(cpuset, memset string) error {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *DarwinResourceController) Path() string {
|
||||||
|
return ""
|
||||||
|
}
|
@ -26,6 +26,7 @@ type ResourceControllerType string
|
|||||||
|
|
||||||
const (
|
const (
|
||||||
LinuxCgroups ResourceControllerType = "cgroups"
|
LinuxCgroups ResourceControllerType = "cgroups"
|
||||||
|
DarwinResourceControllerType ResourceControllerType = "darwin"
|
||||||
)
|
)
|
||||||
|
|
||||||
// String converts a resource type to a string.
|
// String converts a resource type to a string.
|
||||||
|
@ -19,6 +19,9 @@ var (
|
|||||||
ErrCgroupMode = errors.New("cgroup controller type error")
|
ErrCgroupMode = errors.New("cgroup controller type error")
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// DefaultResourceControllerID runtime-determined location in the cgroups hierarchy.
|
||||||
|
const DefaultResourceControllerID = "/vc"
|
||||||
|
|
||||||
func DeviceToCgroupDeviceRule(device string) (*devices.Rule, error) {
|
func DeviceToCgroupDeviceRule(device string) (*devices.Rule, error) {
|
||||||
var st unix.Stat_t
|
var st unix.Stat_t
|
||||||
deviceRule := devices.Rule{
|
deviceRule := devices.Rule{
|
||||||
|
@ -17,9 +17,6 @@ import (
|
|||||||
"github.com/opencontainers/runc/libcontainer/cgroups/systemd"
|
"github.com/opencontainers/runc/libcontainer/cgroups/systemd"
|
||||||
)
|
)
|
||||||
|
|
||||||
// DefaultResourceControllerID runtime-determined location in the cgroups hierarchy.
|
|
||||||
const DefaultResourceControllerID = "/vc"
|
|
||||||
|
|
||||||
// ValidCgroupPathV1 returns a valid cgroup path for cgroup v1.
|
// ValidCgroupPathV1 returns a valid cgroup path for cgroup v1.
|
||||||
// see https://github.com/opencontainers/runtime-spec/blob/master/config-linux.md#cgroups-path
|
// see https://github.com/opencontainers/runtime-spec/blob/master/config-linux.md#cgroups-path
|
||||||
func ValidCgroupPathV1(path string, systemdCgroup bool) (string, error) {
|
func ValidCgroupPathV1(path string, systemdCgroup bool) (string, error) {
|
||||||
|
Loading…
Reference in New Issue
Block a user