Artix Linux QEMU with Virt-Manager Notes
Table of Contents
These are my notes for setting up virt-manager with QEMU/KVM on Artix Linux. I’m using runit, but anything runit-specific should be easily converted to other init systems/service managers.
This is largely the same as tomit4’s instructions, but I’m doing networking over a bridge rather than a NAT.
Install virt-manager#
Firstly, install relevant packages:
# pacman -S qemu virt-manager virt-viewer vde2 openbsd-netcat libvirt libvirt-runit
If you need virtualised TPM (e.g. for Windows 11), you also need to install swtpm
. Also, for Windows VMs in general,
install virtio-win
from the AUR for virtio drivers for Windows guests.
Enable the services:
# ln -s /etc/runit/sv/libvirtd /run/runit/service
# ln -s /etc/runit/sv/virtlogd /run/runit/service
# ln -s /etc/runit/sv/virtlockd /run/runit/service
Optionally, set up logging separate from the system log. Edit /etc/runit/sv/libvirtd/log
. Its contents will likely
be:
#!/bin/bash
exec logger -t libvirtd -p daemon.info
Comment out the line starting with exec
and replace it with:
exec 2>&1; set -e
[ -d /var/log/libvirtd ] || install -dm /var/log/libvirtd
exec svlogd -tt /var/log/libvirtd
(Keeping the shebang at the top.)
Create the directory for the logs:
# mkdir -p /var/log/libvirtd
Edit /etc/libvirt/libvirtd.conf
and uncomment the following lines:
unix_sock_group = "libvirt"
unix_sock_ro_perms = "0777"
unix_sock_rw_perms = "0770"
Add your user to the libvirt group:
# usermod -aG libvirt <username>
You should also add the kernel parameter amd_iommu=on
for AMD CPUs, and intel_iommu=on
for Intel CPUs. e.g. for
GRUB users, add it to the GRUB_CMDLINE_LINUX_DEFAULT
line of your GRUB config.
Set up networking#
We’re now going to create a network bridge to give your virtual machines internet. This will depend on how you have
networking set up on the host, but I use NetworkManager. In the case of NetworkManager, you can run the following
commands. I can run them without escalating privileges as my user is in the network
group, but if your user is not a
network
user, you will have to run the following commands as root.
Create a bridge named br0
:
$ nmcli con add ifname br0 type bridge con-name br0
Now have br0
use whatever interface you get your internet from. In my case, it’s eth0
. (You can run just nmcli
to
see what interfaces you have.)
$ nmcli con add type bridge-slave ifname eth0 master br0
To use br0
, you need to bring down whatever connection you were previously using (in my case, Wired connection 1
)
and up br0
:
$ nmcli con down "Wired connection 1"
$ nmcli con up br0
Now make it available as a virtual network for VMs.
Create a br0.xml
file anywhere (it’s only temporary):
<network>
<name>br0</name>
<forward mode="bridge" />
<bridge name="br0" />
</network>
Now run the following commands:
# virsh net-define br0.xml
# virsh net-start br0
# virsh net-autostart br0
Tips#
SPICE is used to share clipboard, share USB devices, share directories, and more, between hosts and guests. You will
need the spice
package installed on the host, which should already be installed as a dependency of qemu
on Artix
and Arch.
On Linux guests, you will need to install the spice-vdagent
package.
On Windows guests, you can install SPICE guest drivers one of two ways:
- The way you “traditionally” install software on Windows, i.e. by downloading and running random .exes off the internet; in that case, download spice-guest-tools here: https://www.spice-space.org/download.html
- If you prefer to use a package manager for Windows, Chocolatey has a SPICE guest agent with package name
spice-agent
.
On guests, you should also install the QEMU guest agent for functionality such as being able to shut down the VM from
the host (not force-off, but graceful shut down). The package name is usually qemu-guest-agent
. This also works with
Chocolatey Windows packages.
Most Linux distros detect if they’re running in a VM during installation, and if so, install qemu-guest-agent
.
qemu-guest-agent
is a daemon, so you’ll need to enable the service with whatever you use to manage services. e.g. on
Artix, there are the qemu-guest-agent-runit
etc packages you can install and then enable the service.
You should now be all set.