core

package
v0.5.7 Latest Latest
Warning

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

Go to latest
Published: Jul 27, 2026 License: MIT Imports: 42 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CaptureSnapshot added in v0.4.8

func CaptureSnapshot(ctx context.Context, cmd *cobra.Command, snapBackend snapshot.Snapshot, capture func() (*types.SnapshotConfig, string, error)) (string, error)

CaptureSnapshot checks the --name preflight, runs capture, and persists the capture dir, returning the stored snapshot id.

func CloneVMConfigFromFlags

func CloneVMConfigFromFlags(cmd *cobra.Command, snapCfg types.SnapshotConfig) (*types.VMConfig, error)

func CloseMetaStore added in v0.5.4

func CloseMetaStore(ctx context.Context)

CloseMetaStore ends the store's unified lifecycle at command teardown (design §10 P0); a process that never opened it is a no-op.

func CloseOnCancel added in v0.4.1

func CloseOnCancel(ctx context.Context, c io.Closer) func() bool

CloseOnCancel closes c when ctx is canceled; callers `defer CloseOnCancel(ctx, c)()` to stop the watcher on return.

func EnsureFirmwarePath

func EnsureFirmwarePath(conf *config.Config, bootCfg *types.BootConfig)

func EnsureImage added in v0.3.6

func EnsureImage(ctx context.Context, backends []imagebackend.Images, vmCfg *types.VMConfig)

EnsureImage pulls the digest-pinned base if missing; only warns so VerifyBaseFiles surfaces the real error for imported images.

func EnsureSnapshotNameFree added in v0.4.8

func EnsureSnapshotNameFree(ctx context.Context, snapBackend snapshot.Snapshot, name string) error

EnsureSnapshotNameFree validates name and rejects a duplicate; empty passes.

func FindHypervisor added in v0.2.9

func FindHypervisor(ctx context.Context, conf *config.Config, ref string) (hypervisor.Hypervisor, error)

func InitAllHypervisors added in v0.2.9

func InitAllHypervisors(ctx context.Context, conf *config.Config) ([]hypervisor.Hypervisor, error)

func InitBridgeNetwork added in v0.3.2

func InitBridgeNetwork(conf *config.Config, bridgeDev string) (network.Network, error)

func InitHypervisor

func InitHypervisor(ctx context.Context, conf *config.Config) (hypervisor.Hypervisor, error)

func InitImageBackends

func InitImageBackends(ctx context.Context, conf *config.Config) ([]imagebackend.Images, error)

func InitImageBackendsForPull

func InitImageBackendsForPull(ctx context.Context, conf *config.Config) (*oci.OCI, *cloudimg.CloudImg, error)

func InitNetwork

func InitNetwork(conf *config.Config) (network.Network, error)

func InitSnapshot

func InitSnapshot(ctx context.Context, conf *config.Config, opts ...localfile.Option) (snapshot.Snapshot, error)

func LegacyJSONPresent added in v0.5.6

func LegacyJSONPresent(conf *config.Config) bool

LegacyJSONPresent reports whether any json-engine namespace file exists under the root — data a fresh sqlite store must never shadow.

func ListAllVMs added in v0.2.9

func ListAllVMs(ctx context.Context, hypers []hypervisor.Hypervisor) ([]*types.VM, error)

func MetaDBPath added in v0.5.4

func MetaDBPath(conf *config.Config) string

MetaDBPath is the sqlite engine's database under the meta root.

func MetaJSONNamespaces added in v0.5.4

func MetaJSONNamespaces(conf *config.Config) []metajson.Namespace

MetaJSONNamespaces declares the json engine's namespace set: legacy file locations and field mappings, consumed by open and by conversion.

func MetaNamespaces added in v0.5.4

func MetaNamespaces() []metasqlite.Namespace

MetaNamespaces lists every namespace with its tables — the engine-neutral declaration both engines consume.

func MetaStore added in v0.5.4

func MetaStore(conf *config.Config) (meta.Store, error)

MetaStore builds the process-wide meta store once — one store, every namespace — and injects it into every backend (design §10 P0 boundary). The engine follows ResolveMetaBackend; a fresh sqlite root bootstraps itself.

func MeteringRecorder added in v0.4.1

func MeteringRecorder(ctx context.Context, conf *config.Config) metering.Recorder

MeteringRecorder returns the process-wide recorder per conf.Metering.Backend; lazy-init shared across callers.

func NewGCOrchestrator added in v0.5.5

