aev-vm 0.1.0

Manage QEMU virtual machines in Rust and open their consoles in Aen
Documentation

Aev VM

Aev VM is a Rust VM manager with a native Aen console. It uses QEMU/KVM for hardware virtualization while Rust owns VM definitions, process lifecycle, QMP control, the bounded RFB client, and the native console. KnottCompositor

The Rust manager creates qcow2 VMs and controls QEMU through QMP. The native Aen console displays guest RFB pixels and forwards keyboard and pointer input. Private socket tests cover this transport; complete guest boot and physical display acceptance remain separate release checks.

KnottCompositor <- native Aen frames <- KnottVM Rust console
                                             |
                                      private Unix RFB
                                             |
                                          QEMU/KVM
                                             |
                                       private Unix QMP
                                             |
                                      KnottVM lifecycle

Requirements

  • Linux x86-64 with Rust 1.88 or newer
  • qemu-system-x86_64 and qemu-img
  • /dev/kvm access for hardware acceleration; TCG is the automatic fallback
  • OVMF/EDK2 for the default UEFI firmware
  • An SMM-capable OVMF Secure Boot image for optional uefi-secure mode
  • A running native Aen session on KnottCompositor

On Arch Linux, the headless host packages are qemu-base and edk2-ovmf.

Install

cargo install aev-vm --locked

Run aev-vm in a terminal to create a VM or select one to open. On KnottOS, open Aev VM in Applications or the App Store to launch the same menu in Lios. The bundled knottvm command uses the existing VM definitions and storage directories.

Build from source

cargo build --release

The binary is target/release/aev-vm.

KnottCompositor

Use the native Aen session already managed by KnottDesktop. The console resolves AEN_WINDOW_SOCKET, then KNOTT_COMPOSITOR_SHELL_SOCKET with .windows appended, then $XDG_RUNTIME_DIR/knottx-shell.sock.windows.

For an explicitly configured existing session:

export AEN_WINDOW_SOCKET="$XDG_RUNTIME_DIR/knottx-shell.sock.windows"
aev-vm doctor

doctor verifies a native configure handshake without uploading a visible frame; it does not certify scanout or guest boot. No compositor restart or hardware display takeover is needed to open a console. See the native Aen guide for frame limits and input behavior. The opt-in scripts/e2e-headless.sh test uses a private native-only software compositor and QEMU.

First VM

aev-vm doctor
aev-vm init workstation \
  --iso "$HOME/Downloads/installer.iso" \
  --disk-size 128G \
  --memory 8192 \
  --cpus 8 \
  --firmware uefi
aev-vm run workstation

run starts a stopped VM and opens its console. Closing the console leaves the VM running. Reopen it with aev-vm console workstation. Add --tpm2 to aev-vm init when the guest needs a software TPM 2.0.

aev-vm status workstation
aev-vm pause workstation
aev-vm resume workstation
aev-vm reset workstation
aev-vm balloon workstation show
aev-vm stop workstation
aev-vm kill workstation

stop first requests an ACPI shutdown and escalates to QMP quit after the configured timeout. kill means immediate QMP quit; it does not send a Unix signal to an unverified PID.

Screenshots

Capture a running VM's current QEMU framebuffer without opening a console:

aev-vm screenshot workstation workstation.ppm

Screenshots are binary PPM files. QEMU writes to a fixed file inside the VM's private runtime directory; KnottVM validates the format and 256 MiB size limit before publishing the requested destination with owner-only permissions. Existing files and symlinks are never replaced.

Runtime Memory

Every VM includes a virtio memory balloon. A running VM can cooperatively return memory to the host without changing its next-boot configuration:

aev-vm balloon workstation show
aev-vm balloon workstation set 4096
aev-vm balloon workstation restore

Targets are limited to 256 MiB through the VM's configured boot memory. restore requests that configured maximum again. Balloon changes are asynchronous and require a functioning guest virtio-balloon driver; show reports QEMU's current guest-reported byte count. Targets are runtime-only and reset when QEMU restarts.

