This document tries to give an overview how recent versions of OpenBSD run best as VM on an hypervisor. It is centered on Linux/KVM/qemu, but some of it is also valid for other hypervisors.

If you notice errors or have information/advice that is missing here, send it to me at sf@sfritsch.de.

Short summary

Disk drivers

Network drivers

General advice for virtio drivers

Unfortunately the OpenBSD virtio drivers had some ugly bugs up to and including 5.6. In particular this could cause network hangs that would go away after a “ifconfig down” and “ifconfig up”. To fix this, apply the virtio errata patches for OpenBSD 5.5/5.6. If you use an older OpenBSD version, upgrade.

Other random bits

The problem of i386

OpenBSD/i386 uses some interrupt controller feature (the “TPR”) excessively that is difficult to emulate without special hardware support. Intel introduced this hardware support (called “flexpriority”) in back 2008 or so, but AMD unfortunately never did. Therefore it is a really bad idea to run OpenBSD/i386 as VM on AMD hosts or on very old Intel hosts. The performance will be at least 10 times slower than normal. A kind of workaround is possible for single VCPU VMs by switching “mpbios” off in OpenBSD, but that may expose other problems.

The general advice is: Use OpenBSD/amd64 in VMs, not OpenBSD/i386. In particular if your machine lacks the flexpriority feature (see /proc/cpuinfo). Even with the flexpriority feature, i386 is not as fast as amd64. The difference will become even larger with OpenBSD 5.7, because it will get some optimizations under amd64 that are not there under i386, yet. And OpenBSD/amd64 has better NX and ASLR support, anyway.

Update: AMD’s “Carrizo” introduces the AVIC feature which also solves the problem. This is also present in all AMD Ryzen CPUs. Support in KVM came with Linux 4.7. As of 4.19, it is disabled by default and needs to be enabled using the kvm_amd.avic=1 kernel parameter. Also, qemu needs to be started with -kernel_irqchip=split (will be default for q35 machine type starting with qemu 4.0). I have tested this with qemu 2.8 on linux 4.19.