Skip to content

openvmm: pin the ENOSYS reply to FUSE_COPY_FILE_RANGE_64 - #2069

Merged
Pedro Henrique Penna (ppenna) merged 3 commits into
devfrom
agents/issue-1899-copy-file-range-64
Nov 24, 2026
Merged

Pedro Henrique Penna (ppenna) merged 3 commits into
devfrom
agents/issue-1899-copy-file-range-64

Conversation

@ppenna

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

Copy link
Copy Markdown
Contributor

Fixes #1899

What does this pull request change?

A copy_file_range(2) between two files of a virtio-fs share no longer fails
with EINVAL in a Linux 6.18 guest, such as NVX's 6.18.38 one. Linux now falls
back to a copy that it makes itself.

  • OpenVMM pin (openvmm: pin the ENOSYS reply to FUSE_COPY_FILE_RANGE_64)
    moves the openvmm gitlink to [DO NOT REVIEW] fuse: fail FUSE_COPY_FILE_RANGE_64 with ENOSYS, not EINVAL openvmm#5255. Its one commit,
    fuse: fail FUSE_COPY_FILE_RANGE_64 with ENOSYS, not EINVAL, makes OpenVMM's
    FUSE session decode FUSE_COPY_FILE_RANGE_64 (opcode 53) the way it decodes
    FUSE_COPY_FILE_RANGE (opcode 47), and fail it with ENOSYS without calling
    the file system. Fuse::copy_file_range keeps answering
    FUSE_COPY_FILE_RANGE alone, as its documentation now says. A short request
    still fails with EINVAL, as every malformed request does.
  • Design document (doc: say that both FUSE copy variants fail with ENOSYS): §3.6.3 of doc/design/3.6-host-filesystem.md now says that both
    wire variants of a copy fail with ENOSYS. It also says how Linux falls back
    from COPY_FILE_RANGE_64 to COPY_FILE_RANGE and then to its own copy.
  • Roadmap (doc: map the ENOSYS reply to FUSE_COPY_FILE_RANGE_64 in the OpenVMM roadmap): maps chain position 365, after 1901's positions 362-364.

Start with the OpenVMM commit (git diff --submodule=diff origin/agents/issue-1901-snapshot-replaced-path HEAD), then the design-document
paragraph.

Left out:

  • Accelerated copying. No file system in OpenVMM implements
    Fuse::copy_file_range, and the issue does not require it.
  • The session's catch-all for unknown opcodes, which still fails them with
    EINVAL.

Separate bug, not fixed here: FUSE_TMPFILE (opcode 51) also reaches that
catch-all and fails with EINVAL. Linux 6.18's fuse_tmpfile turns only
ENOSYS into EOPNOTSUPP (and sets no_tmpfile). So open(2) with
O_TMPFILE on a share fails with EINVAL instead of EOPNOTSUPP, which is
the error that applications check before they fall back. Both WHP guest runs
below show it. libfuse and virtiofsd fail unknown opcodes with ENOSYS.

Why is this change needed?

Since 6.18, __fuse_copy_file_range in fs/fuse/file.c sends each copy as
FUSE_COPY_FILE_RANGE_64, opcode 53 of protocol 7.45, whatever minor version
the session negotiated (OpenVMM negotiates 7.39). Linux handles the reply as
follows:

  • -ENOSYS: Linux sets no_copy_file_range_64 and resends the copy as
    FUSE_COPY_FILE_RANGE for the rest of the connection. If that one also gets
    -ENOSYS, Linux sets no_copy_file_range, and fuse_copy_file_range copies
    with splice_copy_file_range.
  • Any other error fails the system call, and the next copy tries opcode 53
    again.

OpenVMM's session did not know opcode 53. The catch-all of
FuseOperation::read logged "Invalid opcode" and failed the request with
EINVAL. FUSE_COPY_FILE_RANGE, by contrast, reaches Fuse::copy_file_range,
whose default, which VirtioFs keeps, is ENOSYS. #1864 fixed the size of a
legacy copy's reply, not the newer opcode. Upstream OpenVMM main has the same
catch-all and lacks the opcode too.

Alternatives rejected:

  • Answering opcode 53 through Fuse::copy_file_range with a 64-bit
    fuse_copy_file_range_out reply. No file system implements copying, so it
    would add an untested reply path without changing any behavior. Linux
    already clamps the legacy request to what its u32 reply can count.
  • Failing every unknown opcode with ENOSYS. That would also change
    FUSE_TMPFILE and every future opcode, which is beyond this issue; it is
    left for the separate bug above.

How was this change validated?

Checks and results:

OpenVMM, on Windows, at the pinned be75ab532:

