Skip to content

openvmm: pin the virtio-fs saves that refuse replaced objects - #2068

Merged
Pedro Henrique Penna (ppenna) merged 3 commits into
devfrom
agents/issue-1901-snapshot-replaced-path
Nov 24, 2026
Merged

Pedro Henrique Penna (ppenna) merged 3 commits into
devfrom
agents/issue-1901-snapshot-replaced-path

Conversation

@ppenna

@ppenna Pedro Henrique Penna (ppenna) commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #1901

What does this pull request change?

It pins microsoft/openvmm#5254, which makes OpenVMM's microVM virtio-fs save, VirtioFs::save_microvm_state, refuse a snapshot that cannot restore when the host has replaced an object that the guest holds, instead of saving it. The save took the identity that it records for a node from whatever object the node's first name reached at the save, and checked only that the node's other names agreed with each other. When host software renamed a new file over a file that the guest held open, the save recorded the held node with the new file's identity under the held file's guest inode number, and, once the guest had looked the name up again, both nodes under the same name: the restore then failed with "saved aliases are duplicated or ambiguous", or, without that lookup, with "saved guest inode ID does not match the attachment".

The save now records each node's own identity, the device, inode number, and file type of the object that the node got, and checks every name and handle of the node against it, as a restore does, and it refuses two nodes of one volume that share a name or one object, as a restore does. Each refusal is an actionable error that names the node or handle and says what the guest must release; the held object has no name left by which a restore could reopen it, and a snapshot records nothing else, so no save can keep it. Once the guest releases it, as a Linux guest does when it closes the file, since the microVM profile's entry timeout is zero, the save succeeds, and its restore binds the name to the new object. The guest's handle keeps reading the old file meanwhile, and a restore never binds the old node or handle to the replacement. The restore and the snapshot format are unchanged, and the save refuses only states that the restore rejects, or would restore as an object of another file type.

No version is created or bumped: no ABI, machine-contract, time-ABI, snapshot, manifest, saved-state, or protocol version changes, in NVX or in OpenVMM, and no saved-state, snapshot, or on-disk format changes.

Commits:

Start with save_microvm_state in microsoft/openvmm#5254's vm/devices/virtio/virtiofs/src/microvm/fs.rs, then its three tests in src/microvm/fs_tests.rs.

Left out: a replacement with the device, inode number, and file type of the object that a node holds, as when the host removes a file that the guest holds only through a lookup, with no open handle, and creates one that reuses its inode number, still passes every check, and a restore binds the node to the replacement. The running device already resolves the node to the replacement, since it keys nodes by that identity and nodes hold no host descriptor; telling the two apart would need a host reference per node or a generation number in the snapshot, a format change, which this change avoids. An open handle keeps its object, so its inode number cannot be reused while the guest holds the handle.

Why is this change needed?

A successful save tells the caller that it has a usable checkpoint, and #1901 found, with the scratch test of #1889, a save that succeeded and a snapshot that then failed to restore after the host replaced an object that the guest held. The save's identity check came from the chain's position 083, virtiofs: persist microVM FUSE namespaces, handles, and directory cookies, which recorded the identity that a node's first name reached, so it could not tell a replaced object from the node's own.

Rejected:

  • Dropping the stale name from the held node when the guest looks up the replacement: the held node then has no name left, and the save fails anyway, since nothing could reopen its object; without that lookup, the stale name stays, and the save still records the wrong object.
  • Saving the held object under another name, or by a host handle: a snapshot records only names and identities, so this needs a format change, which is out of bounds.
  • Binding the held node to the replacement at restore: it would silently redirect the guest's node, and a handle that the guest believes reads the old file, to another object.

How was this change validated?

