Skip to content

KVM On Arch

date: 2021-10-07


This is not intended to be a tutorial, but rather a walk-through of how I would install libvirt/kvm on Arch Linux.


  • iptables-nft
  • dnsmasq
  • bridge-utils
  • openbsd-netcat
  • libvirt
  • qemu-headless
  • virt-install

virt-install is not needed if connecting remotely with virt-manager, but it does provide virt-clone.


  • enable libvirtd service
    • systemctl enable libvirtd
  • add user to libvirt group
    • usermod -a -G libvirt <user>


# ~/.bashrc
export LIBVIRT_DEFAULT_URI="qemu:///system"
reboot the machine


The default network is defined in /etc/libvirt/qemu/networks/default.xml.

  • Start the default network virsh net-start default.
  • Permanently enable the default network virsh net-autostart default.

Jump Host With virt-manager

Abstract your jump host in ~/.ssh/config

# ~/.ssh/config
Host jumphost
        Hostname <ip address>
        Port 22
        User <user>

Host kvmhost
        Hostname <ip address>
        ProxyJump jumphost
        Port 22
        User <user>
Now you can connect virt-manager to <user>@kvmhost

Console Access

Enable serial console on guest. systemctl enable serial-getty@ttyS0.service

Nested KVM

I was going to try to figure out how to permantly set the cpu mode default such that all virtualmachines will be capable of nested virtualization, but it already is. Perhaps that is the default in virt-manager now?

Anyway, in case you want to make sure nested virtualization is enabled in the host kernel.

Clone Ip Address Conflict

I found a great tutorial for assigning ip addresses.

The problem we need to solve here is that virtual machine clones won't necessarily solicit a unique ip address, although a clone will have a new mac address.

So, you clone a vm:

  • virt-clone --original arch --name archone --auto-clone

Get the clone's mac address:

  • virsh dumpxml archone | grep mac

Now assign the clone a dhcp reservation:

  • virsh net-edit default

Notice that I tighten up the dhcp range, and add a reservation outside the new dhcp range.

<network connections='1'>
  <forward mode='nat'>
      <port start='1024' end='65535'/>
  <bridge name='virbr0' stp='on' delay='0'/>
  <mac address='52:54:00:ef:cb:d2'/>
  <ip address='' netmask=''>
      <!-- previous dhcp range
      <range start='' end=''/>
      <!-- begin new lines -->
      <range start='' end=''/>
      <host mac='52:54:00:cd:7d:7f' name='archone' ip=''/>
      <!-- end new lines -->

Restart Default Network

  • virsh net-destroy default
  • virsh net-start default