Guest Agent

Every VM includes a private virtio-serial channel named org.qemu.guest_agent.0. Install and enable qemu-guest-agent inside the guest to use OS-aware controls:

aev-vm agent workstation ping
aev-vm agent workstation info
aev-vm agent workstation shutdown
aev-vm agent workstation shutdown reboot

The channel is proxied through an owner-only Unix socket. agent shutdown asks the guest operating system to perform the action; stop remains the QMP/ACPI lifecycle fallback when an agent is unavailable.

Snapshots

Internal snapshots are intentionally offline so disk mutation cannot race a running guest:

aev-vm stop workstation
aev-vm snapshot workstation create clean-install
aev-vm snapshot workstation list
aev-vm snapshot workstation revert clean-install
aev-vm snapshot workstation delete clean-install

Snapshots cover only the qcow2 system disk; they do not include UEFI variable or software TPM state. To prevent a disk rollback from being paired with newer TPM state, KnottVM rejects snapshot creation and reversion for VMs with software TPM 2 enabled. Existing snapshots can still be listed or deleted. Portable backups include the stopped VM's software TPM state.

Cloning

Cloning is offline and creates an independent full qcow2 copy rather than a fragile backing-file chain:

aev-vm stop workstation
aev-vm clone workstation workstation-lab
aev-vm run workstation-lab

The clone receives its own disk, UEFI variable file, runtime sockets, and deterministic MAC identity. Installation-media configuration is retained, while host port forwards are cleared to prevent listener conflicts.

Backup And Restore

Portable backups are offline, independent, and self-verifying:

aev-vm stop workstation
aev-vm backup create workstation /mnt/backups/workstation-2026-07-10
aev-vm backup verify /mnt/backups/workstation-2026-07-10
aev-vm backup restore /mnt/backups/workstation-2026-07-10 workstation-restored

A backup directory contains an independent qcow2 image, portable TOML definition, optional UEFI variables, and a versioned JSON manifest with SHA-256 and exact-size checks for every artifact. Verification also runs qemu-img check. Restore verifies first, publishes the new definition last, assigns a new MAC identity, clears host port forwards, and does not retain installation-media paths.

Deletion

Deletion requires an explicit confirmation and a stopped VM:

aev-vm delete workstation-restored --yes

KnottVM removes only its definition, managed system.qcow2, UEFI variables, and runtime metadata. A manually configured disk outside the VM's managed data directory is reported and preserved. Unknown files in the data directory are also left untouched. Before creation, launch, or disk mutation, ownership checks compare canonical paths and file identities across definitions and pending deletions. They also detect another VM's reference to a managed path before its disk file exists; unreadable or unresolved peer references fail closed. A private cross-process lock serializes ownership scans, and deletion holds it until the disk and its tombstone are cleared.

Configuration

VM definitions use strict, versioned TOML under $XDG_CONFIG_HOME/knottvm/vms. Disks and UEFI variables live under $XDG_DATA_HOME/knottvm/vms. Owner-only sockets, PID metadata, and operation locks live under $XDG_RUNTIME_DIR/knottvm.

Example definition:

schema_version = 1
name = "workstation"
generation_id = "7d845e9b-b00f-4d7c-b845-e0bffb33d063"
memory_mib = 8192
vcpus = 8
acceleration = "auto"
firmware = "uefi"
audio = "none"
install_media = "/home/user/Downloads/installer.iso"

[disk]
path = "/home/user/.local/share/knottvm/vms/workstation/system.qcow2"
format = "qcow2"

[network]
mode = "user"

[[network.forwards]]
protocol = "tcp"
host_address = "127.0.0.1"
host_port = 2222
guest_port = 22

Remove install_media after installation if the ISO should no longer be attached, or manage it without editing TOML:

aev-vm media workstation show
aev-vm media workstation attach ~/Downloads/tools.iso
aev-vm media workstation detach

Media changes require the VM to be stopped. aev-vm command NAME prints the exact argument-safe QEMU launch for inspection.

USB Passthrough

An exact Linux USB bus and device address can be cold-plugged into a stopped VM. Use lsusb to identify the current numbers:

aev-vm stop workstation
aev-vm usb workstation add --bus 1 --address 4
aev-vm usb workstation list
aev-vm run workstation

The guest receives the entire physical device through QEMU's usb-host backend. The invoking user must already have permission to open its /dev/bus/usb node; KnottVM never elevates privileges or changes device permissions. Do not run KnottVM as root or pass through host hubs, keyboards, or other devices needed to control the host.

USB addresses can change after reconnect. Stop the VM and update the binding before restarting it:

aev-vm usb workstation remove --bus 1 --address 4

Host USB bindings are intentionally cleared from clones and portable backups. An absent, inaccessible, busy, or unsupported device makes VM startup fail rather than silently booting without it. Up to 14 host devices can be assigned to one VM.

Host Directory Shares

KnottVM can expose an existing host directory through QEMU's built-in virtio-9p transport without an external helper. Shares default to read-only and are changed while the VM is stopped:

aev-vm share workstation add host-data "$HOME/VM-Share"
aev-vm share workstation list
aev-vm run workstation

On a Linux guest with 9p support, mount the tag with:

mount -t 9p -o trans=virtio,version=9p2000.L host-data /mnt/host-data

Guest writes require explicit opt-in:

aev-vm stop workstation
aev-vm share workstation remove host-data
aev-vm share workstation add host-data "$HOME/VM-Share" --writable

Writable shares let guest software modify or delete files as the host user running QEMU. KnottVM uses mapped-xattr, never changes host permissions, and does not treat 9p as an isolation boundary. Share paths are host-local and are therefore cleared from clones and portable backups. Up to 16 shares can be configured per VM.

Storage Growth

System disks can only grow, never shrink, and the VM must be stopped:

aev-vm disk workstation info
aev-vm disk workstation grow 40G

After growing the virtual disk, expand the partition and filesystem inside the guest using its operating-system tools.

Port Forwarding

User-mode networking can expose guest services on IPv4 loopback without root or a bridge:

aev-vm stop workstation
aev-vm port workstation add --host-port 2222 --guest-port 22
aev-vm port workstation list
aev-vm run workstation
ssh -p 2222 localhost

Remove it while the VM is stopped:

aev-vm port workstation remove --host-port 2222

TCP and UDP are supported. Listener addresses are restricted to loopback by configuration validation so a typo cannot expose a guest service publicly.

Compute And Audio

Compute, accelerator, network, and audio settings are changed atomically while the VM is stopped:

aev-vm configure workstation \
  --memory 16384 \
  --cpus 8 \
  --acceleration auto \
  --network user \
  --audio pipewire

Audio is disabled by default. --audio pipewire creates an Intel HDA duplex device connected directly to the user's PipeWire session; this is a QEMU/host integration and does not require compositor-specific audio APIs.

Machine Identity

Each new VM receives a stable UUID exposed through QEMU's vmgenid device. KnottVM automatically generates a different identity for clones and restores, and changes it after snapshot rollback so modern guests can detect duplicated or rolled-back machine state.

aev-vm identity workstation show
aev-vm stop workstation
aev-vm identity workstation regenerate

Firmware And Secure Boot

New VMs use standard UEFI by default. Hosts with an SMM-capable OVMF Secure Boot image can select the secure firmware profile at creation or while the VM is stopped:

aev-vm doctor
aev-vm init workstation-secure --firmware uefi-secure
aev-vm configure workstation --firmware uefi-secure

The secure profile uses Q35 with SMM enabled, read-only secure OVMF code, a protected writable pflash device, and per-VM variable storage. doctor reports the matched uefi-secure-code and uefi-secure-vars paths. bios, uefi, and uefi-secure are the supported modes.

Selecting uefi-secure provides firmware capable of enforcing Secure Boot; it does not enroll keys. Enrollment and verification policy remain guest/firmware operations. The per-VM UEFI variables containing enrollment state are retained by clones and included in verified backups.

Design Choices

  • QEMU/KVM is the hypervisor instead of an incomplete new device model.
  • All control and display channels are Unix sockets inside mode-0700 runtime directories. RFB security type None is accepted only on that local socket.
  • The console uses the native Aen window SDK with bounded opaque BGRA frames, configure revisions and explicit frame acknowledgement credit.
  • Native GPU import and explicit synchronization remain prerequisites for an accelerated console presenter.
  • Guest-controlled dimensions, names, clipboard messages, rectangles, and framebuffer allocations are bounded before allocation or copying.

See docs/ARCHITECTURE.md for component and failure-boundary details. See COMPOSITOR_NEEDED.md for requirements that must be implemented in KnottCompositor rather than worked around in the VM manager.

Current Limits

  • One x86-64 system disk and one optional installation ISO
  • CPU frame scaling and native socket uploads; GPU presentation is pending
  • Native compositor-resolved keysyms, with a basic evdev fallback; primary touch maps to guest pointer input, while IME text commits and multitouch remain pending
  • Absolute tablet input remains the default; aev-vm configure NAME --pointer-device mouse opts into relative QEMU input and Aen capture. Escape releases capture, and a deliberate click requests it again.
  • USB passthrough is cold-plug only and uses reconnect-sensitive Linux bus and address selectors; no USB hotplug or stable physical-port matching yet
  • Host directory sharing uses virtio-9p and primarily targets Linux guests; virtiofsd is not installed on the current validation host
  • Framebuffer screenshots are bounded binary PPM files; image conversion is intentionally left to external user tools
  • No bridged networking, live migration, host-side Secure Boot enrollment UI, or atomic focus-generation fence from host clipboard read through final guest delivery. Host-to-guest paste is disabled by default; the unsafe --unsafe-unfenced-host-clipboard-paste option explicitly opts in despite that delivery race. Guest-to-host copy is an explicit shortcut scoped to the focused Aen window.
  • aev-vm init --tpm2 enables a persistent per-VM TPM 2.0. It requires the external swtpm and swtpm_ioctl helpers; KnottVM does not install them. Backups retain TPM state, while clones start with a fresh TPM identity.
  • KnottCompositor itself still needs broader toolkit compatibility, production input semantics, GPU composition, and session mediation

This is a tested foundation, not a claim of feature parity with mature desktop products. The process boundaries allow those features to be added without replacing VM definitions, QMP control, or the compositor-native console.

Development

cargo fmt --all -- --check
cargo clippy --all-targets -- -D warnings
cargo test --all-targets
bash scripts/e2e-headless.sh

The end-to-end test requires the sibling KnottCompositor debug binary. It boots real temporary QEMU VMs, validates QMP, screenshots, secure UEFI, balloon control, storage, host shares, network, USB configuration, snapshots, clone, backup/restore, and deletion, opens the RFB/native Aen console for three seconds, and cleans all temporary state.

Local verification — 2026-11-08

Offline all-target tests passed 154 library, 1 main, and 6 console-socket cases. Strict Clippy and formatting pass. The headless end-to-end script now creates private mode-0700 XDG directories before its doctor check and passes against KnottCompositor's headless backend. QEMU used TCG because /dev/kvm is not accessible here. The run exercises VM lifecycle/QMP, screenshots, storage, shares, snapshots, clone/backup/restore, and the native Aen console; it does not qualify KVM acceleration, complete guest OS boot, or physical display. Its temporary /tmp state is cleaned on exit.

Licensed under either Apache-2.0 or MIT.