refactor(vmm): separate qemu launch concerns#787
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Refactors dstack-vmm’s QEMU integration by separating VM workdir/state persistence, runtime info/protobuf presentation, measurement/app-identity derivation, and host-share image creation from QEMU launch preparation and command-line construction. This aims to make QEMU argument construction more testable and reduce host-side side effects in the command-building path.
Changes:
- Introduced
workdir.rsfor VM workdir layout + persisted state (manifest/state/paths, instance info, sys/app config accessors). - Introduced
vm_info.rsfor aggregating runtime state intoVmInfoand converting to protobuf for RPC. - Split out measurement/app identity logic into
mr_config.rsand host-share FAT disk creation intohost_share.rs, while restructuring QEMU launch intoPreparedQemuLaunch+QemuCommandBuilder(and adding a unit test for command construction with nonexistent paths).
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| dstack/vmm/src/app/workdir.rs | New module encapsulating VM workdir paths and persisted state access. |
| dstack/vmm/src/app/vm_info.rs | New module for VM runtime info merging and RPC/protobuf presentation. |
| dstack/vmm/src/app/qemu.rs | Refactors QEMU launch into preparation vs command building; adds builder-focused unit test. |
| dstack/vmm/src/app/mr_config.rs | New module for MAC + TDX/SNP measurement/app identity derivation and persisted instance info updates. |
| dstack/vmm/src/app/host_share.rs | New module extracting FAT32 host-share disk image creation. |
| dstack/vmm/src/app.rs | Wires in new modules and updates re-exports/imports accordingly. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
Problem
vmm/src/app/qemu.rsmixed QEMU launch mechanics with unrelated responsibilities: VM workdir persistence, RPC presentation, application identity/measurement derivation, and host-share disk creation.VmConfig::config_qemualso interleaved host filesystem/probing side effects with a large block of command-line construction, which made the launch arguments difficult to test without a prepared host environment.Fix
workdir.rsvm_info.rsmr_config.rshost_share.rsVmConfigandVmWorkDirre-exports for callersPreparedQemuLaunchfor disk creation, config reads, NUMA/TPM probing, and SNP capability detectionQemuCommandBuilderfor host-I/O-free QEMU argument constructionVerification
cargo test -p dstack-vmmcargo clippy -p dstack-vmm --all-targets --all-features -- -D warnings./run-tests.sh