Checks and results:

  • OpenVMM, with Rust 1.97.1, cargo nextest run --profile agent -p virtiofs on Windows 11, local, without each fix and with them:

    Without either fix (09966aa63, the base, with the new tests) Without the second commit's checks (b5914cf2d, with the second commit's tests) With them
    The 3 new tests fail, each because the save succeeds: "look_up_replacement=false: a save succeeded while the guest held a replaced file", "file: a save succeeded with two nodes of one object", and "a save succeeded with a handle of another object than its node" Its 2 tests fail the same way 236 run: 236 pass, 3 skipped, at b2ac1073d and at the pin, 5e0e72d72
  • At 899dcd63f, below the stack, a scratch probe that was not committed restored such saves and got: "saved aliases are duplicated or ambiguous" for the held file after a lookup of the new file, the error of openvmm: virtiofs saves a snapshot it cannot restore after the host replaces a referenced path #1901, and for two nodes under one name; "saved guest inode ID does not match the attachment" without that lookup; "saved inode aliases are ambiguous" for two nodes under different names; and "reopened handle identity does not match" for the handle.

  • At each of the three OpenVMM commits, on Windows, cargo check, cargo clippy --all-targets, and cargo doc --no-deps for virtiofs are clean, apart from the LNK4199 linker message that every linked artifact gets on this machine, cargo nextest run --profile agent -p virtiofs passes (234, 236, and 236 pass, 3 skipped), and cargo xtask fmt --fix changes nothing. Before the rebase onto [DO NOT REVIEW] virtiofs: keep the node that a LINK returns until the guest forgets it openvmm#5253, the first two commits on 899dcd63f passed the same checks and cargo clippy --all-targets --target x86_64-unknown-linux-gnu -p virtiofs.

  • python scripts/local_gates.py --base origin/agents/issue-1897-link-forget-race --only test-changes markdown-links test-layout openvmm-vectors openvmm-cpu-profiles --run on Windows: all five pass; check_test_changes.py lists no change to an existing test.

  • python scripts/openvmm_pin.py check-branch --topic --target origin/agents/issue-1897-link-forget-race and python scripts/openvmm_pin.py check-roadmap pass; python scripts/openvmm_pin.py source 5e0e72d72d60bce5e2c5735a08ffebd57ae24216 --pr 5254 reports a good signature and the pull request's head; python scripts/nvx.py verify and python scripts/check_markdown_links.py pass.

  • Reviews: a review of the OpenVMM commits found two things. The Guide said that closing the file unblocks capture, which needs the guest to release its node too; the Guide's wording is fixed. The same-number replacement is the limit under What does this pull request change?. A review of this branch's whole diff, git diff --submodule=diff origin/agents/issue-1897-link-forget-race HEAD, also found two things: the checks keep apart only the nodes of one volume, which the third OpenVMM commit and step 3 of 3.6.8 now say, and the roadmap misattributed the policy tests' helpers, which it now attributes to positions 160 and 164.

  • Runtime: none of the shared Linux test hosts, for KVM or MSHV, accepted a TCP connection on their SSH ports while this was open (their VPN was down), so the microVM scenarios ran only in CI, at this head. Run 45290465963 built OpenVMM at 5e0e72d72d60bce5e2c5735a08ffebd57ae24216 and passed every job, among them the microVM tests on KVM, MSHV, and WHP, whose filesystem-snapshot and platform-filesystem scenarios, among others, capture virtio-fs shares through the changed save. Its first attempt failed only its OpenVMM CI of the pinned revision job, since OpenVMM's run vmm-tests [x64-linux-amd-kvm] was skipped after the runner of build artifacts (for VMM tests) [aarch64-linux] shut down (exit code 143); that OpenVMM job's one rerun passed, and so did the NVX job's, in attempt 2.

  • OpenVMM's CI of the pin: microsoft/openvmm run 45287652986, at 5e0e72d72d60bce5e2c5735a08ffebd57ae24216, passed the jobs that NVX's OpenVMM CI of the pinned revision job requires, unit tests [x64-linux], unit tests [x64-windows], and run vmm-tests on x64-linux-amd-kvm, x64-linux-intel-mshv, x64-windows-intel, and x64-windows-amd, and its quick check [fmt, clippy x64-linux] and xtask fmt (windows). Its x64-windows-amd-snp VMM tests, which NVX does not require, failed, and with them the openvmm checkin gates summary.

Backend, host OS, host type, and guest: the unit tests ran on Windows 11, local, and in OpenVMM's CI on Linux and Windows. The microVM scenarios ran in CI only, on Linux KVM, Linux MSHV, and Windows WHP virtual machines, with the Alpine guest, and with the Ubuntu and Azure Linux guests in the guests-and-sandboxes jobs.

Left to CI: the microVM scenarios on every backend and the Linux unit tests, which no reachable host could run; runs 45290465963 and 45287652986 passed them at this head and pin.

Checklist

  • Tests cover the new or fixed behavior, in the layout that
    python3 scripts/check_test_layout.py checks.
  • python3 scripts/check_test_changes.py --base origin/dev lists no change
    to an existing test, or a Changes to existing tests section below
    explains each one.
  • The documentation that the change affects is updated, including
    .github/copilot-instructions.md and the skills when a convention or
    workflow changes.
  • A change to the public API of nvx updates nvx/public-api/ with
    python3 scripts/public_api.py --update.
  • Snapshots, protocols, and on-disk formats stay compatible, or the
    description says how the change versions or migrates them.

OpenVMM pin

OpenVMM's microVM virtio-fs save recorded each node with the identity
of whatever object its first name reached at the save, and checked
only that the node's names agreed with each other (#1901).
Once host software had renamed a new file over a file that the guest
held open, the save thus recorded the held node with the new file's
identity under the held file's guest inode number, and the snapshot
failed to restore: with "saved aliases are duplicated or ambiguous"
once the guest had looked the name up again, and with "saved guest
inode ID does not match the attachment" without that lookup.

