Skip to content

virtiofs: Add aggregate (multi-share) device support#3821

Open
damanm24 wants to merge 22 commits into
microsoft:mainfrom
damanm24:synth_root
Open

virtiofs: Add aggregate (multi-share) device support#3821
damanm24 wants to merge 22 commits into
microsoft:mainfrom
damanm24:synth_root

Conversation

@damanm24

Copy link
Copy Markdown
Contributor

This PR adds an aggragate mode to the virtiofs device, so that a single virtiofs device can serve several, independent host-folder shares, instead of requiring one device per share. It does so by introducing a synthetic, read-only root directory whose named children are the host folders where each child is advertised to the guest with FUSE_ATTR_SUBMOUNT.

This allows us to use virtiofs in areas where MMIO/PCI device space is limited (i.e. WSL) and users frequently want to expose multiple shares.

@damanm24
damanm24 requested a review from a team as a code owner June 25, 2026 23:51
Copilot AI review requested due to automatic review settings June 25, 2026 23:51
@github-actions github-actions Bot added the unsafe Related to unsafe code label Jun 25, 2026
@github-actions

Copy link
Copy Markdown

⚠️ Unsafe Code Detected

This PR modifies files containing unsafe Rust code. Extra scrutiny is required during review.

For more on why we check whole files, instead of just diffs, check out the Rustonomicon

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.

Pull request overview

This PR extends the virtiofs device to support an aggregate (multi-share) mode: a single virtio-fs instance can expose multiple independent host-folder shares by presenting a synthetic, read-only root directory whose named children map to each share, optionally advertised as FUSE submounts.

Changes:

  • Add aggregate-mode virtio-fs implementation (aggregate.rs) with synthetic root handling, child registry management, and (optional) FUSE_ATTR_SUBMOUNT advertisement.
  • Refactor core VirtioFs to support direct vs aggregate mode, per-share read-only enforcement, and inode namespacing across multiple volumes.
  • Extend resources/resolver plumbing with a new VirtioFsBackend::Aggregate backend and child descriptors.

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 8 comments.

Show a summary per file
File Description
vm/devices/virtio/virtiofs/src/util.rs Update fuse_attr construction to initialize the new flags field.
vm/devices/virtio/virtiofs/src/section.rs Update section-backed fs attribute construction to use flags instead of the old padding field.
vm/devices/virtio/virtiofs/src/resolver.rs Add resolver support for VirtioFsBackend::Aggregate and populate children via add_child.
vm/devices/virtio/virtiofs/src/lib.rs Introduce aggregate-aware VirtioFs internals, synthetic-root dispatch, per-inode read-only checks, and volume-id-aware inode mapping.
vm/devices/virtio/virtiofs/src/inode.rs Add volume IDs + inode-number namespacing helpers to avoid cross-share inode collisions.
vm/devices/virtio/virtiofs/src/file.rs Ensure readdir/readdirplus reports namespaced inode numbers consistent with lookup/getattr.
vm/devices/virtio/virtiofs/src/aggregate.rs New aggregate-mode implementation: synthetic root, child registry, teardown gating, and unit tests.
vm/devices/virtio/virtio_resources/src/lib.rs Add VirtioFsBackend::Aggregate and the VirtioFsAggregateChild Mesh payload.
vm/devices/support/fs/fuse/src/protocol.rs Extend fuse_attr with flags and define FUSE_ATTR_SUBMOUNT/FUSE_ATTR_DAX.
Comments suppressed due to low confidence (1)

vm/devices/virtio/virtiofs/src/lib.rs:571

  • In aggregate mode the synthetic root inode (node_id == FUSE_ROOT_ID) is intentionally not stored in the inode map, so any unexpected call path that reaches get_inode(FUSE_ROOT_ID) will emit a warning log about an “unknown inode”. This can be guest-triggerable (e.g. attempts to modify root) and lead to noisy logs. Consider suppressing the warning for the synthetic root ID.
    fn get_inode(&self, node_id: u64) -> lx::Result<Arc<VirtioFsInode>> {
        self.inner.inodes.read().get(node_id).ok_or_else(|| {
            tracing::warn!(node_id, "request for unknown inode");
            lx::Error::EINVAL
        })
    }

