diff options
| -rw-r--r-- | docs/superpowers/specs/2026-11-13-vm-tab-design.md | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/docs/superpowers/specs/2026-11-13-vm-tab-design.md b/docs/superpowers/specs/2026-11-13-vm-tab-design.md new file mode 100644 index 0000000..b327f7a --- /dev/null +++ b/docs/superpowers/specs/2026-11-13-vm-tab-design.md @@ -0,0 +1,50 @@ +# VM tab design + +A tab that manages the libvirt VMs on `qemu:///system`: power, state, +snapshots, and an ssh session in kitty. Mirrors keystone's drawer VM page +(quickshell `desktop/modules/vm/Virsh.qml`) so the tab can supersede it. + +## Server: `deckit/modules/vm.py` + +- `state()` runs `virsh domstats --state --cpu-total --balloon --vcpu` (one + call for every VM, default URI) and returns `{vms: [{name, state, vcpus, + cpu, mem, ip, saved, snapshots}]}`. CPU% is the delta of `cpu.time` + between two polls over wall time and vCPUs. Memory is `balloon.current`. +- A background thread (like `stats`' updates) refreshes the slow parts at + most every 10s: `dominfo` (managed save), `snapshot-list --name`, and the + guest agent IP (`domifaddr --source agent`, running VMs only). A missing + agent gives no IP, never an error. Any action triggers a refresh. +- `virsh` failing gives `{offline: true, reason}`, drawn by `offline.js`. +- Actions take `{vm, snap?}`; `vm` must be in the last listed names and + `snap` in that VM's snapshots, else `ModuleError`: + `start`, `shutdown` (acpi), `reboot`, `reset`, `destroy`, `suspend`, + `resume`, `discardsave`, `snapshot` (named `<vm>_<ddMMyyyy_HHmmss>`), + `revert`, `snapdelete`, `ssh`. virsh's stderr becomes the error. +- `ssh`: the first `$XDG_RUNTIME_DIR/kitty-<pid>` socket that answers gets + `kitty @ launch --type=tab ssh <vm>` and its window is focused through + hyprctl (`pid:<pid>`, Lua or classic as `windows`); with no kitty, + `kitty ssh <vm>` is spawned. The host is the VM name, so an `~/.ssh/config` + alias named after the VM is expected (as the drawer assumes). + +## Panel: `static/modules/vm.js`, tab "VMs" + +One card per VM: name, state pill, CPU and memory bars, IP, a managed-save +badge. Buttons by state as in the drawer. Destructive ones (`destroy`, +`reset`, `discardsave`, `revert`, `snapdelete`) are press-and-hold like the +K1C stop. Snapshot rows under each VM with revert and delete. An action's +error shows on the card. + +## Keystone + +`Modules.js` (quickshell repo): `vm` in `TABS`, `vm: "VMs"` in `NAMES`. The +`[modules] vm` switch appears by itself from `deck-it defaults`. + +## Skipped + +VM delete (undefine with storage), `qemu:///session`, the ssh-ready notice, +Docker, a dashboard chip. Add when wanted. + +## Tests + +`tests/test_vm.py`: domstats parsing, CPU delta, action validation, the ssh +command choice. `node --check static/modules/vm.js`. |
