firecracker

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: May 20, 2026 License: MIT Imports: 26 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DevPath added in v0.3.9

func DevPath(idx int) string

DevPath maps idx to vda..vdz, vdaa..vdaz, vdba..vdbz, ...

func EnsureVmlinux

func EnsureVmlinux(kernelPath string) (string, error)

EnsureVmlinux decompresses kernelPath if needed and returns the ELF path.

func IsRelayMode

func IsRelayMode() bool

IsRelayMode returns true when the process was started as a console relay.

func RunRelay

func RunRelay(ctx context.Context)

RunRelay runs the console relay loop. Inherits fd 3 (PTY master), fd 4 (console.sock listener), $_COCOON_FC_PID. A single persistent goroutine reads the PTY and broadcasts to the active session so disconnects don't strand readers.

Types

type Config

type Config struct {
	hypervisor.BaseConfig
}

Config holds Firecracker specific configuration.

func NewConfig added in v0.3.1

func NewConfig(conf *config.Config) *Config

NewConfig creates a Config from a global config.

func (*Config) BinaryName

func (c *Config) BinaryName() string

func (*Config) COWRawPath

func (c *Config) COWRawPath(vmID string) string

func (*Config) PIDFileName

func (c *Config) PIDFileName() string

type Firecracker

type Firecracker struct {
	*hypervisor.Backend
	// contains filtered or unexported fields
}

Firecracker implements hypervisor.Hypervisor using the Firecracker VMM. Only OCI images (direct kernel boot) are supported — no UEFI, no cloudimg, no Windows.

func New

func New(conf *config.Config, rec metering.Recorder) (*Firecracker, error)

New creates a Firecracker backend. rec may be nil; the backend falls back to NopRecorder for emit calls.

func (*Firecracker) Clone

func (fc *Firecracker) Clone(ctx context.Context, vmID string, vmCfg *types.VMConfig, net types.NetSetup, snapshotConfig *types.SnapshotConfig, snapshot io.Reader) (*types.VM, error)

func (*Firecracker) Console

func (fc *Firecracker) Console(ctx context.Context, ref string) (io.ReadWriteCloser, error)

func (*Firecracker) Create

func (fc *Firecracker) Create(ctx context.Context, id string, vmCfg *types.VMConfig, storageConfigs []*types.StorageConfig, net types.NetSetup, bootCfg *types.BootConfig) (*types.VM, error)

func (*Firecracker) Delete

func (fc *Firecracker) Delete(ctx context.Context, refs []string, force bool) ([]string, error)

Delete removes VMs. Running VMs require force=true (stops them first).

func (*Firecracker) DirectClone

func (fc *Firecracker) DirectClone(ctx context.Context, vmID string, vmCfg *types.VMConfig, net types.NetSetup, snapshotConfig *types.SnapshotConfig, srcDir string) (*types.VM, error)

DirectClone clones from a local snapshot dir. Per-type: hardlink mem, reflink/copy COW, plain copy metadata.

func (*Firecracker) DirectRestore

func (fc *Firecracker) DirectRestore(ctx context.Context, vmRef string, vmCfg *types.VMConfig, srcDir, sourceSnapshotID string) (*types.VM, error)

func (*Firecracker) Restore

func (fc *Firecracker) Restore(ctx context.Context, vmRef string, vmCfg *types.VMConfig, snapshot io.Reader, sourceSnapshotID string) (*types.VM, error)

func (*Firecracker) Snapshot

func (fc *Firecracker) Snapshot(ctx context.Context, ref string) (*types.SnapshotConfig, io.ReadCloser, error)

Snapshot pauses, captures vmstate+mem+COW, resumes, and streams the result.

func (*Firecracker) Start

func (fc *Firecracker) Start(ctx context.Context, refs []string) ([]string, error)

Start launches FC, configures via REST, then InstanceStart.

func (*Firecracker) Stop

func (fc *Firecracker) Stop(ctx context.Context, refs []string) ([]string, error)

Stop shuts down each FC: SendCtrlAltDel + --timeout wait, or --force for immediate kill.

Jump to

Keyboard shortcuts

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