Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrNotFound = errors.New("VM not found") ErrNotRunning = errors.New("VM not running") )
Functions ¶
This section is empty.
Types ¶
type Direct ¶
type Direct interface {
DirectClone(ctx context.Context, vmID string, vmCfg *types.VMConfig, networkConfigs []*types.NetworkConfig, snapshotConfig *types.SnapshotConfig, srcDir string) (*types.VM, error)
DirectRestore(ctx context.Context, vmRef string, vmCfg *types.VMConfig, srcDir string) (*types.VM, error)
}
Direct is an optional interface for hypervisors that support clone/restore from a local snapshot directory.
type Hypervisor ¶
type Hypervisor interface {
Type() string
Create(ctx context.Context, vmID string, vmCfg *types.VMConfig, storage []*types.StorageConfig, network []*types.NetworkConfig, boot *types.BootConfig) (*types.VM, error)
Start(ctx context.Context, refs []string) ([]string, error)
Stop(ctx context.Context, refs []string) ([]string, error)
Inspect(ctx context.Context, ref string) (*types.VM, error)
List(context.Context) ([]*types.VM, error)
Delete(ctx context.Context, refs []string, force bool) ([]string, error)
Console(ctx context.Context, ref string) (io.ReadWriteCloser, error)
Snapshot(ctx context.Context, ref string) (*types.SnapshotConfig, io.ReadCloser, error)
Clone(ctx context.Context, vmID string, vmCfg *types.VMConfig, networkConfigs []*types.NetworkConfig, snapshotConfig *types.SnapshotConfig, snapshot io.Reader) (*types.VM, error)
Restore(ctx context.Context, vmRef string, vmCfg *types.VMConfig, snapshot io.Reader) (*types.VM, error)
RegisterGC(*gc.Orchestrator)
}
Hypervisor manages VM lifecycle. Implemented by each backend.
type VMIndex ¶
type VMIndex struct {
VMs map[string]*VMRecord `json:"vms"`
Names map[string]string `json:"names"` // name → VM ID
}
VMIndex is the top-level DB structure for a hypervisor backend.
type VMRecord ¶
type VMRecord struct {
types.VM
BootConfig *types.BootConfig `json:"boot_config,omitempty"` // nil for UEFI boot (cloudimg)
ImageBlobIDs map[string]struct{} `json:"image_blob_ids,omitempty"` // blob hex set for GC pinning
// RunDir and LogDir store the absolute paths used when the VM was created.
// Persisting them ensures cleanup succeeds even if --run-dir / --log-dir
// differ from the values at creation time.
RunDir string `json:"run_dir,omitempty"`
LogDir string `json:"log_dir,omitempty"`
}
VMRecord is the persisted record for a single VM.
StorageConfigs and NetworkConfigs live on the embedded types.VM so that a value-copy (info := rec.VM) automatically includes them — no manual field copying needed. The JSON tags are on types.VM; do NOT duplicate them here or Go's encoding/json will silently shadow the promoted fields.
Click to show internal directories.
Click to hide internal directories.