driver

package
v2.0.0 Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2025 License: Apache-2.0 Imports: 3 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

This section is empty.

Functions

This section is empty.

Types

type ConfiguredDriver

type ConfiguredDriver struct {
	Driver
}

type Driver

type Driver interface {
	Lifecycle
	GUI
	SnapshotManager
	GuestAgent

	Info() Info

	// Configure sets the configuration for the instance.
	// TODO: merge Configure and FillConfig?
	// Or come up with a better name to clarify the difference.
	Configure(inst *limatype.Instance) *ConfiguredDriver

	// FillConfig fills and validates the configuration for the instance.
	// The config is not set to the instance.
	FillConfig(ctx context.Context, cfg *limatype.LimaYAML, filePath string) 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"`
}

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() 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() 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() (map[string][]byte, error)
}

Lifecycle defines basic lifecycle operations.

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.

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