Skip to content

openvmm: pin the refusal of aggregate root reads too small for an entry - #1947

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

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

Conversation

@ppenna

Copy link
Copy Markdown
Contributor

Fixes #1617

What does this pull request change?

It pins OpenVMM 189dc519f (microsoft/openvmm#5216), one commit on top of the pin of #1946, in which OpenVMM's virtio-fs server fails a FUSE_READDIR or FUSE_READDIRPLUS of an aggregate's synthetic root whose buffer cannot hold the next entry with EINVAL, as it already fails such a read of any other directory, rather than return an empty reply, which the guest takes for the end of the directory. Stacked on #1946 (#1620); only the top three commits belong to this pull request.

  • Before: VirtioFs::read_synthetic_root_dir_with stopped at the first entry that did not fit and returned what it had written, even nothing. A read from the start with a buffer too small for . (at most 31 bytes for READDIR, 159 for READDIRPLUS) listed an empty root, and a listing whose buffer held the entries before a child with a longer name ended before that child without an error.
  • After: such a read fails with EINVAL. A read that fits some entries still returns them, and a read at the end of the root still returns an empty reply, even with a buffer too small for an entry. READDIRPLUS checks that an entry fits before it looks the child up, so the failed read takes no lookup reference.

Three commits:

  1. openvmm: pin the refusal of aggregate root reads too small for an entry: the gitlink only.
  2. doc: say that directory reads refuse buffers too small for an entry: one sentence in section 3.6.3 of doc/design/3.6-host-filesystem.md, next to the 1 MiB bound of directory reads.
  3. doc: map undersized aggregate root reads in the OpenVMM roadmap: position 350.

Start with the OpenVMM commit: the !fit branch in vm/devices/virtio/virtiofs/src/aggregate.rs and its test in aggregate_tests.rs.

Left out, tracked separately: FSYNCDIR on the synthetic root (#1624), the handle map's u64::MAX and SYNTHETIC_ROOT_FH (#1627), and the root's st_nlink (#1632).

Why is this change needed?

FUSE defines an empty READDIR or READDIRPLUS reply as the end of the directory: Linux's fuse_readdir_uncached returns 0 to getdents64 for it. Upstream's aggregate support (microsoft/openvmm#3821) wrote the synthetic root's loop to break on the first entry that did not fit and return its buffer, even when empty, while VirtioFsFile::read_dir_with and read_dir_microvm fail a read that fits none of the remaining entries with EINVAL, as getdents64 does. A FUSE client with a small buffer therefore saw a truncated root, without an error. The Linux FUSE client reads directories with buffers of at least a page, which holds any entry, so NVX's Linux guest sees no change; the fix makes the root keep the contract of every other directory for any client.

The issue's suggested patch tracked a full flag and returned EINVAL after the loop; this change returns it in the !fit branch when nothing was written, which is the same condition. The issue's test was an integration test on a microVM aggregate; the test here is a unit test among the aggregate's own tests, on an aggregate built with upstream's VirtioFs::new_aggregate, so that the commit applies to upstream main on its own, which has the same defect.

How was this change validated?

Checks and results:

Check Result
cargo nextest run --profile agent -p virtiofs -E 'test(synthetic_root_refuses_a_buffer_too_small_for_the_next_entry)' with the fix reverted (Windows 11, local) fails at aggregate_tests.rs:365: plus: false, left: None, right: Some(Error(EINVAL (22))), the listing ending after work
The same on nvx-mshv-test (Azure Linux 3.0 VM, kernel 6.18) fails the same way
cargo check, cargo clippy --all-targets, cargo doc --no-deps -p virtiofs at 189dc519f, Windows and nvx-mshv-test clean
cargo nextest run --profile agent -p virtiofs at 189dc519f Windows: 200 passed, 1 skipped; nvx-mshv-test: 206 passed, 1 skipped
cargo xtask fmt --fix (OpenVMM) no changes
The commit on upstream main bf353460f (merged tree): cargo check -p virtiofs --tests, the new test without and with the fix, cargo nextest run -p virtiofs (Windows) type-checks; fails without the fix; 72 passed with it
python scripts/nvx.py test-microvm --backend kvm --scenario filesystem-shares --scenario platform-aggregate-export --scenario platform-filesystem --scenario filesystem-snapshot at this head, with OpenVMM built from 189dc519f pass
cargo test --locked --manifest-path nvx/Cargo.toml --no-default-features --test openvmm_vectors -- --ignored and --test openvmm_cpu_profiles -- --ignored 4 and 1 passed: nothing that nvx copies changes
python scripts/local_gates.py --base origin/agents/issue-1620-rename-hardlinks --only test-changes markdown-links test-layout openvmm-vectors openvmm-cpu-profiles nvx-cli --run (Windows) all passed; nvx-cli: 2314 tests OK (89 skipped), 84 adversarial tests OK (11 skipped)
python scripts/openvmm_pin.py source 189dc519f --pr 5216 good signature; the PR's head
python scripts/openvmm_pin.py check-branch --target origin/agents/issue-1620-rename-hardlinks --topic, check-roadmap --worktree, python scripts/check_markdown_links.py, python scripts/nvx.py verify passed

Backend, host OS, host type, and guest: KVM on nvx-kvm-test, an Azure Linux 3.0 virtual machine, Alpine guest.

Left to CI: the WHP and MSHV microVM suites and the rest of the KVM matrix, benchmarks, and openvmm-ci, which waits for OpenVMM's CI of 189dc519f on microsoft/openvmm#5216.

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.

The OpenVMM test is new and no existing test changes (check_test_changes.py --base origin/agents/issue-1620-rename-hardlinks: 0 changes). nvx itself does not change. No saved state, protocol, ABI, or on-disk format changes, and no version of any of them is created or bumped.

OpenVMM pin

OpenVMM's virtio-fs server answered a FUSE_READDIR or FUSE_READDIRPLUS
of an aggregate's synthetic root whose buffer could not hold the next
entry with an empty reply, which the guest takes for the end of the
directory (#1617). A read from the start with a buffer
too small for `.` therefore listed an empty root, and a listing whose
buffer held the entries before a child with a longer name ended before
that child, without an error. The reads of every other directory fail
with EINVAL, as getdents64 does.

Pin microsoft/openvmm 189dc519ffcf30c5b9cfea4805e5b917c1556b1b, one
commit on 2a483a06f, the head of microsoft/openvmm#5215:

- virtiofs: fail a synthetic root read too small for its next entry.
  The read fails with EINVAL when the first entry that it reaches does
  not fit. A read that fits some entries still returns them, and a
  read at the end of the root still returns an empty reply. Its test
  fails without the change on Windows and on Linux (nvx-mshv-test).

NVX's Linux guest reads directories with buffers of at least a page,
which holds any entry, so the microVM behaves as it did. 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>
The host filesystem's description of the request path said how large a
buffer a READDIR or READDIRPLUS may ask for, but not what a read whose
buffer cannot hold the next entry returns. The server answered such a
read of an aggregate's root with no entries, which the guest takes for
the end of the directory, so the guest listed the root without the
children from that entry on (#1617), while it fails such a
read of any other directory with EINVAL, as getdents64 does. The
pinned OpenVMM fails the root's read with EINVAL too.

Say that a READDIR or READDIRPLUS whose buffer cannot hold the next
entry fails with EINVAL rather than return no entries.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Map position 350, the commit of microsoft/openvmm#5216, which NVX now
pins at 189dc519f, 224 commits past the mapped tip:

- 350, virtiofs: fail a synthetic root read too small for its next
  entry. VirtioFs::read_synthetic_root_dir_with fails a FUSE_READDIR
  or FUSE_READDIRPLUS of an aggregate's synthetic root whose buffer
  cannot hold the next entry with EINVAL, as the reads of every other
  directory do. It returned an empty reply, which the guest takes for
  the end of the directory, so the guest listed the root without the
  children from that entry on.

Position 350 is not yet assigned to a PR. It changes only the !fit
branch of upstream's loop from a5f055dd7 (microsoft/openvmm#3821),
which no chain commit changes, and adds a test to upstream's
aggregate_tests.rs; it changes nothing that a mapped PR adds, so it is
no fixup. Upstream main, bf353460f, has the defect. The commit applies
there as it is, and on the merged tree virtiofs type-checks with its
tests, the new test fails without the change, and all 72 tests of the
package pass with it, on Windows, so it can go upstream on its own.

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

The review has no active issues for the OpenVMM pin update and accompanying directory-read documentation.

No open issues 🎉

What changed in this PR

This PR advances NVX’s OpenVMM pin to 189dc519f to address #1617: aggregate-root directory reads return EINVAL when entries remain but none fit, rather than falsely signaling end-of-directory. Partial reads and genuine end-of-directory replies remain unchanged.

Changes:

  • Documents the undersized-buffer behavior for READDIR and READDIRPLUS.
  • Updates the OpenVMM roadmap to position 350, including the new pin, chain counts, and upstream applicability.
File Description
doc/​openvmm-upstream-roadmap.md Maps the new pin and explains the fix, test coverage, and upstream applicability.
doc/​design/​3.6-host-filesystem.md Documents EINVAL for directory-read buffers too small to hold an entry.

Review effort: Balanced

Base automatically changed from agents/issue-1620-rename-hardlinks to dev November 22, 2026 07:10
@ppenna
Pedro Henrique Penna (ppenna) added this pull request to the merge queue Nov 22, 2026
Merged via the queue into dev with commit 42f413d Nov 22, 2026
48 checks passed
@ppenna
Pedro Henrique Penna (ppenna) deleted the agents/issue-1617-synthetic-root-einval branch November 22, 2026 07:43
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: aggregate synthetic root returns empty EOF reply instead of EINVAL when buffer fits no entry

2 participants