KVM VMs with virt-manager on openSUSE
I quite like virtual machines because I get to mess up with other systems without affecting my primary one. There are different virtualization technologies, I mostly used VirtualBox before, one of which is KVM.
KVM is basically a type of a hypervisor. It’s a different piece of technology than what VirtualBox provides. I won’t pretend to know many details, so if you need to know exactly how they differ, look it up.
virt-manager
is a frontend for managing virtual machines via libvirt
, and it mostly focuses on those KVM virtual machines. This is how the outcome looks with some running virtual machines:
I want to share a quick tutorial how to set this up on openSUSE (although it will likely be similar on other Linux distributions).
If I remember correctly, there are two packages that need to be installed (plus their dependencies, but zypper
can take of it):
$ sudo zypper install libvirt virt-manager
You also need to have kvm
kernel module (I think that’s already included in openSUSE):
$ lsmod | grep kvm
kvm_intel 385024 0
kvm 1114112 1 kvm_intel
irqbypass 16384 1 kvm
If you want to use a non-root user, you need to add your unprivileged user to a libvirt
group:
$ sudo usermod -aG libvirt pavel
$ grep libvirt /etc/group
libvirt:x:108:pavel
You also need to start libvirtd.service
:
$ sudo systemctl start libvirtd.service
After that, you should be able to use virt-manager
.
There’s, however, one caveat. Let’s say you have an iso file somewhere in your /home
directory and you have 700
permissions on the home dir:
$ la
total 0
dr-xr-xr-x 1 root root 10 Sep 10 22:35 .
drwxr-xr-x 1 root root 166 Sep 22 20:36 ..
drwx------ 1 pavel pavel 1190 Oct 6 20:15 pavel
Then you will see the following error in virt-manager
when setting up your VM:
Clicking yes will pretty much solve it. The solution is to add ACL to the home directory for qemu
user:
$ sudo setfacl -m u:qemu:x pavel/
$ getfacl pavel/
# file: pavel/
# owner: pavel
# group: pavel
user::rwx
user:qemu:--x
group::---
mask::--x
other::---
Execution permission on the home dir should be enough.
You can change the permissions in a different way (e.g. adding x
to other) but that’s probably too much, ACL is probably a better solution here.
What also happens is that your iso file will change the owner when used for a VM in this way:
$ la
total 391184
drwxr-xr-x 1 pavel pavel 112 Oct 6 19:22 .
drwxr-xr-x 1 pavel pavel 222 Oct 6 19:20 ..
-rw-r--r-- 1 qemu qemu 400556032 Oct 6 19:21 debian-11.5.0-amd64-netinst.iso
That should be all important that’s needed to set up this virtualization technology. Now you can install various OS and enjoy them as virtual machines.