boot

package
v0.29.10002026112300 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2026 License: Apache-2.0 Imports: 153 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package boot loads the kernel and runs a container.

Index

Constants

View Source
const (
	// VersionKey is the key used to save runsc version in the save metadata and compare
	// it across checkpoint restore.
	VersionKey = "runsc_version"
	// ContainerCountKey is the key used to save number of containers in the save metadata.
	ContainerCountKey = "container_count"
	// ContainerSpecsKey is the key used to add and pop the container specs to the
	// metadata during save/restore.
	ContainerSpecsKey = "container_specs"
)

Variables

This section is empty.

Functions

func ParseMountOptions

func ParseMountOptions(opts []string) *vfs.MountOptions

ParseMountOptions converts specs.Mount.Options to vfs.MountOptions.

Types

type Args

type Args struct {
	// Id is the sandbox ID.
	ID string
	// Spec is the sandbox specification.
	Spec *specs.Spec
	// Conf is the system configuration.
	Conf *config.Config
	// ControllerFD is the FD to the URPC controller. The Loader takes ownership
	// of this FD and may close it at any time.
	ControllerFD int
	// PinRingFD is the FD of the donated pin ring where the sentry registers
	// its expensive-to-release files into. See `//pkg/pinring`.
	// -1 if there is no ring.
	PinRingFD int
	// CPUDMALatencyFD is an FD for /dev/cpu_dma_latency that the boot
	// process opened to cap host CPU idle states. The Loader takes
	// ownership of it. -1 if unset.
	CPUDMALatencyFD int
	// Device is an optional argument that is passed to the platform. The Loader
	// takes ownership of this file and may close it at any time.
	Device *fd.FD
	// GoferFDs is an array of FDs used to connect with the Gofer. The Loader
	// takes ownership of these FDs and may close them at any time.
	GoferFDs []int
	// DevGoferFD is the FD for the dev gofer connection. The Loader takes
	// ownership of this FD and may close it at any time.
	DevGoferFD int
	// StdioFDs is the stdio for the application. The Loader takes ownership of
	// these FDs and may close them at any time.
	StdioFDs []int
	// PassFDs are user-supplied FD mappings from host to guest descriptors.
	// The Loader takes ownership of these FDs and may close them at any time.
	PassFDs []sentryapi.FDMapping
	// ExecFD is the host file descriptor used for program execution.
	ExecFD int
	// ProcSelfFD is a directory FD to procfs' self/fd. Required with directfs,
	// -1 otherwise. It must stay open for the lifetime of the sandbox.
	ProcSelfFD int
	// GoferFilestoreFDs are FDs to the regular files that will back the tmpfs or
	// overlayfs mount for certain gofer mounts.
	GoferFilestoreFDs []int
	// GoferMountConfs contains information about how the gofer mounts have been
	// configured. The first entry is for rootfs and the following entries are
	// for bind mounts in Spec.Mounts (in the same order).
	GoferMountConfs []specutils.GoferMountConf
	// NumCPU is the number of CPUs to create inside the sandbox.
	NumCPU int
	// LifecycleNumCPU is the number of CPUs that the sandbox can use during
	// checkpoint and restore. `NumCPU` takes precedence if larger.
	LifecycleNumCPU int
	// CPUQuota and CPUPeriod are the raw host CFS settings that should be
	// reflected by sandbox cgroupfs.
	CPUQuota  int64
	CPUPeriod int64
	// TotalMem is the initial amount of total memory to report back to the
	// container.
	TotalMem uint64
	// TotalHostMem is the total memory reported by host /proc/meminfo.
	TotalHostMem uint64
	// UserLogFD is the file descriptor to write user logs to.
	UserLogFD int
	// ProductName is the value to show in
	// /sys/devices/virtual/dmi/id/product_name.
	ProductName string

	// RDMASysfs is the host sysfs snapshot for RDMA device topology, or
	// nil when disabled.
	RDMASysfs *rdma.Snapshot
	// PodInitConfigFD is the file descriptor to a file passed in the
	//	--pod-init-config flag
	PodInitConfigFD int
	// SinkFDs is an ordered array of file descriptors to be used by seccheck
	// sinks configured from the --pod-init-config file.
	SinkFDs []int
	// ProfileOpts contains the set of profiles to enable and the
	// corresponding FDs where profile data will be written.
	ProfileOpts profile.Opts
	// NvidiaDriverVersion is the NVIDIA driver ABI version to use for
	// communicating with NVIDIA devices on the host.
	NvidiaDriverVersion nvconf.DriverVersion
	NvidiaHostSettings  *nvconf.HostSettings
	// HostTHP contains host transparent hugepage settings.
	HostTHP HostTHP
	// SaveFDs are FDs used for user-triggered checkpoint saving.
	SaveFDs []*fd.FD
	// If SaveCheckpointGofer is true, Args.SaveFDs contains only one FD, which
	// is a socket connected to a checkpoint gofer.
	SaveCheckpointGofer bool
	// FSRestoreFDs are FDs used for filesystem checkpoint restore. For local
	// checkpoints, contains 4 FDs (manifest, multi-tar, pages metadata, pages)
	// per bundle.
	FSRestoreFDs []*fd.FD
	// If FSRestoreCheckpointGofer is true, Args.FSRestoreFDs contains only one
	// FD, which is a socket connected to a checkpoint gofer.
	FSRestoreCheckpointGofer bool
	// FSSaveFDs are FDs used for user-triggered filesystem checkpoint saving.
	FSSaveFDs []*fd.FD
	// If FSSaveCheckpointGofer is true, Args.FSSaveFDs contains only one FD,
	// which is a socket connected to a checkpoint gofer.
	FSSaveCheckpointGofer bool
	// RootfsUpperTarFD is the file descriptor to the tar file containing the rootfs
	// upper layer changes.
	RootfsUpperTarFD int
	// NoRootContainer boots without a root container; Spec then has neither
	// Process nor Root. See Loader.noRootContainer.
	NoRootContainer bool

	// StartupTimer tracks overall sandbox startup.
	// The `Loader` records midpoints on it as it goes through loader creation
	// and sandbox startup. The `Loader` does not take ownership of it.
	StartupTimer *timing.Timer
}

