package systemd
import "github.com/opencontainers/runc/libcontainer/cgroups/systemd"
Index ¶
- Variables
- func DetectUID() (int, error)
- func DetectUserDbusSessionBusAddress() (string, error)
- func ExpandSlice(slice string) (string, error)
- func IsRunningSystemd() bool
- func RangeToBits(str string) ([]byte, error)
- type LegacyManager
- func NewLegacyManager(cg *configs.Cgroup, paths map[string]string) (*LegacyManager, error)
- func (m *LegacyManager) Apply(pid int) error
- func (m *LegacyManager) Destroy() error
- func (m *LegacyManager) Exists() bool
- func (m *LegacyManager) Freeze(state configs.FreezerState) error
- func (m *LegacyManager) GetAllPids() ([]int, error)
- func (m *LegacyManager) GetCgroups() (*configs.Cgroup, error)
- func (m *LegacyManager) GetFreezerState() (configs.FreezerState, error)
- func (m *LegacyManager) GetPaths() map[string]string
- func (m *LegacyManager) GetPids() ([]int, error)
- func (m *LegacyManager) GetStats() (*cgroups.Stats, error)
- func (m *LegacyManager) OOMKillCount() (uint64, error)
- func (m *LegacyManager) Path(subsys string) string
- func (m *LegacyManager) Set(r *configs.Resources) error
- type UnifiedManager
- func NewUnifiedManager(config *configs.Cgroup, path string) (*UnifiedManager, error)
- func (m *UnifiedManager) Apply(pid int) error
- func (m *UnifiedManager) Destroy() error
- func (m *UnifiedManager) Exists() bool
- func (m *UnifiedManager) Freeze(state configs.FreezerState) error
- func (m *UnifiedManager) GetAllPids() ([]int, error)
- func (m *UnifiedManager) GetCgroups() (*configs.Cgroup, error)
- func (m *UnifiedManager) GetFreezerState() (configs.FreezerState, error)
- func (m *UnifiedManager) GetPaths() map[string]string
- func (m *UnifiedManager) GetPids() ([]int, error)
- func (m *UnifiedManager) GetStats() (*cgroups.Stats, error)
- func (m *UnifiedManager) OOMKillCount() (uint64, error)
- func (m *UnifiedManager) Path(_ string) string
- func (m *UnifiedManager) Set(r *configs.Resources) error
Variables ¶
var ( // GenerateDeviceProps is a function to generate systemd device // properties, used by Set methods. Unless // [github.com/opencontainers/runc/libcontainer/cgroups/devices] // package is imported, it is set to nil, so cgroup managers can't // configure devices. GenerateDeviceProps func(r *configs.Resources, sdVer int) ([]systemdDbus.Property, error) )
Functions ¶
func DetectUID ¶
DetectUID detects UID from the OwnerUID field of `busctl --user status` if running in userNS. The value corresponds to sd_bus_creds_get_owner_uid(3) .
Otherwise returns os.Getuid() .
func DetectUserDbusSessionBusAddress ¶
DetectUserDbusSessionBusAddress returns $DBUS_SESSION_BUS_ADDRESS, if set. Otherwise it returns "unix:path=$XDG_RUNTIME_DIR/bus", if $XDG_RUNTIME_DIR/bus exists.
func ExpandSlice ¶
systemd represents slice hierarchy using `-`, so we need to follow suit when generating the path of slice. Essentially, test-a-b.slice becomes /test.slice/test-a.slice/test-a-b.slice.
func IsRunningSystemd ¶
func IsRunningSystemd() bool
NOTE: This function comes from package github.com/coreos/go-systemd/util It was borrowed here to avoid a dependency on cgo.
IsRunningSystemd checks whether the host was booted with systemd as its init system. This functions similarly to systemd's `sd_booted(3)`: internally, it checks whether /run/systemd/system/ exists and is a directory. http://www.freedesktop.org/software/systemd/man/sd_booted.html
func RangeToBits ¶
RangeToBits converts a text representation of a CPU mask (as written to or read from cgroups' cpuset.* files, e.g. "1,3-5") to a slice of bytes with the corresponding bits set (as consumed by systemd over dbus as AllowedCPUs/AllowedMemoryNodes unit property value).
Types ¶
type LegacyManager ¶
type LegacyManager struct {
// contains filtered or unexported fields
}
func NewLegacyManager ¶
func (*LegacyManager) Apply ¶
func (m *LegacyManager) Apply(pid int) error
func (*LegacyManager) Destroy ¶
func (m *LegacyManager) Destroy() error
func (*LegacyManager) Exists ¶
func (m *LegacyManager) Exists() bool
func (*LegacyManager) Freeze ¶
func (m *LegacyManager) Freeze(state configs.FreezerState) error
func (*LegacyManager) GetAllPids ¶
func (m *LegacyManager) GetAllPids() ([]int, error)
func (*LegacyManager) GetCgroups ¶
func (m *LegacyManager) GetCgroups() (*configs.Cgroup, error)
func (*LegacyManager) GetFreezerState ¶
func (m *LegacyManager) GetFreezerState() (configs.FreezerState, error)
func (*LegacyManager) GetPaths ¶
func (m *LegacyManager) GetPaths() map[string]string
func (*LegacyManager) GetPids ¶
func (m *LegacyManager) GetPids() ([]int, error)
func (*LegacyManager) GetStats ¶
func (m *LegacyManager) GetStats() (*cgroups.Stats, error)
func (*LegacyManager) OOMKillCount ¶
func (m *LegacyManager) OOMKillCount() (uint64, error)
func (*LegacyManager) Path ¶
func (m *LegacyManager) Path(subsys string) string
func (*LegacyManager) Set ¶
func (m *LegacyManager) Set(r *configs.Resources) error
type UnifiedManager ¶
type UnifiedManager struct {
// contains filtered or unexported fields
}
func NewUnifiedManager ¶
func NewUnifiedManager(config *configs.Cgroup, path string) (*UnifiedManager, error)
func (*UnifiedManager) Apply ¶
func (m *UnifiedManager) Apply(pid int) error
func (*UnifiedManager) Destroy ¶
func (m *UnifiedManager) Destroy() error
func (*UnifiedManager) Exists ¶
func (m *UnifiedManager) Exists() bool
func (*UnifiedManager) Freeze ¶
func (m *UnifiedManager) Freeze(state configs.FreezerState) error
func (*UnifiedManager) GetAllPids ¶
func (m *UnifiedManager) GetAllPids() ([]int, error)
func (*UnifiedManager) GetCgroups ¶
func (m *UnifiedManager) GetCgroups() (*configs.Cgroup, error)
func (*UnifiedManager) GetFreezerState ¶
func (m *UnifiedManager) GetFreezerState() (configs.FreezerState, error)
func (*UnifiedManager) GetPaths ¶
func (m *UnifiedManager) GetPaths() map[string]string
func (*UnifiedManager) GetPids ¶
func (m *UnifiedManager) GetPids() ([]int, error)
func (*UnifiedManager) GetStats ¶
func (m *UnifiedManager) GetStats() (*cgroups.Stats, error)
func (*UnifiedManager) OOMKillCount ¶
func (m *UnifiedManager) OOMKillCount() (uint64, error)
func (*UnifiedManager) Path ¶
func (m *UnifiedManager) Path(_ string) string
func (*UnifiedManager) Set ¶
func (m *UnifiedManager) Set(r *configs.Resources) error
Source Files ¶
common.go cpuset.go dbus.go devices.go user.go v1.go v2.go
- Version
- v1.2.6 (latest)
- Published
- Mar 14, 2025
- Platform
- linux/amd64
- Imports
- 24 packages
- Last checked
- 1 hour ago –
Tools for package owners.