systemd

package
v1.2.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 10, 2024 License: Apache-2.0 Imports: 24 Imported by: 458

Documentation

Index

Constants

This section is empty.

Variables

View Source
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 added in v1.0.0

func DetectUID() (int, error)

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 added in v1.0.0

func DetectUserDbusSessionBusAddress() (string, error)

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 added in v1.0.0

func ExpandSlice(slice string) (string, error)

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 added in v1.0.0

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 added in v1.0.0

func RangeToBits(str string) ([]byte, error)

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 added in v1.2.0

type LegacyManager struct {
	// contains filtered or unexported fields
}

func NewLegacyManager added in v1.0.0

func NewLegacyManager(cg *configs.Cgroup, paths map[string]string) (*LegacyManager, error)

func (*LegacyManager) Apply added in v1.2.0

func (m *LegacyManager) Apply(pid int) error

func (*LegacyManager) Destroy added in v1.2.0

func (m *LegacyManager) Destroy() error

func (*LegacyManager) Exists added in v1.2.0

func (m *LegacyManager) Exists() bool

func (*LegacyManager) Freeze added in v1.2.0

func (m *LegacyManager) Freeze(state configs.FreezerState) error

func (*LegacyManager) GetAllPids added in v1.2.0

func (m *LegacyManager) GetAllPids() ([]int, error)

func (*LegacyManager) GetCgroups added in v1.2.0

func (m *LegacyManager) GetCgroups() (*configs.Cgroup, error)

func (*LegacyManager) GetFreezerState added in v1.2.0

func (m *LegacyManager) GetFreezerState() (configs.FreezerState, error)

func (*LegacyManager) GetPaths added in v1.2.0

func (m *LegacyManager) GetPaths() map[string]string

func (*LegacyManager) GetPids added in v1.2.0

func (m *LegacyManager) GetPids() ([]int, error)

func (*LegacyManager) GetStats added in v1.2.0

func (m *LegacyManager) GetStats() (*cgroups.Stats, error)

func (*LegacyManager) OOMKillCount added in v1.2.0

func (m *LegacyManager) OOMKillCount() (uint64, error)

func (*LegacyManager) Path added in v1.2.0

func (m *LegacyManager) Path(subsys string) string

func (*LegacyManager) Set added in v1.2.0

func (m *LegacyManager) Set(r *configs.Resources) error

type UnifiedManager added in v1.2.0

type UnifiedManager struct {
	// contains filtered or unexported fields
}

func NewUnifiedManager added in v1.0.0

func NewUnifiedManager(config *configs.Cgroup, path string) (*UnifiedManager, error)

func (*UnifiedManager) Apply added in v1.2.0

func (m *UnifiedManager) Apply(pid int) error

func (*UnifiedManager) Destroy added in v1.2.0

func (m *UnifiedManager) Destroy() error

func (*UnifiedManager) Exists added in v1.2.0

func (m *UnifiedManager) Exists() bool

func (*UnifiedManager) Freeze added in v1.2.0

func (m *UnifiedManager) Freeze(state configs.FreezerState) error

func (*UnifiedManager) GetAllPids added in v1.2.0

func (m *UnifiedManager) GetAllPids() ([]int, error)

func (*UnifiedManager) GetCgroups added in v1.2.0

func (m *UnifiedManager) GetCgroups() (*configs.Cgroup, error)

func (*UnifiedManager) GetFreezerState added in v1.2.0

func (m *UnifiedManager) GetFreezerState() (configs.FreezerState, error)

func (*UnifiedManager) GetPaths added in v1.2.0

func (m *UnifiedManager) GetPaths() map[string]string

func (*UnifiedManager) GetPids added in v1.2.0

func (m *UnifiedManager) GetPids() ([]int, error)

func (*UnifiedManager) GetStats added in v1.2.0

func (m *UnifiedManager) GetStats() (*cgroups.Stats, error)

func (*UnifiedManager) OOMKillCount added in v1.2.0

func (m *UnifiedManager) OOMKillCount() (uint64, error)

func (*UnifiedManager) Path added in v1.2.0

func (m *UnifiedManager) Path(_ string) string

func (*UnifiedManager) Set added in v1.2.0

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL