vm

package
v0.2.9 Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func KernelDNSParam added in v0.1.7

func KernelDNSParam(dnsServers []string) string

KernelDNSParam returns a comma-separated DNS list for the matchlock.dns= cmdline param.

func KernelIPDNSSuffix added in v0.1.7

func KernelIPDNSSuffix(dnsServers []string) string

KernelIPDNSSuffix returns the DNS portion of the kernel ip= parameter. The ip= format only supports up to 2 DNS servers (`:dns0:dns1`).

Types

type Backend

type Backend interface {
	Create(ctx context.Context, config *VMConfig) (Machine, error)
	Name() string
}

type DiskConfig added in v0.1.6

type DiskConfig struct {
	HostPath   string // Path to the ext4 image on the host
	GuestMount string // Mount point inside the guest (e.g., "/var/lib/buildkit")
	ReadOnly   bool
}

DiskConfig describes an additional block device to attach to the VM.

type InteractiveMachine

type InteractiveMachine interface {
	Machine
	ExecInteractive(ctx context.Context, command string, opts *api.ExecOptions, rows, cols uint16, stdin io.Reader, stdout io.Writer, resizeCh <-chan [2]uint16) (int, error)
}

type Machine

type Machine interface {
	Start(ctx context.Context) error
	Stop(ctx context.Context) error
	Wait(ctx context.Context) error
	Exec(ctx context.Context, command string, opts *api.ExecOptions) (*api.ExecResult, error)
	WriteFile(ctx context.Context, path string, content []byte, mode uint32) error
	ReadFile(ctx context.Context, path string) ([]byte, error)
	ListFiles(ctx context.Context, path string) ([]api.FileInfo, error)
	NetworkFD() (int, error)
	VsockFD() (int, error)
	PID() int
	Close(ctx context.Context) error
	RootfsPath() string // Returns the path to the VM's rootfs (may be a temp copy)
}

type VMConfig

type VMConfig struct {
	ID                  string
	KernelPath          string
	RootfsPath          string
	OverlayEnabled      bool     // Boot via overlay root assembly in guest-init
	OverlayLowerPaths   []string // Host paths to read-only lower images attached as extra disks
	OverlayLowerFSTypes []string // Filesystem type per lower image (erofs)
	OverlayUpperPath    string   // Host path to writable upper image attached as extra disk
	CPUs                float64
	MemoryMB            int
	NetworkFD           int
	VsockCID            uint32
	VsockPath           string
	SocketPath          string
	LogPath             string
	KernelArgs          string
	Env                 map[string]string
	GatewayIP           string              // Host TAP IP (e.g., 192.168.100.1)
	GuestIP             string              // Guest IP (e.g., 192.168.100.2)
	SubnetCIDR          string              // CIDR notation (e.g., 192.168.100.1/24)
	Workspace           string              // Guest VFS mount point (empty when VFS is disabled)
	UseInterception     bool                // Use network interception (MITM proxy)
	Privileged          bool                // Skip in-guest security restrictions (seccomp, cap drop, no_new_privs)
	DNSServers          []string            // DNS servers for the guest (default: 8.8.8.8, 8.8.4.4)
	Hostname            string              // Hostname for the guest (default: vm's ID)
	AddHosts            []api.HostIPMapping // Additional /etc/hosts entries injected at boot
	MTU                 int                 // Guest interface/network stack MTU (default: 1500)
	NoNetwork           bool                // Disable guest network interface entirely
	PrebuiltRootfs      string              // Pre-prepared rootfs path (skips internal copy if set)
	ExtraDisks          []DiskConfig        // Additional block devices to attach
}

type VsockDialer added in v0.1.20

type VsockDialer interface {
	DialVsock(port uint32) (net.Conn, error)
}

VsockDialer is implemented by backends that can establish host-initiated vsock connections to guest service ports.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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