Commit graph

55 commits

Author SHA1 Message Date
08709827fb feat: replace crosvm USB passthrough with usbip-over-vsock
Replace crosvm xhci-based USB passthrough with usbip-rs over vsock,
enabling USB passthrough for both crosvm and cloud-hypervisor VMs.

Guest runs a persistent usbip-rs client listener on vsock port 5002.
Host runs one sandboxed usbip-rs host connect process per attached
device as a systemd template service (vmsilo-<vm>-usb@<devpath>).

Eliminates the JSON state file, file locking, and crosvm-specific
shell helper library in favor of systemd as the source of truth.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-22 16:15:27 +00:00
bf23b518b8 feat: use cloud-hypervisor custom flake input instead of nixpkgs
Now that git.dsg.is/dsg/cloud-hypervisor.git has a flake.nix,
use it as a proper flake input with inputs.nixpkgs.follows.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-21 09:36:45 +00:00
e4326c77df feat: add cloud-hypervisor and vmsilo-wayland-seccontext to flake.nix
Add buildVmsiloWaylandSeccontext build function and expose vmsilo-wayland-seccontext
and cloud-hypervisor (from nixpkgs) as package outputs. Inject both into
_internal module options. Remove nvidiaWeakenSandbox-conditional crosvm selection.

Note: git.dsg.is/dsg/cloud-hypervisor.git has no flake.nix, so cloud-hypervisor
is sourced from nixpkgs instead of a dedicated flake input.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-21 09:34:52 +00:00
9eef2c4506 Rename vmsilo-tray to vmsilo-dbus-proxy in NixOS modules, add dbus.notifications and dbus.tray options
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-20 17:19:43 +00:00
26ce3c9683 Use vhost-device flake input for vhost-device-sound
Replace the local package derivation with the one now provided by the
vhost-device flake, removing packages/vhost-device-sound.nix.

Also bump wayland-proxy-virtwl.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-17 21:32:24 +00:00
cd9c24e6c1 Format with nixfmt
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-17 18:42:12 +00:00
f82e4121d3 Wire vhost-device-sound into flake and module _internal
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-17 18:41:00 +00:00
66abe2d2d3 Remove netvmSettings, mostly automated by isNetvm now 2026-03-17 12:55:23 +00:00
e976b3d05b Add KDE/Breeze theming infrastructure to base guest config
Move Qt platform theme setup (plasma-integration, breeze, breeze-gtk,
breeze-icons) into the base VM configuration so all guests get consistent
theming out of the box. Previously qt.platformTheme was set in
optionalGuestSettings but qt.enable was never set, so it had no effect.

optionalGuestSettings now only configures dark theme (BreezeDark color
scheme, Breeze-Dark GTK theme, breeze-dark icons) on top of the base.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-13 00:31:05 +00:00
1eb064d184 Fix dark theme broken by xdg-desktop-portal-kde
xdg-desktop-portal-kde reports color-scheme via org.freedesktop.appearance
by reading QApplication palette colors. Without a KDE dark color scheme in
kdeglobals, the portal reported "prefer-light", overriding the GTK dark
theme settings for Firefox and other apps.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-13 00:24:12 +00:00
16b08cc3c8 Add nvidiaWeakenSandbox option to select crosvm-nvidia package
Nvidia GPU drivers require RWX memory pages, which crosvm's seccomp
sandbox blocks. This option switches to a crosvm-nvidia build with
a relaxed W+X memory policy, keeping the default secure.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-21 00:46:58 +00:00
e382e6003c Enable realtime priority for audio thread
crosvm changes for realtime audio, plus some minor log message improvements.

Also stop pinning nixpkgs as the upstream build failure has been resolved.
2026-02-19 17:33:49 +00:00
2450a4f06f Implement wayland protocol whitelist for VM windows
Also pin nixpkgs to avoid build failure for deno in current master.
2026-02-18 11:44:37 +00:00
61ca26690a Remove vm-switch and bufferbloat-test
The vm-switch experiment for VM-to-VM networking via vhost-user-net
didn't work out — it performs poorly under load, with busy connections
saturating the buffer and causing high latency for others.