Pin microsoft/openvmm 5e0e72d72d60bce5e2c5735a08ffebd57ae24216, three
commits on 09966aa63, the head of microsoft/openvmm#5253, which NVX
pins below this commit:

- virtiofs: fail a microVM save while the guest holds a replaced
  object. The save records each node's own identity, the device,
  inode number, and file type of the object that the node got, and
  fails when a name of the node reaches another object, with an error
  that says that the guest must release the object.
- virtiofs: fail a microVM save of nodes or handles that a restore
  rejects. The save also fails when two nodes of one volume share a
  name or the key of one object, or when a handle reaches another
  object than its node, which a restore rejects too.
- virtiofs: say which nodes a microVM save keeps apart. The comments
  of the second commit's checks now say that they keep apart only the
  nodes of one volume, and how two nodes of one object arise.

Their tests pass with the fixes; without them, the saves succeed, on
Windows.

A capture now fails, instead of saving a snapshot that cannot
restore, while the guest holds such an object, and succeeds again once
the guest releases it, as a Linux guest does when it closes the file.
No other capture changes, and the restore is unchanged. No saved-state,
protocol, or ABI format, and no version of any of them, changes. The
protocol vectors and CPU profiles that nvx copies are unchanged.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Capture of a microVM's virtio-fs state now checks each name and handle
of a node against the node's own object, by the device, inode number,
and file type that a restore requires, and that no two nodes of one
volume share a name or an object (#1901). It thus fails
while the guest holds an object that the host has replaced, as after
host software renamed a new file over a file that the guest holds
open, rather than save a snapshot that cannot restore, and succeeds
again once the guest stops using the object. Step 3 of 3.6.8 said
only that capture checks that all names of a node reach one object.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…VMM roadmap

Map positions 362-364, the commits of microsoft/openvmm#5254, which
NVX now pins at 5e0e72d72, 238 commits past the mapped tip:

- 362, virtiofs: fail a microVM save while the guest holds a replaced
  object. The save records each node's own identity, the device,
  inode number, and file type of the object that the node got, and
  checks every name of the node against it, as the restore does. It
  took the identity from the object that the node's first name
  reached, so once host software had renamed a new file over a file
  that the guest held open, it saved a snapshot that failed to
  restore.
- 363, virtiofs: fail a microVM save of nodes or handles that a
  restore rejects. The save also fails when two nodes of one volume
  share a name or a dedup key, or when a handle reaches another object
  than its node, which the restore rejects too.
- 364, virtiofs: say which nodes a microVM save keeps apart. Two
  comments of position 363's checks now say that they keep apart only
  the nodes of one volume, and how two nodes of one object arise.

Positions 362-364 are not yet assigned to a PR. They change the node
and handle loops of save_microvm_state, in lines that PR18's position
083 adds, remove position 083's validate_saved_identity, add
VirtioFsInode::object_identity after position 083's from_saved, and
add three tests after position 083's test of hard link aliases, which
call the policy tests' helpers that position 160 adds and position
164 exports. They fix defects of position 083's save, but position 362
compares by the device that position 329 records, through position
330's device_nr, and their tests need position 164's export, so they
are no PR18 fixups, and they follow position 330. Upstream main,
5d6ab1cfa, lacks the microVM's snapshots; replaying the commits there
conflicts in the microVM's files and in the Guide's virtio-fs page,
which it lacks, so they cannot go upstream on their own.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues were identified for the OpenVMM pin and capture-check documentation updates.

No open issues 🎉

What changed in this PR

Pins the OpenVMM fix for #1901 so virtio-fs capture rejects snapshots that cannot safely restore after the host replaces a guest-referenced object, without changing the snapshot format.

Changes:

  • Documents capture checks against each node’s identity, including handle mismatches and duplicate names or objects within a volume.
  • Updates the OpenVMM roadmap to pin 5e0e72d72 and map positions 362–364, including their dependencies.
File Description
doc/​openvmm-upstream-roadmap.md Updates the pin, chain counts, and mapping for the three OpenVMM commits.
doc/​design/​3.6-host-filesystem.md Explains capture rejection conditions and when releasing guest references permits capture again.

Review effort: Balanced

Base automatically changed from agents/issue-1897-link-forget-race to dev November 24, 2026 02:33
@ppenna
Pedro Henrique Penna (ppenna) added this pull request to the merge queue Nov 24, 2026
Merged via the queue into dev with commit bae8d1b Nov 24, 2026
91 of 93 checks passed
@ppenna
Pedro Henrique Penna (ppenna) deleted the agents/issue-1901-snapshot-replaced-path branch November 24, 2026 03:45
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.

openvmm: virtiofs saves a snapshot it cannot restore after the host replaces a referenced path

2 participants