crit

package
v7.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 15, 2024 License: Apache-2.0 Imports: 35 Imported by: 2

Documentation

Index

Constants

View Source
const (
	StatsDump    = "stats-dump"
	StatsRestore = "stats-restore"
)

Variables

This section is empty.

Functions

func GetDumpStats

func GetDumpStats(dir string) (*stats.DumpStatsEntry, error)

GetDumpStats returns the dump statistics of a checkpoint. dir is the path to the directory with the checkpoint images.

func GetRestoreStats

func GetRestoreStats(dir string) (*stats.RestoreStatsEntry, error)

GetRestoreStats returns the restore statistics of a checkpoint. dir is the path to the directory with the checkpoint images.

func ReadMagic

func ReadMagic(f *os.File) (string, error)

Helper to decode magic name from hex value

Types

type Critter

type Critter interface {
	// Read binary image file into Go struct (decode.go)
	Decode(proto.Message) (*CriuImage, error)
	// Read only counts of image file entries into Go struct
	Info() (*CriuImage, error)
	// Read JSON into Go struct
	Parse(proto.Message) (*CriuImage, error)
	// Write JSON to binary image file (encode.go)
	Encode(*CriuImage) error
	// Explore process information (explore.go)
	ExplorePs() (*PsTree, error)
	ExploreFds() ([]*Fd, error)
	ExploreMems() ([]*MemMap, error)
	ExploreRss() ([]*RssMap, error)
	ExploreSk() ([]*Sk, error)
}

Critter is the interface that wraps all CRIT operations. To create a CRIT service instance, use New().

func New

func New(
	inputFilePath, outputFilePath *os.File,
	inputDirPath string,
	pretty, noPayload bool,
) Critter

New creates an instance of the CRIT service

type CriuEntry

type CriuEntry struct {
	proto.Message
	Extra string
}

CriuEntry represents a single entry in an image

func (*CriuEntry) MarshalJSON

func (c *CriuEntry) MarshalJSON() ([]byte, error)

MarshalJSON is the marshaler for CriuEntry. This is required as protojson.Marshal is used for the proto.Message, and any extra data is manually appended to the entry

type CriuImage

type CriuImage struct {
	Magic     string        `json:"magic"`
	Entries   []*CriuEntry  `json:"entries"`
	EntryType proto.Message `json:"-"`
}

CriuImage represents a CRIU binary image file

func (*CriuImage) UnmarshalJSON

func (img *CriuImage) UnmarshalJSON(data []byte) error

UnmarshalJSON is the unmarshaler for CriuImage. This is required as the object must be checked for any extra data, which must be removed from the JSON byte stream before unmarshaling the remaining bytes into a proto.Message object

type Fd

type Fd struct {
	PId   uint32  `json:"pid"`
	Files []*File `json:"files,omitempty"`
}

Fd represents the file descriptors opened in a single process

type File

type File struct {
	Fd   string `json:"fd"`
	Type string `json:"type,omitempty"`
	Path string `json:"path"`
}

File represents a single opened file

type Mem

type Mem struct {
	Start      string `json:"start"`
	End        string `json:"end"`
	Protection string `json:"protection"`
	Resource   string `json:"resource,omitempty"`
}

Mem represents the memory mapping of a single file

type MemMap

type MemMap struct {
	PId  uint32 `json:"pid"`
	Exe  string `json:"exe"`
	Mems []*Mem `json:"mems,omitempty"`
}

MemMap represents the memory mapping of a single process

type MemoryReader

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

MemoryReader is a struct used to retrieve the content of memory associated with a specific process ID (pid). New instances should be created with NewMemoryReader()

func NewMemoryReader

func NewMemoryReader(checkpointDir string, pid uint32, pageSize int) (*MemoryReader, error)

NewMemoryReader creates a new instance of MemoryReader with all the fields populated

func (*MemoryReader) GetMemPages

func (mr *MemoryReader) GetMemPages(start, end uint64) (*bytes.Buffer, error)

GetMemPages retrieves the content of memory pages associated with a given process ID (pid). It retrieves the memory content within the specified range defined by the start and end addresses.

func (*MemoryReader) GetPagemapEntries

func (mr *MemoryReader) GetPagemapEntries() []*pagemap.PagemapEntry

func (*MemoryReader) GetPagesID

func (mr *MemoryReader) GetPagesID() uint32

func (*MemoryReader) GetPsArgs

func (mr *MemoryReader) GetPsArgs() (*bytes.Buffer, error)

GetPsArgs retrieves process arguments from memory pages

func (*MemoryReader) GetPsEnvVars

func (mr *MemoryReader) GetPsEnvVars() (*bytes.Buffer, error)

GetPsArgs retrieves process environment variables from memory pages.

func (*MemoryReader) GetShmemSize

func (mr *MemoryReader) GetShmemSize() (int64, error)

GetShmemSize calculates and returns the size of shared memory used by the process.

type PsTree

type PsTree struct {
	PID      uint32               `json:"pid"`
	PgID     uint32               `json:"pgid"`
	SID      uint32               `json:"sid"`
	Comm     string               `json:"comm"`
	Process  *pstree.PstreeEntry  `json:"-"`
	Core     *criu_core.CoreEntry `json:"-"`
	Children []*PsTree            `json:"children,omitempty"`
}

PsTree represents the process tree

func (*PsTree) FindPs

func (ps *PsTree) FindPs(pid uint32) *PsTree

FindPs performs a short-circuiting depth-first search to find a process with a given PID in a process tree.

type Rss

type Rss struct {
	PhyAddr  string `json:"phy_addr,omitempty"`
	PhyPages int64  `json:"phy_pages,omitempty"`
	Vmas     []*Vma `json:"vmas,omitempty"`
	Resource string `json:"resource,omitempty"`
}

Rss represents a single resident set size mapping

type RssMap

type RssMap struct {
	PId uint32 `json:"pid"`
	/*
		walrus -> walruses
		radius -> radii
		If you code without breaks,
		rss -> rsi :P
	*/
	Rsses []*Rss `json:"rss,omitempty"`
}

RssMap represents the resident set size mapping of a single process

type Sk

type Sk struct {
	PId     uint32    `json:"pid"`
	Sockets []*Socket `json:"sockets"`
}

Sk represents the sockets associated with a single process

type Socket

type Socket struct {
	Fd       uint32 `json:"fd"`
	FdType   string `json:"fd_type"`
	Family   string `json:"family,omitempty"`
	Protocol string `json:"protocol,omitempty"`
	Type     string `json:"type,omitempty"`
	State    string `json:"state,omitempty"`
	SrcAddr  string `json:"src_addr,omitempty"`
	SrcPort  uint32 `json:"src_port,omitempty"`
	DestAddr string `json:"dest_addr,omitempty"`
	DestPort uint32 `json:"dest_port,omitempty"`
	SendBuf  string `json:"send_buf,omitempty"`
	RecvBuf  string `json:"recv_buf,omitempty"`
}

Socket represents a single socket

type Vma

type Vma struct {
	Addr  string `json:"addr,omitempty"`
	Pages int64  `json:"pages,omitempty"`
}

Vma represents a single virtual memory area

Jump to

Keyboard shortcuts

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