Removes the vm-switch Rust crate, bufferbloat-test suite, all NixOS
module integration (options, services, networking, assertions, scripts),
and documentation.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-17 23:41:13 +00:00
a4b967862f feat(tray): add tray proxy for VM system tray integration
Proxy guest StatusNotifierItems to the host system tray over vsock:5001.
Guest-side watches SNI registrations on D-Bus, collects snapshots
(properties + DBusMenu tree), and streams them to the host. Host-side
creates synthetic SNI items with sanitized data and forwards user
interactions (clicks, scrolls, menu events) back to the guest. Includes
icon theme forwarding, VM color tinting on icon borders, CSS named color
resolution, and automatic service startup with the VM.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-17 23:29:42 +00:00
db711e9cff feat: add vmsilo-balloond dynamic balloon memory daemon
Implements a host-side daemon that equalizes free memory headroom between
host and guests via virtio-balloon, using ChromeOS's BalanceAvailablePolicy.
Includes VM discovery via inotify, crosvm control socket client, stall
detection, NixOS module integration, and CLI argument parsing.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-17 18:09:30 +00:00
54ef59ba23 Fix wrong option name 2026-02-16 22:23:30 +00:00
2fadb48ae8 Add optional netvm config module 2026-02-16 22:14:48 +00:00
5fd3f1578a Add some opinionated optional guest config, update docs 2026-02-16 22:02:39 +00:00
84203ff1da feat: accept list of NixOS modules in guestConfig
guestConfig now accepts a single module or a list of modules via
coercedTo. Single modules are auto-wrapped in a list for backwards
compatibility.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-16 20:37:39 +00:00
0d36da9f55 Move project under dsg gitlab namespace 2026-02-15 13:15:50 +00:00
cbfab2fc6d feat(modules): add per-VM waylandProxy option (wayland-proxy-virtwl or sommelier)
Allows each VM to choose its Wayland proxy. Defaults to wayland-proxy-virtwl
(existing behavior). Setting waylandProxy = "sommelier" uses the ChromeOS
sommelier compositor instead.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-14 17:09:56 +00:00
7636ef28cb Add sommelier package 2026-02-14 17:01:22 +00:00
5e396eb587 add wayland decoration security test suite
Nine minimal Wayland client programs to exercise decoration bypass
vectors identified in the security audit. Tests 1-6 cover CSD request,
no-protocol, mode-none, server-decoration-none, fullscreen, and layer
shell. Tests 7-9 add large popup, subsurface overflow, and SSD request
(control). Includes Nix package and dev shell in flake.nix.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-12 22:31:53 +00:00
c4da5c47b0 Fix bufferbloat-test VM boot
VM returns iperf and ping results. vm-switch metrics are not working.
2026-02-11 21:53:33 +00:00
faffa186cb bufferbloat-test: Add test harness for bufferbloat analysis
New `nix run .#bufferbloat-test -- --initial-credits 64k` command that:
- Launches vm-switch with two benchmark VMs (server + client)
- Runs iperf3 throughput test with concurrent ping for latency measurement
- Collects vm-switch metrics on shutdown
- Outputs merged JSON with throughput, latency, and internal switch metrics

Files:
- bufferbloat-test/guest-config.nix: NixOS guest config with role-based startup
- bufferbloat-test/run-test.sh: Orchestration script
- bufferbloat-test/default.nix: Nix package definition
- flake.nix: Package and app integration

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-11 21:53:33 +00:00
8ea84378c5 Rename project from qubes-lite to vmsilo
All references updated: NixOS module namespace (programs.vmsilo),
systemd units (vmsilo-*), runtime paths (/run/vmsilo/), bash
completion functions (_vmsilo_*), XDG categories (X-Vmsilo-*),
desktop integration, and documentation. No backward compatibility.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-09 20:34:39 +00:00
8bb35bfc0f vm-switch: Switch back to upstream vhost 2026-02-07 21:45:26 +00:00
32330ecd20 Fix vm-switch memory mapping bug causing TX timeouts
Two bugs were causing virtio_net TX timeouts in guest VMs:

1. inject_rx_frame used the source VM's memory mapping to access the
   destination VM's vring descriptors. Fixed by making inject_rx_frame
   a static method that uses the vring's own internal memory via a new
   memory() accessor in VringState.

2. handle_event called read_kick() redundantly after the event loop
   already consumed the eventfd, potentially blocking on a drained fd.

We temporarily use a local vnet library for debugging.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-07 21:25:33 +00:00
830b30f72f Add VIRTIO_NET_F_STATUS feature and fix config status/queue values
- Add VIRTIO_NET_F_STATUS feature flag to advertise link status support
- Set config status byte to VIRTIO_NET_S_LINK_UP (1) so guests see the
  link as up instead of down
- Set max_virtqueue_pairs to 1 (was 0, which could confuse guests)
- Update vhost crate hash (upstream change)

This prevents potential issues where guest drivers might see the
interface as disconnected because the status field was returning 0.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-07 20:14:12 +00:00
32dd49c47b Add vm-switch daemon for VM-to-VM networking
Implements a vhost-user network switch daemon that enables L2 networking
between VMs in the same vmNetwork. The switch uses a router/client
topology where:

- Each network has exactly one router VM
- Client VMs can only communicate through the router
- MAC addresses are discovered via inotify-watched config directory

The daemon implements the vhost-user protocol to provide virtio-net
backends that crosvm connects to via --vhost-user sockets.

Key components:
- vm-switch Rust crate with MAC parsing, frame routing, and vhost-user backend
- NixOS module integration with per-network systemd services
- Automatic daemon startup when VMs are added to a network

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-07 15:58:26 +00:00
eb4e2ffcaa Add VM configuration options and migrate to --block
- Rename `disks` to `additionalDisks` with structured format
  (path, readOnly, enableDiscard, blockSize, devIdentifier, useDirect)
