providerfc

package
v0.1.35 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2026 License: AGPL-3.0 Imports: 20 Imported by: 0

Documentation

Overview

Package providerfc provides the host-side implementations (process management, networking, rootfs preparation and API access) backing cloud.ProviderFC, plus configuration loading from viper.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetConfig

func GetConfig() cloud.FCConfig

GetConfig reads fc.* settings from viper, applying defaults for anything that isn't set.

func NewAPIClient

func NewAPIClient() cloud.FCAPI

NewAPIClient returns a cloud.FCAPI that talks to firecracker over its API socket.

func NewCacheDiskPreparer added in v0.1.32

func NewCacheDiskPreparer() cloud.CacheDiskPreparer

NewCacheDiskPreparer returns a cloud.CacheDiskPreparer backed by reflink copies and mkfs.ext4.

func NewNetworkManager

func NewNetworkManager() cloud.NetworkManager

NewNetworkManager returns a cloud.NetworkManager backed by `ip`.

func NewProcessManager

func NewProcessManager(binPath string) cloud.FCProcess

NewProcessManager returns a cloud.FCProcess backed by the firecracker binary at binPath ("firecracker" if empty).

func NewRootfsPreparer

func NewRootfsPreparer() cloud.RootfsPreparer

NewRootfsPreparer returns a cloud.RootfsPreparer backed by `debugfs`.

Types

type APIClient

type APIClient struct{}

APIClient is the real cloud.FCAPI implementation.

func (APIClient) CreateSnapshot added in v0.1.32

func (APIClient) CreateSnapshot(socketPath, snapshotPath, memFilePath string) error

func (APIClient) LoadSnapshot added in v0.1.32

func (APIClient) LoadSnapshot(socketPath, snapshotPath, memFilePath string, resume bool, overrides []cloud.FCNetworkOverride) error

func (APIClient) SetState

func (APIClient) SetState(socketPath, state string) error

type DebugfsRootfsPreparer

type DebugfsRootfsPreparer struct{}

DebugfsRootfsPreparer is the real cloud.RootfsPreparer implementation: it copies the base rootfs image and injects the SSH public key with debugfs, avoiding the need to mount the image (and therefore root) on the host.

func (DebugfsRootfsPreparer) BaseImageIdentity added in v0.1.34

func (DebugfsRootfsPreparer) BaseImageIdentity(baseImage string) (sha256Hex string, sizeBytes int64, err error)

func (DebugfsRootfsPreparer) GrowRootfs added in v0.1.34

func (DebugfsRootfsPreparer) GrowRootfs(rootfsPath string, sizeMib int64) error

GrowRootfs extends rootfsPath to sizeMib with a sparse truncate, then grows its ext4 filesystem offline with resize2fs (e2fsprogs, the same package debugfs comes from). resize2fs refuses to grow an image that hasn't just been checked, hence the e2fsck -f first.

func (DebugfsRootfsPreparer) Prepare

func (DebugfsRootfsPreparer) Prepare(baseImage, destPath, hostname, sshPublicKey, username string) error

type LinuxNetworkManager

type LinuxNetworkManager struct{}

LinuxNetworkManager is the real cloud.NetworkManager implementation, shelling out to `ip` (iproute2). Creating bridges and TAP devices requires CAP_NET_ADMIN (typically root).

func (LinuxNetworkManager) CreateTap

func (LinuxNetworkManager) CreateTap(tapName, bridge string) error

func (LinuxNetworkManager) DeleteTap

func (LinuxNetworkManager) DeleteTap(tapName string) error

func (LinuxNetworkManager) EnsureBridge

func (LinuxNetworkManager) EnsureBridge(bridge, cidr string) error

func (LinuxNetworkManager) ForgetNeighbor added in v0.1.35

func (LinuxNetworkManager) ForgetNeighbor(bridge, ip string) error

type ProcessManager

type ProcessManager struct {
	BinPath string
}

ProcessManager is the real cloud.FCProcess implementation: it spawns the firecracker binary, configures it over its API socket and manages the resulting OS process.

func (ProcessManager) IsRunning

func (m ProcessManager) IsRunning(pid int) bool

func (ProcessManager) Owns

func (m ProcessManager) Owns(pid int, socketPath string) bool

Owns reports whether pid is a firecracker process bound to socketPath, by checking its command line for a "--api-sock socketPath" argument pair. This guards against a persisted PID having been reused by an unrelated host process after a VMM exit or host reboot.

func (ProcessManager) Start

func (m ProcessManager) Start(socketPath string, cfg cloud.FCVMConfig, logFile string) (int, error)

func (ProcessManager) StartBare added in v0.1.32

func (m ProcessManager) StartBare(socketPath, logFile string) (int, error)

func (ProcessManager) Stop

func (m ProcessManager) Stop(pid int) error

type ReflinkCacheDiskPreparer added in v0.1.32

type ReflinkCacheDiskPreparer struct{}

ReflinkCacheDiskPreparer is the real cloud.CacheDiskPreparer implementation. It clones the golden cache image into a per-VM copy via a copy-on-write reflink (`cp --reflink=always`), so attaching a multi-GB pre-warmed cache costs the same near-zero time regardless of image size — a plain byte-for-byte copy here would defeat the point of pre-warming (every VM boot would pay the full copy cost up front). Requires a CoW-capable host filesystem (btrfs, or XFS with reflink=1) — fc-host already relies on btrfs for VM state.

func (ReflinkCacheDiskPreparer) MergeBack added in v0.1.32

func (ReflinkCacheDiskPreparer) MergeBack(vmCachePath, goldenImage string) error

func (ReflinkCacheDiskPreparer) Prepare added in v0.1.32

func (ReflinkCacheDiskPreparer) Prepare(goldenImage, destPath string, sizeMib int64) error

Jump to

Keyboard shortcuts

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