libvirt (KVM/Qemu)

Libvirt (license LGPL, https://libvirt.org) is one of the best and most flexible virtual machine environments. A graphic frontend for libvirt is the tool Virt-Manager (license GPLv2, https://virt-manager.org). It can manage your virtual machines e.g. on a KVM/qemu server.

Interestingly there is a 3D driver in development called VirGL, it will use the host GPU and is not a complete GPU pass-trough.

libvirt

Based on https://wiki.archlinux.org/index.php/Libvirt you need to do the following base setup to get libvirt up and running on a host machine.

$ sudo pacman -Sy libvirt qemu dnsmasq ebtables bridge-utils openbsd-netcat qemu-block-gluster

As defined in /etc/libvirt/qemu.conf and /etc/libvirt/libvirtd.conf defaults to nobody, libvirt and kvm, replace USERNAME with your user.

$ sudo gpasswd -a USERNAME libvirt
$ sudo gpasswd -a nobody kvm

Then uncomment or comment the following lines in libvirtd.conf like in the example below.

$ sudo nano /etc/libvirt/libvirtd.conf
 unix_sock_group = "libvirt"
 unix_sock_ro_perms = "0770"
 unix_sock_rw_perms = "0770"
 auth_unix_ro = "none"
 auth_unix_rw = "none"
 #listen_tls = 0
 #listen_tcp = 1
 #auth_tcp=none
$ sudo nano /etc/conf.d/libvirtd
LIBVIRTD_ARGS=""
$ systemctl enable libvirtd.service
$ systemctl start libvirtd.service

Then reboot or logout and login again.

Host and VM direct network

Read Bridge Network – Connect Host with VM

Libvirt on Btrfs

Before creating a new virtual machine, make sure to disable the copy on write feature on a Btrfs file system so that it behaves like a traditional file system and directly modifies files without creating a copy first:

sudo chattr +C -R /var/lib/libvirt/images

If files are created in that directory already, move them to first to another directory and then copy them again into this folder so that they get the +C added as well. you can see the actual attributes with this command:

sudo lsattr /var/lib/libvirt/images

Virt-Manager

Virt-Manager (https://virt-manager.org, GPLv3+) is a good tool to manage local and remote virtual machines on a Qemu/KVM on libvirt.

sudo pacman -Sy virt-manager

If you have issues on KDE with ksshaskpass remembering passwords, run:

sudo ln -s /usr/bin/ksshaskpass /usr/lib/ssh/ssh-askpass

Virt-Manager runs directly on Wayland and on Plasma-Wayland 5.12.

You can install Qt-Virt-Manager (https://github.com/F1ash/qt-virt-manager, GPLv2) from AUR. It runs natively on Wayland:

yaourt qt-virt-manager

It works, but the qt5-remote–viewer doesn’t show any content, read the bug report https://github.com/F1ash/qt-virt-manager/issues/25.

So there is on Wayland currently no working solution at all.

Virt-Manager Unknown Disk Format

If you create in Virt-Manager a pool and it doesn’t work as of unknown format, then do it via the console. Example:

sudo virsh pool-define-as sdf disk - - /dev/sdf - /dev

Check, edit and compare to other pools, e.g. make sure the format type is gpt.

sudo virsh pool-edit sdf

Then you can start the partition in Virt-Manager and you can enable auto start if you want.

Serial Console

https://unix.stackexchange.com/questions/346090/disable-framebuffer-in-qemu-guests#347751

Cockpit

Additionally to Virt-Manager you can use Cockpit to manage virtual machines, read Cockpit – Server Monitoring & Management.

Qemu

Qemu 2.12 is finally deprecating GTK2 and SDL1 in favor of GTK3 and SDL2.

To use UEFI boot you must define it before creating the new virtual machine. Click on “Edit configuration before installation” and then select in the field firmware “”.

OVMF

OVMP is the Tianocore open source UEFI firmware for qemu. It allows you to replace the grub with systemd-boot. At the boot you should see then the white Tianocore logo indicating UEFI support. As always, booting with UEFI is slower, the Tianocore needs 3 seconds for initialization, Linux needs less time to boot to a console.

$ sudo pacman -Sy ovmf
$ sudo nano /etc/libvirt/qemu.conf nvram = [ "/usr/share/ovmf/x64/OVMF_CODE.fd:/usr/share/ovmf/x64/OVMF_VARS.fd" ]

Skip Bootloader

https://wiki.archlinux.org/index.php/QEMU#By_specifying_kernel_and_initrd_manually

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Blog at WordPress.com.

Up ↑

%d bloggers like this: