Ubuntu – Is there something like “VirtualBox Guest Additions” for QEMU/KVM

customizationguest-additionskvmqemuvirtualization

I run some Ubuntu VMs in QEMU/KVM with virt-manager as the GUI. The one thing I really miss from VirtualBox though is the ability to install "Guest Additions" which would allow a shared clipboard and the ability to drag and drop files from host to guest and visa versa (though one would be able to select if it would just work one way or both).

Is there something like this for QEMU/KVM? I am running Ubuntu GNOME 16.04.1 with GNOME 3.20 as the host and similar VMs.

Best Answer

Yes, there is something like guest additions in virt-manager - it just has to be done a little bit differently. To make it easy for you to see how it works, I'll provide you with some screenshots.

First change the ACL attributes of the libvirt-qemu user to give write permissions on the shared folder : sudo setfacl -R -m u:libvirt-qemu:rwx /<path-of-the-shared folder>
and the Vdisk : sudo setfacl -R -m u:libvirt-qemu:rwx /<path-of-the-virtual-disk>

In the example below I gave permissions for all separate mounted partitions to be flexible :
sudo setfacl -R -m u:libvirt-qemu:rwx /media/cl (as I said - an example of my setup)

Open the virtual machine in virt-manager - select the disk - mark Shareable - click on Apply.

enter image description here

Click on Add Hardware - select Filesystem - change the Mode to Mapped - click on Browse.

enter image description here

Click on Browse Local.

enter image description here

Select the folder you want to share with the guest operating system - click on Open.

enter image description here

Type /host into the field Target path - click on Finish.

enter image description here

Now boot the guest system, create a folder with the same name as the one you selected to be shared in the host system (in my example : share) in the /home directory of the guest system. Open a terminal and execute the following command to mount the shared folder in the guest :

sudo mount -t 9p -o trans=virtio,version=9p2000.L /host /home/<your-user-name>/<your-shared-folder-name>  

Et voilà - now you are having equivalent functionality as with the guest additions in VirtualBox.