Virtualization - Sawangg/dotfiles GitHub Wiki

To emulate any OS on our machine, we're going to use the QEMU emulator with the KVM hypervisor.

KVM

Follow this article to see if your hardware supports KVM and if it's currently running on your machine.

QEMU

Install all the necessaries dependencies and start the services.

doas pacman -S qemu-desktop libvirt libvirt-dinit dnsmasq dnsmasq-dinit virt-manager
doas dinitctl enable dnsmasq
doas dinitctl enable libvirtd
doas usermod -aG libvirt,dnsmasq $(whoami)

Network

You need to setup the network so your VMs will be able to access the internet. First start the default network by running

doas virsh net-start default

Next we're going to use the helper called qemu-bridge-helper. Check that you have ip forwarding enabled in /etc/sysctl.d/99-network.conf and run

doas echo "allow virbr0" > /etc/qemu/bridge.conf
doas chown root:kvm /etc/qemu/bridge.conf
doas chmod 0660 /etc/qemu/bridge.conf
doas chmod u+s /usr/lib/qemu/qemu-bridge-helper

Now you can create a VM and assign a bridge network with vibr0 as the interface.