Slow performance issues of OpenBSD or FreeBSD KVM guest on Linux

last updated in Categories , , ,

I run a couple of OpenBSD and FreeBSD guest/virtual machines under KVM. My server has 32GB ram and 4C/8T Intel Xeon CPU. Everything was working fine until recent CentOS Linux 7 kernel update. After a fresh reboot of my CentOS 7 Linux box OpenBSD and FreeBSD machine become very slow and after 24 hours stop responding to the network request. How can I solve significant performance problems with BSD family of oses running on CentOS 7 KVM?

Kernel-based Virtual Machine (KVM), is a hypervisor built into the Linux kernel. CentOS Linux version 7 can turn into a hypervisor with the help of KVM installation. One can run multiple virtual machines/guest VM running unmodified GNU/Linux, *BSD family of operating system such as OpenBSD, NetBSD, FreeBSD,MS-Windows, or more.

Fixing the slow performance issues of OpenBSD or FreeBSD KVM guest

It looks like after CentOS Linux kernel updates (reboot) OpenBSD and FreeBSD based virtual machines becomes very slow. You can run a simple command such as date or sleep to verify this dealy issue on a BSD based system running under KVM:
time date
time sleep 1
time sleep 5

The “sleep 1” command takes up to 5-10 seconds to complete it. Naturally, it is annoying, and after a day or two, my OpenBSD based system complete stopped responding.

Solution for kvm_intel

You need to disable kvm_intel.preemption_time when loading kvm model on Intel based cpu. You need to create a file named kvm.conf in /etc/modprobe.d. Use a text editor such as vim or vi or nano to create a file:
# vim /etc/modprobe.d/kvm.conf
Append the following
options kvm_intel preemption_timer=N
Save and close the file in vim/vi. Next you need to reboot the CentOS Linux 7.x server using the reboot command or shutdown command:
# reboot
OR
# shutdown -r 0

Verification

Use the cat command as follows:
$ cat /sys/module/kvm_intel/parameters/preemption_timer
Login to OpenBSD/FreeBSD based VM using the ssh command or virsh command:
$ ssh vivek@openbsd-kvm-vm-ip
OR
# virsh console openbsd63-vm1
Run commands inside the VM with time:
$ time sleep 1
$ time sleep 5
$ time date
$ ping -c 2 cyberciti.biz

Solve slow performance issues of OpenBSD or FreeBSD KVM guest on Linux
Now everything should work fine and your VM will stay up and running for days or until your reboot the box/vm for kernel update or hardware update.

Conclusion

Timing issue with QEMU/KVM and OpenBSD has been reported and I hope fix will be released.

Posted by: Vivek Gite

The author is the creator of nixCraft and a seasoned sysadmin, DevOps engineer, and a trainer for the Linux operating system/Unix shell scripting. Get the latest tutorials on SysAdmin, Linux/Unix and open source topics via RSS/XML feed or weekly email newsletter.