Repository navigation
openvmm: pin microVM restores of handles opened with O_DIRECT - #2150
Merged
Pedro Henrique Penna (ppenna) merged 2 commits intoNov 26, 2026
Merged
Pedro Henrique Penna (ppenna) merged 2 commits into
Pedro Henrique Penna (ppenna) merged 2 commits into
Conversation
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues are recorded for the roadmap update documenting the OpenVMM pin and its O_DIRECT restore fix.
No open issues 🎉
What changed in this PR
This PR pins OpenVMM’s fix for #2128 in NVX, allowing microVM snapshots to restore virtio-fs handles opened with O_DIRECT while preserving their host behavior.
Changes:
- Updates the roadmap’s recorded pin to
5af753b17, position 393, and adjusts chain counts and the diagram. - Documents the restore fix, its dependencies, and why it cannot be upstreamed independently.
| File | Description |
|---|---|
doc/openvmm-upstream-roadmap.md |
Maps the new OpenVMM pin and explains the O_DIRECT restore fix. |
Review effort: Balanced
This was referenced Nov 25, 2026
Pedro Henrique Penna (ppenna)
force-pushed
the
agents/issue-2126-virtiofs-empty-symlink
branch
from
November 25, 2026 18:37
751cdf0 to
0415be9
Compare
A microVM guest that holds a file on a virtio-fs share open with O_DIRECT could save the VM's state, but not restore it: the restore refused the saved handle with "saved handle has unsupported open flags 0x4002" for O_RDWR | O_DIRECT, from FUSE_OPEN, and with 0x4041 for O_WRONLY | O_CREAT | O_DIRECT, from FUSE_CREATE (#2128). OpenVMM's reopen_flags, which checks a saved handle's flags and gives those with which a restore reopens it, refused every flag outside a list that lacked O_DIRECT, although FUSE_OPEN and FUSE_CREATE accept it, keep it in the handle's flags, and open the host file with it. Pin microsoft/openvmm 5af753b17035f548039cab531027a3cc635ac4fa, the head of microsoft/openvmm#5285, one commit on e61fa5326, the head of microsoft/openvmm#5284, which NVX pins below this commit: - virtiofs: reopen a microVM handle with O_DIRECT on restore. reopen_flags keeps O_DIRECT, so a restore reopens the handle as the guest opened it, with the host's O_DIRECT semantics. Its test fails without the fix on Windows and Linux and passes with it, and the virtiofs tests pass at the pin on both. On KVM, a filesystem-snapshot run whose guest held files open with O_DIRECT across the capture failed its restore before the fix and restored after it. No saved-state, protocol, or ABI format, and no version of any of them, changes; a snapshot that an earlier release saved with such a handle now restores. The protocol vectors and CPU profiles that nvx copies are unchanged. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…VMM roadmap Map position 393, the commit of microsoft/openvmm#5285, which NVX now pins at 5af753b17, 267 commits past the mapped tip, on e61fa5326, position 392, the head of microsoft/openvmm#5284, as a PR18 fixup: - 393, virtiofs: reopen a microVM handle with O_DIRECT on restore. reopen_flags keeps O_DIRECT, which FUSE_OPEN and FUSE_CREATE accept, record, and open the host file with, so that a restore reopens a handle that the guest opened with O_DIRECT as the guest opened it, rather than refuse the saved state with "saved handle has unsupported open flags" (#2128). Position 393 fixes a defect of PR18's position 083, whose list in reopen_flags lacked O_DIRECT, and needs nothing that a later position adds but, for its test, position 164's helpers, position 334's create_with_flags, and position 335's get_file, so, as position 389 does for position 081, it is a PR18 fixup: fold it into position 083, where its line applies as it is, and its test into position 335. The Scope, the DAG, the fold sentences after it, the table, PR18's node, its row in the PR summary, and its commit mapping count it. Of positions 372-392, only 385, 389, and 390 change its files: they add other tests to fs_tests.rs, and position 390 also removes position 083's check of the access mode from reopen_flags, after the list. Upstream main, 8d4e03132, lacks the microVM's saved state, and replaying the commit there conflicts in the microVM's state.rs, fs_tests.rs, and policy_tests.rs, so it cannot go upstream on its own. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Pedro Henrique Penna (ppenna)
force-pushed
the
agents/issue-2128-virtiofs-o-direct-restore
branch
from
November 25, 2026 18:47
55cecc0 to
fac0a70
Compare
Base automatically changed from
agents/issue-2126-virtiofs-empty-symlink
to
dev
November 25, 2026 23:52
Pedro Henrique Penna (ppenna)
deleted the
agents/issue-2128-virtiofs-o-direct-restore
branch
November 26, 2026 00:40
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.
Fixes #2128
Stacked on #2148 (
agents/issue-2126-virtiofs-empty-symlink), itself stacked on #2147 and the pull requests below it; only the top two commits belong to this pull request (see OpenVMM pin for the landing order).What does this pull request change?
A microVM guest that holds a file on a virtio-fs share open with
O_DIRECTacross a snapshot now restores. Before, the capture succeeded, but every restore of the snapshot failed before the guest ran, withsaved state is invalid: saved handle has unsupported open flags, such as0x4002for a file opened withO_RDWR | O_DIRECT. The restored handle now reopens the host file withO_DIRECT, as the guest opened it, so it keeps the host's direct I/O: on a Linux host filesystem that enforcesO_DIRECT's alignment, such as ext4, it serves block-aligned I/O and fails unaligned I/O withEINVAL, as the saved handle did. A Windows host ignoresO_DIRECT, before and after the restore.The fix is in OpenVMM, microsoft/openvmm#5285, which this pull request pins:
virtiofs: reopen a microVM handle with O_DIRECT on restore.reopen_flags(vm/devices/virtio/virtiofs/src/microvm/state.rs), with which the validation of a saved state checks each handle's flags and the restore reopens the handle, now keepsO_DIRECT. One regression test,handles_opened_with_o_direct_restore_with_it, inmicrovm/fs_tests.rs, andcreate_with_flagsofmicrovm/policy_tests.rsbecomespub(super)for it.The NVX commits are the gitlink-only pin and the mapping of the commit, position 393, in the OpenVMM roadmap, as a PR18 fixup. Restore already says that the server "reopens every handle with its saved open flags, except that it drops
O_CREAT,O_EXCL, andO_TRUNC", which the fix makes true ofO_DIRECT, so no documentation changes. Start with the OpenVMM diff:git diff --submodule=diff origin/agents/issue-2126-virtiofs-empty-symlink...HEAD.Left out and limitations:
O_DIRECThandle is unchanged: on a Linux host, the host filesystem's alignment rules apply to the guest's requests, as they did before; this pull request only lets such a handle survive a snapshot.reopen_flags' other differences from whatFUSE_CREATErecords, such as its x86 value ofO_LARGEFILEon an ARM64 host, are left to virtio-fs microVM: FUSE_CREATE stores raw guest open flags in its handle, causing restore to fail #2129.Why is this change needed?
A guest program that keeps a file open with
O_DIRECT, as databases and benchmarks do, made every snapshot of its VM unrestorable, although the capture itself succeeded, so the failure appeared only at restore.Root cause:
FUSE_OPENandFUSE_CREATEacceptO_DIRECT(util::open_flagsandcreate_flags), keep it in the flags that the handle records, which the save stores, and pass it to the host open, which Linux performs with it and Windows ignores.reopen_flagsrefused any saved flag outside its own list, which lackedO_DIRECTsince position 083 (6315c16c5, in PR18 of the OpenVMM roadmap) made microVM handles persist.Alternatives rejected:
O_DIRECTwhen the restore reopens the handle, or before the host open of everyFUSE_OPENandFUSE_CREATE: either would make the restore pass, but the first would change the handle's behavior across the snapshot, since a reopened handle would then accept, on ext4, unaligned I/O that the saved one failed, and the second would change every liveO_DIRECThandle, which upstream'sfuse_flags_only_consume_guest_flags(Reject unsafe filesystem opens across virtio-fs and virtio-9p openvmm#4783) expects to keep the flag.reopen_flagsdirectly, so that it fails on any host, and opens theFUSE_CREATEhandle too, whose saved flags carryO_CREAT.How was this change validated?
This branch was restacked onto the rewritten
agents/issue-2126-virtiofs-empty-symlink(0415be91945), whose OpenVMM pin,e61fa5326, did not change; its pin and roadmap commits were rebuilt on it, and the checks of the NVX commits below ran again there.Checks and results. "Before" is OpenVMM
1633b3797, the head offeature/microvm/dev, or the release built from it; "after" is the fix, as2cb90b693on1633b3797and, after its rebase onto microsoft/openvmm#5284, as the pinned5af753b17, whose patchgit range-diffreports equal but for the context of its one new import.cargo nextest run --profile agent -p virtiofs -E 'test(handles_opened_with_o_direct_restore_with_it)'(new test), on Windows 11 (NTFS) and Linux (ext4)saved handle has unsupported open flags 0x4002; without that check, the round trip fails at the restore, with0x4002on Windows and0x4041on Linux1633b3797and at5af753b17cargo check,cargo clippy --all-targets, andcargo doc --no-deps, each-p virtiofs1633b3797, andclippyagain on both at5af753b17, apart from the linker'sLNK4199notes about unused delay-loaded DLLs, which every Windows build of this workstation prints for build scriptscargo nextest run --profile agent -p virtiofs1633b3797, and 244 passed, 3 skipped at5af753b17; Linux: 242 passed, 1 skipped, and 245 passed, 1 skippedcargo xtask fmt --fix2cb90b693and5af753b17VirtioFs, not committed, on Linux's ext4: reads and writes through a handle opened withO_RDWR | O_DIRECT, then a save, a restore, and reads through the restored handleEINVAL; after the restore, 4 KiB at offset 0 reads and 100 bytes at offset 1 fail withEINVAL, as before the savepython3 scripts/nvx.py test-microvm --backend kvm --scenario filesystem-snapshot, withfilesystem-live.shchanged, not committed, so that twonvx-device-io file ... write 15000 65536 directwriters hold files open withO_DIRECTacross the capture, one byFUSE_OPEN(existing) and one byFUSE_CREATE(create)saved state is invalid: saved handle has unsupported open flags 0x4002python3 scripts/nvx.py test-microvm --backend kvmwith the unmodifiedfilesystem-snapshot,filesystem-shares,filesystem-policy,filesystem-owner,denied-filesystem-paths,filesystem-comma-paths,platform-filesystem, andplatform-aggregate-exportscenarioscargo test --locked --manifest-path nvx/Cargo.toml --no-default-features --test openvmm_vectors -- --ignored, and the same with--test openvmm_cpu_profiles5af753b17: the vectors and CPU profiles thatnvxcopies are unchangedpython scripts/openvmm_pin.py source 5af753b17035f548039cab531027a3cc635ac4fa --pr 5285python scripts/openvmm_pin.py check-branch --topic --target origin/agents/issue-2126-virtiofs-empty-symlink,python scripts/openvmm_pin.py check-roadmap --worktree,python scripts/check_markdown_links.py,git diff --check,python scripts/nvx.py verifypython scripts/local_gates.py --base origin/agents/issue-2126-virtiofs-empty-symlink --run --only test-changes markdown-links test-layout openvmm-vectors openvmm-cpu-profilesBackend, host OS, host type, and guest: KVM on a Linux test virtual machine (Azure Linux 3, kernel 6.18, x86_64), with its
/tmpand the scenarios' shares on ext4, and the Alpine guest and kernel of releasev0.1.0-dev.fb28ca4c3f07, whose OpenVMM CI built from1633b3797, the "before" OpenVMM. The "after" OpenVMM was built there from2cb90b693withpython3 scripts/nvx.py build-openvmm --backend kvm --skip-restore. The Windows checks ran on a Windows 11 Enterprise (NTFS) workstation, whose host type is not classified, whereO_DIRECTchanges nothing on the host.Left to CI: OpenVMM's CI of the pin, which is running; this pull request's CI, with its KVM, MSHV, and WHP microVM jobs, which build OpenVMM from the pin, and its NVX CLI jobs on Linux and Windows; no MSHV host ran here, and WHP microVM runs were left to CI on this shared, loaded workstation; and the
nvx-cliandopenvmm-cilocal gates: the first starts with apip installand tests the scripts, which this branch does not change, and the second waits for OpenVMM's CI of the pin.Checklist
python3 scripts/check_test_layout.pychecks.python3 scripts/check_test_changes.py --base origin/devlists no changeto an existing test, or a Changes to existing tests section below
explains each one.
.github/copilot-instructions.mdand the skills when a convention orworkflow changes.
nvxupdatesnvx/public-api/withpython3 scripts/public_api.py --update.description says how the change versions or migrates them.
Changes to existing tests
None:
python scripts/check_test_changes.py --base origin/agents/issue-2126-virtiofs-empty-symlinklists no change to an existing test, and the OpenVMM pull request adds one test and changes none.OpenVMM pin
5af753b17035f548039cab531027a3cc635ac4fa, one commit one61fa5326, the head of [DO NOT REVIEW] lxutil: fail an empty symlink target with ENOENT on Windows openvmm#5284, which the base branch pins.e61fa5326, position 392), open, which openvmm: pin the refusal of an empty symlink target on Windows #2148 pins, on [DO NOT REVIEW] lxutil: reject xattr names longer than an NTFS EA name allows openvmm#5283 (c7f6a04fd, position 391, openvmm: pin the xattr name limit of virtio-fs shares on Windows #2147), #5282 (770bc61e7, position 390, openvmm: pin microVM restores of handles opened with access mode 3 #2146), and #5281 (350018ce4, position 389, openvmm: pin new microVM objects that take the last node ID #2144), all open, on1633b3797, position 388, the head offeature/microvm/dev.2cb90b693on1633b3797, on which the evidence before the rebase was collected, asgit range-diffreports but for the context of its one new import infs_tests.rs, where the rebase conflicted with the imports that #5281 and #5282 add. #5282 also changesreopen_flags, after the list to which this commit addsO_DIRECT, so thevirtiofschecks ran again at the pin.reopen_flagslackedO_DIRECT, and needs nothing that a later position adds but, for its test, position 164's helpers, position 334'screate_with_flags, and position 335'sget_file, so, as openvmm: pin new microVM objects that take the last node ID #2144 maps position 389 into position 081, it folds into position 083, where its line applies as it is, and its test into position 335. Position 390, which also changesreopen_flags, stays unassigned, since its code needs positions 160 and 334. It cannot go upstream on its own: upstream main,8d4e03132, lacks the microVM's saved state, and replaying the commit there conflicts in the microVM'sstate.rs,fs_tests.rs, andpolicy_tests.rs.nvxcopies are unchanged.feature/microvm/devexactly to5af753b17035f548039cab531027a3cc635ac4fa(not with the merge button, which squashes) before this pull request merges;python scripts/openvmm_pin.py land 5af753b17035f548039cab531027a3cc635ac4fa --remote originfinds that fast-forward once #5284 has landed.