Like I said in Libvirt Prologue#List, Chap.1 would include the following content:
- Virt-Manager Setup
- QEMU/KVM user session
- Default bridge
virbr0
Setup
A few explanation in case you want a minimal install (which usually would NOT work due to missing packages, you have been warned):
- virt-manager libvirt qemu: must have
- dkms linux-headers: kernel modules/headers
- polkit: remove desktop warning
- passt: Port Forwarding in QEMU/KVM user session
- bridge-utils:…bridge network interface
- virtiofsd: File Sharing daemon
- hwloc: Optimization utility, you can use
lscpu
instead - edk2-ovmf: UEFI firmware
# install, package name may differ
# and for void user, xi is from xtools
xi virt-manager libvirt qemu dkms linux-headers polkit passt bridge-utils virtiofsd hwloc edk2-ovmf
# add user to these groups
sudo usermod -a -G libvirt,kvm <user>
# double check
id
# enable services
# dbus/polkit is usually enabled by default on desktop
# sudo ln -s /etc/sv/dbus /var/service/
# sudo ln -s /etc/sv/polkitd /var/service
sudo ln -s /etc/sv/libvirtd /var/service/
sudo ln -s /etc/sv/virtlockd /var/service/
sudo ln -s /etc/sv/virtlogd /var/service/
You can also disable root QEMU/KVM session and image pool, but it’s not recommended at current stage.
User Session
QEMU/KVM User Sessions are generally fine. It just comes with limited benefits and more trouble to make people scared of. The most common issue is network interface, others are just minor annoyance. As a result, I’ll just talk about this.
The idea is simple: root session comes with a default bridge network while user session does not (which is why bridge in user session does not work out of the box). All you need is to create a similar (but not exactly the same, since you are not root) interface using the example.
Just make sure the inet address does not conflict with your existing one, you can check it via ip a
and focus on inet
line.
Network Interface
$ touch .config/libvirt/qemu/networks/userdefault.xml
$ virsh net-create .config/libvirt/qemu/networks/userdefault.xml
error: Failed to create network from .config/libvirt/qemu/networks/userdefault.xml
error: error creating bridge interface virbr100: Operation not permitted
$ sudo virsh net-create .config/libvirt/qemu/networks/userdefault.xml
Network userdefault created from .config/libvirt/qemu/networks/userdefault.xml
$ ip a
19: virbr100: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN group default qlen 1000
link/ether 11:45:14:aa:cc:2b brd ff:ff:ff:ff:ff:ff
inet 192.168.123.1/24 brd 192.168.123.255 scope global virbr100
valid_lft forever preferred_lft forever
<network>
<name>userdefault</name>
<forward mode='nat' />
<bridge name='virbr100' stp='on' delay='0' />
<ip address='192.168.123.1' netmask='255.255.255.0'>
<dhcp>
<range start='192.168.123.2' end='192.168.123.254' />
</dhcp>
</ip>
</network>