Documentation
¶
Overview ¶
Package hypervisor provides an abstraction layer for virtual machine managers. This allows the instances package to work with different hypervisors (e.g., Cloud Hypervisor, QEMU) through a common interface.
Index ¶
- Constants
- Variables
- func FinishTraceSpan(span trace.Span, err error)
- func LockSnapshotSourceAliasMutation() func()
- func LockSnapshotSourceAliasReaders() func()
- func ProcessEnv() []string
- func RegisterCapabilities(t Type, caps Capabilities)deprecated
- func RegisterClientFactory(t Type, factory ClientFactory)
- func RegisterRuntime(t Type, reg RuntimeRegistration)
- func RegisterSocketName(t Type, name string)
- func RegisterVsockDialerFactory(t Type, factory VsockDialerFactory)
- func RegisterVsockSocketName(t Type, name string)
- func ResolveProcessPID(socketPath string) (pid int, err error)
- func ResolveProcessPIDForOwner(socketPath string, ownerPID int) (pid int, err error)
- func ShouldTraceHypervisorHTTPSpan(method, path string) bool
- func SocketCacheKey(socketPath string) string
- func SocketNameForType(t Type) string
- func StartDetachedTraceSpan(ctx context.Context, tracer trace.Tracer, name string, ...) (context.Context, trace.Span)
- func StartImplementationSpan(ctx context.Context, hvType Type, name string, attrs ...attribute.KeyValue) (context.Context, trace.Span)
- func StartProcessSpan(ctx context.Context, hvType Type) (context.Context, trace.Span)
- func TraceAttributesFromContext(ctx context.Context) []attribute.KeyValue
- func VZShimPIDs(string) ([]int, error)
- func ValidateBootConfig(cfg VMConfig) error
- func ValidateDirectRawConfig(backend string, cfg VMConfig) error
- func VsockSocketNameForType(t Type) string
- func WithTraceAttributes(ctx context.Context, attrs ...attribute.KeyValue) context.Context
- type BalloonTargetCache
- type BootMode
- type CPUTopology
- type Capabilities
- type ClientFactory
- type DiskConfig
- type DiskFormat
- type FirmwareConfig
- type ForkNetworkConfig
- type ForkPrepareRequest
- type ForkPrepareResult
- type GuestMemoryConfig
- type Hypervisor
- type MacOSPlatform
- type NetworkConfig
- type RegisteredRuntime
- type RuntimeRegistration
- type SnapshotSupportValidator
- type TPMConfig
- type Type
- type VMConfig
- type VMInfo
- type VMStarter
- type VMState
- type VsockDialer
- type VsockDialerFactory
Constants ¶
const ( // FeatureSnapshots: snapshot/restore of instance state. FeatureSnapshots = "snapshots" // FeatureStandby: pause + memory snapshot, with later restore. FeatureStandby = "standby" // FeatureFork: cloning an instance from a stopped source. Derived from // the explicit SupportsFork capability, which each backend keeps aligned // with its VMStarter.PrepareFork implementation. Fork of a standby or // running source additionally restores/creates snapshots, so clients // must gate those operations on FeatureStandby as well — vz on macOS 13 // advertises fork (stopped-source clones need no machine-state // save/restore) without snapshots or standby. FeatureFork = "fork" // FeaturePause: pause/resume of a running instance. FeaturePause = "pause" // FeatureHotplugMemory: live memory resize. FeatureHotplugMemory = "hotplug-memory" // FeatureBalloonControl: runtime balloon target changes. FeatureBalloonControl = "balloon-control" // FeatureVsock: guest vsock communication. FeatureVsock = "vsock" // FeatureGPUPassthrough: GPU/PCI device passthrough. FeatureGPUPassthrough = "gpu-passthrough" // FeatureDiskIOLimit: disk I/O rate limiting. FeatureDiskIOLimit = "disk-io-limit" // FeatureDiskResize: live disk resize. FeatureDiskResize = "disk-resize" )
Stable per-runtime feature IDs derived from Capabilities. These are part of the public capabilities API contract: clients gate behavior on these IDs rather than on hypervisor names. Adding a client-visible Capabilities field means adding its ID here, deriving it in FeatureIDs, and documenting it in the OpenAPI CapabilitiesRuntime schema — HTTP handlers never derive feature lists themselves.
const VFIOTermGrace = 5 * time.Second
VFIOTermGrace allows VFIO teardown to finish after SIGTERM before SIGKILL; SIGKILL during initialization can wedge the VF, while teardown takes 1-2s.
Variables ¶
var ( // ErrHypervisorNotRunning is returned when trying to connect to a hypervisor // that is not currently running or cannot be reconnected to. ErrHypervisorNotRunning = errors.New("hypervisor is not running") // ErrNotSupported is returned when an operation is not supported by the hypervisor. ErrNotSupported = errors.New("operation not supported by this hypervisor") )
Common errors
var ErrNoOwningProcess = errors.New("no owning process found")
Functions ¶
func FinishTraceSpan ¶ added in v0.1.0
func LockSnapshotSourceAliasMutation ¶ added in v0.1.0
func LockSnapshotSourceAliasMutation() func()
LockSnapshotSourceAliasMutation serializes the short Firecracker restore window where a snapshotted source guest directory is temporarily replaced by a symlink to the fork being restored.
func LockSnapshotSourceAliasReaders ¶ added in v0.1.0
func LockSnapshotSourceAliasReaders() func()
LockSnapshotSourceAliasReaders blocks source-directory readers while a snapshot source alias mutation is active.
func ProcessEnv ¶ added in v0.4.0
func ProcessEnv() []string
ProcessEnv returns the environment for a VMM or helper process.
func RegisterCapabilities
deprecated
added in
v0.1.0
func RegisterCapabilities(t Type, caps Capabilities)
RegisterCapabilities registers a static capability set for a hypervisor type with no launch check, so registration alone implies launchability.
Deprecated: Use RegisterRuntime, which resolves capabilities per registry read (so configuration applied after init stays truthful) and supports an optional LaunchCheck for host launch prerequisites. RegisterCapabilities is kept so custom backends built against earlier versions of this module keep compiling; it wraps RegisterRuntime with a resolver that returns the given set unchanged.
func RegisterClientFactory ¶ added in v0.0.6
func RegisterClientFactory(t Type, factory ClientFactory)
RegisterClientFactory registers a Hypervisor client factory.
func RegisterRuntime ¶ added in v0.4.0
func RegisterRuntime(t Type, reg RuntimeRegistration)
RegisterRuntime registers a hypervisor backend in the capability registry. Backends must register only on platforms where they can genuinely launch VMs: the Linux backends (cloud-hypervisor, firecracker, qemu) register from linux-only files, and vz registers from its darwin-only package. That keeps RegisteredRuntimes truthful without a hand-maintained platform switch.
func RegisterSocketName ¶
RegisterSocketName registers the socket filename for a hypervisor type. Called by each hypervisor implementation's init() function.
func RegisterVsockDialerFactory ¶
func RegisterVsockDialerFactory(t Type, factory VsockDialerFactory)
RegisterVsockDialerFactory registers a VsockDialer factory for a hypervisor type. Called by each hypervisor implementation's init() function.
func RegisterVsockSocketName ¶ added in v0.0.7
RegisterVsockSocketName registers the vsock socket filename for a hypervisor type.
func ResolveProcessPID ¶ added in v0.1.0
ResolveProcessPID finds the process currently holding the listening Unix socket for the given hypervisor control path, via the socket inode in /proc/net/unix and each process's fd table. The fd scan requires the caller to hold CAP_SYS_PTRACE (or run as root) so no live owner is missed; an ErrNoOwningProcess result is proof the listener is gone.
func ResolveProcessPIDForOwner ¶ added in v0.4.0
ResolveProcessPIDForOwner resolves a socket while preferring an expected owner when the socket descriptor is temporarily shared with a child process.
func ShouldTraceHypervisorHTTPSpan ¶ added in v0.1.0
func SocketCacheKey ¶ added in v0.1.0
SocketCacheKey returns a cache key that changes when a Unix socket path is recreated, preventing stale state from being reused across VM restarts.
func SocketNameForType ¶
SocketNameForType returns the socket filename for a hypervisor type. Falls back to type + ".sock" if not registered.
func StartDetachedTraceSpan ¶ added in v0.1.0
func StartImplementationSpan ¶ added in v0.1.0
func StartProcessSpan ¶ added in v0.1.0
func TraceAttributesFromContext ¶ added in v0.1.0
func VZShimPIDs ¶ added in v0.4.0
VZShimPIDs finds vz-shim processes, which only run on macOS hosts.
func ValidateBootConfig ¶ added in v0.4.0
ValidateBootConfig validates boot and disk fields shared by hypervisor backends.
func ValidateDirectRawConfig ¶ added in v0.4.0
ValidateDirectRawConfig preserves the Linux-only contract of backends that do not implement firmware boot or qcow2 disks.
func VsockSocketNameForType ¶ added in v0.0.7
VsockSocketNameForType returns the vsock socket filename for a hypervisor type. Falls back to "vsock.sock" when a hypervisor doesn't require a custom name.
Types ¶
type BalloonTargetCache ¶ added in v0.1.0
type BalloonTargetCache struct {
// contains filtered or unexported fields
}
BalloonTargetCache keeps the last requested guest-memory target warm across reconnects and Hypeman restarts.
func (*BalloonTargetCache) Delete ¶ added in v0.1.0
func (c *BalloonTargetCache) Delete(socketPath string)
func (*BalloonTargetCache) Load ¶ added in v0.1.0
func (c *BalloonTargetCache) Load(socketPath string) (int64, bool)
func (*BalloonTargetCache) Store ¶ added in v0.1.0
func (c *BalloonTargetCache) Store(socketPath string, bytes int64)
type CPUTopology ¶
CPUTopology defines the virtual CPU topology
type Capabilities ¶
type Capabilities struct {
// SupportsMacOSBoot indicates the backend can cold-boot an imported macOS disk bundle.
SupportsMacOSBoot bool
// SupportsSnapshot indicates if Snapshot/Restore are available
SupportsSnapshot bool
// SupportsFork indicates VMStarter.PrepareFork implements instance
// forking, which every fork source state needs. It is explicit rather
// than derived from SupportsSnapshot because the two are independent in
// both directions: a snapshot-capable backend may still reject
// PrepareFork with ErrNotSupported, and a backend can fork a stopped
// source (a disk clone, no machine-state snapshot involved) without
// snapshot support at all — vz does exactly that on macOS 13. Forking a
// standby or running source additionally restores/creates snapshots, so
// those operations require SupportsStandby() as well; SupportsFork alone
// promises only the stopped-source fork.
SupportsFork bool
// SupportsHotplugMemory indicates if ResizeMemory is available
SupportsHotplugMemory bool
// SupportsBalloonControl indicates if runtime balloon target changes are available.
SupportsBalloonControl bool
// SupportsPause indicates if Pause/Resume are available
SupportsPause bool
// SupportsVsock indicates if vsock communication is available
SupportsVsock bool
// SupportsUEFIBoot indicates if firmware boot is available.
SupportsUEFIBoot bool
// SupportsTPM indicates if a software TPM can be attached at boot.
SupportsTPM bool
// SupportsGPUPassthrough indicates if PCI device passthrough is available
SupportsGPUPassthrough bool
// SupportsDiskIOLimit indicates if disk I/O rate limiting is available
SupportsDiskIOLimit bool
// SupportsGracefulVMMShutdown indicates the hypervisor exposes an API to
// ask the VMM process itself to exit cleanly.
SupportsGracefulVMMShutdown bool
// SupportsSnapshotBaseReuse indicates snapshots can safely reuse a retained
// on-disk base across restore/standby cycles.
SupportsSnapshotBaseReuse bool
// RequiresHostSnapshotVersion means memory snapshots are tied to the
// currently installed host binary; the backend cannot launch a historical
// version selected from instance metadata. Generic lifecycle code therefore
// records the installed version on every cold start and treats a failure to
// detect it as fatal.
//
// For example, qemu-microvm uses the host's qemu-system binary. A standby
// snapshot written by QEMU 8.2 cannot be restored after the host upgrades to
// QEMU 9.0. Firecracker snapshots are also version-sensitive, but Firecracker
// leaves this false because Hypeman can launch the managed binary version
// recorded in instance metadata; Cloud Hypervisor is managed the same way.
RequiresHostSnapshotVersion bool
// SupportsConcurrentForkPrepare indicates stopped/standby forks can prepare
// separate target snapshots concurrently from the same source.
SupportsConcurrentForkPrepare bool
// SupportsDiskResize indicates if live disk resizing (/vm.resize-disk) is available.
// Cloud Hypervisor v50.0+ only.
SupportsDiskResize bool
}
Capabilities indicates which optional features a hypervisor supports. Callers should check these before calling optional methods.
func CapabilitiesForType ¶ added in v0.1.0
func CapabilitiesForType(t Type) (Capabilities, bool)
CapabilitiesForType returns the effective capabilities for a hypervisor type, resolved at call time. It reports ok=false for runtimes that cannot run on the current host platform, because such runtimes never register.
func (Capabilities) FeatureIDs ¶ added in v0.4.0
func (c Capabilities) FeatureIDs() []string
FeatureIDs returns the stable feature IDs implied by this capability set, in a fixed deterministic order. Only client-visible features are included; internal lifecycle hints (snapshot base reuse, host snapshot version pinning, graceful VMM shutdown) are implementation details and deliberately have no IDs. The result is always non-nil so it serializes as an empty JSON array rather than null.
func (Capabilities) SupportsStandby ¶ added in v0.4.0
func (c Capabilities) SupportsStandby() bool
SupportsStandby reports whether standby is genuinely available. Standby pauses the VM and then snapshots its memory, so it requires both pause and snapshot support — neither alone is sufficient.
type ClientFactory ¶ added in v0.0.6
type ClientFactory func(socketPath string) (Hypervisor, error)
ClientFactory creates Hypervisor client instances for a hypervisor type.
type DiskConfig ¶
type DiskConfig struct {
Path string
Format DiskFormat
Readonly bool
Parents []string // vz only: read-only images below Path, base first; Path is their ASIF overlay
IOBps int64 // Sustained I/O rate limit in bytes/sec (0 = unlimited)
IOBurstBps int64 // Burst I/O rate in bytes/sec (0 = same as IOBps)
}
DiskConfig represents a disk attached to the VM
func (DiskConfig) EffectiveFormat ¶ added in v0.4.0
func (d DiskConfig) EffectiveFormat() DiskFormat
EffectiveFormat preserves raw disks for existing callers.
type DiskFormat ¶ added in v0.4.0
type DiskFormat string
const ( DiskFormatRaw DiskFormat = "raw" DiskFormatQCOW2 DiskFormat = "qcow2" // DiskFormatASIF is an ASIF overlay on its Parents, only for macOS boot disks. DiskFormatASIF DiskFormat = "asif" )
type FirmwareConfig ¶ added in v0.4.0
FirmwareConfig describes UEFI firmware files. CodePath is immutable firmware; VarsPath is per-instance writable variable storage.
type ForkNetworkConfig ¶ added in v0.0.7
ForkNetworkConfig contains network identity fields for fork preparation.
type ForkPrepareRequest ¶ added in v0.0.7
type ForkPrepareRequest struct {
// SnapshotConfigPath is optional. When empty, implementations should only
// validate fork support and return without snapshot rewrites.
SnapshotConfigPath string
SourceDataDir string
TargetDataDir string
VsockCID int64
VsockSocket string
SerialLogPath string
Network *ForkNetworkConfig
}
ForkPrepareRequest contains hypervisor-specific fork preparation inputs.
type ForkPrepareResult ¶ added in v0.0.7
type ForkPrepareResult struct {
// VsockCIDUpdated indicates whether snapshot state was updated to use
// ForkPrepareRequest.VsockCID.
VsockCIDUpdated bool
// RequiresSnapshotSourceAlias indicates the restored fork still depends on
// temporarily aliasing the source data directory during snapshot load.
RequiresSnapshotSourceAlias bool
}
ForkPrepareResult describes which optional fork rewrites were actually applied.
type GuestMemoryConfig ¶ added in v0.1.0
type GuestMemoryConfig struct {
EnableBalloon bool
FreePageReporting bool
DeflateOnOOM bool
FreePageHinting bool
// RequireBalloon controls whether VM startup should fail if balloon setup fails.
RequireBalloon bool
}
GuestMemoryConfig contains hypervisor-agnostic guest memory feature toggles.
type Hypervisor ¶
type Hypervisor interface {
// DeleteVM sends a graceful shutdown signal to the guest.
DeleteVM(ctx context.Context) error
// Shutdown stops the VMM process gracefully.
Shutdown(ctx context.Context) error
// GetVMInfo returns current VM state information.
GetVMInfo(ctx context.Context) (*VMInfo, error)
// Pause suspends VM execution.
// Check Capabilities().SupportsPause before calling.
Pause(ctx context.Context) error
// Resume continues VM execution after pause.
// Check Capabilities().SupportsPause before calling.
Resume(ctx context.Context) error
// Snapshot creates a VM snapshot at the given path.
// Check Capabilities().SupportsSnapshot before calling.
Snapshot(ctx context.Context, destPath string) error
// ResizeMemory changes the VM's memory allocation.
// Check Capabilities().SupportsHotplugMemory before calling.
ResizeMemory(ctx context.Context, bytes int64) error
// ResizeMemoryAndWait changes the VM's memory allocation and waits for it to stabilize.
// This polls until the actual memory size matches the target or stabilizes.
// Check Capabilities().SupportsHotplugMemory before calling.
ResizeMemoryAndWait(ctx context.Context, bytes int64, timeout time.Duration) error
// SetTargetGuestMemoryBytes adjusts the runtime balloon target so the guest
// sees the requested amount of RAM.
// Check Capabilities().SupportsBalloonControl before calling.
SetTargetGuestMemoryBytes(ctx context.Context, bytes int64) error
// GetTargetGuestMemoryBytes returns the current guest-visible RAM target after
// runtime ballooning is applied.
// Check Capabilities().SupportsBalloonControl before calling.
GetTargetGuestMemoryBytes(ctx context.Context) (int64, error)
// Capabilities returns what features this hypervisor supports.
Capabilities() Capabilities
}
Hypervisor defines the interface for VM control operations. A Hypervisor client is returned by VMStarter.StartVM after the VM is running.
func NewClient ¶ added in v0.0.6
func NewClient(hvType Type, socketPath string) (Hypervisor, error)
NewClient creates a Hypervisor client for the given type and socket.
func WrapHypervisor ¶ added in v0.1.0
func WrapHypervisor(hvType Type, hv Hypervisor) Hypervisor
type MacOSPlatform ¶ added in v0.4.0
type MacOSPlatform struct {
HardwareModelData []byte
MachineIdentifierData []byte
AuxStoragePath string
}
MacOSPlatform carries the persistent Apple-silicon platform identity. The auxiliary storage belongs to the instance, never to the image template.
type NetworkConfig ¶
type NetworkConfig struct {
TAPDevice string
IP string
MAC string
Netmask string
// DownloadBps limits host->guest bandwidth in bytes/sec (0 = unlimited).
// Hypeman enforces this host-side via TAP shaping for all hypervisors.
// Firecracker also maps it to per-interface API rate limiters.
DownloadBps int64
// UploadBps limits guest->host bandwidth in bytes/sec (0 = unlimited).
// Hypeman enforces this host-side via TAP shaping for all hypervisors.
// Firecracker also maps it to per-interface API rate limiters.
UploadBps int64
}
NetworkConfig represents a network interface attached to the VM
type RegisteredRuntime ¶ added in v0.4.0
type RegisteredRuntime struct {
Type Type
Capabilities Capabilities
// LaunchErr is non-nil when the runtime is supported by this build on
// this platform but its launch prerequisites are not currently met (for
// example QEMU registered on Linux without a system QEMU binary
// installed). Ordinary launches of the runtime will fail while it is
// non-nil.
LaunchErr error
}
RegisteredRuntime is one capability-registry entry resolved at read time.
func RegisteredRuntimes ¶ added in v0.4.0
func RegisteredRuntimes() []RegisteredRuntime
RegisteredRuntimes enumerates every registered runtime, sorted by type name so output is deterministic. Because registration is platform-gated, the result is the set of runtimes the linked backends support on the current host; per-entry Available/LaunchErr additionally reflect whether launch prerequisites are met right now.
func (RegisteredRuntime) Available ¶ added in v0.4.0
func (r RegisteredRuntime) Available() bool
Available reports whether ordinary launches of this runtime can succeed on this host: it is registered for the platform and its launch-prerequisite check passed.
type RuntimeRegistration ¶ added in v0.4.0
type RuntimeRegistration struct {
// Capabilities resolves the runtime's effective capability set. It is
// evaluated on every registry read — never cached at registration time —
// so capabilities that depend on configuration applied after package init
// (for example the configured cloud-hypervisor default version) stay
// truthful. Required.
Capabilities func() Capabilities
// LaunchCheck verifies host launch prerequisites that platform-gated
// registration cannot express, such as a required system-installed binary
// (QEMU). nil means registration alone implies launchability (backends
// that ship an embedded VMM binary). The registry invokes it on every
// read; a backend may memoize startup readiness when changing host
// prerequisites requires a process restart.
LaunchCheck func() error
}
RuntimeRegistration describes how a hypervisor backend reports itself in the capability registry.
type SnapshotSupportValidator ¶ added in v0.4.0
SnapshotSupportValidator checks configuration-specific support before pausing.
type Type ¶
type Type string
Type identifies the hypervisor implementation
const ( // TypeCloudHypervisor is the Cloud Hypervisor VMM TypeCloudHypervisor Type = "cloud-hypervisor" // TypeFirecracker is the Firecracker VMM TypeFirecracker Type = "firecracker" // TypeQEMU is QEMU with its architecture-native standard board. TypeQEMU Type = "qemu" // TypeQEMUMicroVM is QEMU with the minimal x86 microvm board. TypeQEMUMicroVM Type = "qemu-microvm" // TypeVZ is the Virtualization.framework VMM (macOS only) TypeVZ Type = "vz" )
type VMConfig ¶
type VMConfig struct {
// Compute resources
VCPUs int
MemoryBytes int64
HotplugBytes int64
Topology *CPUTopology
GuestMemory GuestMemoryConfig
// Storage
Disks []DiskConfig
// Network
Networks []NetworkConfig
// Console
SerialLogPath string
// Vsock
VsockCID int64
VsockSocket string
// PCI device passthrough (GPU, etc.)
PCIDevices []string
VGPUDevicePath string
// Boot configuration. Empty BootMode preserves the existing direct-kernel
// behavior for Linux callers.
BootMode BootMode
MacOS *MacOSPlatform
Firmware *FirmwareConfig
TPM *TPMConfig
KernelPath string
InitrdPath string
KernelArgs string
// EnableRosetta attaches an Apple Rosetta virtio-fs share (vz on Apple
// silicon only) so the guest can execute x86-64 binaries.
EnableRosetta bool
}
VMConfig is the hypervisor-agnostic VM configuration. Each hypervisor implementation translates this to its native format.
func (VMConfig) EffectiveBootMode ¶ added in v0.4.0
EffectiveBootMode preserves direct Linux kernel boot for existing callers.
type VMInfo ¶
type VMInfo struct {
State VMState
MemoryActualSize *int64 // Current actual memory size in bytes (if available)
}
VMInfo contains current VM state information
type VMStarter ¶
type VMStarter interface {
// ValidateConfig performs side-effect-free backend validation. Managers call
// it during preflight; starters must also validate final launch/restore state.
ValidateConfig(VMConfig) error
// SocketName returns the socket filename for this hypervisor.
// Uses short names to stay within Unix socket path length limits (SUN_LEN ~108 bytes).
SocketName() string
// GetBinaryPath returns the path to the hypervisor binary, extracting if needed.
GetBinaryPath(p *paths.Paths, version string) (string, error)
// GetVersion returns the default or installed hypervisor version.
GetVersion(p *paths.Paths) (string, error)
// ResolveVersion validates an optional requested version and returns the
// concrete binary version to persist for a new VM or snapshot target.
ResolveVersion(p *paths.Paths, requested string) (string, error)
// StartVM launches the hypervisor process and boots the VM.
// Returns the process ID and a Hypervisor client for subsequent operations.
StartVM(ctx context.Context, p *paths.Paths, version string, socketPath string, config VMConfig) (pid int, hv Hypervisor, err error)
// RestoreVM starts the hypervisor and restores VM state from a snapshot.
// Each hypervisor implements its own restore flow:
// - Cloud Hypervisor: starts process, calls Restore API
// - QEMU: would start with -incoming or -loadvm flags (not yet implemented)
// Returns the process ID and a Hypervisor client. The VM is in paused state after restore.
RestoreVM(ctx context.Context, p *paths.Paths, version string, socketPath string, snapshotPath string) (pid int, hv Hypervisor, err error)
// PrepareFork allows hypervisors to prepare forked instance state.
// For snapshot-based forks, implementations can rewrite snapshot config with
// fork identity (paths, vsock, network). Hypervisors that don't support fork
// should return ErrNotSupported.
PrepareFork(ctx context.Context, req ForkPrepareRequest) (ForkPrepareResult, error)
}
VMStarter handles the full VM startup sequence. Each hypervisor implements its own startup flow: - Cloud Hypervisor: starts process, configures via HTTP API, boots via HTTP API - QEMU: converts config to command-line args, starts process (VM runs immediately)
func WrapVMStarter ¶ added in v0.1.0
type VMState ¶
type VMState string
VMState represents the VM execution state
const ( // StateCreated means the VM is configured but not running StateCreated VMState = "created" // StateRunning means the VM is actively executing StateRunning VMState = "running" // StatePaused means the VM execution is suspended StatePaused VMState = "paused" // StateShutdown means the VM has stopped but VMM exists StateShutdown VMState = "shutdown" )
type VsockDialer ¶
type VsockDialer interface {
// DialVsock connects to the guest on the specified port.
// Returns a net.Conn that can be used for bidirectional communication.
DialVsock(ctx context.Context, port int) (net.Conn, error)
// Key returns a unique identifier for this dialer, used for connection pooling.
Key() string
}
VsockDialer provides vsock connectivity to a guest VM. Each hypervisor implements its own connection method: - Cloud Hypervisor: Unix socket file + text handshake protocol - QEMU: Kernel AF_VSOCK with CID-based addressing
func NewVsockDialer ¶
func NewVsockDialer(hvType Type, vsockSocket string, vsockCID int64) (VsockDialer, error)
NewVsockDialer creates a VsockDialer for the given hypervisor type. Returns an error if the hypervisor type doesn't have a registered factory.
type VsockDialerFactory ¶
type VsockDialerFactory func(vsockSocket string, vsockCID int64) VsockDialer
VsockDialerFactory creates VsockDialer instances for a hypervisor type.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package cloudhypervisor implements the hypervisor.Hypervisor interface for Cloud Hypervisor VMM.
|
Package cloudhypervisor implements the hypervisor.Hypervisor interface for Cloud Hypervisor VMM. |
|
Package qemu implements the hypervisor.Hypervisor interface for QEMU.
|
Package qemu implements the hypervisor.Hypervisor interface for QEMU. |
|
shimconfig
Package shimconfig defines the configuration types shared between the hypeman API server and the vz-shim subprocess.
|
Package shimconfig defines the configuration types shared between the hypeman API server and the vz-shim subprocess. |