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.
ide: Using emulated IDE disks with OpenBSD is very very slow.
ahci: qemu’s AHCI emulation is much faster.
virtio-block: vioblk is supported in OpenBSD since 5.3. This currently offers the best performance.
The virtio-scsi driver in OpenBSD <= 6.0 is broken, don’t use it. The choice between virtio-block and virtio-scsi is done in the qemu configuration. Update: Some bugs in the driver have been fixed in OpenBSD-current. The fixes will appear in OpenBSD 6.1. Hopefully, virtio-scsi will be reliable, then.
Realtek: In early qemu 0.x versions, realtek emulation didn’t work at all with OpenBSD. This has been fixed by now (at least since 0.9.1). Performance ist not great, though.
Intel e1000: qemu’s e1000 emulation has better performance.
Virtio: virtio-net is even better. It is supported since OpenBSD 5.3, but see below. Earlier qemu versions have a bug that prevents VLAN tagging from working with virtio. This is fixed in qemu 1.7.2 and 2.0 and up. OpenBSD 5.6+ has a configurable workaround for this bug, see the vio(4) man page.
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.
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.