How to Share a directory with the Guest System

Linux KVM

sudo virsh edit <machine-name>

after currentMemory add:

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

and in devices add:

<filesystem type="mount" accessmode="passthrough">
      <driver type="virtiofs"/>
      <source dir="/opt/shared"/>
      <target dir="devops_shared"/>
    </filesystem>

In the guest' you will be able to do:

mount -t virtiofs devops_shared /mnt/shared

Or simply add to /dev/fstab the following:

devops_shared  /opt/shared  virtiofs  defaults  0  0

See also: ref



[linux]