Args are the arguments for New().

type HostTHP

type HostTHP struct {
	// ShmemEnabled is the selected option in
	// /sys/kernel/mm/transparent_hugepage/shmem_enabled.
	ShmemEnabled string

	// Defrag is the selected option in
	// /sys/kernel/mm/transparent_hugepage/defrag.
	Defrag string
}

HostTHP holds host transparent hugepage settings.

type Loader

type Loader struct {

	// PreSeccompCallback is called right before installing seccomp filters.
	PreSeccompCallback func()

	// PostStartCallback, if set, is called once Run has successfully started
	// the sandbox, right before the result is reported to the controller (and
	// thus before `runsc start` returns).
	PostStartCallback func()
	// contains filtered or unexported fields
}

Loader keeps state needed to start the kernel and run the container.

func New

func New(args Args) (*Loader, error)

New initializes a new kernel loader configured by spec. New also handles setting up a kernel for restoring a container.

func (*Loader) ConfigureNetwork

func (l *Loader) ConfigureNetwork(s inet.Stack) error

ConfigureNetwork implements inet.NetworkArgs.ConfigureNetwork.

Startup calls this directly before installing seccomp filters. Restore calls it synchronously through Kernel.LoadFrom after installing filters. Both callers hold l.mu, but the restore interface call cannot convey this concrete lock contract to checklocks.

+checklocks:l.mu

func (*Loader) Destroy

func (l *Loader) Destroy()

Destroy cleans up all resources used by the loader.

Note that this will block until all open control server connections have been closed. For that reason, this should NOT be called in a defer, because a panic in a control server rpc would then hang forever.

+checklocksexclude:l.mu +checklocksexclude:l.k.fsSaveMu

func (*Loader) FSSave

func (l *Loader) FSSave() error

FSSave implements kernel.Saver.FSSave.

+checklocksexclude:l.mu +checklocksexclude:l.k.fsSaveMu

func (*Loader) GetContainerSpecs

func (l *Loader) GetContainerSpecs() map[string]*specs.Spec

GetContainerSpecs returns a copy of the container specs map.

+checklocksexclude:l.mu

func (*Loader) Run

func (l *Loader) Run() error

Run runs the root container.

+checklocksexclude:l.mu

func (*Loader) SaveAsync

func (l *Loader) SaveAsync() (err error)

SaveAsync starts a goroutine to save the kernel. Implements kernel.Saver.

func (*Loader) StartControlServer

func (l *Loader) StartControlServer()

StartControlServer starts serving control RPCs, including those that might have been backlogged while the sandbox was booting.

func (*Loader) WaitExit

func (l *Loader) WaitExit() linux.WaitStatus

WaitExit waits for the sandbox to finish and returns the root container's exit status, or zero if there is no root container.

func (*Loader) WaitForStartSignal

func (l *Loader) WaitForStartSignal()

WaitForStartSignal waits for a start signal from the control server.

type Network

type Network struct {
	Stack  *stack.Stack
	Kernel *kernel.Kernel

	// PluginStack is a third-party network stack to use in place of
	// netstack when non-nil.
	PluginStack plugin.PluginStack
}

Network exposes methods that can be used to configure a network stack.

func (*Network) CreateLinksAndRoutes

func (n *Network) CreateLinksAndRoutes(args *sentryapi.CreateLinksAndRoutesArgs, _ *struct{}) error

CreateLinksAndRoutes creates links and routes in a network stack. It should only be called once.

func (*Network) InitPluginStack

func (n *Network) InitPluginStack(args *sentryapi.InitPluginStackArgs, _ *struct{}) error

InitPluginStack initializes plugin network stack. It will invoke Init() that is registered by current plugin stack.

Directories

Path Synopsis
Package filter installs seccomp filters to prevent prohibited syscalls in case it's compromised.
Package filter installs seccomp filters to prevent prohibited syscalls in case it's compromised.
config
Package config defines all syscalls the sandbox is allowed to make to the host.
Package config defines all syscalls the sandbox is allowed to make to the host.
Package portforward holds the infrastructure to support the port forward command.
Package portforward holds the infrastructure to support the port forward command.
Package pprof provides a stub to initialize custom profilers.
Package pprof provides a stub to initialize custom profilers.
Package procfs holds the procfs information dumped for sandboxed processes.
Package procfs holds the procfs information dumped for sandboxed processes.
Package sentryapi is the internal API of the Sentry process.
Package sentryapi is the internal API of the Sentry process.

Jump to

Keyboard shortcuts

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