NOTE: These instructions aren't comprehensive! This just covers the main roadblocks every time I need to re-do this process...
(For context, I'm using a Debian 10 host and a Debian 10 guest)
host $ mkdir vmshared
host $ chown libvirt-qemu:libvirt-qemu vmshared
host $ chmod 0750 vmshared
host $ sudo virsh edit my-vm
<domain type='kvm'>
<!-- ... -->
<devices>
<!-- ... -->
<filesystem type='mount' accessmode='mapped'>
<source dir='/path/to/vmshared'/>
<target dir='vmshared'/>
<!-- NOTE: To add multiple devices, use different bus values -->
<address type='pci' domain='0x0000' bus='0x07' slot='0x00' function='0x0'/>
</filesystem>
</devices>
</domain>
my-vm $ sudo vim /etc/fstab
# <file system> <mount point> <type> <options>
# ^^^^^^^^^^^^^
# this is from `virsh edit`
vmshared /mnt/vmshared 9p trans=virtio,version=9p2000.L,rw,noauto,x-systemd.automount,x-systemd.mount-timeout=30s,x-systemd.device-timeout=30s,_netdev 0 0
host $ sudo virsh shutdown my-vm
host $ sudo systemctl restart apparmor
NOTE: this is needed because editing the VM's config auto-generates AppArmor config files for the directory (somewhere under /etc/apparmor.d/libvirt/libvirt-*.files
)
host $ sudo virsh start my-vm