Repository navigation
[DO NOT REVIEW] virtiofs: let a new microVM object take the last node ID - #5281
Merged
Pedro Henrique Penna (ppenna) merged 1 commit intoNov 25, 2026
Conversation
A microVM MKDIR, MKNOD, SYMLINK, or CREATE that reserved the last node ID that the node table hands out, u64::MAX - 1, made its object on the host and then failed with ENOSPC (microsoft/nvx#2135). The guest saw the request fail while the object stayed on the host, and every retry under another name left another object behind. A restore reaches that state, since it accepts any next node ID above the saved ones; live requests would need some 2^64 allocations. These requests reserve the node ID of their object before they make it, so that a full table refuses them before the host changes, and insert the object's node with that ID afterwards. InodeReservation::insert checked that insert against the microVM limits with InodeMap::preflight_microvm_insert, which, for a node of its own, also requires that the table can hand out its next node ID. The reservation has already taken that ID, so the check asked about the ID after it: after a reservation of u64::MAX - 1, the table's next node ID is u64::MAX, which it never hands out, and the insert failed although it needed no other ID. The check dates from the microVM profile (dbf0fa4); before 3019375 made u64::MAX - 1 the last node ID, it failed this way after a reservation of u64::MAX. FileReservation::insert checks only the handle limit, so handles are not affected. Check a reserved insert with the new InodeMap::preflight_microvm_reserved_insert, which checks the inode and alias limits as before but not the next node ID. The checks that run before the host changes, and inserts without a reservation, such as a LOOKUP's, are unchanged. microvm::fs_tests::a_created_object_takes_the_last_node_id restores a state whose next node ID is u64::MAX - 1 and checks, for each of the four requests, that the request returns node u64::MAX - 1, which a LOOKUP of the new name returns too, that the next such request fails with ENOSPC and leaves nothing on the host, and that the state then saves the node and the next node ID u64::MAX, and restores. On 1633b37, MKDIR fails the test with ENOSPC; a probe there showed each of the four requests failing with ENOSPC twice in a row, each time leaving its object on the host, and the state saving no node, on Windows and on a Linux KVM host. With the fix, the test and the rest of cargo nextest -p virtiofs pass on both. 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 25, 2026 16:39
This was referenced Nov 25, 2026
Pedro Henrique Penna (ppenna)
added a commit
to microsoft/nvx
that referenced
this pull request
Nov 25, 2026
…M roadmap Map position 389, the commit of microsoft/openvmm#5281, which NVX now pins at 350018ce4, 263 commits past the mapped tip, on 1633b3797, position 388, the head of feature/microvm/dev since microsoft/openvmm#5280 landed positions 386-388: - 389, virtiofs: let a new microVM object take the last node ID. The insert of the node of an object that FUSE_MKDIR, FUSE_MKNOD, FUSE_SYMLINK, or FUSE_CREATE makes, with the node ID that the request reserved before it made the object, no longer requires that the table can hand out another node ID, so that the object takes the last node ID, u64::MAX - 1, rather than stay on the host without a node after the request fails with ENOSPC (#2135). The inode and alias limits still apply to that insert. Position 389 is a PR18 fixup. It fixes a defect of PR18's position 081, whose InodeReservation::insert check required another free node ID, which position 083's restore makes reachable and position 350 moved to u64::MAX - 1, and it needs nothing that a later position adds but, for its test, position 350's table and position 164's helpers. Fold it into position 081, where its changes of lib.rs and limits.rs apply as they are, as git merge-tree shows, and its test into position 350, where only the imports conflict: at 301937559, position 350, with the fix and the test so placed, the virtiofs tests pass on Windows, and without the fix the test fails. The Scope, the DAG, the fold sentences, the PR summary, the dependency graph, and the commit mapping record the fixup. Of positions 372-388, only 385 changes one of its files, fs_tests.rs. Upstream main, 8d4e03132, lacks the defect, since it lacks the microVM's limits, and replaying the commit there conflicts in lib.rs and in the microVM's limits.rs and fs_tests.rs, so it follows PR18 upstream. The Scope also records that microsoft/openvmm#5277, microsoft/openvmm#5278, microsoft/openvmm#5279, and microsoft/openvmm#5280 have landed positions 383-388 on feature/microvm/dev. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This was referenced Nov 25, 2026
Pedro Henrique Penna (ppenna)
added a commit
to microsoft/nvx
that referenced
this pull request
Nov 25, 2026
A microVM guest that opened a virtio-fs file with access mode 3, which neither reads nor writes, and held it open could save the VM's state, but its restore failed with "saved handle has invalid access mode", on read-write and read-only shares alike (#2125). FUSE_OPEN accepts that access mode, but the restore's validation rejected it, and also took every access mode other than O_RDONLY for one that writes. Pin microsoft/openvmm 770bc61e7b2c683b092bffb5c8cd83b8696cf54a, the head of microsoft/openvmm#5282, one commit on 350018ce4, the head of microsoft/openvmm#5281, which NVX pins below this commit: - virtiofs: restore microVM handles opened with access mode 3. A restore keeps every access mode, and needs a writable node only for a handle whose access mode is O_WRONLY or O_RDWR, as FUSE_OPEN does. Its test fails without the fix, on a read-write share, on a read-only share, and outside the writable paths, and passes with it, on Windows and on Linux, and the virtiofs package's tests pass at the pin on both. 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>
Pedro Henrique Penna (ppenna)
added a commit
to microsoft/nvx
that referenced
this pull request
Nov 25, 2026
… OpenVMM roadmap Map position 390, the commit of microsoft/openvmm#5282, which NVX now pins at 770bc61e7, 264 commits past the mapped tip, on 350018ce4, position 389, the head of microsoft/openvmm#5281: - 390, virtiofs: restore microVM handles opened with access mode 3. A restore reopens a handle that the guest opened with access mode 3, which neither reads nor writes, rather than reject it, and needs a writable node only for a handle whose access mode is O_WRONLY or O_RDWR, as FUSE_OPEN does, so that a snapshot of a guest that holds such a handle on a read-only share or outside the writable paths restores (#2125). Position 390 is not yet assigned to a PR. It fixes a defect of PR18's position 083, whose reopen_flags rejected access mode 3 and whose restore took every access mode but O_RDONLY for a writable one, as position 160 kept doing for its writable paths, but its code changes position 160's line and calls position 334's opens_for_writing, and its test needs positions 160, 164, and 352, so it is not a PR18 fixup. Of positions 372-389, only 385 and 389 change one of its files, fs_tests.rs. Upstream main, 8d4e03132, lacks the defect, since it lacks the microVM's saved state, and replaying the commit there conflicts in the microVM's state.rs and fs_tests.rs, so it cannot go upstream on its own. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This was referenced Nov 25, 2026
Pedro Henrique Penna (ppenna)
merged commit Nov 25, 2026
350018c
into
feature/microvm/dev
104 of 105 checks passed
Pedro Henrique Penna (ppenna)
added a commit
to microsoft/nvx
that referenced
this pull request
Nov 25, 2026
… roadmap Map position 396, the commit of microsoft/openvmm#5288, which NVX now pins at 1495ac815, 270 commits past the mapped tip, on 4aeb405d9, position 395, the head of microsoft/openvmm#5287: - 396, virtiofs: record the host open flags of a microVM create handle. VirtioFs::create records the host options with which it opens the file, as VirtioFs::open does, rather than the guest's flags, so that a save stores no __FMODE_EXEC, O_LARGEFILE, or O_NOFOLLOW, and reopen_flags accepts the host architecture's O_LARGEFILE in place of x86's 0x8000, so that the create handles that earlier releases saved restore on every architecture (#2129). Position 396 is a PR18 fixup, as positions 389 and 393 are: it fixes defects of PR18's position 083 and needs nothing that a later position adds but, for its test, position 164's helpers and position 334's create_with_flags. Fold it into position 083, where its lines apply as they are, and its test into position 335, where position 393's fold shares create_with_flags. Of positions 372-395, only 385, 389, 390, 392, and 393 change its files. Upstream main, 8d4e03132, lacks the defects, since its handles record no open flags and it lacks the microVM's saved state, and replaying the commit there conflicts, so it cannot go upstream on its own. The Scope now names 350018ce4, position 389, as the head of feature/microvm/dev, since microsoft/openvmm#5281 landed it. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Aphrody (aphrody-dev)
pushed a commit
to aphrody-labs/nvx
that referenced
this pull request
Nov 26, 2026
A microVM's FUSE_MKDIR, FUSE_MKNOD, FUSE_SYMLINK, or FUSE_CREATE that reserved the last node ID that the node table hands out, u64::MAX - 1, made its object on the host and then failed with ENOSPC, so the guest saw the request fail while the object stayed on the host without a node, and each retry under another name left another such object (microsoft#2135). A restore reaches that state, since it accepts any next node ID above the saved ones. Pin microsoft/openvmm 350018ce4335ba60ad722852f4004f90674f69e9, the head of microsoft/openvmm#5281, one commit on 1633b3797, the head of feature/microvm/dev, which NVX pins below this commit: - virtiofs: let a new microVM object take the last node ID. The insert of a node with the ID that its request reserved checks the microVM's inode and alias limits as before, but no longer requires that the table can hand out another node ID after the reserved one. Its test fails without the fix, for FUSE_MKDIR, and passes with it, on Windows and on Linux, and the virtiofs package's tests pass at the pin on both. 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>
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#2135.
One commit,
350018ce4, on the head offeature/microvm/dev,1633b3797. NVX pins the head of this branch,350018ce4335ba60ad722852f4004f90674f69e9, in microsoft/nvx#2144, the NVX pull request of microsoft/nvx#2135 (branchagents/issue-2135-virtiofs-last-node-id), so this pull request is a prerequisite of that NVX change. It lands by fast-forwardingfeature/microvm/devto that exact commit, not with the merge button, which squashes.What and why
A microVM
FUSE_MKDIR,FUSE_MKNOD,FUSE_SYMLINK, orFUSE_CREATEthat reserved the last node ID that the node table hands out,u64::MAX - 1, made its object on the host and then failed withENOSPC. The guest saw the request fail while the object stayed on the host without a node, and every retry under another name left another such object. A restore reaches that state, since it accepts any next node ID above the saved ones; live requests would need some 2^64 allocations.These requests reserve the node ID of their object before they make it, so that a full table refuses them before the host changes, and insert the object's node with that ID afterwards.
InodeReservation::insert(vm/devices/virtio/virtiofs/src/lib.rs) checked that insert against the microVM limits withInodeMap::preflight_microvm_insert(microvm/limits.rs), which, for a node of its own, also requires that the table can hand out its next node ID. The reservation has already taken that ID, so the check asked about the ID after it: after a reservation ofu64::MAX - 1, the table's next node ID isu64::MAX, whichHandleMap::can_insertnever hands out, and the insert failed although it needed no other ID. The check dates fromdbf0fa400("virtiofs: add the fixed microVM filesystem profile"); before301937559(#5225) madeu64::MAX - 1the last node ID, it failed the same way after a reservation ofu64::MAX.FileReservation::insertchecks only the handle limit, so file handles are not affected.A reserved insert is now checked with the new
InodeMap::preflight_microvm_reserved_insert, which shares the code ofpreflight_microvm_insertand skips only the check of the next node ID: the inode limit, the alias limits, the path checks, and their order are unchanged. The checks that run before the host changes, and the inserts without a reservation, such as aFUSE_LOOKUP's, are unchanged too.No saved state, protocol, ABI, or format, and no version of any of them, changes.
Tests
a_created_object_takes_the_last_node_id(microvm/fs_tests.rs) restores a state whose next node ID isu64::MAX - 1and checks, for each of the four requests, that the request returns nodeu64::MAX - 1, which aFUSE_LOOKUPof the new name returns too, that the next such request fails withENOSPCand leaves nothing on the host, and that the state then saves the node and the next node IDu64::MAX, and restores. The existingretyped_object_is_refused_at_the_inode_limitstill checks that a reserved insert is refused at the inode limit.Validation
On Windows 11 Enterprise (NTFS) and on a Linux KVM test VM (Azure Linux 3, kernel 6.18, x86_64, tmpfs):
1633b3797, the new test fails:FUSE_MKDIRreturnsENOSPC. A probe, not committed, showed each of the four requests failing withENOSPCtwice in a row, under two names, each time leaving its object on the host, and the next save recording no node and the next node IDu64::MAX - 1. With the fix, each request returns nodeu64::MAX - 1, the next fails withENOSPCbefore the host changes, and the save records the node and the next node IDu64::MAX.cargo check,cargo clippy --all-targets, andcargo doc --no-depsofvirtiofshave no warnings, andcargo nextest run --profile agent -p virtiofspasses 241 tests on Windows (3 skipped) and 242 on Linux (1 skipped).cargo xtask fmt --fixchanges nothing.