driver

package
v2.2.0-rc.0 Latest Latest
Warning

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

Go to latest
Published: Jul 16, 2026 License: Apache-2.0 Imports: 5 Imported by: ? 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

Index

Constants

This section is empty.

Variables

View Source
var ErrDriverNotScreenshotter = errors.New("driver does not support screenshots")

ErrDriverNotScreenshotter is returned when the active driver does not implement Screenshotter.

View Source
var ErrNoDisplay = errors.New("no display configured")

ErrNoDisplay is returned when the VM has no display configured.

Functions

This section is empty.

Types

type ConfiguredDriver

type ConfiguredDriver struct {
	Driver
}

type Driver

type Driver interface {
	Lifecycle
	GUI
	SnapshotManager
	GuestAgent

	Info(context.Context) Info

	// Configure fills driver-specific configuration defaults, validates
	// the configuration, and sets up the driver for the given instance.
	Configure(ctx context.Context, inst *limatype.Instance) (*ConfiguredDriver, error)

	SSHAddress(ctx context.Context) (string, error)

	// AdditionalSetupForSSH provides additional setup required for SSH connection.
	// It is called after VM is started, before first SSH connection.
	// It returns an error if the setup fails.
	AdditionalSetupForSSH(ctx context.Context) error
}

Driver interface is used by hostagent for managing vm.

type DriverFeatures

type DriverFeatures struct {
	CanRunGUI             bool     `json:"canRunGui,omitempty"`
	DynamicSSHAddress     bool     `json:"dynamicSSHAddress"`
	StaticSSHPort         bool     `json:"staticSSHPort"`
	SkipSocketForwarding  bool     `json:"skipSocketForwarding"`
	NoCloudInit           bool     `json:"noCloudInit"`
	RosettaEnabled        bool     `json:"rosettaEnabled"`
	RosettaBinFmt         bool     `json:"rosettaBinFmt"`
	SupportedImageFormats []string `json:"supportedImageFormats,omitempty"`
}

type GUI

type GUI interface {
	// RunGUI is for starting GUI synchronously by hostagent. This method should be wait and return only after vm terminates
	// It returns error if there are any failures
	RunGUI(context.Context) error

	ChangeDisplayPassword(ctx context.Context, password string) error
	DisplayConnection(ctx context.Context) (string, error)
}

GUI defines GUI-related operations.

type GuestAgent

type GuestAgent interface {
	// ForwardGuestAgent returns if the guest agent sock needs forwarding by host agent.
	ForwardGuestAgent(context.Context) bool

	// GuestAgentConn returns the guest agent connection, or nil (if forwarded by ssh).
	GuestAgentConn(_ context.Context) (net.Conn, string, error)
}

GuestAgent defines operations for the guest agent.

type Info

type Info struct {
	Name        string         `json:"name"`
	VsockPort   int            `json:"vsockPort"`
	VirtioPort  string         `json:"virtioPort"`
	InstanceDir string         `json:"instanceDir,omitempty"`
	Features    DriverFeatures `json:"features"`
}

type Lifecycle

type Lifecycle interface {
	// Validate returns error if the current driver isn't support for given config
	Validate(_ context.Context) error

	// Create is called on creating the instance for the first time.
	// (e.g., creating "vz-identifier" file)
	//
	// Create MUST return nil when it is called against an existing instance.
	//
	// Create does not create the disks.
	Create(_ context.Context) error

	// CreateDisk returns error if the current driver fails in creating disk
	CreateDisk(_ context.Context) error

	// Start is used for booting the vm using driver instance
	// It returns a chan error on successful boot
	// The second argument may contain error occurred while starting driver
	Start(_ context.Context) (chan error, error)

	// Stop will terminate the running vm instance.
	// It returns error if there are any errors during Stop
	Stop(_ context.Context) error

	Delete(_ context.Context) error

	InspectStatus(_ context.Context, inst *limatype.Instance) string

	// BootScripts returns the content of boot scripts to be injected into the vm.
	// The key must be "boot.<OS>/<SCRIPT>" or "<SCRIPT>" (deprecated alias for "boot.Linux/<SCRIPT>").
	BootScripts(ctx context.Context) (map[string][]byte, error)
}

Lifecycle defines basic lifecycle operations.

type Screenshotter added in v2.2.0

type Screenshotter interface {
	CaptureScreenshot(format string) ([]byte, error)
}

Screenshotter is an optional interface for drivers that can capture the VM display. format is "png" or "bmp"; an empty string defaults to "png".

type SnapshotManager

type SnapshotManager interface {
	CreateSnapshot(ctx context.Context, tag string) error
	ApplySnapshot(ctx context.Context, tag string) error
	DeleteSnapshot(ctx context.Context, tag string) error
	ListSnapshots(ctx context.Context) (string, error)
}

SnapshotManager defines operations for managing snapshots.

type VsockEventEmitter added in v2.1.0

type VsockEventEmitter interface {
	SetVsockEventCallback(callback func(*events.VsockEvent))
}

VsockEventEmitter is an optional interface for drivers to emit vsock events.

Directories

Path Synopsis
entitlementutil
Package entitlementutil provides a workaround for https://github.com/lima-vm/lima/issues/1742
Package entitlementutil provides a workaround for https://github.com/lima-vm/lima/issues/1742

Jump to

Keyboard shortcuts

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