Getting virt-manager to work with qemu and kvm on arch linux

Written By: Max

Date: December 2022

Last updated: September 2023

Here are the related wiki pages.

Here's how to get virt-manager to work with qemu/kvm

Checking support for kvm

Make sure your hardware supports virtualization (Intel VT-X for intel based processors, AMD-V for AMD based processors). Moddern processors have support for this, however some PC manufacturers disable it by default so make sure it is enabled in your computer's BIOS/UEFI.
Next, run the following command
zgrep CONFIG_KVM /proc/config.gz
This will output if the kernel modules are available.
To ensure that the kernel modules are automatically loaded, paste the following command
lsmod | grep kvm
If the command returns nothing, load the kernel modules manually.

Installing the necessary packages to get livbirt to work

Next, install the following packages

If the package manager finds any conflicting packages, remove them when asked.
Note that if you want to use QEMU to install Windows 11, you must also install the swtpm package.

Starting the libvirtd service

Next, you need to enable the libvirtd service using systemctl.
#systemctl enable --now libvirtd.service

Running virt-manager as a non-root user

If you are ok with using virt-manager as root, you can stop here. However, to run as a normal user, keep reading.

Step 1. edit /etc/libvirt/libvirtd.conf

open /etc/libvirt/libvirtd.conf in a text editor, in this example we will be using nano, but you can use your prefered if you wish.
#nano /etc/libvirt/libvirtd.conf
Make sure to run your text editor as root, as shown above.

Find and uncomment the following lines.
#unix_sock_group = 'libvirt'
#unix_sock_rw_perms = '0770'
Save the file by pressing control+o, then exit.

Step 2. Add your user to the libvirt group

Next, you must add your user account to the libvirt group to avoid permission issues. #usermod -aG $USER libvirt

Step 3. Delete the connection to qemu:///system and connect to qemu:///session instead

Currently, you are still using the root variant of QEMU/KVM. You need to disconnect from the root variant and connect to the user session instead.

  1. Open virt-manager.
  2. Delete the qemu/kvm connection under the edit menu.
  3. Under the file menu, choose add connection...
  4. Choose qemu/kvm user session and click connect.

Congratulations!

You have configured virt-manager. If configured correctly, you should be able to start creating virtual machines.