@@ -1252,6 +1252,103 @@ recommended to always use a limiter to avoid guests using too many host
1252
1252
resources. If desired, a value of '0' for `max_bytes` can be used to disable
1253
1253
all limits.
1254
1254
1255
+ [[qm_virtiofs]]
1256
+ Virtio-fs
1257
+ ~~~~~~~~~
1258
+
1259
+ Virtio-fs is a shared filesystem designed for virtual environments. It allows to
1260
+ share a directory tree available on the host by mounting it within VMs. It does
1261
+ not use the network stack and aims to offer similar performance and semantics as
1262
+ the source filesystem.
1263
+
1264
+ To use virtio-fs, the https://gitlab.com/virtio-fs/virtiofsd[virtiofsd] daemon
1265
+ needs to run in the background. This happens automatically in {pve} when
1266
+ starting a VM using a virtio-fs mount.
1267
+
1268
+ Linux VMs with kernel >=5.4 support virtio-fs by default
1269
+ (https://www.kernelconfig.io/CONFIG_VIRTIO_FS[virtiofs kernel module]), but some
1270
+ features require a newer kernel.
1271
+
1272
+ There is a
1273
+ https://github.com/virtio-win/kvm-guest-drivers-windows/wiki/Virtiofs:-Shared-file-system[guide]
1274
+ available on how to utilize virtio-fs in Windows VMs.
1275
+
1276
+ Known Limitations
1277
+ ^^^^^^^^^^^^^^^^^
1278
+
1279
+ * If virtiofsd crashes, its mount point will hang in the VM until the VM
1280
+ is completely stopped.
1281
+ * virtiofsd not responding may result in a hanging mount in the VM, similar to
1282
+ an unreachable NFS.
1283
+ * Memory hotplug does not work in combination with virtio-fs (also results in
1284
+ hanging access).
1285
+ * Memory related features such as live migration, snapshots, and hibernate are
1286
+ not available with virtio-fs devices.
1287
+ * Windows cannot understand ACLs in the context of virtio-fs. Therefore, do not
1288
+ expose ACLs for Windows VMs, otherwise the virtio-fs device will not be
1289
+ visible within the VM.
1290
+
1291
+ Add Mapping for Shared Directories
1292
+ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1293
+
1294
+ To add a mapping for a shared directory, you can use the API directly with
1295
+ `pvesh` as described in the xref:resource_mapping[Resource Mapping] section:
1296
+
1297
+ ----
1298
+ pvesh create /cluster/mapping/dir --id dir1 \
1299
+ --map node=node1,path=/path/to/share1 \
1300
+ --map node=node2,path=/path/to/share2 \
1301
+ ----
1302
+
1303
+ Add virtio-fs to a VM
1304
+ ^^^^^^^^^^^^^^^^^^^^^
1305
+
1306
+ To share a directory using virtio-fs, add the parameter `virtiofs<N>` (N can be
1307
+ anything between 0 and 9) to the VM config and use a directory ID (dirid) that
1308
+ has been configured in the resource mapping. Additionally, you can set the
1309
+ `cache` option to either `always`, `never`, `metadata`, or `auto` (default:
1310
+ `auto`), depending on your requirements. How the different caching modes behave
1311
+ can be read https://lwn.net/Articles/774495/[here under the "Caching Modes"
1312
+ section]. To enable writeback cache set `writeback` to `1`.
1313
+
1314
+ Virtiofsd supports ACL and xattr passthrough (can be enabled with the
1315
+ `expose-acl` and `expose-xattr` options), allowing the guest to access ACLs and
1316
+ xattrs if the underlying host filesystem supports them, but they must also be
1317
+ compatible with the guest filesystem (for example most Linux filesystems support
1318
+ ACLs, while Windows filesystems do not).
1319
+
1320
+ The `expose-acl` option automatically implies `expose-xattr`, that is, it makes
1321
+ no difference if you set `expose-xattr` to `0` if `expose-acl` is set to `1`.
1322
+
1323
+ If you want virtio-fs to honor the `O_DIRECT` flag, you can set the `direct-io`
1324
+ parameter to `1` (default: `0`). This will degrade performance, but is useful if
1325
+ applications do their own caching.
1326
+
1327
+ ----
1328
+ qm set <vmid> -virtiofs0 dirid=<dirid>,cache=always,direct-io=1
1329
+ qm set <vmid> -virtiofs1 <dirid>,cache=never,expose-xattr=1
1330
+ qm set <vmid> -virtiofs2 <dirid>,expose-acl=1,writeback=1
1331
+ ----
1332
+
1333
+ To temporarily mount virtio-fs in a guest VM with the Linux kernel virtio-fs
1334
+ driver, run the following command inside the guest:
1335
+
1336
+ ----
1337
+ mount -t virtiofs <dirid> <mount point>
1338
+ ----
1339
+
1340
+ To have a persistent virtiofs mount, you can create an fstab entry:
1341
+
1342
+ ----
1343
+ <dirid> <mount point> virtiofs rw,relatime 0 0
1344
+ ----
1345
+
1346
+ The dirid associated with the path on the current node is also used as the mount
1347
+ tag (name used to mount the device on the guest).
1348
+
1349
+ For more information on available virtiofsd parameters, see the
1350
+ https://gitlab.com/virtio-fs/virtiofsd[GitLab virtiofsd project page].
1351
+
1255
1352
[[qm_bootorder]]
1256
1353
Device Boot Order
1257
1354
~~~~~~~~~~~~~~~~~
@@ -1940,8 +2037,9 @@ in the relevant tab in the `Resource Mappings` category, or on the cli with
1940
2037
1941
2038
[thumbnail="screenshot/gui-datacenter-mapping-pci-edit.png"]
1942
2039
1943
- Where `<type>` is the hardware type (currently either `pci` or `usb`) and
1944
- `<options>` are the device mappings and other configuration parameters.
2040
+ Where `<type>` is the hardware type (currently either `pci`, `usb` or
2041
+ xref:qm_virtiofs[dir]) and `<options>` are the device mappings and other
2042
+ configuration parameters.
1945
2043
1946
2044
Note that the options must include a map property with all identifying
1947
2045
properties of that hardware, so that it's possible to verify the hardware did
0 commit comments