hardware

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2026 License: Apache-2.0 Imports: 12 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package hardware probes host hardware compatibility attributes and evaluates sandbox runtime compatibility between workers and snapshots.

Index

Constants

View Source
const (
	// SchemaVersionV1 is the initial compatibility schema version.
	SchemaVersionV1 = "v1"

	// AttrArchitecture is the CPU architecture ("amd64", "arm64", etc.).
	AttrArchitecture = "architecture"

	// AttrSandboxBundleHash identifies the sandbox runtime bundle: a
	// sha256 over a SandboxConfig version's asset digests, computed by atelet.
	AttrSandboxBundleHash = "sandbox_bundle_hash"

	// AttrCPUFeatures is the set of CPU features `runsc cpu-features` reports
	// for a gVisor runtime, encoded by EncodeCPUFeatures as a hex bitmask over
	// the architecture's feature table. A snapshot's set must be a subset of
	// the worker's.
	AttrCPUFeatures = "cpu_features"

	// AttrCPUVendor identifies the host CPU vendor (e.g. "GenuineIntel",
	// "AuthenticAMD", or arm64 implementer "0x41") reported by microVM
	// runtimes.
	AttrCPUVendor = "cpu_vendor"

	// AttrCPUModel identifies the host CPU family/model (e.g. "6:143" on amd64
	// or "0x0:0xd40:1" on arm64) reported by microVM runtimes.
	AttrCPUModel = "cpu_model"
)

Variables

This section is empty.

Functions

func ColdBootRuntime

func ColdBootRuntime(status *ateapipb.WorkerStatus) *ateapipb.ActorSandboxRuntime

ColdBootRuntime returns the runtime a fresh actor starts under on a worker with status: the DefaultRuntime of its class, as a stamp, or nil before the worker has registered.

func DecodeCPUFeatures

func DecodeCPUFeatures(arch, value string) ([]string, error)

DecodeCPUFeatures returns the feature names a cpu_features value encodes for arch, in bit order. A set bit with no name is an error: the hardware reserves it, so no encoder of this schema could have produced the value.

func EncodeCPUFeatures

func EncodeCPUFeatures(arch string, features []string) (string, error)

EncodeCPUFeatures encodes the feature names `runsc cpu-features` printed for arch as a cpu_features value. Blank names are skipped; duplicates and order do not matter. An unknown name is an error rather than a dropped bit: a snapshot encoded without a feature its sandbox used would match workers that lack it.

func Matches

func Matches(rt, snap *ateapipb.ActorSandboxRuntime) bool

Matches reports whether rt, the runtime an assignment records, can restore a snapshot stamped with snap, for one comparison; a caller holding one snap against many workers should prepare a Requirement once. A nil snap imposes no constraint.

func MatchesCompat

func MatchesCompat(worker, snap *ateapipb.VersionedSandboxCompat) bool

MatchesCompat reports whether worker can restore a snapshot stamped with snap, for one comparison. Unlike Matches, a nil snap is a stamp missing its identity and matches nothing.

func MatchingRuntime

MatchingRuntime is NewRequirement(snap).MatchingRuntime(status).

func ProbeCPUIdentity

func ProbeCPUIdentity() (vendor, model string, err error)

ProbeCPUIdentity reads /proc/cpuinfo for the host CPU's vendor and model: the AttrCPUVendor and AttrCPUModel values of a microVM runtime.

func ProbeHost

func ProbeHost() *ateletpb.VersionedSandboxCompat

ProbeHost returns a minimal v1 VersionedSandboxCompat with the current host's architecture in atelet wire format, for synthetic workers in tests and benchmarks. Production workers report the attributes atelet writes to sandbox-runtimes.json instead.

func RuntimeFor

RuntimeFor is NewRequirement(snap).RuntimeFor(status).

func SandboxClass

func SandboxClass(status *ateapipb.WorkerStatus) string

SandboxClass returns the sandbox class a worker with status registered, or "" before it has.

func WorkerMatches

func WorkerMatches(status *ateapipb.WorkerStatus, snap *ateapipb.ActorSandboxRuntime) bool

WorkerMatches is NewRequirement(snap).WorkerMatches(status).

Types

type Requirement

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

Requirement is what a worker must run to restore a snapshot: the ActorSandboxRuntime the snapshot was stamped with, prepared for matching against many workers. The scheduler asks it once per candidate, so the snapshot's AttrCPUFeatures is parsed here, once, rather than on every comparison. The zero Requirement, like NewRequirement(nil), requires nothing.

func NewRequirement

func NewRequirement(snap *ateapipb.ActorSandboxRuntime) Requirement

NewRequirement prepares snap for matching. A nil snap requires nothing.

func (Requirement) Matches

Matches reports whether rt, the runtime an assignment records, can restore the snapshot. A requirement of nothing is met by any runtime. Otherwise the sandbox classes must be equal and the compat must match.

func (Requirement) MatchingRuntime

func (r Requirement) MatchingRuntime(status *ateapipb.WorkerStatus) *ateapipb.ActorSandboxRuntime

MatchingRuntime returns the runtime from status that can restore the snapshot, as a stamp: the snapshot's class with the version matchingCompat finds, or nil when it finds none. A requirement of nothing returns ColdBootRuntime.

func (Requirement) Runtime

Runtime returns the ActorSandboxRuntime the requirement was prepared from, or nil when it requires nothing.

func (Requirement) RuntimeFor

RuntimeFor returns the runtime a worker with status runs an actor under whose snapshot is stamped with the required runtime: the matching runtime when it can restore the snapshot, else the ColdBootRuntime the guest boots fresh under. This is what an assignment records and what the actor's next checkpoint is stamped with.

func (Requirement) WorkerMatches

func (r Requirement) WorkerMatches(status *ateapipb.WorkerStatus) bool

WorkerMatches reports whether a worker with status can restore the snapshot. A requirement of nothing is met by any worker.

Jump to

Keyboard shortcuts

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