func NewGCOrchestrator(ctx context.Context, conf *config.Config, snapOpts ...localfile.Option) (*gc.Orchestrator, error)

NewGCOrchestrator registers every collector; both hypervisor backends join so a sweep protects blobs pinned by either.

func ParseDirectIO added in v0.4.9

func ParseDirectIO(val string) (*bool, error)

ParseDirectIO maps a directio value (on/off/auto) to the tri-state StorageConfig.DirectIO; auto is nil.

func PersistSnapshotDir added in v0.4.9

func PersistSnapshotDir(ctx context.Context, snapBackend snapshot.Snapshot, cfg *types.SnapshotConfig, srcDir, name, description string) (string, error)

PersistSnapshotDir stores a finalized capture dir, preferring a direct in-place move (DirectCreator) when srcDir shares a filesystem with the backend's data dir, and falling back to a tar stream otherwise (cross-filesystem, or a backend without DirectCreator such as a remote store). srcDir is consumed on every path.

func PersistSnapshotStream added in v0.4.8

func PersistSnapshotStream(ctx context.Context, snapBackend snapshot.Snapshot, cfg *types.SnapshotConfig, stream io.ReadCloser, name, description string) (string, error)

PersistSnapshotStream labels cfg and stores the stream, closing it either way.

func PinEnvelopeBlobs added in v0.5.4

func PinEnvelopeBlobs(ctx context.Context, conf *config.Config, blobIDs map[string]struct{}) (func(), error)

PinEnvelopeBlobs locks envelope-sourced pins (clone/restore --from-dir, snapshot import) on the owning backend; digests with no local blob are skipped.

func ReconcileState

func ReconcileState(vm *types.VM) string

func ResolveImage

func ResolveImage(ctx context.Context, backends []imagebackend.Images, vmCfg *types.VMConfig) ([]*types.StorageConfig, *types.BootConfig, error)

func ResolveImageOwner added in v0.3.1

func ResolveImageOwner(ctx context.Context, backends []imagebackend.Images, ref string) (imagebackend.Images, error)

func ResolveMetaBackend added in v0.5.6

func ResolveMetaBackend(conf *config.Config) string

ResolveMetaBackend returns the effective engine: an explicit setting wins, then an existing store binds (meta.db → sqlite, legacy json files → json), and a fresh root gets sqlite.

func RestoreVMConfigFromFlags

func RestoreVMConfigFromFlags(cmd *cobra.Command, vm *types.VM, snapCfg types.SnapshotConfig) (*types.VMConfig, error)

RestoreVMConfigFromFlags builds VMConfig for restore: resources from the snapshot, Name/Network from the VM (CNI namespace survives restore).

func RouteRefs added in v0.2.9

func RouteRefs(ctx context.Context, hypers []hypervisor.Hypervisor, refs []string) (map[hypervisor.Hypervisor][]string, error)

RouteRefs resolves user refs to (hypervisor → full VM IDs).

func SnapshotNameFlags added in v0.5.0

func SnapshotNameFlags(ctx context.Context, cmd *cobra.Command, snapBackend snapshot.Snapshot) (name, description string, err error)

SnapshotNameFlags reads the --name/--description pair and rejects a taken name.

func VMConfigFromFlags

func VMConfigFromFlags(cmd *cobra.Command, image string) (*types.VMConfig, error)

Types

type BaseHandler

type BaseHandler struct {
	ConfProvider func() *config.Config
}

func (BaseHandler) Conf

func (h BaseHandler) Conf() (*config.Config, error)

func (BaseHandler) Init

type NetProviders added in v0.5.5

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

NetProviders resolves and caches the network provider each VM's record names.

func NetworkSeam added in v0.5.5

func NetworkSeam(conf *config.Config) *NetProviders

NetworkSeam returns the process-wide seam, so both backends share one provider cache.

func (*NetProviders) Cleanup added in v0.5.5

func (n *NetProviders) Cleanup(ctx context.Context, vmID string) error

A partial CNI failure leaves the tombstone for retry or GC to resume.

func (*NetProviders) ForVM added in v0.5.5

func (n *NetProviders) ForVM(vm *types.VM) (network.Network, error)

ForVM picks the provider from the VM's persisted network state.

func (*NetProviders) Quiesce added in v0.5.5

func (n *NetProviders) Quiesce(ctx context.Context, vm *types.VM) error

func (*NetProviders) Recover added in v0.5.5

func (n *NetProviders) Recover(ctx context.Context, vm *types.VM) error

A recover error aborts the launch, since half-built networking strands the guest.

Jump to

Keyboard shortcuts

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