Repository navigation
[DO NOT REVIEW] virtiofs: keep node names when renaming a name onto itself - #5206
Merged
Pedro Henrique Penna (ppenna) merged 1 commit intoNov 22, 2026
Conversation
A guest rename of a name onto itself, in the same directory, succeeds on the host without changing anything, as POSIX requires, but it dropped the names at and below that name from every node of the volume (microsoft/nvx#1610). A node that the guest knew only through them was left with no names, so a microVM save then failed with "inode has no bounded reopenable aliases", and a volume that deduplicates nodes by path stopped finding it. A node with another hard link kept only the other name, and once the guest removed that one, the node's requests failed with ENOENT although the renamed name still reached its object. VirtioFs::rename tracks a rename that is not an exchange as a move: it drops the names at and below the destination, which the host replaced, and then rewrites those at and below the source under the destination. When both are one name, the first step drops the names that the second should keep. The microVM alias preflight models the same steps. A rename whose source and destination are one name now changes no names and skips the preflight. It still reaches the host after the same writability checks, so the host fails it as it fails any other rename: with ENOENT for a missing name, and with EEXIST under RENAME_NOREPLACE on Linux. renaming_a_name_onto_itself_keeps_every_name, in virtiofs' microVM exchange tests, which now cover a rename of a name onto itself too, renames a directory with nodes below it, a file in it, and a file with a second hard link each onto itself. It checks that every node keeps exactly its names, that a snapshot taken right away saves and restores them, and that the hard-linked file's node still reads the file once the guest removes the other link; and that the host still fails a missing name with ENOENT, and RENAME_NOREPLACE with EEXIST on Linux and EINVAL on Windows. Without the fix, at feature/microvm/dev b51f915, it fails on Windows and on Linux (Azure Linux 3.0, nvx-mshv-test), where the renamed directory's node has no names left; with the fix, it and the package's other tests pass there. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Pedro Henrique Penna (ppenna)
requested review from
a team and
Anatol Belski (weltling)
as code owners
November 21, 2026 22:50
This was referenced Nov 21, 2026
Pedro Henrique Penna (ppenna)
merged commit Nov 22, 2026
3288834
into
feature/microvm/dev
104 of 105 checks passed
This was referenced Nov 22, 2026
Merged
syeedali
pushed a commit
to syeedali/nvx
that referenced
this pull request
Nov 22, 2026
Map position 340, the commit of microsoft/openvmm#5206, which NVX now pins at 32888344a, 214 commits past the mapped tip: - 340, virtiofs: keep node names when renaming a name onto itself. VirtioFs::rename returns the host's result for a rename whose source and destination are one name, after the writability checks, without the microVM alias preflight or any change to the names. It tracked every rename that is not an exchange as a move, dropping the names at and below the destination before rewriting those of the source, so a rename of a name onto itself, which changes nothing on the host, dropped the names at and below that name from every node, after which saving a microVM failed. Position 340 is a PR13 fixup. It fixes the name bookkeeping that PR13's position 048 adds, and its test, in the microVM exchange tests that position 166 adds, needs nothing that a later position adds, so it folds into position 048, with its early return after the writability checks that position 160 adds, and its test into position 166, as the fold sentence after the DAG and the commit mapping say; the Scope, the DAG, the dependency graph, the PR summary, and the commit mapping record it with PR13. It skips the alias preflight of PR18's position 081, which modeled the same steps but never refused such a rename, so it is no PR18 fixup. Upstream main, bf353460f, lacks the defect, since it lacks the names of position 048, and replaying the commit there conflicts in lib.rs, next to the names and checks of positions 048 and 160, and in the microVM's exchange_tests.rs, which upstream main lacks, so it follows PR13 upstream. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
syeedali
pushed a commit
to syeedali/nvx
that referenced
this pull request
Nov 22, 2026
OpenVMM's virtio-fs server answered FUSE_READDIR and FUSE_READDIRPLUS on an aggregate's synthetic root with a reply buffer that it reserved infallibly, with Vec::with_capacity, at whatever size the guest asked for, so a guest that read the root with a size of u32::MAX made the VMM reserve 4 GiB for one request, and a host that could not provide it aborted the VMM with "memory allocation of 4294967295 bytes failed" (microsoft#1598). The reads of every other directory, and every other buffer that the guest sizes, are bounded at 1 MiB and reserved fallibly. Pin microsoft/openvmm ed2d7e3a15c9519fde09046ba6643f773c8285df, one commit on 32888344a, the head of microsoft/openvmm#5206: - virtiofs: bound the buffer of an aggregate root's directory read. A read of the synthetic root that asks for more than 1 MiB fails with E2BIG before anything is reserved, and the buffer is reserved with try_reserve_exact, failing with ENOMEM, as for every other directory. A read of 1 MiB still lists the whole root. Its test fails without the change on Windows and on Linux (nvx-kvm-test). No saved state, protocol, ABI, or 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>
syeedali
pushed a commit
to syeedali/nvx
that referenced
this pull request
Nov 22, 2026
OpenVMM's virtio-fs server lists a microVM directory once, on the first read of each handle, and keeps the listing for the handle's later reads and for its saved state. A saved state holds at most 16,384 entries and 4 MiB of names in the listings of all handles, but the server checked only each listing's own bounds of 4,096 entries and 64 KiB of names, across up to 4,096 handles (microsoft#1613). A guest that kept five handles listing a directory of 4,094 files therefore failed every capture of the VM with "saved directory entries exceed the aggregate bound" until it released them, and its handles could pin 256 MiB of names in the VMM. Pin microsoft/openvmm 5c82edac42ca480d546459e019860759a27c2211, one commit on ed2d7e3a1, the head of microsoft/openvmm#5207, which stacks on microsoft/openvmm#5206 and feature/microvm/dev b51f9156c: - virtiofs: bound microVM directory snapshots in total when listing. The first read of a handle charges its listing to the totals of the attachment's listings, and fails with ENOSPC, keeping no listing, when the listings would then exceed them. A released handle returns its share, and a restore charges the listings that it restores in place of those of the handles that it replaces. Its tests fail without the change on Windows and on Linux (nvx-mshv-test). No saved state, protocol, ABI, or 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>
5 tasks done
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.
Refs microsoft/nvx#1610.
NVX pins the head of this branch, so this is a prerequisite of the NVX change that pins it, and it lands by fast-forwarding
feature/microvm/devto that exact commit, not with the merge button, which squashes.What and why
Each virtio-fs node keeps the volume-relative names, or aliases, through which the guest has reached its object, and a primary path among them that its operations use.
VirtioFs::renametracks a rename that is not an exchange as a move: after the host rename,InodeMap::remove_alias_prefix(new_path)drops the names at and below the destination, which the host replaced, andInodeMap::rename_alias_prefix(old_path, new_path)then rewrites those at and below the source under the destination. The microVM alias preflight,InodeMap::preflight_microvm_rename, models the same two steps.When the guest renames a name onto itself, with the same parent and name, the host rename succeeds without changing anything, as POSIX requires (Linux
renameat2returns 0; the Windows host renames the name to itself). But both paths are then one name, so the first step dropped the names at and below it from every node of the volume, and the second found nothing left to rewrite:save_microvm_state, and so a microVM snapshot, failed withinode has no bounded reopenable aliases, and on a volume that deduplicates nodes by path,rebuild_dedup_keysstopped finding the node;ENOENT, although the renamed name still reached its object.A Linux guest never sends such a request: its VFS completes a rename whose two names reach one inode itself (
vfs_renamereturns 0 whensource == target, before it calls the filesystem). Only a guest that sendsFUSE_RENAMEdirectly reaches this path, but OpenVMM does not trust the guest, so its state must stay consistent for any request; the regression test therefore drives the FUSE server directly, and no microVM scenario can reproduce the defect.The fix: after the same writability checks, a rename whose source and destination are one name returns the host's result directly, and changes no names and skips the alias preflight, since nothing changes. It still goes to the host, so the host fails it as it fails any other rename: with
ENOENTfor a missing name, and withEEXISTunderRENAME_NOREPLACEon Linux (EINVALon Windows, which rejects every rename flag). The exchange of a name with itself, which the previous code already left unchanged, takes the same path. No saved state, protocol, ABI, or format, and no version of any of them, changes.Kept from the issue's suggested fix: skipping the preflight and the name updates while still calling the host. Changed: the check returns the host's result in one place rather than in two, and the regression test also covers nodes below a renamed directory, a hard-linked file, and a snapshot taken right after the rename.
Out of scope, handled separately: a rename between two hard links of one file (microsoft/nvx#1620), which also changes nothing on the host but names two different paths.
Tests
One unit test in
virtiofs,microvm::exchange_tests::renaming_a_name_onto_itself_keeps_every_name, next to theRENAME_EXCHANGEtests, whose module doc now covers it: on a read-write microVM share, it renames a directory with nodes below it, a file in it, and a file with a second hard link each onto itself, and checks that:ENOENT, andRENAME_NOREPLACEwithEEXISTon Linux andEINVALon Windows.Validation
cargo nextest run -p virtiofsat this head, and at its parent with the new test applied (the fix reverted):b51f9156c)aliases of node 2,left: {},right: {"directory"})nvx-mshv-test, Azure Linux 3.0 VMAt this head, on both hosts,
cargo check,cargo clippy --all-targets, andcargo doc --no-depsforvirtiofsare clean, with no warning but theLNK4199linker message that every linked artifact gets on the Windows machine, and one ignored test is skipped, as at the base.cargo xtask fmt --fixchanges nothing. At the base, a scratch reproduction of the issue's steps showed the file's names going fromout/existingto none while the host file stayed intact, and the save failing withinode has no bounded reopenable aliases.