Repository navigation
[DO NOT REVIEW] fuse: adopt a FUSE_INIT negotiation only once its reply is sent - #5248
Merged
Pedro Henrique Penna (ppenna) merged 1 commit intoNov 23, 2026
Conversation
Session::dispatch_init negotiated in the session's own SessionInfo, under its write lock, and marked the session initialized only after it sent the reply (microsoft/nvx#1898). When the reply could not be sent, as when a virtio-fs client's buffers cannot hold it, the session stayed uninitialized but kept the values of the attempt that the client never received. save_state then saved them with initialized false, which SessionState::validate refuses as UninitializedWithInfo, so such a save could not be restored, and a dormant microVM virtio-fs slot refused to save at all. A later FUSE_INIT reset only the fields that dispatch_init sets before Fuse::init, so the failed attempt's max_background and congestion_threshold reached the file system's init, the reply, and the saved state of the next negotiation. dispatch_init now negotiates in a SessionInfo of the request's own, built from the defaults and the client's offer alone, and stores it in the session, and marks the session initialized, only once the reply is sent. A reply that cannot be sent, like a negotiation that the session refuses, leaves the session as it was: uninitialized, without a negotiation. A FUSE_INIT whose reply is sent negotiates, replies, and saves as before. Fuse::init documents it. Tests, in fuse's session tests of init, with a sender that fails each reply with WriteZero, and a file system that records what each init receives and allows more background requests when the client offers FUSE_ASYNC_DIO: - init_whose_reply_fails_leaves_no_negotiation fails at feature/microvm/dev 899dcd6: the uninitialized session saves the failed attempt's version 7.39, capabilities, and background limits. - init_after_a_failed_reply_negotiates_afresh, whose second FUSE_INIT offers only FUSE_ASYNC_READ at 7.31, fails there: that reply carries the failed attempt's background limits, (64, 48) instead of (0, 0). With the fix, its reply, what init receives, and the saved state match those of a new session. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Pedro Henrique Penna (ppenna)
requested a review
from a team
as a code owner
November 23, 2026 19:50
Pedro Henrique Penna (ppenna)
added a commit
to microsoft/nvx
that referenced
this pull request
Nov 23, 2026
…he OpenVMM roadmap Map position 356, the commit of microsoft/openvmm#5248, which NVX now pins at b73db6676, 230 commits past the mapped tip: - 356, fuse: adopt a FUSE_INIT negotiation only once its reply is sent. Session::dispatch_init negotiates in a SessionInfo of the request's own, from the defaults and the guest's offer alone, and stores it in the session, and marks the session initialized, only once the reply is sent. It negotiated in the session's own SessionInfo, so a reply that could not be sent left the values of a negotiation that the guest never received in an uninitialized session, whose saved state SessionState::validate refuses, and the next FUSE_INIT inherited the failed attempt's max_background and congestion_threshold. Position 356 is not yet assigned to a PR. It changes dispatch_init in session.rs, in lines that PR13's position 047 and position 328 also change, documents the adoption on Fuse::init in lib.rs after position 328's paragraph, and adds two tests to position 328's tests of FUSE_INIT, which use the harness of positions 321 and 325 and PR13's session state. It is no PR13 fixup, although the failed attempt's values reached position 047's saved state: the in-place negotiation is upstream's, and the commit changes lines that position 328 adds, so it follows position 328. Upstream main, b50d0c979, negotiates in place too, so its next FUSE_INIT after a failed reply inherits the same two fields, but it saves no session state; replaying the commit there conflicts in lib.rs, session.rs, and position 328's init.rs, so it cannot go upstream on its own. 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 23, 2026
…he OpenVMM roadmap Map position 356, the commit of microsoft/openvmm#5248, which NVX now pins at b73db6676, 230 commits past the mapped tip: - 356, fuse: adopt a FUSE_INIT negotiation only once its reply is sent. Session::dispatch_init negotiates in a SessionInfo of the request's own, from the defaults and the guest's offer alone, and stores it in the session, and marks the session initialized, only once the reply is sent. It negotiated in the session's own SessionInfo, so a reply that could not be sent left the values of a negotiation that the guest never received in an uninitialized session, whose saved state SessionState::validate refuses, and the next FUSE_INIT inherited the failed attempt's max_background and congestion_threshold. Position 356 is not yet assigned to a PR. It changes dispatch_init in session.rs, in lines that PR13's position 047 and position 328 also change, documents the adoption on Fuse::init in lib.rs after position 328's paragraph, and adds two tests to position 328's tests of FUSE_INIT, which use the harness of positions 321 and 325 and PR13's session state. It is no PR13 fixup, although the failed attempt's values reached position 047's saved state: the in-place negotiation is upstream's, and the commit changes lines that position 328 adds, so it follows position 328. Upstream main, b50d0c979, negotiates in place too, so its next FUSE_INIT after a failed reply inherits the same two fields, but it saves no session state; replaying the commit there conflicts in lib.rs, session.rs, and position 328's init.rs, so it cannot go upstream on its own. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
5 tasks done
Pedro Henrique Penna (ppenna)
merged commit Nov 23, 2026
b73db66
into
feature/microvm/dev
102 of 105 checks passed
This was referenced Nov 23, 2026
Merged
aphrody-labs Bot
pushed a commit
to aphrody-labs/nvx
that referenced
this pull request
Nov 24, 2026
OpenVMM's chipset device builder registered a PCI chipset device's place, its bus, device, and function, its PCIe downstream port, or its devfn as an RCiEP, with its bus resolver before it finalized the add, which can still fail, as with NameInUse when another state unit has the device's name (microsoft#1904). A failed add thus left the dropped device in that place when the chipset was built, where it answered no configuration access, and a device added there instead failed the build with a PciConflict or PcieConflict that named the dropped device. Pin microsoft/openvmm e8324ea31864e90e3486ec89d11f28d15e2c7b67, one commit on b73db6676, the head of microsoft/openvmm#5248, which NVX pinned before this commit: - vmotherboard: claim a device's PCI slot only once its unit spawns. The builder's services only record the places that an add asks for, and finalize registers them with the resolver after the spawn of the device's unit, its last step that can fail, under the builder's lock, so a failed add leaves no place behind and touches no other device's. Its tests pass with the fix; without it, the chipset build fails with a conflict that names the failed device, on Windows. Every caller of the add, the microVM loader among them, returns its error, and NVX's microVMs have no PCI bus or device, so they build and run as before. 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>
aphrody-labs Bot
pushed a commit
to aphrody-labs/nvx
that referenced
this pull request
Nov 24, 2026
…m in the OpenVMM roadmap Map position 361, the commit of microsoft/openvmm#5253, which NVX now pins at 09966aa63, 235 commits past the mapped tip: - 361, virtiofs: keep the node that a LINK returns until the guest forgets it. FUSE_LINK takes the lookup reference that its reply hands the guest when it resolves its target node, under the inode map's lock, with a new VirtioFs::reference_inode, and a LINK that fails releases it through a new InodeMap::forget, which FORGET uses too. Upstream's link counted the reference only after its host link, outside that lock, so a FORGET that raced it on the high-priority queue could remove the node, and the LINK then replied with an ID that every later request failed with EINVAL. Position 361 is not yet assigned to a PR. In lib.rs, it changes upstream's link and forget, and in link the argument of the alias preflight that PR18's position 081 adds, and it adds reference_inode, LookupReference, and InodeMap::forget; in inode.rs, it has inc_lookup, which position 331 saturates, report whether it changed the count. It adds three tests to the tests of lib.rs. It is no fixup: the race is upstream's, since microsoft/openvmm#2661. Upstream main, 5d6ab1cfa, has the race too; replaying the commit there conflicts in inode.rs and lib.rs, so it cannot go upstream on its own. The Scope now also says that feature/microvm/dev is at e8324ea31, since microsoft/openvmm#5248 and microsoft/openvmm#5249 landed positions 356 and 357. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
syeedali
pushed a commit
to syeedali/nvx
that referenced
this pull request
Nov 24, 2026
…iscards OpenVMM's FUSE session called the file system's Fuse::init for each FUSE_INIT and then did not always adopt its negotiation: it failed the request with EIO when init wanted a flag that the guest did not offer, and, since microsoft/openvmm#5248, it adopted nothing when it could not send the reply. In both cases, it called no Fuse::destroy (microsoft#1900). The guest completes no such FUSE_INIT, and Linux sends no FUSE_DESTROY for a connection that it did not initialize, so the next FUSE_INIT called init again over what the first one had set up. VirtioFs::init records the negotiation that it agrees to, so after an INIT reply that the device could not send, a microVM capture failed with "FUSE session and filesystem negotiation state disagree" until the guest negotiated again. Pin microsoft/openvmm 9805f89843ee01890f19d47d2f04f6460bd22024, three commits on be75ab532, the head of microsoft/openvmm#5255, which NVX pins below this commit: - fuse: let FUSE_INIT negotiate only once a session has ended. Session::destroy takes the session's lock before it marks the session uninitialized and calls Fuse::destroy, as dispatch_init does before it calls Fuse::init, so a FUSE_INIT that the session dispatches once it is uninitialized negotiates only once the session has ended, and the session calls init and destroy one at a time. Its test fails without the change, on Windows. - fuse: call destroy after an init that the session does not adopt. dispatch_init calls Fuse::destroy right after an init whose negotiation it refuses or whose reply it cannot send, under the session's lock, and the session's documentation pairs each init with one destroy, before the next init. Its four tests that fail without the change, among them a microVM save after an INIT reply that cannot be sent, pass with it, on Windows. - fuse: say which FUSE_INIT waits for the end of a session. Comments only: a FUSE_INIT that the session dispatches before Session::destroy marks it uninitialized fails as a duplicate, as on any initialized session, and only a later one waits for the end of the session, which Session::destroy and the first commit's test now say. A FUSE_INIT whose reply is sent negotiates, replies, saves, and restores as before. 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#1898.
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
fuse::Session::dispatch_initinvm/devices/support/fs/fuse/src/session.rsnegotiatedFUSE_INITin the session's ownSessionInfo, through the write guard that it holds for the whole request, and marked the session initialized only after it sent the reply. When the reply could not be sent,sender.send_arg(..)?returned early, and the session stayed uninitialized but kept the values of a negotiation that the client never received:Session::save_state()saved them withinitialized: false, a state thatSessionState::validate()refuses asUninitializedWithInfo, so such a save could not be restored, and a dormant microVM virtio-fs slot, whose save requires the default session state, refused to save at all.FUSE_INITreset only the fields thatdispatch_initsets beforeFuse::init, so the failed attempt'smax_backgroundandcongestion_thresholdreached the file system'sinit, the reply, and the saved state of the next negotiation.A virtio-fs reply fails when the guest's writable descriptors cannot hold it, where
write_allfails withWriteZero, or lie outside guest memory, so the guest decides whether this happens.dispatch_initnow negotiates in aSessionInfoof the request's own, built from the defaults and the client's offer alone, with..SessionInfo::default()for the rest, and stores it in the session, and marks the session initialized, only oncesend_arghas succeeded. A reply that cannot be sent, like a negotiation that the session refuses, leaves the session as it was: uninitialized, with the defaultSessionInfo, sosave_state()saves the default state, and the nextFUSE_INITnegotiates as on a new session. The refusal of unoffered flags no longer resetsinfo, since it no longer touches the session. AFUSE_INITwhose reply is sent negotiates, replies, and saves as before, and the write guard still serializes racingFUSE_INITrequests.Fuse::initdocuments it.Left out: when the reply cannot be sent,
Fuse::inithas already run, and nothing pairs it withFuse::destroy; microsoft/nvx#1900 defines that cleanup for aninitthat the session does not complete. Until then,VirtioFs::init, which records its negotiation before the reply, keeps that record after a failed reply, so a microVM save then finds the record and the session's state disagree, as it did before this change.Upstream main,
b50d0c979, negotiates in the session'sSessionInfothe same way, so its nextFUSE_INITafter a failed reply also inheritsmax_backgroundandcongestion_threshold; it has no saved session state. This commit does not apply there as it is: it changes lines ofdispatch_initand of the documentation ofFuse::initthat only this branch has, the version cap of the chain'sfuse: save and restore negotiated session stateand the code of #5200, and its tests use the session's test harness andSessionState.No saved-state, protocol, or ABI format, and no version of any of them, changes.
Tests
In
session::tests::init, with a sender that fails each reply withWriteZeroand counts the replies that the session tries to send, one, and a file system that records theSessionInfothat eachinitreceives and allows more background requests, 64 and 48, when the client offersFUSE_ASYNC_DIO:init_whose_reply_fails_leaves_no_negotiation: after aFUSE_INITat 7.39 that offersFUSE_ASYNC_READ | FUSE_ASYNC_DIO | FUSE_INIT_EXTandFUSE_DIRECT_IO_ALLOW_MMAP_FLAG2, whose reply fails, the session is uninitialized and savesSessionState::default().init_after_a_failed_reply_negotiates_afresh: a secondFUSE_INIT, at 7.31 with onlyFUSE_ASYNC_READ, replies without background limits, and its reply, theSessionInfothatinitreceives, and the saved state equal those of a new session that receives only that request.Validation
With
cargo nextest run --profile agent -p fuseon Windows 11, local, with the fix reverted (session.rsandlib.rsof899dcd63f) and with it:init_whose_reply_fails_leaves_no_negotiationsavesSessionState { initialized: false, info: SessionInfoState { major: 7, minor: 39, max_readahead: 131072, capable: 1073774593, capable2: 16, want: 1073774593, want2: 0, max_background: 64, congestion_threshold: 48, max_write: 1048576, time_gran: 1 } }instead of the default;init_after_a_failed_reply_negotiates_afreshreplies(max_background, congestion_threshold)(64, 48)instead of(0, 0)At this head,
cargo check,cargo clippy --all-targets, andcargo doc --no-depsforfuseare clean, but for theLNK4199linker message that every linked artifact gets on this machine;cargo xtask fmt --fixchanges nothing; andcargo nextest run --profile agent -p virtiofspasses, 230 pass and 3 skipped. The change touches no platform-specific code; this pull request's CI runs the Linux unit tests.