Step by Step

Step 1: Check if virtualization is enabled

command 1

grep -Ec '(vmx|svm)' /proc/cpuinfo

command 2

lscpu | grep -i Virtualization
  • VT-x for Intel
  • AMD-Vi for AMD

ensure that your kernel includes KVM modules

zgrep CONFIG_KVM /proc/config.gz
  • y = Yes (always installed)
  • m = Loadable module

Step 2: Install the required KVM packages

sudo pacman -S qemu-full qemu-img libvirt virt-install virt-manager virt-viewer \
edk2-ovmf dnsmasq swtpm guestfs-tools libosinfo tuned
  • qemu-full - user-space KVM emulator, manages communication between hosts and VMs
  • qemu-img - provides create, convert, modify, and snapshot, offline disk images
  • libvirt - an open-source API, daemon, and tool for managing platform virtualization
  • virt-install - CLI tool to create guest VMs
  • virt-manager - GUI tool to create and manage guest VMs
  • virt-viewer - GUI console to connect to running VMs
  • edk2-ovmf - enables UEFI support for VMs
  • dnsmasq - lightweight DNS forwarder and DHCP server
  • swtpm - TPM (Trusted Platform Module) emulator for VMs
  • guestfs-tools - provides a set of extended CLI tools for managing VMs
  • libosinfo - a library for managing OS information for virtualization.
  • tuned - system tuning service for linux allows us to optimise the hypervisor for speed.

Enable and start libvirt daemon

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

Troubleshooting

No internet in guest os

You need to set firewall_backend = "iptables" in /etc/libvirt/network.conf

Then restart the service:

sudo systemctl restart libvirtd

source: https://superuser.com/questions/1671932/unable-to-connect-to-internet-in-windows-10-vm-using-kvm-qemu

Error Operation not supported: Cannot use direct socket mode if no URI is set

solution

systemctl start virtqemud.socket

source: https://libvirt.org/kbase/failed_connection_after_install.html

Error Failed to connect socket to '/var/run/libvirt/libvirt-sock': Connection refused

run

sudo setfacl -m user:$USER:rw /var/run/libvirt/libvirt-sock

then

sudo systemctl enable libvirtd
sudo systemctl start libvirtd

source: https://stackoverflow.com/questions/64130268/error-failed-to-connect-socket-to-var-run-libvirt-libvirt-sock-connection-r

References