Help us shape the future of Go! Take the 2026 Go Developer Survey

launch

package
v1.6.1 Latest Latest
Warning

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

Go to latest
Published: Oct 12, 2026 License: Apache-2.0 Imports: 27 Imported by: 0

Documentation

Overview

Package launch runs the aibox VM: virtiofsd for each share, the proxy and the terminal for the VM, then QEMU.

Index

Constants

This section is empty.

Variables

View Source
var ErrNoTerminal = host.ErrNoTerminal

ErrNoTerminal is a VM that ended before the command in it connected, which the console log usually explains.

View Source
var ErrSocketTimeout = errors.New("virtiofsd did not create its socket in time")

ErrSocketTimeout is returned when virtiofsd does not create its socket in time.

Functions

func Run

func Run(ctx context.Context, machine vm.Machine, options Options) error

Run boots the machine with the proxy and the terminal listening for it and returns when QEMU exits, or with the error of the context when it ends first. On return the proxy and the virtiofsd processes are stopped, their sockets are removed and the terminal is as it was.

Types

type Backend

type Backend struct {
	QEMU      string
	Virtiofsd string
	Owner     vm.Owner
}

Backend runs the VM on QEMU and virtiofsd, on a Linux host with KVM. Owner is the host user the VM user stands for in the shares. An empty Virtiofsd is found by Run.

func NewBackend

func NewBackend() Backend

NewBackend returns the Backend for the user running aibox.

func (Backend) Run

func (b Backend) Run(ctx context.Context, spec backend.Spec) error

Run boots the VM of the spec, see the function Run.

type ExitError

type ExitError = backend.ExitError

ExitError is a command in the VM that ended with a code other than 0.

type Options

type Options struct {
	QEMU string
	// Virtiofsd is the program that serves the shares. Empty means
	// virtiofsd on the PATH, or else /usr/libexec/virtiofsd.
	Virtiofsd string
	Stdin     *os.File
	Stdout    io.Writer
	Stderr    io.Writer
	// Progress gets the standard error of a session without a terminal,
	// which a task has. Nil runs the session on the terminal.
	Progress io.Writer
	// RemoveState removes the state disk once QEMU has it open.
	RemoveState bool
	// SocketTimeout is how long virtiofsd may take to create its socket.
	// Zero means ten seconds.
	SocketTimeout time.Duration
	// OpenVsock opens the vsock the VM and aibox talk over. Nil runs the
	// namespace helper of aibox.
	OpenVsock func() (*vsockns.Vsock, error)
	Proxy     proxy.Options
	// Env are variables for the command in the VM, as NAME=value.
	Env []string
	// OnPaste is called each time the person presses Ctrl+V, or is nil.
	OnPaste func()
	// KVMDevice is the KVM device file QEMU gets. Empty means /dev/kvm.
	KVMDevice string
	// Bubblewrap is the program that runs QEMU in its sandbox. Empty means
	// bwrap on the PATH.
	Bubblewrap string
	// NoSandbox runs QEMU without the sandbox.
	NoSandbox bool
	// Confine is called once QEMU has started, with the TCP ports the proxy
	// may still connect to. Nil means confine.Apply.
	Confine func(ports []uint16) error
	// Ports are the TCP ports of the allow list.
	Ports []uint16
	// ConsoleLog is the file the console of the VM is written to. Empty
	// throws it away.
	ConsoleLog string
	// Libraries and Firmware are what QEMU is made of on the host, bound
	// into its sandbox. Empty means those of the QEMU found, see libraries
	// and firmware.
	Libraries []string
	Firmware  string
	// StopDelay is how long a stopped program may take before it is
	// killed, and SessionEndDelay how long the session may go on after
	// QEMU exited, to show the last output of the VM. Zero means the
	// default.
	StopDelay       time.Duration
	SessionEndDelay time.Duration
}

Options are the programs Run starts, the terminal of the person on Stdin and Stdout, where the messages of aibox and of the programs go, and how the VM reaches the host.

Jump to

Keyboard shortcuts

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