|
| 1 | +.. SPDX-License-Identifier: GPL-2.0 |
| 2 | +
|
| 3 | +=================================================== |
| 4 | +virtiofs: virtio-fs host<->guest shared file system |
| 5 | +=================================================== |
| 6 | + |
| 7 | +- Copyright (C) 2019 Red Hat, Inc. |
| 8 | + |
| 9 | +Introduction |
| 10 | +============ |
| 11 | +The virtiofs file system for Linux implements a driver for the paravirtualized |
| 12 | +VIRTIO "virtio-fs" device for guest<->host file system sharing. It allows a |
| 13 | +guest to mount a directory that has been exported on the host. |
| 14 | + |
| 15 | +Guests often require access to files residing on the host or remote systems. |
| 16 | +Use cases include making files available to new guests during installation, |
| 17 | +booting from a root file system located on the host, persistent storage for |
| 18 | +stateless or ephemeral guests, and sharing a directory between guests. |
| 19 | + |
| 20 | +Although it is possible to use existing network file systems for some of these |
| 21 | +tasks, they require configuration steps that are hard to automate and they |
| 22 | +expose the storage network to the guest. The virtio-fs device was designed to |
| 23 | +solve these problems by providing file system access without networking. |
| 24 | + |
| 25 | +Furthermore the virtio-fs device takes advantage of the co-location of the |
| 26 | +guest and host to increase performance and provide semantics that are not |
| 27 | +possible with network file systems. |
| 28 | + |
| 29 | +Usage |
| 30 | +===== |
| 31 | +Mount file system with tag ``myfs`` on ``/mnt``: |
| 32 | + |
| 33 | +.. code-block:: sh |
| 34 | +
|
| 35 | + guest# mount -t virtiofs myfs /mnt |
| 36 | +
|
| 37 | +Please see https://virtio-fs.gitlab.io/ for details on how to configure QEMU |
| 38 | +and the virtiofsd daemon. |
| 39 | + |
| 40 | +Internals |
| 41 | +========= |
| 42 | +Since the virtio-fs device uses the FUSE protocol for file system requests, the |
| 43 | +virtiofs file system for Linux is integrated closely with the FUSE file system |
| 44 | +client. The guest acts as the FUSE client while the host acts as the FUSE |
| 45 | +server. The /dev/fuse interface between the kernel and userspace is replaced |
| 46 | +with the virtio-fs device interface. |
| 47 | + |
| 48 | +FUSE requests are placed into a virtqueue and processed by the host. The |
| 49 | +response portion of the buffer is filled in by the host and the guest handles |
| 50 | +the request completion. |
| 51 | + |
| 52 | +Mapping /dev/fuse to virtqueues requires solving differences in semantics |
| 53 | +between /dev/fuse and virtqueues. Each time the /dev/fuse device is read, the |
| 54 | +FUSE client may choose which request to transfer, making it possible to |
| 55 | +prioritize certain requests over others. Virtqueues have queue semantics and |
| 56 | +it is not possible to change the order of requests that have been enqueued. |
| 57 | +This is especially important if the virtqueue becomes full since it is then |
| 58 | +impossible to add high priority requests. In order to address this difference, |
| 59 | +the virtio-fs device uses a "hiprio" virtqueue specifically for requests that |
| 60 | +have priority over normal requests. |
0 commit comments