daemon

package
v0.0.0-...-6d47f5a Latest Latest
Warning

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

Go to latest
Published: Mar 20, 2022 License: MIT Imports: 30 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddMincoreLayer

func AddMincoreLayer(req *http.Request, ssID string, position int, fromDiff string) error

func ChangeMincoreState

func ChangeMincoreState(ctx context.Context, ssID string, fromRecordSize int, trimRegions bool, toWsFile string, inactiveWs, zeroWs bool, sizeThreshold, intervalThreshold int, nlayers []int64, dropWsCache bool) error

func ChangeReapCacheState

func ChangeReapCacheState(req *http.Request, ssID string, cache bool) error

func ChangeSnapshot

func ChangeSnapshot(req *http.Request, ssID string, digHole, loadCache, dropCache bool) error

func CopyFile

func CopyFile(dst, src string) error

func CopyMincore

func CopyMincore(req *http.Request, ssID string, source string) error

func CopySnapshot

func CopySnapshot(ctx context.Context, fromSnapshot, memFilePath string) (*models.Snapshot, error)

func CreateFunction

func CreateFunction(params operations.PostFunctionsParams) error

func DoStartVM

func DoStartVM(ctx context.Context, function, namespace string) (string, error)

func FileMincore

func FileMincore(f *os.File, size int64) ([]bool, error)

func InvokeFunction

func InvokeFunction(req *http.Request, invoc *models.Invocation) (string, string, string, error)

func LoadSnapshot

func LoadSnapshot(req *http.Request, invoc *models.Invocation, reapId string) (string, error)

func PutNetwork

func PutNetwork(req *http.Request, namespace, hostDevName, ifaceId, guestMac, guestAddr, uniqueAddr string) error

func RandStringRunes

func RandStringRunes(n int) string

func ScanFileMincore

func ScanFileMincore(f *os.File, size int64, startLayer int, interval int, stop chan bool) ([]int, int, error)

func ScanFileMincoreBySize

func ScanFileMincoreBySize(f *os.File, size int64, startLayer int, pid, sizeIncr int, stop chan bool) ([]int, int, error)

func StartVM

func StartVM(req *http.Request, name, ssId, namespace string) (string, error)

func StartVMM

func StartVMM(ctx context.Context, enableReap bool, namespace string) (string, error)

func StopVM

func StopVM(req *http.Request, vmID string) error

func TakeSnapshot

func TakeSnapshot(req *http.Request, vmID string, snapshotType string, snapshotPath string, memFilePath string, version string, recordRegions bool, sizeThreshold, intervalThreshold int) (string, error)

Types

type BootSource

type BootSource struct {
	KernelImagePath string `json:"kernel_image_path"`
	BootArgs        string `json:"boot_args"`
}

type Config

type Config struct {
	LogLevel    string            `json:"log_level"`
	BasePath    string            `json:"base_path"`
	Images      map[string]string `json:"images"`
	Kernels     map[string]string `json:"kernels"`
	Executables map[string]string `json:"executables"`
	RedisHost   string            `json:"redis_host"`
	RedisPasswd string            `json:"redis_passwd"`
}

type DaemonState

type DaemonState struct {
	FnManager       *FunctionManager `json:"functionManager"`
	VmController    *VMController    `json:"vmController"`
	SnapshotManager *SnapshotManager `json:"snapshotManager"`
	Config          *Config          `json:"config"`
}

func Setup

func Setup(s *http.Server, scheme, addr string) *DaemonState

type Drive

type Drive struct {
	DriveId      string `json:"drive_id"`
	PathOnHost   string `json:"path_on_host"`
	IsRootDevice bool   `json:"is_root_device"`
	IsReadOnly   bool   `json:"is_read_only"`
}

type Function

type Function struct {
	Name    string `json:"name"`
	Kernel  string `json:"kernel"`
	Image   string `json:"image"`
	Vcpu    int    `json:"vcpu"`
	MemSize int    `json:"memSize"`
}

type FunctionManager

type FunctionManager struct {
	sync.Mutex
	Functions map[string]*Function `json:"functions"`
	// contains filtered or unexported fields
}

func NewFunctionManager

func NewFunctionManager(config *Config) *FunctionManager

func (*FunctionManager) CreateFunction

func (fm *FunctionManager) CreateFunction(name string, kernel string, image string, vcpu, memSize int) error

type MachineConfig

type MachineConfig struct {
	VcpuCount       int  `json:"vcpu_count"`
	MemSizeMib      int  `json:"mem_size_mib"`
	HtEnabled       bool `json:"ht_enabled"`
	TrackDirtyPages bool `json:"track_dirty_pages"`
}

type Network

type Network struct {
	HostDevName string `json:"host_dev_name"`
	IfaceId     string `json:"iface_id"`
	GuestMac    string `json:"guest_mac"`
	// contains filtered or unexported fields
}

type Snapshot

type Snapshot struct {
	sync.Mutex
	Function    string `json:"function"`
	MemFilePath string `json:"memFilePath"`

	WsFile       string `json:"wsFile"`
	Size         int    `json:"size"`
	BlockSize    int    `json:"blockSize"`
	SnapshotBase string `json:"snapshotBase"`
	SnapshotType string `json:"snapshotType"`
	SnapshotId   string `json:"snapshotId"`
	SnapshotPath string `json:"snapshotPath"`
	Version      string `json:"functionVersion"`
	// contains filtered or unexported fields
}

func (*Snapshot) EmulateMincore

func (snapshot *Snapshot) EmulateMincore(ctx context.Context, mincoreSize int) error

func (*Snapshot) GetNonZeroRegions

func (snapshot *Snapshot) GetNonZeroRegions(buf []byte, blockSize, sizeThreshold, intervalThreshold int)

func (*Snapshot) InsertMincoreLayer

func (snapshot *Snapshot) InsertMincoreLayer(layer []bool, position int) error

func (*Snapshot) PreWarmMincore

func (snapshot *Snapshot) PreWarmMincore(ctx context.Context, nlayers []int64) error

func (*Snapshot) RecordRegions

func (snapshot *Snapshot) RecordRegions(ctx context.Context, sizeThreshold, intervalThreshold int) error

func (*Snapshot) ScanMincore

func (snapshot *Snapshot) ScanMincore(r *http.Request, pid, scanInterval, sizeIncr int, finished chan bool) error

func (*Snapshot) TrimMincoreRegions

func (snapshot *Snapshot) TrimMincoreRegions(ctx context.Context) error

func (*Snapshot) UpdateCacheState

func (snapshot *Snapshot) UpdateCacheState(digHole, loadCache, dropCache bool) error

type SnapshotManager

type SnapshotManager struct {
	sync.Mutex
	Snapshots map[string]*Snapshot `json:"snapshots"`
	// contains filtered or unexported fields
}

func NewSnapshotManager

func NewSnapshotManager(config *Config) *SnapshotManager

func (*SnapshotManager) AddMincoreLayer

func (sm *SnapshotManager) AddMincoreLayer(req *http.Request, ssID string, position int, fromDiff string) error

func (*SnapshotManager) CopyMincore

func (sm *SnapshotManager) CopyMincore(r *http.Request, dst string, src string) error

func (*SnapshotManager) CopySnapshot

func (sm *SnapshotManager) CopySnapshot(ctx context.Context, src, memFilePath string) (*models.Snapshot, error)

func (*SnapshotManager) GetMincore

func (*SnapshotManager) RegisterSnapshot

func (sm *SnapshotManager) RegisterSnapshot(snapshot *Snapshot) error

type VM

type VM struct {
	sync.Mutex
	VmId        string    `json:"vmId"`
	Function    string    `json:"function"`
	State       string    `json:"state"`
	Socket      string    `json:"socket"`
	VMNetwork   *Network  `json:"net"`
	VmConf      *VmConfig `json:"vmConf"`
	VmPath      string    `json:"vmPath"`
	MincoreSize int       `json:"mincoreSize"`
	ReapId      string    `json:"reapId"`

	Snapshot *Snapshot
	// contains filtered or unexported fields
}

func (*VM) Dial

func (vm *VM) Dial() error

type VMController

type VMController struct {
	sync.Mutex

	BasePath string              `json:"basePath"`
	Machines map[string]*VM      `json:"machines"`
	Networks map[string]*Network `json:"netInterfaces"`
	VMMPool  map[string]*VM      `json:"vmmPool"`
	// contains filtered or unexported fields
}

func NewVMController

func NewVMController(config *Config) *VMController

func (*VMController) AddNetwork

func (vc *VMController) AddNetwork(req *http.Request, namespace, hostDevName, ifaceId, guestMac, guestAddr, uniqueAddr string) error

func (*VMController) InvokeFunction

func (vc *VMController) InvokeFunction(r *http.Request, vmID string, function string, params string) (string, error)

func (*VMController) LoadSnapshot

func (vc *VMController) LoadSnapshot(r *http.Request, snapshot *Snapshot, invoc *models.Invocation, reapId string) (string, error)

func (*VMController) StartVM

func (vc *VMController) StartVM(ctx *context.Context, function, kernel, image, namespace string, vcpu, memSize int) (string, error)

func (*VMController) StartVMM

func (vc *VMController) StartVMM(ctx context.Context, enableReap bool, namespace string) (string, error)

func (*VMController) StopVM

func (vc *VMController) StopVM(req *http.Request, vmID string) error

func (*VMController) TakeSnapshot

func (vc *VMController) TakeSnapshot(r *http.Request, vmID string, snap *Snapshot) error

type VmConfig

type VmConfig struct {
	BootSource    BootSource    `json:"boot-source"`
	Drives        []Drive       `json:"drives"`
	MachineConfig MachineConfig `json:"machine-config"`
	Networks      []Network     `json:"network-interfaces"`
}

Jump to

Keyboard shortcuts

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