Write access denied when mounting folder from qemu guest

kvmlibvirtqemu

I have setup a qemu Linux guest using virt-manager. I have mounted a host path successfully. The libvirt configuration snippet on the host:

<filesystem type='mount' accessmode='mapped'>
  <source dir='/home/robert/Documents/sources/oss/linux'/>
  <target dir='/linux-src'/>
  <address type='pci' domain='0x0000' bus='0x00' slot='0x08' function='0x0'/>
</filesystem>

The fstab line on the guest:

/linux-src /mnt/linux-src 9p defaults 0 0

Accessing and reading works fine, but I'm unable to write to that directory

$ cd /mnt/linux-src
$ touch asd
$ touch: cannot touch 'asd': Permission denied

I am running as the root user in the guest and the files belong to my user (robert) on the host.

What can I do to allow write access to that folder from the guest?

Best Answer

Give the libvirt-qemu group write access on the host:

chgrp libvirt-qemu /home/robert/Documents/sources/oss/linux
chmod -R g+w /home/robert/Documents/sources/oss/linux
Related Question