firecracker

package
v0.0.7 Latest Latest
Warning

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

Go to latest
Published: Mar 3, 2026 License: MIT Imports: 22 Imported by: 0

README

Firecracker Hypervisor

This package implements Firecracker support behind the common lib/hypervisor interfaces:

  • Starter (process.go): starts/restores a Firecracker process and waits for the API socket.
  • Firecracker client (firecracker.go): configures boot, controls lifecycle, and manages snapshots.
  • VsockDialer (vsock.go): host-initiated vsock connections via Firecracker's UDS handshake.
  • Config translation (config.go): maps hypervisor.VMConfig to Firecracker API models.

Binaries

Like Cloud Hypervisor, Firecracker binaries are embedded and extracted into data_dir at runtime.

  • Embedded source path: lib/hypervisor/firecracker/binaries/firecracker/<version>/<arch>/firecracker
  • Download helper: make download-firecracker-binaries
  • Runtime override: hypervisor.firecracker_binary_path (uses external binary instead of embedded)

VM State Mapping

mapVMState() maps Firecracker GET / state strings to internal states:

  • Not started -> created
  • Running -> running
  • Paused -> paused

These strings are validated against Firecracker's source/spec:

  • src/vmm/src/vmm_config/instance_info.rs
  • src/firecracker/swagger/firecracker.yaml

Rate Limits

Instance bandwidth limits are still instance-level API inputs, but are propagated into per-interface hypervisor.NetworkConfig so Firecracker can program device rate limiters. Host-level traffic shaping remains handled by Hypeman's network manager.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewVsockDialer

func NewVsockDialer(vsockSocket string, vsockCID int64) hypervisor.VsockDialer

func SetCustomBinaryPath

func SetCustomBinaryPath(path string)

SetCustomBinaryPath configures a runtime override for the firecracker binary. When set, this path always takes precedence over embedded binaries.

Types

type Firecracker

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

Firecracker implements hypervisor.Hypervisor for the Firecracker VMM.

func New

func New(socketPath string) (*Firecracker, error)

func (*Firecracker) Capabilities

func (f *Firecracker) Capabilities() hypervisor.Capabilities

func (*Firecracker) DeleteVM

func (f *Firecracker) DeleteVM(ctx context.Context) error

func (*Firecracker) GetVMInfo

func (f *Firecracker) GetVMInfo(ctx context.Context) (*hypervisor.VMInfo, error)

func (*Firecracker) Pause

func (f *Firecracker) Pause(ctx context.Context) error

func (*Firecracker) ResizeMemory

func (f *Firecracker) ResizeMemory(ctx context.Context, bytes int64) error

func (*Firecracker) ResizeMemoryAndWait

func (f *Firecracker) ResizeMemoryAndWait(ctx context.Context, bytes int64, timeout time.Duration) error

func (*Firecracker) Resume

func (f *Firecracker) Resume(ctx context.Context) error

func (*Firecracker) Shutdown

func (f *Firecracker) Shutdown(ctx context.Context) error

func (*Firecracker) Snapshot

func (f *Firecracker) Snapshot(ctx context.Context, destPath string) error

type Starter

type Starter struct{}

Starter implements hypervisor.VMStarter for Firecracker.

func NewStarter

func NewStarter() *Starter

func (*Starter) GetBinaryPath

func (s *Starter) GetBinaryPath(p *paths.Paths, version string) (string, error)

func (*Starter) GetVersion

func (s *Starter) GetVersion(p *paths.Paths) (string, error)

func (*Starter) PrepareFork

PrepareFork updates Firecracker restore metadata for forked snapshots. Firecracker snapshot restore supports network overrides, but does not expose a public API for rewriting other snapshotted device paths. For standby/running forks, we persist source/target directory mapping so RestoreVM can temporarily alias source paths during snapshot load.

func (*Starter) RestoreVM

func (s *Starter) RestoreVM(ctx context.Context, p *paths.Paths, version string, socketPath string, snapshotPath string) (int, hypervisor.Hypervisor, error)

func (*Starter) SocketName

func (s *Starter) SocketName() string

func (*Starter) StartVM

func (s *Starter) StartVM(ctx context.Context, p *paths.Paths, version string, socketPath string, config hypervisor.VMConfig) (int, hypervisor.Hypervisor, error)

type Version

type Version string
const (
	V1_14_2 Version = "v1.14.2"
)

type VsockDialer

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

func (*VsockDialer) DialVsock

func (d *VsockDialer) DialVsock(ctx context.Context, port int) (net.Conn, error)

func (*VsockDialer) Key

func (d *VsockDialer) Key() string

Jump to

Keyboard shortcuts

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