Documentation
¶
Index ¶
- Constants
- func DebugDiskCLIArgs(storageConfigs []*types.StorageConfig, cpuCount, diskQueueSize int) []string
- func ReverseLayerSerials(storageConfigs []*types.StorageConfig) []string
- type CloudHypervisor
- func (ch *CloudHypervisor) Clone(ctx context.Context, vmID string, vmCfg *types.VMConfig, ...) (_ *types.VM, err error)
- func (ch *CloudHypervisor) Console(ctx context.Context, ref string) (io.ReadWriteCloser, error)
- func (ch *CloudHypervisor) Create(ctx context.Context, id string, vmCfg *types.VMConfig, ...) (_ *types.VM, err error)
- func (ch *CloudHypervisor) Delete(ctx context.Context, refs []string, force bool) ([]string, error)
- func (ch *CloudHypervisor) DirectClone(ctx context.Context, vmID string, vmCfg *types.VMConfig, ...) (_ *types.VM, err error)
- func (ch *CloudHypervisor) DirectRestore(ctx context.Context, vmRef string, vmCfg *types.VMConfig, srcDir string) (*types.VM, error)
- func (ch *CloudHypervisor) GCModule() gc.Module[chSnapshot]
- func (ch *CloudHypervisor) RegisterGC(orch *gc.Orchestrator)
- func (ch *CloudHypervisor) Restore(ctx context.Context, vmRef string, vmCfg *types.VMConfig, snapshot io.Reader) (*types.VM, error)
- func (ch *CloudHypervisor) Snapshot(ctx context.Context, ref string) (*types.SnapshotConfig, io.ReadCloser, error)
- func (ch *CloudHypervisor) Start(ctx context.Context, refs []string) ([]string, error)
- func (ch *CloudHypervisor) Stop(ctx context.Context, refs []string) ([]string, error)
- func (ch *CloudHypervisor) WatchPath() string
- type Config
Constants ¶
const CowSerial = hypervisor.CowSerial
CowSerial is re-exported for backward compatibility with cmd/vm/debug.go.
Variables ¶
This section is empty.
Functions ¶
func DebugDiskCLIArgs ¶
func DebugDiskCLIArgs(storageConfigs []*types.StorageConfig, cpuCount, diskQueueSize int) []string
DebugDiskCLIArgs uses the same storage-to-disk mapping as launch.
func ReverseLayerSerials ¶
func ReverseLayerSerials(storageConfigs []*types.StorageConfig) []string
ReverseLayerSerials extracts read-only layer serial names from StorageConfigs and returns them in reverse order (top layer first for overlayfs lowerdir).
Types ¶
type CloudHypervisor ¶
type CloudHypervisor struct {
*hypervisor.Backend
// contains filtered or unexported fields
}
CloudHypervisor implements hypervisor.Hypervisor.
func New ¶
func New(conf *config.Config) (*CloudHypervisor, error)
New creates a CloudHypervisor backend.
func (*CloudHypervisor) Clone ¶
func (ch *CloudHypervisor) Clone(ctx context.Context, vmID string, vmCfg *types.VMConfig, networkConfigs []*types.NetworkConfig, snapshotConfig *types.SnapshotConfig, snapshot io.Reader) (_ *types.VM, err error)
Clone creates a new VM from a snapshot tar stream.
func (*CloudHypervisor) Console ¶
func (ch *CloudHypervisor) Console(ctx context.Context, ref string) (io.ReadWriteCloser, error)
Console connects to the VM's console output and returns a bidirectional stream.
For UEFI-boot VMs (cloudimg): connects to the serial socket (console.sock). For direct-boot VMs (OCI): opens the virtio-console PTY allocated by CH.
The console path is resolved lazily on first access via the CH API (OCI/PTY) or the deterministic socket path (UEFI), so callers like Clone and Start don't need to query it upfront. The caller is responsible for closing the returned ReadWriteCloser.
func (*CloudHypervisor) Create ¶
func (ch *CloudHypervisor) Create(ctx context.Context, id string, vmCfg *types.VMConfig, storageConfigs []*types.StorageConfig, networkConfigs []*types.NetworkConfig, bootCfg *types.BootConfig) (_ *types.VM, err error)
Create reserves a VM record, prepares disks, and leaves the VM in Created state.
func (*CloudHypervisor) Delete ¶
Delete removes VMs. Running VMs require force=true (stops them first).
func (*CloudHypervisor) DirectClone ¶
func (ch *CloudHypervisor) DirectClone(ctx context.Context, vmID string, vmCfg *types.VMConfig, networkConfigs []*types.NetworkConfig, snapshotConfig *types.SnapshotConfig, srcDir string) (_ *types.VM, err error)
DirectClone creates a new VM from a local snapshot directory. Files are handled per-type: hardlink for memory-range-*, reflink/copy for the COW disk, plain copy for small metadata, and cidata is regenerated.
func (*CloudHypervisor) DirectRestore ¶
func (ch *CloudHypervisor) DirectRestore(ctx context.Context, vmRef string, vmCfg *types.VMConfig, srcDir string) (*types.VM, error)
DirectRestore reverts a running VM using a local snapshot directory. Files are handled per-type: hardlink for memory-range-*, reflink/copy for the COW disk, plain copy for small metadata.
func (*CloudHypervisor) GCModule ¶
func (ch *CloudHypervisor) GCModule() gc.Module[chSnapshot]
GCModule returns the GC module for cross-module blob pinning and orphan cleanup.
func (*CloudHypervisor) RegisterGC ¶
func (ch *CloudHypervisor) RegisterGC(orch *gc.Orchestrator)
RegisterGC registers the Cloud Hypervisor GC module with the given Orchestrator.
func (*CloudHypervisor) Restore ¶
func (ch *CloudHypervisor) Restore(ctx context.Context, vmRef string, vmCfg *types.VMConfig, snapshot io.Reader) (*types.VM, error)
Restore stages a snapshot tar before replacing the running VM state.
func (*CloudHypervisor) Snapshot ¶
func (ch *CloudHypervisor) Snapshot(ctx context.Context, ref string) (*types.SnapshotConfig, io.ReadCloser, error)
Snapshot pauses the VM, captures its full state (CPU, memory, devices via CH snapshot API, plus the COW disk via sparse copy), resumes the VM, and returns a streaming tar.gz reader of the snapshot directory.
func (*CloudHypervisor) Start ¶
Start launches the Cloud Hypervisor process for each VM ref. Returns the IDs that were successfully started.
func (*CloudHypervisor) Stop ¶
Stop shuts down the Cloud Hypervisor process for each VM ref. Two modes are used depending on the VM's boot method:
- UEFI boot (cloudimg): ACPI power-button → poll → fallback SIGTERM/SIGKILL
- Direct boot (OCI): vm.shutdown API → SIGTERM → SIGKILL (no ACPI)
Returns the IDs that were successfully stopped.
func (*CloudHypervisor) WatchPath ¶ added in v0.2.6
func (ch *CloudHypervisor) WatchPath() string
WatchPath returns the path to the VM index file for filesystem-based change watching. Implements hypervisor.Watchable.
type Config ¶
type Config struct {
hypervisor.BaseConfig
}
Config holds Cloud Hypervisor specific configuration.
func (*Config) BinaryName ¶ added in v0.2.9
BinaryName returns the base name of the Cloud Hypervisor binary.
func (*Config) COWRawPath ¶
COWRawPath returns the path for the OCI COW raw disk.
func (*Config) CidataPath ¶
CidataPath returns the path for the cloud-init NoCloud cidata disk.
func (*Config) OverlayPath ¶
OverlayPath returns the path for the cloudimg qcow2 overlay.
func (*Config) PIDFileName ¶ added in v0.2.9
PIDFileName returns the PID file name for the Cloud Hypervisor backend.