[How to] Setting up QEMU/KVM with virt-manager

Note: QEMU/KVM is more complicated to run and maintain than Virtualbox and VMware. This tutorial is for experienced users, and I do not take any responsibility for damage caused by this post.

1. Install KVM packages:

sudo pacman -Syy qemu virt-manager virt-viewer dnsmasq vde2 bridge-utils openbsd-netcat ebtables iptables

2. Start KVM libvirt service

sudo systemctl enable libvirtd.service
sudo systemctl start libvirtd.service

# Check that the service is running (press 'q' to quit):

systemctl status libvirtd.service

3. Allow low-level users to use KVM

Edit the /etc/libvirt/libvirtd.conf file with your preferred editor (nano is used in this example):

sudo nano /etc/libvirt/libvirtd.conf
  1. Navigate to around line 85 and uncomment the following lines:
unix_sock_group = "libvirt"
  1. And then navigate to around line 108 and uncomment:
unix_sock_rw_perms = "0770"
  1. Add your user to the libvirt group
sudo usermod -G libvirt -a `whoami`

# If you get the "usermod: group 'libvirt' does not exist" error, create the group by 
# running the following command, and then try adding your user again.

newgrp libvirt
  1. Restart libvirt deamon:
sudo systemctl restart libvirtd.service

4. Enable Nested Virtualization (Optional)

Nested Virtualization is the ability to run virtual machines inside virtual machines.

- Intel:

echo "options kvm-intel nested=1" | sudo tee /etc/modprobe.d/kvm-intel.conf

- AMD:

echo "options kvm-amd nested=1" | sudo tee /etc/modprobe.d/kvm-amd.conf

5. All Done!

Now you can run the virt-manager command to open the GUI virtual machine manger, or you can open it through your DE application menu.

To create a virtual machine, check this post out.
To open the .qcow2 file in your host, check out libguestfs.

To convert .vdi files to .qcow2:

qemu-img convert -f vdi -O qcow2 input.vdi output.qcow2

To convert .vmdk files to .qcow2:

qemu-img convert -f vmdk -O qcow2 input.vmdk output.qcow2