Skip to content

openvmm: pin FSYNCDIR on an aggregate's synthetic root - #1959

Merged
Pedro Henrique Penna (ppenna) merged 3 commits into
devfrom
agents/issue-1624-synthetic-root-fsyncdir
Nov 22, 2026
Merged

Pedro Henrique Penna (ppenna) merged 3 commits into
devfrom
agents/issue-1624-synthetic-root-fsyncdir

Conversation

@ppenna

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

Copy link
Copy Markdown
Contributor

Fixes #1624

What does this pull request change?

It pins microsoft/openvmm#5222 (21b1a55d0), whose one commit, virtiofs: accept FSYNCDIR through the synthetic root's handle, makes fsync() and fdatasync() of a descriptor of an aggregate's synthetic root succeed in the guest, where they failed with EBADF. OpenVMM's virtio-fs server now answers FUSE_FSYNCDIR through the root's handle, with the root's node, with success, as it answers FUSE_RELEASEDIR, since the root keeps its entries only in memory and has nothing to write back. Every other handle and node reaches get_file as before, with the node check of #1599.

The pull request has three commits:

  • openvmm: pin FSYNCDIR on an aggregate's synthetic root, which changes only the gitlink;
  • doc: say that syncing an aggregate's root succeeds, one clause in 3.6.3 Request Path;
  • doc: map FSYNCDIR on an aggregate's root in the OpenVMM roadmap, which maps the commit as position 356.

Start with VirtioFs::fsync_dir in openvmm/vm/devices/virtio/virtiofs/src/lib.rs and its regression test, synthetic_root_handle_accepts_fsyncdir in openvmm/vm/devices/virtio/virtiofs/src/aggregate_tests.rs.

