Share Folder Between Guest and Host in virt-manager (KVM/Qemu/libvirt)
A note about virtiofs
The sharing files and folders are powered by the libvirt shared file system called virtiofs. It provides all the features and parameters to access the directory tree on the host machine. Since most of the virt-manager virtual machine configurations are translated to XML, the share files/folders can also be specified by the XML file.
Share folder in virt-manager

- Click on the icon which says show virtual hardware details in the toolbar. And then click on Memory on the left panel.
- Select the option “Enable shared memory“. Click Apply.

- And then click “Add hardware” at the bottom.

- The XML settings are below for the above configuration. You can find it in the XML tab.
<filesystem type="mount" accessmode="passthrough">
<driver type="virtiofs"/>
<binary path="/usr/libexec/virtiofsd"/>
<source dir="/home/debugpoint/Pictures/Screenshots"/>
<target dir="mount_tag_pictures"/>
<alias name="fs1"/>
<address type="pci" domain="0x0000" bus="0x08" slot="0x00" function="0x0"/>
</filesystem>
- Click on Finish. In the main virt-manager window, right-click on the VM and click Run to start the virtual machine. Make sure to click on the “show the graphical console” (monitor icon in the toolbar – if the VM is not showing.
- In the guest machine, create a folder where you want to mount the host folder. For this example, I have used /mnt/pictures.
- And finally, mount the host folder using the tag you created in the above step to this new folder. Use the following command to do that from the terminal. Ensure to change the tag and folder name in the below command as your system.
mount -t virtiofs mount_tag_pictures /mnt/pictures
© https://www.debugpoint.com/share-folder-virt-manager/
Содержание