Velvet Star Monitor

Standout celebrity highlights with iconic style.

general

Unable to add virtiofs filesystem to QEMU VM in Ubuntu Server 20.04 due to incomplete feature support

Writer Andrew Mclaughlin

I am having difficulties adding a shared folder on my host Ubuntu Server 20.04 for exchanging data with my Linux VM using virtiofs.

Inside my <domain/> I have added

<memoryBacking> <source type='memfd'/> <access mode='shared'/>
</memoryBacking>

and inside <devices/>

<filesystem type='mount' accessmode='passthrough'> <driver type='virtiofs'/> <source dir='/home/server/VM_share'/> <target dir='VM_share'/>
</filesystem>

Upon saving I get

error: XML document failed to validate against schema: Unable to validate doc against /usr/share/libvirt/schemas/domain.rng Extra element devices in interleave Element domain failed to validate content Failed. Try again? [y,n,f,?]:

Selecting i for information yields

error: unsupported configuration: unknown fs driver type 'virtiofs'

I read somewhere in the Debian mailing list about such a complain and people stated that the version of libvirt is too old.

I checked (e.g. the daemon)

libvirtd --version
libvirtd (libvirt) 6.0.0

Checking qemu yielded

qemu-system-x86_64 --version
QEMU emulator version 4.2.1 (Debian 1:4.2-3ubuntu6.21)

According to the official web site I need Linux kernel 5.4+ (Ubuntu Server 20.04 currently runs on 5.4.0-107 by default), QEMU 5.0, libvirt 6.2.

Now I am confused since this official post from Ubuntu (see Feature highlights in Ubuntu kernel v5.4) states support for virtiofs. However based on the package version of the required components (except the kernel) it seems that this feature is actually not meant to be used unless an external unofficial repository

ppa:jacob/virtualisation

is used. Am I missing something here? I am following mostly this guide among others.

1

2 Answers

there are indeed a few components involved here. The Kernel info about 5.4 is really only related to the guest running that kernel or later to be able to consume virtiofs. There are plenty of fixes though, so in general (as for any kind of new features) you might want to look for a more recent kernel, which in Focal 20.04 guests you can get easily via the HWE kernels.

But in addition - to provide this feature from a host perspective - you'd need libvirt and qemu to be ready for it as well. Focal 20.04 comes with qemu 4.2 which didn't yet have all that is needed for virtiofs - the same is true for libvirt 6.0 that is in Focal.

As documented (also has config examples for virtiofs) in the Ubuntu server guide - see section "Sharing files between Host<->Guest" - that feature is enabled and working in later versions of qemu/libvirt and thereby later versions of Ubuntu. If you go through the changelogs of Qemu, libvirt and Ubuntu you'll see that there were plenty of improvements in most of the following releases - therefore (as with the kernel above) - you should try to use a rather new virtualization stack for this feature.

This is available to you in multiple ways:

  1. You can use any of the already available releases after Focal, like Impish 22.10
  2. If you want/need to stay on Focal you can consume plenty of newer software regularly backported in the server-backports
  3. If you need it in a LTS without any PPAs -> in a two weeks from now the new Jammy LTS 22.04 will be released having all that and much more

Recently, I realized virtiofs between Ubuntu20.04(5.13.0-40-generic) and Win11 by adding server-backports source same as the 2nd way mentioned Christian Ehrhardt

If you want/need to stay on Focal you can consume plenty of newer software regularly backported in the server-backports

Just sudo add-apt-repository ppa:canonical-server/server-backports && sudo apt update, it will update qemu(7.0.0) and libvirt(7.6.0). I tried compiling the latest qemu and libvirt, but there are too many dependencies that need to be installed. Unfortunately, I compiled it with default prefix, and this introduced many problems.

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy