Skip to content

feat(vmm): improve VMM discovery - XDG_RUNTIME_DIR, cross-user, subcommands#593

Merged
kvinwang merged 9 commits intomasterfrom
worktree-vmm-discovery
Mar 21, 2026
Merged

feat(vmm): improve VMM discovery - XDG_RUNTIME_DIR, cross-user, subcommands#593
kvinwang merged 9 commits intomasterfrom
worktree-vmm-discovery

Conversation

@kvinwang
Copy link
Collaborator

Summary

Follow-up to #584. Improvements to the VMM instance discovery mechanism:

  • Use $XDG_RUNTIME_DIR/dstack-vmm instead of /run/dstack-vmm so no root permissions are needed; fall back to /run/user/<uid>/dstack-vmm via nix::unistd::getuid() when the env var is unset
  • vmm-cli.py scans /run/user/*/dstack-vmm/ to discover instances from all users on the host (verified: normal user can discover root's VMM)
  • Rename ls-vmm / switch-vmmvmm ls / vmm switch subcommand group
  • Nested subcommands shown in top-level --help output

Test plan

  • VMM registers in $XDG_RUNTIME_DIR/dstack-vmm/ (tested)
  • Fallback to /run/user/<uid>/ when XDG_RUNTIME_DIR unset (tested with env -u)
  • Root VMM instance discoverable by normal user (tested)
  • vmm ls and vmm switch work correctly
  • Top-level --help shows nested vmm ls / vmm switch
  • cargo fmt, cargo clippy clean

Use $XDG_RUNTIME_DIR/dstack-vmm instead of /run/dstack-vmm so that
no root permissions are needed. Falls back to /run/dstack-vmm when
XDG_RUNTIME_DIR is not set.
- vmm-cli.py scans /run/user/*/dstack-vmm/ to find instances from all
  users, not just the current user's XDG_RUNTIME_DIR
- Rust side falls back to /run/user/<uid>/dstack-vmm when
  XDG_RUNTIME_DIR is not set, reading uid from /proc/self/status
- Remove /run/dstack-vmm fallback (no longer needed)
Replace /proc/self/status parsing with nix crate's getuid() for
cleaner UID detection when XDG_RUNTIME_DIR is not set.
Group VMM instance management commands under a 'vmm' subcommand:
  vmm-cli.py vmm ls       (was: vmm-cli.py ls-vmm)
  vmm-cli.py vmm switch   (was: vmm-cli.py switch-vmm)
Resolve uid from the /run/user/<uid>/dstack-vmm discovery path to
a username via pwd.getpwuid() and display it in the USER column.
@kvinwang kvinwang force-pushed the worktree-vmm-discovery branch from d4e3e79 to 0919e7a Compare March 21, 2026 03:09
@kvinwang kvinwang enabled auto-merge March 21, 2026 03:15
@kvinwang kvinwang merged commit 8630143 into master Mar 21, 2026
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant