qemu

package
v0.3.3 Latest Latest
Warning

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

Go to latest
Published: Aug 21, 2026 License: MIT Imports: 19 Imported by: 0

Documentation

Overview

Package qemu implements a virtle backend that launches virtual machines with QEMU. Config.RemoteControl selects the guest-control transport wired into Instance.RemoteControl: QGA (the QEMU Guest Agent, equivalent to the virtle CLI today) now, a virtle-native guest daemon transport later.

Index

Constants

View Source
const DefaultMemory = 2048 * units.Mebibyte

DefaultMemory is the guest memory size used when vm.Spec.Memory is zero.

Variables

This section is empty.

Functions

func New

func New(cfg Config) (backend.Backend, error)

New returns a QEMU backend. Config.RemoteControl selects guest control — there is no default transport, mirroring how backends themselves are named explicitly:

b, err := qemu.New(qemu.Config{RemoteControl: qemu.QGA{}})

func NewBackendFromDocument

func NewBackendFromDocument(doc imanifest.Document, cfg Config) backend.Backend

NewBackendFromDocument is the bridge for the public manifest package: the returned backend starts from the loaded document, preserving manifest sections that have no vm.Spec equivalent, and overlays the Spec passed to Start on top. The document type is internal, so this is not callable (and not supported) outside the module.

Types

type Config

type Config struct {
	Binary         string            // default: qemu-system-<arch>
	Machine        string            // QEMU machine type; default: microvm
	MachineOptions map[string]string // extra machine options
	CPUModel       string            // QEMU CPU model; default derived per host
	KVM            *bool             // enable KVM acceleration; default derived per host
	ExtraArgs      []string          // passthrough QEMU arguments
	Console        Console
	Seccomp        bool   // enable QEMU seccomp sandboxing
	Balloon        bool   // attach a virtio-balloon device (required for ResizeMemory)
	HostName       string // guest-visible name; default: "virtle"

	// HotplugPorts reserves PCIe hotplug ports at boot so devices can be
	// attached later via backend.DeviceAttacher. Reserving ports forces
	// the PCI transport (as any hotplug configuration does).
	HotplugPorts int

	// RemoteControl selects the guest-control transport wired into
	// Instance.RemoteControl, declaring what the VM image runs. Nil
	// declares an image with no control agent: guest-dependent features
	// (guest file writes, workspace mounts) are disabled, RemoteControl
	// reports errors.ErrUnsupported, and teardown skips the graceful
	// guest shutdown attempt.
	RemoteControl RemoteControl

	// Logger receives manifest, VM lifecycle, SSH, and balloon logs. The
	// default discards logs.
	Logger *slog.Logger

	// ConsoleOutput receives explicitly requested console output. The default
	// is os.Stderr.
	ConsoleOutput io.Writer
}

Config holds the QEMU-only knobs. The zero value works.

type Console

type Console string

Console selects how the guest serial console is wired.

const (
	ConsoleOff         Console = "off"     // no serial console (default)
	ConsolePrint       Console = "print"   // guest console output printed to the host
	ConsoleInteractive Console = "console" // interactive console on the host terminal
)

type QGA

type QGA struct {
	// SocketPath overrides where the host-side guest-agent socket is
	// placed, relative to the state dir unless absolute.
	// Default: "qga.sock".
	SocketPath string
}

QGA is the qemu-guest-agent transport: the guest image runs qemu-guest-agent on the default virtio-serial channel (org.qemu.guest_agent.0), as with the virtle CLI today. The zero value works.

type RemoteControl

type RemoteControl interface {
	// contains filtered or unexported methods
}

RemoteControl is a guest-control transport for Config.RemoteControl. It is sealed (unexported method): QGA today, the virtle-native guest daemon later. Each transport carries its own knobs.

Directories

Path Synopsis
internal
balloon
Package balloon implements the internal virtio-balloon feature.
Package balloon implements the internal virtio-balloon feature.
hotplug
Package hotplug attaches and detaches runtime devices for a running VM.
Package hotplug attaches and detaches runtime devices for a running VM.
launch
Package launch contains the host-side launch planning and startup helpers.
Package launch contains the host-side launch planning and startup helpers.
qga
Package qga wraps the QEMU guest agent commands used by virtle.
Package qga wraps the QEMU guest agent commands used by virtle.
qmpclient
Package qmpclient wraps the QEMU Machine Protocol commands used by virtle.
Package qmpclient wraps the QEMU Machine Protocol commands used by virtle.
qmpwire
Package qmpwire shares line-delimited JSON socket helpers between the QMP and guest-agent clients, which speak the same wire framing over unix sockets.
Package qmpwire shares line-delimited JSON socket helpers between the QMP and guest-agent clients, which speak the same wire framing over unix sockets.
runtime
Package runtime owns the live manager runtime exposed through the control socket.
Package runtime owns the live manager runtime exposed through the control socket.
vmm
Package vmm is the qemu backend's VM machinery: the host-side launcher lifecycle behind backend/qemu and the virtle CLI.
Package vmm is the qemu backend's VM machinery: the host-side launcher lifecycle behind backend/qemu and the virtle CLI.
Package session is the virtle CLI's session layer over the qemu VM machinery: boot with CLI semantics, run the foreground session (the ssh-ready gate, the interactive SSH attach loop with autoprovision and retries, suspend-on-signal, stats), and the out-of-process suspend and hotplug commands.
Package session is the virtle CLI's session layer over the qemu VM machinery: boot with CLI semantics, run the foreground session (the ssh-ready gate, the interactive SSH attach loop with autoprovision and retries, suspend-on-signal, stats), and the out-of-process suspend and hotplug commands.

Jump to

Keyboard shortcuts

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