Command Result
cargo check -p fuse passed
cargo clippy --all-targets -p fuse passed, no warnings
cargo clippy --all-targets -p fuse --target x86_64-unknown-linux-gnu passed, no warnings
cargo doc --no-deps -p fuse passed
cargo nextest run --profile agent -p fuse 52 passed
cargo check --all-targets -p virtiofs passed
cargo xtask fmt --fix passed (rustfmt, lints, verify-fuzzers, verify-flowey), no changes

The two new tests, copy_64_fails_as_the_legacy_copy_does and
legacy_copy_copies_after_copy_64_fails, fail without the fix, with only the
opcode's constant declared (left: Err(EINVAL (22)), right: Err(ENOSYS (38))). That holds at 899dcd63f and at b2ac1073d. They pass with the fix.

NVX:

Command Result
python scripts\nvx.py verify passed
cargo test --locked --manifest-path nvx/Cargo.toml --no-default-features --test openvmm_vectors -- --ignored 4 passed
cargo test --locked --manifest-path nvx/Cargo.toml --no-default-features --test openvmm_cpu_profiles -- --ignored 1 passed
python scripts\openvmm_pin.py source be75ab532b77ce90fa46371f2ced3cb547fd00c7 --pr 5255 good signature, head of microsoft/openvmm#5255
python scripts\openvmm_pin.py check-branch --topic --target origin/agents/issue-1901-snapshot-replaced-path passed, all three commits signed and verified
python scripts\openvmm_pin.py check-roadmap --worktree passed
python scripts\check_markdown_links.py passed
python scripts\check_test_changes.py --base origin/agents/issue-1901-snapshot-replaced-path 0 changes to existing tests
python scripts\check_test_layout.py passed
nvx-cli gate (python -m unittest ..., test_adversarial.py, nvx.py ... --help) left to CI: stopped locally after an hour on a shared machine; NVX CLI / Windows and NVX CLI / Linux passed in run 45294580049
git diff --check clean

Backend, host OS, host type, and guest:

Guest probe: a static binary that calls copy_file_range(2) twice, copying a
1 MiB random file on the share to a new file, then opens an O_TMPFILE. It ran
in NVX's Linux 6.18.38 guest (nvx 0.1.0 kernel and initramfs, 256 MiB), with
OpenVMM's FUSE trace on.

Backend Host OpenVMM copy_file_range(2) Destination FUSE trace
WHP local Windows workstation (host type not recorded) 0.5.0+g09524b79c, whose fuse and virtiofs sources match 899dcd63f (before) -1, EINVAL, twice empty opcode 53 failed as an invalid opcode, EINVAL
WHP same 0.5.0+g0202d795b, the same patch on 899dcd63f (after) 1048576, twice identical to the source CopyFileRange64 -> ENOSYS, CopyFileRange -> ENOSYS, then the guest's copy; no copy request for the second call
KVM nvx-kvm-test, Linux, virtual machine 09524b79c release (before) -1, EINVAL, twice empty opcode 53 failed as an invalid opcode, EINVAL

CI of this head:

  • NVX run 45294580049
    passed: the microVM tests on Linux/KVM, Linux/MSHV, and Windows/WHP, NVX CLI on Linux and Windows, the packages, and OpenVMM CI of the pinned revision. Its first attempt failed only that last job: it found
    OpenVMM's Linux vmm-tests skipped after a transient failure,
    curl: (35) OpenSSL SSL_connect: SSL_ERROR_SYSCALL from
    packages.microsoft.com in resolve mshv boot payloads. I reran
    OpenVMM's failed jobs once, then this job.
  • OpenVMM run 45290009323
    passed the six jobs that NVX requires for be75ab532: unit tests [x64-linux], unit tests [x64-windows], and run vmm-tests on
    x64-linux-amd-kvm, x64-linux-intel-mshv, x64-windows-intel, and
    x64-windows-amd. Its x64-windows-amd-snp vmm-tests, which also fail
    on [DO NOT REVIEW] virtiofs: keep the node that a LINK returns until the guest forgets it openvmm#5253 and #5254, fail one VMGS test, and its
    x64-windows-intel-tdx vmm-tests exit with code 127 before any test;
    NVX requires neither.

Not run: a Linux run of the regression tests and of the KVM guest probe with
the fix. nvx-kvm-test and nvx-mshv-test have been unreachable over SSH
since 11:38 today. NVX CI's Linux microVM tests ran the exact pin.

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/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 is created or bumped. The session still negotiates FUSE protocol
7.39, and no saved-state, snapshot, manifest, ABI, or protocol format or
version changes. nvx is unchanged, so its public API is too.

OpenVMM pin

