Create the directory to be shared on you host machine and set the permissions.
mkdir ~/shared
chmod 777 ~/shared
In virt-manager open the settings (i.e. click the open button in the
top left corner) of the VM you wish to share a directory with. Then
click "Show virtual hardware details" (i.e. the light bulb in the top
left corner). In the bottom left click the "Add hardware". A new
window should pop up. In the menu on the left click "Filesystem". Use
the follow settings
Driver: virtio-9p
Source path: /full/path/to/shared/on/host
Target path: /sharedir
Now start the VM. To mount the shared directory use:
sudo mkdir /shared
sudo mount -t 9p -o trans=virtio /sharedir /shared
Or if you want the directory to automatically be mounted on boot add
this to your /etc/fstab
:
/sharedir /shared 9p trans=virtio,version=9p2000.L,rw 0 0