feat(vmm): add experimental systemd process manager - #1022
Open
kvinwang wants to merge 1 commit into
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Adds an experimental, opt-in systemd-based process manager for dstack-vmm so VMs can be launched as transient systemd services (dedicated cgroups) while preserving existing supervisor-backed behavior as the default.
Changes:
- Introduces a
ProcessManagerabstraction with a newSystemdProcessManagerbackend driven bysystemd-run/systemctl, persisting process metadata for restart reconciliation. - Extends VMM configuration to select the backend and configure systemd unit naming/state storage.
- Adds documentation describing the runtime model, inspection commands, and current limitations.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| dstack/vmm/vmm.toml | Adds config knobs to select the process-manager backend and configure systemd unit/state settings. |
| dstack/vmm/src/process_manager.rs | Implements the new systemd process-manager backend and shared abstraction over supervisor vs systemd. |
| dstack/vmm/src/main.rs | Wires backend selection to instantiate either the existing supervisor client or the new systemd manager. |
| dstack/vmm/src/config.rs | Adds ProcessManagerBackend and systemd-specific configuration defaults. |
| dstack/vmm/src/app.rs | Switches the app’s process control dependency from SupervisorClient to the new ProcessManager. |
| docs/experimental-systemd-vm-processes.md | Documents configuration and operational behavior for the experimental systemd backend. |
Suppressed comments (1)
dstack/vmm/src/process_manager.rs:235
- Error message capitalization is inconsistent with the repo convention (errors should start lowercase).
bail!("Process is running");
}
let record = self.read_record(id)?;
if record.started {
bail!("Process is started");
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| .await? | ||
| .is_some_and(|info| info.state.status.is_running()) | ||
| { | ||
| bail!("Process is already running"); |
Comment on lines
+275
to
+279
| let output = command | ||
| .output() | ||
| .await | ||
| .context("failed to execute systemctl show")?; | ||
| let properties = String::from_utf8_lossy(&output.stdout); |
| ) | ||
| .await | ||
| .context("Failed to connect to supervisor")? | ||
| .context("Failed to connect to supervisor")?; |
Comment on lines
+327
to
+328
| let manager = | ||
| SystemdProcessManager::new(PathBuf::from("/tmp/test"), "dstack-vm".into()).unwrap(); |
Comment on lines
+483
to
+485
| fn default_systemd_state_dir() -> PathBuf { | ||
| "./run/systemd-processes".into() | ||
| } |
Comment on lines
+169
to
+170
| # Process metadata used to reconcile transient services after a VMM restart. | ||
| systemd_state_dir = "./run/systemd-processes" |
Comment on lines
+17
to
+18
| The section retains its historical name so existing configurations remain | ||
| compatible. The default backend is `supervisor`. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
systemdVMM process-manager backend that bypasses the standalone supervisorLifecycle
The transient service uses:
Type=execExitType=cgroupKillMode=mixedKillSignal=SIGTERMSendSIGKILL=yesTimeoutStopSec=infinityFor swtpm VMs, the existing
vm-launcherstill handles swtpm readiness and graceful QEMU/swtpm shutdown. systemd owns the enclosing cgroup and keeps the unit indeactivatingwhile processes remain during long kernel-side teardown.Enable with:
Experiment
On systemd 255, started a transient service with the same lifecycle properties and submitted an asynchronous stop. Immediately after stop, systemd reported:
After the child shutdown completed, it reported:
Tests
cargo test --manifest-path dstack/Cargo.toml -p dstack-vmm(106 passed)cargo clippy --manifest-path dstack/Cargo.toml -p dstack-vmm --all-targets -- -D warningsgit diff --check