gvisorgvisor.dev/gvisor/pkg/sentry/state Index | Files

package state

import "gvisor.dev/gvisor/pkg/sentry/state"

Package state provides high-level state wrappers.

Index

Functions

func CPUTime

func CPUTime() (time.Duration, error)

CPUTime returns the CPU time usage by Sentry and app.

func NewStatefileReader

func NewStatefileReader(source io.ReadCloser, key []byte) (io.ReadCloser, map[string]string, error)

NewStatefileReader returns the statefile's metadata and a reader for it. The ownership of source is transferred to the returned reader.

Types

type ErrStateFile

type ErrStateFile struct {
	Err error
}

ErrStateFile is returned when an error is encountered writing the statefile (which may occur during open or close calls in addition to write).

func (ErrStateFile) Error

func (e ErrStateFile) Error() string

Error implements error.Error().

type SaveOpts

type SaveOpts struct {
	// Destination is the save target.
	Destination io.Writer

	// PagesMetadata is the file into which MemoryFile metadata is stored if
	// PagesMetadata is non-nil. Otherwise this content is stored in Destination.
	PagesMetadata *fd.FD

	// PagesFile is the file in which all MemoryFile pages are stored if
	// PagesFile is non-nil. Otherwise this content is stored in Destination.
	PagesFile *fd.FD

	// Key is used for state integrity check.
	Key []byte

	// Metadata is save metadata.
	Metadata map[string]string

	// MemoryFileSaveOpts is passed to calls to pgalloc.MemoryFile.SaveTo().
	MemoryFileSaveOpts pgalloc.SaveOpts

	// Resume indicates if the statefile is used for save-resume.
	Resume bool

	// Autosave indicates if the statefile is used for autosave.
	Autosave bool
}

SaveOpts contains save-related options.

func (SaveOpts) Save

func (opts SaveOpts) Save(ctx context.Context, k *kernel.Kernel, w *watchdog.Watchdog) error

Save saves the system state.

Source Files

state.go state_metadata.go state_unsafe.go

Version
v0.0.0-20250605235530-a6711d1e1dc6 (latest)
Published
Jun 5, 2025
Platform
linux/amd64
Imports
15 packages
Last checked
4 hours ago

Tools for package owners.