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 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:
# 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 cyberciti.biz
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.