OpenVMM's FUSE session did not know FUSE_COPY_FILE_RANGE_64, opcode 53,
which Linux 6.18 sends first for each copy_file_range(2) on a virtio-fs
share, whatever protocol version the session negotiated
(#1899). Its catch-all for unknown opcodes failed the
request with EINVAL, so the system call failed in NVX's 6.18.38
guests, whereas only ENOSYS makes Linux resend the copy as
FUSE_COPY_FILE_RANGE and, after ENOSYS to that one too, copy the data
itself.

Pin microsoft/openvmm be75ab532b77ce90fa46371f2ced3cb547fd00c7, one
commit on 5e0e72d72, the head of microsoft/openvmm#5254, which NVX
pins below this commit:

- fuse: fail FUSE_COPY_FILE_RANGE_64 with ENOSYS, not EINVAL.
  The session decodes opcode 53 as it decodes FUSE_COPY_FILE_RANGE and
  fails it with ENOSYS without calling the file system, which keeps
  answering FUSE_COPY_FILE_RANGE alone, as Fuse::copy_file_range now
  documents. A short request still fails with EINVAL. Its two tests
  fail without the fix, with EINVAL instead of ENOSYS, and pass with
  it, on Windows.

Two copy_file_range(2) calls of 1 MiB in a 6.18.38 guest on WHP failed
with EINVAL before the fix and copied the file after it, with the
guest's own copy once both variants had failed with ENOSYS. The
session still negotiates protocol 7.39. 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>
Section 3.6.3 names COPY_FILE_RANGE among the operations that the
server fails with ENOSYS, but Linux 6.18 sends each copy first as
COPY_FILE_RANGE_64, which the server failed with EINVAL until the pin
of the previous commit (#1899), so the guest's
copy_file_range(2) failed instead of falling back. Say that both wire
variants fail with ENOSYS, and how Linux falls back from the first to
the second and then to a copy that it makes itself.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…oadmap

Map position 365, the commit of microsoft/openvmm#5255, which NVX now
pins at be75ab532, 239 commits past the mapped tip:

- 365, fuse: fail FUSE_COPY_FILE_RANGE_64 with ENOSYS, not EINVAL.
  The session decodes opcode 53 as it decodes FUSE_COPY_FILE_RANGE
  and fails it with ENOSYS in Session::dispatch_helper, without
  calling the file system. Since 6.18, Linux sends each copy as that
  opcode first, and only ENOSYS makes it fall back to
  FUSE_COPY_FILE_RANGE and then to its own copy; the catch-all of
  upstream's FuseOperation::read failed it with EINVAL, so the copy
  failed in NVX's 6.18.38 guests.

Position 365 is not yet assigned to a PR. It declares the opcode in
protocol.rs, which no earlier position changes, adds it to the
operation table of request.rs, whose request checks positions 318 and
319 change, adds its arm between upstream's in dispatch_helper, and
documents it on Fuse::copy_file_range in lib.rs, after position 327's
paragraph; its tests, registered before position 323's error_reply,
use the session's test harness of positions 321, 322, and 325 and
position 327's reply to FUSE_COPY_FILE_RANGE. It is not a fixup: no
earlier position handles the opcode, and the catch-all is upstream's.
Upstream main, 5d6ab1cfa, lacks the opcode too and fails it the same
way, but replaying the commit there conflicts in lib.rs and
session.rs, which lack position 327's paragraph and the session's test
modules, so it cannot go upstream on its own.

The Scope now names 09966aa63, position 361, as the head of
feature/microvm/dev, since microsoft/openvmm#5251,
microsoft/openvmm#5252, and microsoft/openvmm#5253 landed positions
358-361 there too.

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 recorded for the filesystem documentation and OpenVMM roadmap updates.

No open issues 🎉

What changed in this PR

This PR addresses #1899 by pinning OpenVMM’s ENOSYS response to unsupported FUSE_COPY_FILE_RANGE_64 requests, allowing Linux 6.18 guests to fall back to copying data themselves.

Changes:

  • Documents both FUSE copy variants and Linux’s fallback sequence.
  • Maps OpenVMM chain position 365 and updates the roadmap’s pin, counts, and dependency analysis.
File Description
doc/​openvmm-upstream-roadmap.md Records the new OpenVMM pin and maps the copy-operation fix.
doc/​design/​3.6-host-filesystem.md Explains unsupported copy responses and Linux’s fallback behavior.

Review effort: Balanced

Base automatically changed from agents/issue-1901-snapshot-replaced-path to dev November 24, 2026 03:45
@ppenna
Pedro Henrique Penna (ppenna) added this pull request to the merge queue Nov 24, 2026
Merged via the queue into dev with commit 766091d Nov 24, 2026
93 of 95 checks passed
@ppenna
Pedro Henrique Penna (ppenna) deleted the agents/issue-1899-copy-file-range-64 branch November 24, 2026 04:05
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: unsupported FUSE_COPY_FILE_RANGE_64 returns EINVAL instead of allowing Linux fallback

2 participants