mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-08-31 16:36:38 +00:00
Merge pull request #6052 from egernst/add-darwin-skeletons
Add darwin skeletons
This commit is contained in:
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 ""
|
||||||
|
}
|
@@ -25,7 +25,8 @@ func SetLogger(logger *logrus.Entry) {
|
|||||||
type ResourceControllerType string
|
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{
|
||||||
|
@@ -18,9 +18,6 @@ import (
|
|||||||
"golang.org/x/sys/unix"
|
"golang.org/x/sys/unix"
|
||||||
)
|
)
|
||||||
|
|
||||||
// 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) {
|
||||||
|
101
src/runtime/virtcontainers/network_darwin.go
Normal file
101
src/runtime/virtcontainers/network_darwin.go
Normal file
@@ -0,0 +1,101 @@
|
|||||||
|
// Copyright (c) 2023 Apple Inc.
|
||||||
|
//
|
||||||
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
|
//
|
||||||
|
|
||||||
|
package virtcontainers
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"errors"
|
||||||
|
|
||||||
|
"github.com/vishvananda/netlink"
|
||||||
|
|
||||||
|
persistapi "github.com/kata-containers/kata-containers/src/runtime/virtcontainers/persist/api"
|
||||||
|
)
|
||||||
|
|
||||||
|
var endpointNotSupported error = errors.New("Unsupported endpoint on Darwin")
|
||||||
|
|
||||||
|
// DarwinNetwork represents a sandbox networking setup.
|
||||||
|
type DarwinNetwork struct {
|
||||||
|
networkID string
|
||||||
|
interworkingModel NetInterworkingModel
|
||||||
|
networkCreated bool
|
||||||
|
eps []Endpoint
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewNetwork(configs ...*NetworkConfig) (Network, error) {
|
||||||
|
if len(configs) > 1 {
|
||||||
|
return nil, errors.New("too many network configurations")
|
||||||
|
}
|
||||||
|
|
||||||
|
// Empty constructor
|
||||||
|
if len(configs) == 0 {
|
||||||
|
return &DarwinNetwork{}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
config := configs[0]
|
||||||
|
if config == nil {
|
||||||
|
return nil, errors.New("missing network configuration")
|
||||||
|
}
|
||||||
|
|
||||||
|
return &DarwinNetwork{
|
||||||
|
config.NetworkID,
|
||||||
|
config.InterworkingModel,
|
||||||
|
config.NetworkCreated,
|
||||||
|
[]Endpoint{},
|
||||||
|
}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func LoadNetwork(netInfo persistapi.NetworkInfo) Network {
|
||||||
|
network := DarwinNetwork{
|
||||||
|
networkID: netInfo.NetworkID,
|
||||||
|
networkCreated: netInfo.NetworkCreated,
|
||||||
|
}
|
||||||
|
|
||||||
|
return &network
|
||||||
|
}
|
||||||
|
|
||||||
|
func (n *DarwinNetwork) AddEndpoints(context.Context, *Sandbox, []NetworkInfo, bool) ([]Endpoint, error) {
|
||||||
|
return nil, endpointNotSupported
|
||||||
|
}
|
||||||
|
|
||||||
|
func (n *DarwinNetwork) RemoveEndpoints(context.Context, *Sandbox, []Endpoint, bool) error {
|
||||||
|
return endpointNotSupported
|
||||||
|
}
|
||||||
|
|
||||||
|
func (n *DarwinNetwork) Run(context.Context, func() error) error {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (n *DarwinNetwork) NetworkID() string {
|
||||||
|
return n.networkID
|
||||||
|
}
|
||||||
|
|
||||||
|
func (n *DarwinNetwork) NetworkCreated() bool {
|
||||||
|
return n.networkCreated
|
||||||
|
}
|
||||||
|
|
||||||
|
func (n *DarwinNetwork) NetMonitorThread() int {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
func (n *DarwinNetwork) SetNetMonitorThread(pid int) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func (n *DarwinNetwork) Endpoints() []Endpoint {
|
||||||
|
return n.eps
|
||||||
|
}
|
||||||
|
|
||||||
|
func (n *DarwinNetwork) SetEndpoints(endpoints []Endpoint) {
|
||||||
|
n.eps = endpoints
|
||||||
|
}
|
||||||
|
|
||||||
|
func validGuestRoute(route netlink.Route) bool {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
func validGuestNeighbor(route netlink.Neigh) bool {
|
||||||
|
return true
|
||||||
|
}
|
Reference in New Issue
Block a user