cleanup: remove vmsilo-start-* scripts, rename vmsilo-usb to vm-usb, fix vm-run output

- Remove vmsilo-start-* user-facing symlinks from package.nix (internal
  VM launcher scripts are only used by systemd ExecStart, not by users)
- Rename vmsilo-usb to vm-usb to match the vm-* naming convention
- Increase socat -t timeout in vm-run from default 0.5s to 5s to fix
  missing output from console commands (cloud-hypervisor proxy startup
  latency exceeded the default timeout window)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Davíð Steinn Geirsson 2026-03-22 16:51:07 +00:00
parent 7148a5578c
commit faad5006c9
5 changed files with 18 additions and 21 deletions

View file

@ -54,7 +54,7 @@ The configured user can manage VM services via polkit (no sudo required for `vm-
- `options.nix` — option declarations (`programs.vmsilo`; includes `vm.<name>.hypervisor` for VMM selection: `crosvm` or `cloud-hypervisor`)
- `scripts.nix` — VM launcher scripts (crosvm/cloud-hypervisor) and user-facing CLI scripts (`vm-run`, `vm-start`, `vm-stop`, `vm-shell`)
- `services.nix` — systemd units (VM service, proxy, console relay, session bind, GPU device backend, wayland-seccontext)
- `usb.nix``vmsilo-usb` CLI script (USB passthrough via usbip-rs)
- `usb.nix``vm-usb` CLI script (USB passthrough via usbip-rs)
- `desktop.nix` — .desktop file generation and icon copying
- `networking.nix` — TAP interfaces, host nftables for `netvm = "host"`, guest network config
- `netvm.nix` — auto VM-to-VM and VM-to-host network links
@ -93,7 +93,7 @@ The configured user can manage VM services via polkit (no sudo required for `vm-
- `vm-start <name>` — start VM via systemd (polkit, no sudo)
- `vm-stop <name>` — stop VM via systemd (polkit, no sudo)
- `vm-shell <name>` — connect to VM serial console (default) or SSH with `--ssh`
- `vmsilo-usb [attach|detach] [<name> <vid:pid|devpath>]` — list USB devices, attach/detach USB devices to VMs
- `vm-usb [attach|detach] [<name> <vid:pid|devpath>]` — list USB devices, attach/detach USB devices to VMs
See README.md for full usage details and options.

View file

@ -468,12 +468,12 @@ banking = {
#### Runtime CLI
The `vmsilo-usb` command manages USB device assignments at runtime:
The `vm-usb` command manages USB device assignments at runtime:
```bash
vmsilo-usb # List all USB devices and which VM they're attached to
vmsilo-usb attach <vm> <vid:pid|devpath> # Attach a device (detaches from current VM if needed)
vmsilo-usb detach <vm> <devpath> # Detach a device from a VM (devpath only, not VID:PID)
vm-usb # List all USB devices and which VM they're attached to
vm-usb attach <vm> <vid:pid|devpath> # Attach a device (detaches from current VM if needed)
vm-usb detach <vm> <devpath> # Detach a device from a VM (devpath only, not VID:PID)
```
Devices can be identified by `vid:pid` (e.g., `17ef:60e0`) or by sysfs devpath (e.g., `1-2.3`) for attach. Detach requires the devpath.
@ -596,7 +596,7 @@ The host provides:
- Console PTY for serial access (`/run/vmsilo/<name>/console`)
- VM services run as root for PCI passthrough and sandboxing (crosvm drops privileges)
- Polkit rules for the configured user to manage VM services without sudo
- CLI tools: `vm-run`, `vm-start`, `vm-stop`, `vm-shell`, `vmsilo-usb`
- CLI tools: `vm-run`, `vm-start`, `vm-stop`, `vm-shell`, `vm-usb`
- Desktop integration with .desktop files for guest applications
**Note:** Runtime sockets use per-VM subdirectories (`/run/vmsilo/<name>/*.socket`) rather than the older flat layout (`/run/vmsilo/<name>-*.socket`).

View file

@ -15,11 +15,6 @@ let
mkdir -p $out/bin
mkdir -p $out/share/bash-completion/completions
# VM launcher scripts
${lib.concatMapStringsSep "\n" (vm: ''
ln -s ${cfg._internal.vmScripts.${vm.name}} $out/bin/vmsilo-start-${vm.name}
'') (lib.attrValues cfg.nixosVms)}
# User-facing scripts
${lib.concatMapStringsSep "\n" (name: ''
ln -s ${cfg._internal.userScripts.${name}} $out/bin/${name}
@ -30,7 +25,7 @@ let
# Bash completions
${lib.optionalString cfg.enableBashIntegration ''
for cmd in vm-run vm-start vm-stop vm-shell vmsilo-usb; do
for cmd in vm-run vm-start vm-stop vm-shell vm-usb; do
ln -s ${cfg._internal.bashCompletionScript} $out/share/bash-completion/completions/$cmd
done
''}

View file

@ -370,7 +370,9 @@ let
fi
# Send command via socket (triggers activation if needed)
echo "$@" | ${pkgs.socat}/bin/socat - UNIX-CONNECT:"$SOCKET"
# -t5: wait up to 5s for response after stdin EOF (default 0.5s is too short
# for cloud-hypervisor proxy startup: Python interpreter + CONNECT handshake)
echo "$@" | ${pkgs.socat}/bin/socat -t5 - UNIX-CONNECT:"$SOCKET"
'';
# vm-start: Start VM via systemd (uses polkit for authorization)

View file

@ -1,5 +1,5 @@
# USB passthrough CLI for vmsilo
# Provides vmsilo-usb script for listing, attaching, and detaching USB devices to/from VMs
# Provides vm-usb script for listing, attaching, and detaching USB devices to/from VMs
{
config,
pkgs,
@ -11,7 +11,7 @@ let
cfg = config.programs.vmsilo;
vms = lib.attrValues cfg.nixosVms;
vmsiloUsbScript = pkgs.writeShellScript "vmsilo-usb" ''
vmUsbScript = pkgs.writeShellScript "vm-usb" ''
set -euo pipefail
VM_NAMES="${lib.concatMapStringsSep " " (vm: vm.name) vms}"
@ -127,7 +127,7 @@ let
if ! is_devpath "''${devpath}"; then
echo "Error: detach requires a device port (e.g., 1-2), not VID:PID" >&2
echo "Run 'vmsilo-usb' to see device ports." >&2
echo "Run 'vm-usb' to see device ports." >&2
exit 1
fi
@ -148,20 +148,20 @@ let
;;
attach)
if [ $# -ne 3 ]; then
echo "Usage: vmsilo-usb attach <vm> <vid:pid|devpath>" >&2
echo "Usage: vm-usb attach <vm> <vid:pid|devpath>" >&2
exit 1
fi
cmd_attach "$2" "$3"
;;
detach)
if [ $# -ne 3 ]; then
echo "Usage: vmsilo-usb detach <vm> <devpath>" >&2
echo "Usage: vm-usb detach <vm> <devpath>" >&2
exit 1
fi
cmd_detach "$2" "$3"
;;
*)
echo "Usage: vmsilo-usb [attach <vm> <vid:pid|devpath> | detach <vm> <devpath>]" >&2
echo "Usage: vm-usb [attach <vm> <vid:pid|devpath> | detach <vm> <devpath>]" >&2
echo "" >&2
echo "With no arguments, lists all USB devices and their VM assignments." >&2
exit 1
@ -172,7 +172,7 @@ in
{
config = lib.mkIf cfg.enable {
programs.vmsilo._internal = {
userScripts.vmsilo-usb = vmsiloUsbScript;
userScripts.vm-usb = vmUsbScript;
};
};
}