Introducing a new way to review your PRs.

Read the announcement

arcboxlabs / arcbox

Run AI agents on real and isolated machines — own kernel, filesystem, and network — with <100ms boot. Local first, OCI compatible, pure Rust.

View on GitHub

32 documents · Updated Nov 6, 2026

docs / guest-filesystem-sharing

Guest filesystem sharing

Guest filesystem sharing gives a Linux guest a controlled view of selected host directories through VirtIO-FS. The VM exposes each directory with a mount tag, and the guest mounts that tag at a known path; the result is shared file access without placing the guest's whole host filesystem in the VM. This page complements Virtualization platform, VM lifecycle and backends, and VirtIO devices.

Sharing model

Host directory exposure

A share is a host directory paired with a guest-visible tag and an access mode. The VM configuration carries this pair to the selected backend, while the guest uses the tag as the source name in a virtiofs mount.

The share boundary is the configured host directory. Host and guest can see the same files through that boundary, but guest paths outside the mount do not become host paths. A writable share intentionally makes guest file changes visible on the host; a read-only share is intended to prevent those changes.

ConceptRole
Host pathDirectory whose contents are exposed
TagStable name used by the guest mount
Mount pointGuest path where the directory appears
Access modeWhether guest writes are allowed

References: virt/…/config.rs• L5-14 virt/…/filesystem.rs• L67-103 virt/…/virtual_machine.rs• L136-148

Standard shares

The System VM uses a small set of named shares to connect ArcBox state and common macOS paths to the guest. The guest mounts them during startup when the corresponding devices are present; optional shares do not prevent the rest of the guest from starting.

TagGuest pathHost purpose
arcbox/arcboxArcBox data, logs, and runtime transport files
users/UsersDirect use of macOS home paths in guest bind mounts
private/privatemacOS paths used by symlinks such as /tmp and /var/folders

The /arcbox share is the main system path. For example, a host file under <data-dir>/name is visible as /arcbox/name, and a container can bind that guest path into its own filesystem. The guest's /tmp and /var remain separate writable layers, even when /private is available.

References: common/…/virtiofs.rs• L1-17 guest/…/mount.rs• L105-145 guest/…/init.rs• L27-43 engine/…/machine.rs• L296-309

User-defined shares

User-defined mounts add one VirtIO-FS device per host directory. They use generated tags such as m0 and m1, and the guest boot setup uses the same tag order when it reconstructs the mount table. This path is supported for shim-booted distro machines; other machine types reject the mounts instead of silently dropping them.

The stable tag-to-mount relationship matters during machine reload. Persisted mount records must produce the same tags so that the guest command line and the attached devices continue to refer to the same directories.

References: engine/…/machine.rs• L322-329 engine/…/machine.rs• L450-466

VirtIO-FS request path

Backend paths

The guest sees the same VirtIO-FS contract regardless of the host backend, but the host-side owner of that contract differs. Virtualization.framework delegates the filesystem device to Apple's managed VM service. The custom VMM path owns a VirtIO-FS device and passes FUSE requests to a host filesystem service. Linux KVM also receives filesystem device configuration through the VMM's common device setup.

The custom path uses a passthrough filesystem: FUSE operations are translated to operations under the configured host root. The handler tracks the FUSE session and returns results to the VirtIO queue, so the guest filesystem driver remains the front door for reads, writes, metadata, and directory changes.

References: virt/…/darwin.rs• L24-55 virt/…/linux.rs• L19-50 virt/…/setup.rs• L276-327 virt/…/server.rs• L30-40

Request lifecycle

The following flow shows how a guest filesystem call becomes a host filesystem operation and returns to the guest.

flowchart LR
    G[Guest virtiofs driver] --> M[Mount tag]
    M --> Q[VirtIO-FS request queue]
    Q --> S[FUSE session]
    S --> D[FUSE dispatcher]
    D --> P[Passthrough filesystem]
    P --> H[Selected host directory]
    H --> P --> D --> Q --> G

The first request establishes the FUSE session and negotiates supported features. Later requests are accepted only after that session is ready; the filesystem service then maps them to the selected host root and sends a FUSE response back through the queue.

References: virt/…/mod.rs• L152-223 virt/…/session.rs• L94-212 virt/…/dispatcher.rs• L54-79 virt/…/server.rs• L144-195

Path and inode boundary

The passthrough service treats the configured directory as its root. Guest names are checked as single path components, and the service keeps guest inode and file-handle state so later operations resolve within that root rather than joining an unchecked absolute or parent path.

When the service registers a guest inode during lookup, it also records the host inode identity. Later direct mappings can compare the opened host file with that recorded identity, which helps reject a path replacement between lookup and mapping.

DAX mappings add a second boundary check. Before a file is mapped directly into guest memory, the service checks that the opened file still matches the registered inode. This rejects a path swap between lookup and mapping instead of exposing a different host file through the old guest inode.

References: virt/…/passthrough.rs• L156-213 virt/…/inode_ops.rs• L11-64 virt/…/dax.rs• L10-25 virt/…/dax.rs• L28-71

Performance model

FUSE caching

Normal VirtIO-FS access crosses the guest FUSE layer and the host service for filesystem work. Entry and attribute cache times reduce that round-trip cost, but longer times delay the guest's view of host changes. Shares with changing user files therefore need a more current cache profile than shares that carry fixed runtime files.

