fix(vmm): validate an update before writing any of it - #1351
Merged
Merged
Conversation
kvinwang
added this pull request to stack #1352
September 24, 2026 06:17
kvinwang
force-pushed
the
fix/vmm-update-validate-first
branch
from
September 24, 2026 06:36
573702d to
07a3287
Compare
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
update_vmwrites the compose file, encrypted env and user config, grows the data disk withqemu-img resize, and releases the VM's network interfaces before running the checks that can still reject the request (GPU, port mapping, networking, NIC agreement, key provider). A rejected update therefore leaves a new compose hash, env and grown disk against the old manifest.For example, an update that adds a port the node's
cvm.port_mappingrefuses (#1286) still replaces the stored compose file:Fix
Build and validate the new manifest in memory first, then apply side effects in one place: grow the disk, release interfaces, write compose/env/user config, write the manifest. Disk growth moves out of
apply_resource_updatesintogrow_disk_if_needed, whichresize_vmalso calls. The swtpm decision reads the requested compose instead of the one just written; the result is the same.Stacked on #1286.
Verification
New
a_rejected_update_writes_nothingfails on #1286 (output above) and passes here.cargo test -p dstack-vmm(212 passed),cargo clippy -p dstack-vmm --bins -- -D warnings,cargo fmt --check.