aev-vm 0.2.0

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

The KnottVM console connects directly to KnottCompositor through the vendored
Rust `aen-window` SDK. No Wayland client dependency or display fallback is used.

The vendored SDK is synchronized with KnottCompositor
`07774eb74f2d08853b4e8f5fa76b698a602a5360`. It includes opt-in bounded
semantic accessibility snapshots, frame-local component bounds, and negotiated
app-local actions tied to the accepted snapshot. KnottVM does not opt into these
features, publish an accessibility tree, handle accessibility action events,
or provide an AT-SPI/screen-reader bridge.

`knottvm run` and `knottvm console` request sealed shared-memory frame transfer
(Aen SDK option bit 10). They require a compositor that supports the option,
such as KnottCompositor `b555258` or later; an older server rejects the opt-in
without reconnecting or replaying window creation. Pixels use sealed memfds and
read-only compositor mappings; frame acknowledgement and adoption behavior stay
the same. `knottvm doctor` continues to check the default Aen configure handshake
and does not certify shared-memory support.

The endpoint is selected in this order:

1. `AEN_WINDOW_SOCKET`, an absolute native window socket path.
2. `KNOTT_COMPOSITOR_SHELL_SOCKET` with `.windows` appended.
3. `$XDG_RUNTIME_DIR/knottx-shell.sock.windows`.

Run `knottvm doctor` in the Aen session to check the native configure handshake
and existing VM host dependencies. This opens no visible surface and does not
certify presentation or guest boot. Use `knottvm console NAME` for a running VM,
or `knottvm run NAME` to start it and open its console.

Guest RFB pixels are converted from BGRX to opaque BGRA, preserving aspect ratio
with opaque black letterboxing. Native frames follow SDK limits (8192 pixels per
dimension, 32 MiB per frame), exact configure revisions and one outstanding frame
credit. Large guest modes are scaled; the initial preferred surface is reduced
until it fits those limits. The worker keeps transport progress independent of
rendering; the owner waits on both native Aen and RFB event descriptors and sleeps
indefinitely while idle.

Host-to-guest paste is disabled by default. `Ctrl+Alt+Shift+V` remains guest
input unless the user explicitly passes
`--unsafe-unfenced-host-clipboard-paste` to `knottvm run` or `knottvm console`.
The window title marks this mode as unsafe. The Aen SDK fences each clipboard
read chunk to one compositor focus epoch, and the console discards completions
after observed focus loss, close, or window replacement. The compositor has no
operation that atomically binds the last clipboard read to the final RFB guest
write, so a focus change can race that write. Clipboard text never transfers
automatically.
`Ctrl+Alt+Shift+C` explicitly copies the latest bounded guest clipboard text to
the host through the focused Aen window scope. KnottVM clears its guest-text
snapshot on focus loss, close or window replacement; the compositor checks the
window scope while servicing each write. Text is limited to 64 KiB and legacy
RFB Latin-1; CRLF and CR become LF, and expansion beyond the UTF-8 clipboard
limit is rejected. Pending clipboard work is polled at 50 ms intervals; each
request has a six-second deadline. Observed focus loss, close, or window
replacement cancels the in-flight clipboard worker and discards its pending
request. Modifier keydowns are forwarded immediately
so ordinary game input and slow chord entry remain responsive. When either
host shortcut is recognized, KnottVM sends matching keyups to balance
guest-visible modifier presses, then consumes the host shortcut key and the
physical modifier releases. The guest may briefly observe Ctrl, Alt and Shift
before those balancing keyups.

Input follows the adopted frame's geometry through resizes. Keys use
compositor-resolved keysyms, and key releases retain the original press symbol
even if modifiers change. Focus loss, leave, close and disconnect release held
guest keys/buttons. Absolute pointer mapping remains the default. KnottVM opts
into QEMU's `-257` pointer-mode notice and follows the selected guest input
device. Existing definitions keep the absolute `usb-tablet`. Switch a stopped
VM with `knottvm configure NAME --pointer-device mouse` to attach QEMU's
`usb-mouse`; `--pointer-device tablet` restores the default. Ordinary guests can
select the mouse's relative mode. When QEMU reports that mode, KnottVM requests
an Aen pointer lock. It sends signed 16-bit RFB deltas from Aen only after the
matching grant; button-only relative packets use QEMU's neutral
`0x7fff,0x7fff` coordinates. When unlocked, absolute cursor movement is
converted to bounded deltas so movement and clicks remain usable after Escape or
a denied lock. Each Aen relative-motion event is clamped to at most four QEMU
relative RFB packets per axis to bound work on extreme deltas. Escape releases
input and requests unlock.

Denial, revocation, Escape, focus loss or leave stop captured relative motion and
do not re-request the lock on focus alone. A fresh button press in the window
explicitly retries capture. Unlocked cursor movement is differenced in guest
framebuffer coordinates; the first position after a mode or focus transition
seeds the baseline to avoid a jump.
After a pointer-lock grant, KnottVM requests native desktop shortcut inhibition.
The compositor retains Ctrl+Alt+Escape as its reserved physical escape chord;
capture requires a deliberate click to retry after release. See
[native capture](NATIVE_CAPTURE.md) for configuration and permission behavior.
Guest-to-host clipboard copy uses the focused Aen window scope and an explicit
shortcut. Touch input maps the first active contact to guest pointer motion and
the primary button; extra contacts are ignored, and focus loss or touch cancel
releases the guest hold. Guest IME text commits, multitouch and GPU presentation
remain pending integrations. The application is Rust; virtual hardware and
execution remain QEMU/KVM or TCG.

`cargo test --locked` exercises pure logic and private Unix sockets without a
real display or VM. `scripts/e2e-headless.sh` is an opt-in test that starts the
native-only headless compositor and QEMU; its success must be established
separately before claiming complete guest/display acceptance.

The [native compositor smoke](../scripts/native-compositor-smoke/README.md)
drives this console with a private synthetic RFB peer against the actual native
software compositor. It checks opaque pixels, tiling configure adoption, workspace
hide/restore, close and window-memory release without QEMU or physical devices.