Chimera-Linux-libvirt-QEMU-KVM

Chimera Linux

Goal

This document will walk you through installing a libvirt environment on top of Chimera Linux with support for QEMU/KVM and the configuration of a Network Bridge to connect the Virtual Machines to the LAN through NetworkManager and virsh(1)

Note: The configuration and usage of Virtual Machines as well as Storage Management and more advanced (Virtual) Networking setups is out of scope for this guide.

Target System

In this example our target system is a Raspberry Pi 5 16GB SBC running

Note: Architecture Specific Packages for X86-64 will be pointe out during this guide.

Preparation

A fully configured and running Chimera Linux installation and root access is required.

Please refer to the official Chimera Linux Documentation and my install guide for installation on configuration of Chimera Linux.

Setup

Package Installation

doas apk add qemu qemu-tools qemu-img qemu-edk2-firmware u-boot-qemu_arm64 qemu-system-aarch64 libvirt

or for X86-64 hosts

doas apk add qemu qemu-tools qemu-img qemu-edk2-firmware qemu-system-x86_64 libvirt

User configuration

add the user to the kvm group

doas usermod -a -G kvm myusername

enable libvirt service Daemons

Please refer to the libvirt Documentation to understand the function of a specific Daemon

doas -s
for drv in qemu interface network nodedev nwfilter secret storage proxy log
  do
    dinitctl enable virt${drv}d
  done
exit

Bridge configuration

Tipp: The Network interface Names according to the Predictable Network Naming scheme as well as their associated MAC address can be seen via the ip(8) command.

ip(8) is part of the iproute2 package.

ip link show

Host side via NetworkManager

Create a new Network Bridge interface br0 via NetworkManager’s nmcli(1) command.

The Bridge Connection will automatically be named bridge-br0.

doas nmcli con add type bridge ifname br0

Connect the NIC to the Network Bridge.

The on board NIC of the Raspberry Pi 5 16GB is named end0

You have to replace it with the name of your Network interface.

doas nmcli con add type bridge-slave ifname end0 master br0

disable Spanning Tree Protocol on bridge br0

doas nmcli con modify br0 bridge.stp no

Assign the MAC address of the NIC end0 to the Network Bridge br0.

This makes sure that the bridge gets the same IP as was assigned to the NIC via e.g. Dynamic Host Configuration Protocol.

doas nmcli con modify br0 ethernet.cloned-mac-address 88:a2:9e:23:5e:d1

diasble the NIC connection Wired connection 1 and enable the bridge connection bridge-br0.

Note: Wired connection 1 is the default name for the first NetworkManager connction to a LAN.

Attention: Any ssh sessions on this NIC connection will be dropped.

doas nmcli con down "Wired connection 1" ; doas nmcli con up "bridge-br0"

Reestablish the ssh session and check if everything went well.

doas nmcli con show
doas nmcli con show --active

Virtual Network side through virsh(1)

Create a description for the virtual network end of the Bridge in XML

cat << 'EOF' > /tmp/br0.xml
<network>
  <name>br0</name>
  <forward mode="bridge"/>
  <bridge name="br0"/>
</network>
EOF

Add the persistent virtual network to libvirt

doas virsh net-define /tmp/br0.xml

Start the virtual network end of the Bridge

doas virsh net-start br0

Set the Virtual network end of the Bridge to autostart with libvirt

doas virsh net-autostart br0

Check if all went well

doas virsh net-list --all

Virtual Machines can be created and administrated through e.g.: virsh(1) or Virtual Machine Manager

Disclaimer: This is no official Chimera Linux Documentation