Comment thread vm/devices/virtio/virtiofs/src/lib.rs
Comment thread vm/devices/virtio/virtiofs/src/lib.rs
Comment thread vm/devices/virtio/virtiofs/src/lib.rs
Comment thread vm/devices/virtio/virtiofs/src/lib.rs
Comment thread vm/devices/virtio/virtiofs/src/aggregate.rs Outdated
Comment thread vm/devices/virtio/virtiofs/src/inode.rs Outdated
Comment thread vm/devices/virtio/virtiofs/src/lib.rs Outdated
Comment thread vm/devices/virtio/virtiofs/src/lib.rs Outdated
Copilot AI review requested due to automatic review settings June 26, 2026 00:00

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.

Pull request overview

Copilot reviewed 9 out of 9 changed files in this pull request and generated 4 comments.

Comment thread vm/devices/virtio/virtiofs/src/aggregate.rs Outdated
Comment thread vm/devices/virtio/virtiofs/src/aggregate.rs Outdated
Comment thread vm/devices/virtio/virtiofs/src/lib.rs Outdated
Comment thread vm/devices/virtio/virtiofs/src/lib.rs Outdated
Copilot AI review requested due to automatic review settings June 26, 2026 17:25

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.

Pull request overview

Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.

Comment thread vm/devices/virtio/virtiofs/src/lib.rs Outdated
Comment thread vm/devices/virtio/virtiofs/src/aggregate.rs
@github-actions

Copy link
Copy Markdown

@github-actions

Copy link
Copy Markdown

Copilot AI review requested due to automatic review settings June 30, 2026 21:15

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.

Pull request overview

Copilot reviewed 12 out of 12 changed files in this pull request and generated 1 comment.

Comment thread vm/devices/virtio/virtiofs/src/resolver.rs
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings July 7, 2026 16:37

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.

Pull request overview

Copilot reviewed 12 out of 12 changed files in this pull request and generated 2 comments.

Comment thread vm/devices/virtio/virtiofs/src/aggregate.rs Outdated
Comment thread vm/devices/virtio/virtiofs/src/aggregate.rs Outdated
@github-actions

github-actions Bot commented Jul 7, 2026

Copy link
Copy Markdown

Comment thread vm/devices/virtio/virtiofs/src/aggregate.rs Outdated
Comment thread vm/devices/virtio/virtiofs/src/aggregate.rs Outdated
Comment thread vm/devices/virtio/virtiofs/src/lib.rs
Comment thread vm/devices/virtio/virtiofs/src/aggregate.rs Outdated
Comment thread vm/devices/virtio/virtiofs/src/lib.rs Outdated
Comment thread vm/devices/virtio/virtiofs/src/aggregate.rs Outdated
Comment thread vm/devices/virtio/virtiofs/src/inode.rs
Comment thread vm/devices/virtio/virtiofs/src/lib.rs Outdated
Comment thread vm/devices/virtio/virtiofs/src/lib.rs Outdated
Copilot AI review requested due to automatic review settings July 10, 2026 21:33

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.

Pull request overview

Copilot reviewed 15 out of 15 changed files in this pull request and generated 3 comments.

Comment thread vm/devices/virtio/virtiofs/src/aggregate.rs
Comment thread vm/devices/virtio/virtiofs/src/aggregate.rs Outdated
Comment thread vm/devices/support/fs/fuse/src/protocol.rs Outdated
Copilot AI review requested due to automatic review settings July 13, 2026 17:35

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.

Pull request overview

Copilot reviewed 15 out of 15 changed files in this pull request and generated 2 comments.

Comment thread vm/devices/virtio/virtiofs/src/lib.rs
Comment thread vm/devices/virtio/virtiofs/src/aggregate.rs
Copilot AI review requested due to automatic review settings July 15, 2026 22:49

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.

Pull request overview

Copilot reviewed 12 out of 12 changed files in this pull request and generated 2 comments.

Comment thread vm/devices/virtio/virtiofs/src/inode.rs Outdated
Comment thread vm/devices/virtio/virtiofs/src/lib.rs Outdated
@github-actions

Copy link
Copy Markdown

Copilot AI review requested due to automatic review settings July 17, 2026 16:05

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.

Pull request overview

Copilot reviewed 12 out of 12 changed files in this pull request and generated 3 comments.

Comment thread vm/devices/virtio/virtio_resources/src/lib.rs
Comment thread vm/devices/virtio/virtio_resources/src/lib.rs
Comment thread vm/devices/virtio/virtiofs/src/aggregate.rs
@github-actions

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

unsafe Related to unsafe code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants