Blog/Virtiofsd wrapper
Virtio-fs[edit | edit source]
Virtio-fs is a shared filesystem used in virtualisation environments. It allows a guest inside a VM to access a shared directory on the host, as if it was a local filsystem inside the guest.
Other approaches to allow guests access to local directories have included NFS, Samba or plan9 network filesystems. These have the drawback of added overhead and latency compared to local filesystems. Virtiofs was developed to take advantage of the locality between the guest and the host or hypervisor to improve performance.
virtiofsd in Rust language[edit | edit source]
QEMU includes a daemon virtiofsd
which is used for handling the communication between the guest and the host.
The development of the built-in virtiofsd has been deprecated in favor of a new version written in Rust instead of C. https://gitlab.com/virtio-fs/virtiofsd
The Rust version has more features and should have better performance and memory safety than the previous c-lang version.
Wrapper script[edit | edit source]
The libvirt XML specification doesn't yet include all the new features. Therefore a wrapper may be used to include additional options.
#!/bin/bash
options="--inode-file-handles=mandatory --announce-submounts"
exec /opt/virtiofsd-rust/virtiofsd.sh $options "$@"
Currently, the available options are:
--allow-direct-io --announce-submounts --cache --gid --inode-file-handles --killpriv-v2 / --no-killpriv-v2 --log-level --modcaps --no-readdirplus --posix-acl --preserve-noatime --rlimit-nofile --sandbox --seccomp --security-label --thread-pool-size --uid --writeback --xattr --xattrmap
The full documentation can be found at https://gitlab.com/virtio-fs/virtiofsd
To use the wrapper script, use the <binary>
element in the domain XML using virsh edit
<filesystem type='mount' accessmode='passthrough'>
<driver type='virtiofs' ats='on'/>
<binary path='/opt/virtiofsd-rust/virtiofsd.sh'/>
<source dir='/mnt/share/'/>
<target dir='share'/>
</filesystem>
[edit | edit source]
Use the <target dir='share'/>
name when mounting the directory in the guest.
# mount -t virtiofs share /mnt/share/
# df /mnt/share/
Filesystem Size Used Available Use% Mounted on share 18.2T 17.0T 1.2T 93% /media/share