Left out: FUSE_FSYNC through the root's handle, which a Linux guest sends only for files, still fails with EBADF, and the handle map's u64::MAX and SYNTHETIC_ROOT_FH (#1627) are handled separately.

Why is this change needed?

A guest that syncs the root of an aggregate share, the mount that holds every --mount of a microVM, as sync /run/nvx/shares or sync -d /run/nvx/shares does, got Bad file descriptor, an error that POSIX reserves for a descriptor that is not open, although it held a valid descriptor of the directory. The Linux FUSE client sends fsync and fdatasync of a directory as FUSE_FSYNCDIR, with the directory's node and the handle that FUSE_OPENDIR returned. FUSE_OPENDIR of the synthetic root returns the sentinel SYNTHETIC_ROOT_FH, which names no open file; READDIR, READDIRPLUS, RELEASEDIR, and GETATTR and STATX through a handle recognize it with the root's node, but VirtioFs::fsync_dir looked it up in the handle map, found nothing, and failed with EBADF. The defect came with upstream's aggregate support, a5f055dd7 (microsoft/openvmm#3821), which added the sentinel and the handlers that recognize it, and upstream main still has it.

Rejected alternatives:

  • Answering ENOSYS would make the Linux client set no_fsyncdir for the whole mount, so it would stop sending FSYNCDIR for the children's real directories too, which have something to write back.
  • Accepting any handle on the root's node, or the sentinel on any node, would hide requests that name no open directory, which still fail with EBADF, as they do for the other directory requests.
  • The issue's patch takes the same approach. The fix keeps it, and moves the test into the aggregate module's unit tests, on an aggregate of VirtioFs::new_aggregate, which upstream has too, rather than a new integration-test file; the test sends well-formed FUSE_OPENDIR, FUSE_LOOKUP, and FUSE_FSYNCDIR requests, and also checks that the root's handle with a child's node, and another handle with the root's node, still fail with EBADF.

How was this change validated?

Checks and results:

Check Result
cargo nextest run --profile agent -p virtiofs -E 'test(synthetic_root_handle_accepts_fsyncdir)' in openvmm/, with lib.rs of the pin's parent 655bc319d (fix reverted) Fails on Windows and on Linux: flags 0x0, left: Err(Error(EBADF (9))), right: Ok(())
cargo nextest run --profile agent -p virtiofs at 21b1a55d0 Passed: 207 on Windows (3 ignored tests skipped), 215 on Linux (1 skipped)
cargo check, cargo clippy --all-targets, cargo doc --no-deps for virtiofs at 21b1a55d0, Windows and Linux Clean, apart from the LNK4199 linker message that every linked artifact gets on the Windows machine
cargo xtask fmt --fix in openvmm/ Passed, no changes
The same change on upstream main bf353460f: cargo check -p virtiofs --all-targets and cargo nextest run --profile agent -p virtiofs, Windows Type-checks; 72 passed (1 skipped); the new test fails without the change
python scripts\openvmm_pin.py source 21b1a55d01bcd7bd916e1cc92c05c70c7d5c80e1 --pr 5222 Good signature; the revision is the pull request's head
cargo test --locked --manifest-path nvx/Cargo.toml --no-default-features --test openvmm_vectors -- --ignored and --test openvmm_cpu_profiles Passed (4 and 1): the vectors and CPU profiles that nvx copies are unchanged
python scripts\openvmm_pin.py check-branch --topic --target origin/agents/issue-1606-setgroups-restore Passed: three verified signed commits, no coordinated files
python scripts\openvmm_pin.py check-roadmap --worktree Passed: 356 chain positions, 366 references
python scripts\check_markdown_links.py, git diff --check, python scripts\nvx.py verify Passed
python scripts\check_test_changes.py --base origin/agents/issue-1606-setgroups-restore 0 changes to existing tests
python scripts\local_gates.py --base origin/agents/issue-1606-setgroups-restore --run --keep-going --only test-changes markdown-links test-layout openvmm-vectors openvmm-cpu-profiles nvx-cli Passed, all six; nvx-cli ran 2,314 unit tests (89 skipped) and 84 adversarial tests (11 skipped)
python scripts\nvx.py check-openvmm-ci --revision 21b1a55d01bcd7bd916e1cc92c05c70c7d5c80e1 Passed: all six required jobs of run 44990399705
In the guest, sync /run/nvx/shares and sync -d /run/nvx/shares with the aggregate of the filesystem-shares scenario, with the OpenVMM of release v0.1.0-dev.3e98eff40820 (b51f9156c) Both fail: sync: /run/nvx/shares: Bad file descriptor
The same, with OpenVMM built from the pin by python3 scripts/nvx.py build-openvmm --backend kvm (provenance 21b1a55d0, clean) Both succeed
python3 scripts/nvx.py test-microvm --backend kvm --scenario filesystem-shares --scenario platform-aggregate-export --scenario platform-filesystem --scenario filesystem-snapshot at this pull request's head 465d0225d, with that OpenVMM and the guest artifacts of v0.1.0-dev.3e98eff40820 Passed: all four scenarios

Backend, host OS, host type, and guest: the unit tests ran on Windows 11 (local machine) and on Azure Linux 3.0 (nvx-kvm-test, virtual machine); the guest checks and the microVM scenarios ran on KVM on Azure Linux 3.0 (nvx-kvm-test, virtual machine) with the Alpine guest, whose guest and kernel inputs are unchanged since v0.1.0-dev.3e98eff40820, the release that installed them.

Left to CI: the MSHV and WHP microVM suites, the rest of the KVM suite, the platform and performance jobs, and openvmm-ci, which checks OpenVMM's CI of the pinned revision. CI run 44997832368 at this head 465d0225d passed every job that it ran, among them every microVM suite on KVM, MSHV, and WHP, the platform and package jobs, the performance regression gate, and OpenVMM CI of the pinned revision. OpenVMM's CI of the pin also failed run vmm-tests [x64-windows-amd-snp], which NVX does not require, and run vmm-tests [x64-windows-intel-tdx], which NVX does not require either, in four TDX hardware-seal TPM tests and a Windows kdnet test, none of which uses virtio-fs, as on microsoft/openvmm#5220.

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-rs/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.

No version was created or bumped: no ABI, machine-contract, time-ABI, snapshot, manifest, saved-state, protocol, magic, or schema version changes, in NVX or in OpenVMM. The public API of nvx does not change.

OpenVMM pin

OpenVMM's virtio-fs server failed FUSE_FSYNCDIR through the handle of
an aggregate's synthetic root with EBADF (#1624), so
fsync and fdatasync of a descriptor of the root, as `sync DIR` calls,
failed in the guest with "Bad file descriptor", which POSIX reserves
for a descriptor that is not open. In a microVM whose aggregate is
mounted at /run/nvx/shares, `sync /run/nvx/shares` and
`sync -d /run/nvx/shares` both failed so.

Pin microsoft/openvmm 21b1a55d01bcd7bd916e1cc92c05c70c7d5c80e1, one
commit on 655bc319d, the head of microsoft/openvmm#5221:

- virtiofs: accept FSYNCDIR through the synthetic root's handle.
  VirtioFs::fsync_dir succeeds for the root's handle with the root's
  node, as release_dir does, since the root keeps its entries only in
  memory and has nothing to write back; every other handle and node
  reaches get_file as before. 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>
A guest's fsync or fdatasync of a descriptor of an aggregate's
synthetic root, which reaches OpenVMM as FUSE_FSYNCDIR through the
root's handle, now succeeds without flushing anything, since the root
has no host object, where it failed with EBADF (#1624).
Say so in 3.6.3, next to the acknowledgment of a guest syncfs.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Map position 356, the commit of microsoft/openvmm#5222, which NVX now
pins at 21b1a55d0, 230 commits past the mapped tip:

- 356, virtiofs: accept FSYNCDIR through the synthetic root's handle.
  VirtioFs::fsync_dir succeeds for the handle that FUSE_OPENDIR
  returns for an aggregate's synthetic root, with the root's node, as
  release_dir does, rather than look that sentinel up in the handle
  map and fail with EBADF, so fsync and fdatasync of a descriptor of
  the root succeed in the guest.

Position 356 is not yet assigned to a PR. It fixes upstream's
fsync_dir, which microsoft/openvmm#3821 adds and which no chain commit
changes but position 346, which passes it the request's node, and it
changes nothing that a mapped PR adds. Upstream main, bf353460f, has
the defect, and replaying the commit there conflicts in lib.rs, next
to position 346's node, and in aggregate_tests.rs, among position
350's imports. The same change made on upstream's code applies there
without conflicts, and virtiofs type-checks there with its tests,
which pass, so it can go upstream on its own in that form.

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 are reported for the OpenVMM pin and synthetic-root sync documentation updates.

No open issues 🎉

What changed in this PR

This PR pins the OpenVMM fix for #1624 so guest fsync() and fdatasync() calls on an aggregate share’s synthetic root succeed instead of returning EBADF.

Changes:

  • Documents that syncing the synthetic root succeeds without flushing the host.
  • Updates the OpenVMM roadmap to revision 21b1a55d0, position 356, with the fix’s scope and upstream applicability.
File Description
doc/​openvmm-upstream-roadmap.md Records the new pin, chain position, and upstream mapping.
doc/​design/​3.6-host-filesystem.md Clarifies sync behavior for an aggregate’s synthetic root.

Review effort: Balanced

Base automatically changed from agents/issue-1606-setgroups-restore to dev November 22, 2026 11:31
@ppenna
Pedro Henrique Penna (ppenna) added this pull request to the merge queue Nov 22, 2026
Merged via the queue into dev with commit 1b13016 Nov 22, 2026
51 checks passed
@ppenna
Pedro Henrique Penna (ppenna) deleted the agents/issue-1624-synthetic-root-fsyncdir branch November 22, 2026 12:10
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: FUSE_FSYNCDIR on aggregate synthetic root handle fails with EBADF

2 participants