diff --git a/CLAUDE.md b/CLAUDE.md index 5e2aa45..ec20afe 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -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..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 ` — start VM via systemd (polkit, no sudo) - `vm-stop ` — stop VM via systemd (polkit, no sudo) - `vm-shell ` — connect to VM serial console (default) or SSH with `--ssh` -- `vmsilo-usb [attach|detach] [ ]` — list USB devices, attach/detach USB devices to VMs +- `vm-usb [attach|detach] [ ]` — list USB devices, attach/detach USB devices to VMs See README.md for full usage details and options. diff --git a/README.md b/README.md index a4c013d..bc7bdfb 100644 --- a/README.md +++ b/README.md @@ -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 # Attach a device (detaches from current VM if needed) -vmsilo-usb detach # 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 # Attach a device (detaches from current VM if needed) +vm-usb detach # 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//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//*.socket`) rather than the older flat layout (`/run/vmsilo/-*.socket`). diff --git a/modules/package.nix b/modules/package.nix index 90dd217..a80d8ec 100644 --- a/modules/package.nix +++ b/modules/package.nix @@ -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 ''} diff --git a/modules/scripts.nix b/modules/scripts.nix index a2a550e..433e818 100644 --- a/modules/scripts.nix +++ b/modules/scripts.nix @@ -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) diff --git a/modules/usb.nix b/modules/usb.nix index e29b59e..508114c 100644 --- a/modules/usb.nix +++ b/modules/usb.nix @@ -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 " >&2 + echo "Usage: vm-usb attach " >&2 exit 1 fi cmd_attach "$2" "$3" ;; detach) if [ $# -ne 3 ]; then - echo "Usage: vmsilo-usb detach " >&2 + echo "Usage: vm-usb detach " >&2 exit 1 fi cmd_detach "$2" "$3" ;; *) - echo "Usage: vmsilo-usb [attach | detach ]" >&2 + echo "Usage: vm-usb [attach | detach ]" >&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; }; }; }