Slow performance issues of OpenBSD or FreeBSD KVM guest on Linux

See all Linux Kernel Based Virtual Machine related FAQs/Howtos
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
# shutdown -r 0


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
# virsh console openbsd63-vm1
Run commands inside the VM with time:
$ time sleep 1
$ time sleep 5
$ time date
$ ping -c 2

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.


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

🥺 Was this helpful? Please add a comment to show your appreciation or feedback.

nixCrat Tux Pixel Penguin
Hi! 🤠
I'm Vivek Gite, and I write about Linux, macOS, Unix, IT, programming, infosec, and open source. Subscribe to my RSS feed or email newsletter for updates.

0 comments… add one

Leave a Reply

Your email address will not be published. Required fields are marked *

Use HTML <pre>...</pre> for code samples. Your comment will appear only after approval by the site admin.