storage

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2026 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultGuestAgentPath = "/usr/local/bin/herd-guest-agent"

DefaultGuestAgentPath is where the binary is placed inside the VM rootfs and must match the kernel boot arg init=...

Variables

This section is empty.

Functions

func Bootstrap

func Bootstrap(stateDir string) (err error)

Bootstrap devmapper and containerd requirements given a working dir.

func Teardown

func Teardown(stateDir string) error

Teardown intentionally destroys previously bootstrapped devmapper/containerd state in strict reverse dependency order.

Types

type ImageConfig

type ImageConfig struct {
	Entrypoint []string
	Cmd        []string
	Env        []string
}

ImageConfig holds the default container execution parameters.

type Manager

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

Manager mediates between herd and containerd for rootfs provisioning.

Lifecycle:

  1. Call WarmImage on demand to pull/cache an image.
  2. Call Snapshot per-VM to create a copy-on-write block device from the cached image.
  3. Call Teardown per-VM when the VM is destroyed.

func NewManager

func NewManager(client *containerd.Client, namespace, snapshotter string) *Manager

func (*Manager) ExtractImageConfig

func (m *Manager) ExtractImageConfig(ctx context.Context, imageRef string) (*ImageConfig, error)

ExtractImageConfig asks containerd to parse the OCI image metadata and returns the default Entrypoint, Cmd, and Env baked into the image.

func (*Manager) InjectGuestAgent

func (m *Manager) InjectGuestAgent(ctx context.Context, vmID, hostBinaryPath, guestPath string) error

InjectGuestAgent mounts the snapshot's root filesystem on the host, copies a static herd-guest-agent binary into the image, then unmounts. Required for initrd-less boot (kernel runs init from ext4).

func (*Manager) Snapshot

func (m *Manager) Snapshot(ctx context.Context, vmID, imageRef string) (string, error)

Snapshot creates a copy-on-write devmapper thin-volume for a single VM, derived from the parent image cached by WarmImage.

It returns the host path to the block device (e.g. /dev/dm-X). This is a pure local operation — no registry or network calls.

func (*Manager) Teardown

func (m *Manager) Teardown(ctx context.Context, vmID string) error

Teardown safely releases the VM's lease, allowing containerd's garbage collector to destroy the block device.

func (*Manager) WarmImage

func (m *Manager) WarmImage(ctx context.Context, imageRef string) error

WarmImage ensures the base image is present in the local content store and unpacked for the configured snapshotter. It caches the parent chain ID so that subsequent Snapshot calls never touch the network.

Jump to

Keyboard shortcuts

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