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