Virtio-fs is a shared file system that lets virtual machines access a directory tree on the host. Unlike existing approaches, it is designed to offer local file system semantics and performance.
Virtio-fs was started at Red Hat and is being developed in the Linux, QEMU, FUSE, and Kata Containers open source communities.
See the design document for a more in-depth explanation of virtio-fs.
Virtio-fs is used in production and has been available since Linux 5.4, QEMU 5.0, and libvirt 6.2. Instructions for use with libvirt are available here.
Kata Containers 1.7 and later ships with virtio-fs support built-in.
Earlier versions of Linux and QEMU were available as out-of-tree code for Linux here and for QEMU here. See the HowTos for setup instructions.
IRC channel: #virtio-fs on chat.freenode.net
Mailing list: email@example.com (list info)
Virtio-fs is not a network file system repurposed for virtualization, it is specifically designed to take advantage of the locality of virtual machines and the hypervisor.
The goal of virtio-fs is to provide local file system semantics between multiple virtual machines sharing a directory tree. This is especially useful for lightweight VMs and container workloads, where shared volumes are a requirement.
Existing solutions to this problem, such as virtio-9p, are based on existing network protocols that are not optimized for virtualization use cases. As a result they do not perform as well as local file systems and do not provide the semantics that some applications rely on.
Virtio-fs takes advantage of the virtual machine’s co-location with the hypervisor to avoid overheads associated with network file systems.
Virtio-fs uses FUSE as the foundation. Unlike traditional FUSE where the file system daemon runs in userspace, the virtio-fs daemon runs on the host. A VIRTIO device carries FUSE messages and provides extensions for advanced features not available in traditional FUSE.
FUSE has no dependencies on a networking stack and exposes a rich native Linux file system interface that allows virtio-fs to act like a local file system.
File contents can be mapped into a memory window on the host, allowing the guest to directly access data from the host page cache. This has several advantages:
A metadata version table in shared memory provides coherent access for multiple virtual machines without expensive communication. Version numbers for file system metadata are implemented using atomic compare-and-swap operations. Virtual machines refresh metadata when the version number has changed since they last cached a copy.