The custom filesystem service distinguishes static and dynamic content. Static content uses a longer cache window, while dynamic content uses a short window; this is a visibility-versus-cost choice, not a guarantee that host and guest changes are conflict-free.

Share useMain goalTrade-off
Runtime or other fixed contentFewer metadata requestsHost changes take longer to appear
User source or other changing contentFresher metadataMore FUSE round trips

References: virt/…/lib.rs• L77-121 virt/…/server.rs• L94-112 guest/…/mount.rs• L70-84

DAX fast path

DAX, or Direct Access, maps file pages into a guest memory window so reads and memory mappings can avoid ordinary copy-through FUSE reads. It is an optional fast path. It is suitable for content that does not change while the VM runs, and it is not a replacement for normal cache coherence.

The custom HV path gives each share a separate DAX window slice and maps pages only after the guest requests them. The managed VZ path uses Apple's VirtIO-FS device; measurements show that DAX is not active there, even when the guest mount attempts dax=always. The guest mount code treats a failed DAX remount as non-fatal.

VirtioFS still has a transport and scheduling cost after DAX is considered. The measured VZ work shows the largest limit in metadata operations is the guest-to-device wake path; the fuse-spin-wait kernel change improved metadata_stat by 58% in the documented same-VM comparison. Read the filesystem performance limits page before setting a new performance target.

References: virt/…/setup.rs• L276-334 virt/…/dax.rs• L18-39 guest/…/mount.rs• L70-84 docs/fs-perf-limits.md• L11-41

Isolation boundaries

Access modes

Read-only mode is part of the managed device configuration for Virtualization.framework and the common KVM device configuration. It must be checked separately for the custom filesystem service: its current server setup receives the host path and cache policy, but does not pass a read-only flag into arcbox-fs. Do not treat a custom-HV share as read-only unless the full backend path enforces that policy.

For writable shares, host and guest changes are two views of the same directory. A caller must choose a share root and mode with that effect in mind. The path checks protect the root boundary, but they do not make a writable share private.

References: virt/…/darwin.rs• L42-55 virt/…/linux.rs• L37-50 virt/…/setup.rs• L282-298 virt/…/config.rs• L5-14

Host change visibility

Host and guest can change the same directory at the same time. FUSE cache settings control how soon metadata changes become visible, while the underlying host filesystem remains the source of the shared data. The consistency e2e path checks byte round trips, permission propagation, and concurrent metadata visibility across both sides.

This boundary is different from a block device. A block device gives the guest a disk view with its own filesystem state; VirtIO-FS gives the guest operations on a host directory. Use the block path for guest-owned persistent filesystem state and a share for data that must be visible on both sides.

References: tests/…/virtiofs_consistency.rs• L14-23 tests/…/virtiofs_consistency.rs• L134-222 tests/…/virtiofs_consistency.rs• L225-296

Change checklist

When these files or sections are changed, remember to consider these:

  • Keep each share tag aligned with its guest mount point, boot mount table, and persisted user-mount order.
  • If a backend adds or changes read-only support, check the managed-device path and the host filesystem service path separately.
  • If a cache or DAX policy changes, confirm that the content is static or dynamic as intended and update the measured performance limits when the measurement basis changes.
  • If a standard share changes, check the guest's writable tmpfs layers and macOS path rewrites so /private and /Users do not silently become required.
  • If DAX window layout changes, keep the per-share mapping regions disjoint and preserve cleanup before VM destruction.

Important failure modes

TriggerConsequenceGuard
Host source is missing or is not a directoryShare configuration or filesystem service setup failsValidate the source before attaching the device; managed VZ checks this during share creation
Guest mount tag differs from the attached device tagThe guest cannot mount the share at its expected pathTreat tags as a shared contract across constants, VM config, and guest mount setup
Optional users or private device is absentThe guest keeps running but matching macOS paths are unavailableTreat these mounts as optional and do not use them as a readiness signal
Long cache window on changing host dataGuest metadata can remain staleUse the dynamic cache profile for changing content
dax=always used for content changed by the hostDirect mappings can expose stale or unsafe file viewsUse DAX only for content that remains stable during the VM run
Read-only intent sent through the custom HV pathGuest writes can reach the host shareVerify enforcement in the custom server path before relying on the flag
User mount tags change after persistence or reloadThe guest mount table can point at the wrong host directoryPreserve generated tag order when reconstructing a machine

Key files

FileWhy to read it
common/…/virtiofs.rsDefines the standard tag and mount-point contract
engine/…/machine.rsShows how System VM and user-defined shares become VM configuration
guest/…/mount.rsShows guest mount behavior, optional shares, cache choices, and DAX fallback
virt/…/darwin.rsShows the managed macOS backend's VirtIO-FS attachment path
virt/…/setup.rsShows the custom host filesystem server and per-share DAX setup
virt/…/mod.rsExplains the guest request/session boundary for the custom VirtIO-FS device
virt/…/server.rsConnects FUSE request handling to host directory access
virt/…/passthrough.rsDefines the host-root and path safety boundary
virt/…/inode_ops.rsShows inode registration and host inode identity tracking used by the safety boundary
docs/fs-perf-limits.mdRecords measured VZ performance and known limits