virtiofs is a shared file system for virtual machines that exposes a directory on the host to a guest using the FUSE protocol carried over a virtio transport, giving the guest local file system semantics and high performance without network file protocols. In Linux virtualization, it is the preferred way to share host directories with KVM and QEMU guests, and it has largely replaced the older 9p-based sharing.
virtiofs was developed to serve lightweight virtual machines and secure containers, such as Kata Containers, where many guests need fast access to the same root file systems or images. It is supported in the Linux kernel since version 5.4, in QEMU, in libvirt and in several other virtual machine monitors.
How virtiofs connects guest and host
virtiofs splits the file system into a guest driver and a host daemon. The guest kernel runs a FUSE client that, instead of talking to a local user-space process, sends FUSE requests through virtio queues to the host. On the host, the virtiofsd daemon receives those requests, performs the real operations on the shared directory, and returns the results.
Communication uses the vhost-user protocol, so virtiofsd runs as a separate process rather than inside QEMU. This separation improves isolation, because the daemon can be sandboxed with namespaces and seccomp and can run with fewer privileges than the virtual machine monitor itself. The guest mounts the share with a simple command such as mount -t virtiofs myshare /mnt.
The table below summarizes the components that participate in a virtiofs share.
| Component | Runs in | Role |
|---|---|---|
| virtiofs guest driver | Guest kernel | FUSE client sending requests over virtio |
| virtiofsd | Host user space | Executes file operations on the shared directory |
| vhost-user-fs device | Virtual machine monitor | Connects guest queues to the daemon socket |
| DAX window | Shared memory region | Maps host page cache directly into the guest |
| Mount tag | Guest configuration | Name the guest uses to select the share |
Caching modes and the DAX window
Performance and consistency in virtiofs depend mainly on the cache policy chosen for virtiofsd. A stronger cache gives faster metadata and data access inside the guest, while a weaker cache keeps the guest view consistent with changes made on the host or by other guests.
| Cache mode | Behavior | Best suited for |
|---|---|---|
| never | No guest caching of data or metadata | Directories shared between several writers |
| auto | Caching with timeouts and revalidation | General-purpose development shares |
| always | Aggressive caching, host changes may appear late | Read-mostly images used by one guest |
| metadata | Caches metadata only | Workloads heavy in directory lookups |
The optional DAX (direct access) window maps file contents from the host page cache directly into guest memory. Reads and writes in that window avoid copying data through the virtio queue, and several guests that open the same file can share one copy of the page cache, which reduces memory use on dense hosts. DAX support depends on the virtual machine monitor and kernel versions, and it requires a correctly sized shared memory region.
virtiofs compared with other sharing methods
virtiofs differs from earlier approaches because it was designed for co-located guests on the same host, not for access across a network. Network file systems must handle latency, packet loss and remote authentication, while virtiofs can rely on shared memory and the host kernel directly.
| Method | Transport | Relative performance | Main drawback |
|---|---|---|---|
| virtiofs | FUSE over virtio | High | Requires recent kernel and shared memory |
| 9p (virtio-9p) | Plan 9 protocol over virtio | Low to moderate | Weak POSIX compliance and slow metadata |
| NFS | Network stack | Moderate | Network configuration and locking complexity |
| SMB/CIFS | Network stack | Moderate | Permission mapping across platforms |
| Virtual disk image | virtio-blk | High | Cannot be safely shared while mounted |
Compared with 9p, virtiofs typically delivers several times better throughput and correctly handles features such as mmap, file locking and extended attributes. Unlike a shared virtio disk, it allows the host and multiple guests to see the same directory tree concurrently without file system corruption.
Configuring virtiofs with QEMU and libvirt
A working virtiofs setup requires shared guest memory, because the daemon must access the guest’s virtio queues directly. With QEMU, this means using a memory backend such as memory-backend-memfd with share=on; with libvirt, it means adding a memoryBacking element with shared access to the domain definition.
- Enable shared memory backing for the virtual machine.
- Add a filesystem device with the virtiofs driver, a source directory and a mount tag.
- Let libvirt start virtiofsd automatically, or launch it manually with a socket path.
- Mount the share inside the guest using the tag, or add an entry to /etc/fstab.
Modern virtiofsd is a Rust implementation that replaced the original C daemon shipped with QEMU. Its options control sandboxing, cache policy, extended attribute handling and user ID mapping, which matters when the guest and host use different UID ranges. The decision table below shows typical choices.
| Situation | Recommended choice | Reason |
|---|---|---|
| Source code edited on host, built in guest | cache=auto | Balances speed and visibility of edits |
| Container root file systems in microVMs | cache=always with DAX | Fast reads and shared page cache |
| Two guests writing the same directory | cache=never | Avoids stale data between guests |
| Untrusted guest | Sandboxed virtiofsd, minimal share | Limits damage from a malicious guest |
Limitations and security considerations
virtiofs is limited to guests on the same physical host as the shared directory; it is not a replacement for distributed or network storage. Live migration of virtual machines with virtiofs mounts has historically been restricted, and support depends on both the virtual machine monitor and the daemon version.
- Host exposure: a guest that can write to a share can place files that host processes might later trust.
- Ownership mismatches: without UID mapping, files created in the guest may appear with unexpected owners on the host.
- Memory requirements: shared memory backing can conflict with some memory overcommit and ballooning setups.
- Stale views: aggressive caching can hide changes made by other writers for a period of time.
The safest practice is to share only the minimum directory needed, run virtiofsd with its sandbox enabled, and treat any content written by a guest as untrusted input on the host.
Explained without jargon
A virtual machine is a computer running inside another computer, and normally the two keep their files completely separate. virtiofs acts like a private hallway between them: the main computer opens one folder, and the virtual machine can walk in and use it as if it were its own local drive.
Because the hallway stays inside the same machine instead of going out through a network, it is fast and behaves like a normal folder. Files saved on one side appear on the other side almost immediately.
A typical use case
A software developer works on a Linux laptop with an IDE on the host but needs to compile and test code inside a KVM virtual machine running an older enterprise distribution. Instead of copying the 40,000-file source tree into the guest after every change, the developer configures a virtiofs share in virt-manager with the mount tag src and the cache mode set to auto.
Inside the guest, the directory is mounted at /home/dev/src. Edits saved in the IDE are visible to the build system within moments, and incremental builds run noticeably faster than with the previous 9p share because file lookups and metadata operations no longer dominate build time. The result is a workflow in which the developer edits once on the host and builds in the guest without manual synchronization.