- Add custom boot options: rootDisk, kernel, initramfs, rootDiskReadonly
- Add kernelParams for extra kernel command line options
- Add gpu option (default: "context-types=cross-domain:virgl2")
- Add sharedDirectories for crosvm --shared-dir
- Add global crosvmLogLevel option (default: "info")
- Add --name argument to crosvm set to VM name
- Migrate deprecated --disk/--rwdisk to --block format
- Switch flake to nixos-unstable channel

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-04 19:09:51 +00:00
3450465149 Bump crosvm (rebased on latest upstream) 2026-02-04 16:03:00 +00:00
1fcad4dca8 Add treefmt-nix formatter and clean up idiomatic Nix patterns
- Add treefmt-nix with nixfmt for code formatting (nix fmt)
- Extract cidrToNetworkBase and mkVmCase helper functions
- Use lib.nameValuePair for cleaner listToAttrs patterns
- Consolidate assertions with single let block
- Remove duplicate util-linux package
- Document formatting requirement in CLAUDE.md
- Apply nixfmt to all Nix files

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-04 16:02:43 +00:00
45ffac9190 Update crosvm GPU seccomp policy to fix segfaults
Allow madvise(MADV_NOHUGEPAGE), setsockopt and sendmmsg. nvidia driver
calls XOpenDisplay which triggers DNS resolution so these are needed.
2026-02-04 11:09:51 +00:00
7274fafbdc Force server-side decorations
Use my wayland-proxy-virtwl fork. Unconditionally requests server-side
decorations even if the client doesn't want them.

Tested with firefox, works there.
2026-02-04 09:39:57 +00:00
62ab0476b8 refactor: remove legacy s6-based rootfs implementation
Remove the old s6/execline-based rootfs in favor of the NixOS module approach:

- Delete rootfs/ directory (s6-based rootfs builder)
- Delete mktuntap/ directory (TAP utility, now using --tap-name)
- Delete default.nix (legacy package with vs*/tt*/ff* scripts)
- Update flake.nix to point packages.default to rootfs-nixos
- Update documentation to reflect NixOS-only architecture

The NixOS module (modules/) with socket-activated VMs is now the only
supported approach. VMs are configured declaratively via
programs.qubes-lite.nixosVms.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-04 02:09:10 +00:00
eb758f1892 Add declarative NixOS module for VM configuration
Replace the simple guestPrograms-only module with a full declarative
module that allows configuring VMs from configuration.nix:

- programs.qubes-lite.enable, user, vmNetwork, natEnable, natInterface
- programs.qubes-lite.nixosVms list with per-VM config (id, name,
  memory, cpus, network, disks, guestPrograms, guestConfig)
- Automatic TAP interface creation via networking.interfaces
- NAT configuration for VM internet access
- Per-VM NixOS rootfs builds with combined packages
- Generated launcher scripts (qubes-lite-start-<name>)
- run-in-vm helper for executing commands via vsock
- Systemd user services for each VM
- Validation: odd IDs 3-255, unique IDs/names
2026-02-03 23:09:56 +00:00
c50b309807 WIP: Add rootfs-nixos package for NixOS-based VM images
Adds a new rootfs-nixos/ package that builds a NixOS system into a
qcow2 image with overlayfs root (read-only ext4 + tmpfs upper).
2026-02-03 21:32:14 +00:00
b46e11d551 Use my crosvm fork for nVidia compat, home paths 2026-02-03 19:18:07 +00:00
Thomas Leonard
76c845a22f Update to NixOS 25.11
Changes needed:

- Some minor renaming for nixpkgs changes.
- Kernel modules now come from a separate output.
- dash over vsock seems to be broken; switched to bash.
  (it seems to be trying to use the console instead of the vsock)
2025-12-01 12:24:02 +00:00
Thomas Leonard
6bb8e07552 Allow configuring guest packages 2025-11-19 12:12:03 +00:00
Thomas Leonard
8f24386f06 Update to nixos-25.05 stable branch 2025-05-24 09:12:41 +01:00
Thomas Leonard
e7514f2358 Update to nixos 25.05 beta 2025-05-17 10:02:59 +01:00
Thomas Leonard
57e84cceef Update to NixOS 24.11 2024-12-28 16:20:03 +00:00
Thomas Leonard
a5ae46c4ee Update to NixOS 24.05 2024-06-17 11:16:08 +01:00
Thomas Leonard
0c9ce8f2dd Update crosvm to r124
Requires new wayland proxy, as the protocol changed
(https://github.com/talex5/wayland-proxy-virtwl/pull/77).
2024-04-08 16:49:50 +01:00
Thomas Leonard
090c8c9c8f Update Linux and crosvm 2024-04-07 12:27:41 +01:00
Thomas Leonard
9b7f33afc6 Update to latest Wayland proxy 2024-03-26 14:31:37 +00:00
Thomas Leonard
50b9cd446b Update to NixOS 23.11
Had to enable dbus as xfce4-terminal no longer works without a dbus
configuration service (it defaults to an unusable font and you can't
change it).

`chmod a+rw /dev/vsock` avoids a warning from socat, although it seems
to work OK without it.

`/run/current-system/sw/bin` is used by dbus-launch.
2023-11-28 15:00:24 +00:00