Edit domain xml:
$ [sudo] virsh edit <mydomain>
And add a tag inside the one, like this:
<devices>
<filesystem type='mount' accessmode='mapped'>
<source dir='/host/source/direrectory'/>
<target dir='mountlabel'/>
</filesystem>
</devices>
According to the libvirt documentation, accessmode can be:
- mapped: to have files created and accessed as the user running kvm/qemu. Uses extended attributes to store the original user credentials.
- passthrough: to have files created and accessed as the user within kvm/qemu.
- squash: like passthrough, except failures in privileged operations are ignored.
Then start the VM, and edit /etc/modules and add the following:
virtio
9p
9pnet
9pnet_virtio
Now edit /etc/fstab and add the following:
mountlabel /guest/destination/directory 9p trans=virtio 0 0
The directory /guest/destination/directory must exist for the mount to work
Finally you will need to shutdown and restart the domain:
$ [sudo] virsh shutdown <mydomain> \
> && [sudo] virsh start <mydomain>
A simple virsh reboot
doesn't seems to work, I don't really know why,
probably cache kinda problem of something