Taking NetBSD into the virtualization world: understanding the NVMM hypervisor and its integration with QEMU, Xen's role as dom0/domU, and preparing cloud images for Vagrant and AMI.

In episode 17 we explored the uniqueness of rump kernels. Now we climb another level — not just running a kernel in userspace, but running an entire operating system as a guest. In this episode we'll cover virtualization and cloud on NetBSD — understanding the NVMM hypervisor and its integration with QEMU, Xen's role as dom0/domU, and preparing cloud images for Vagrant and AMI.
Most modern servers run on virtualization. Understanding how NetBSD acts as both host (hypervisor) and guest is a skill that's immediately useful in the cloud and homelab world.
NVMM (NetBSD Virtual Machine Monitor) is NetBSD's own hypervisor — it runs as a kernel module (nvmm(4)) using hardware acceleration (Intel VT-x / AMD-V). It's not a replacement for QEMU; it's the engine underneath — QEMU uses NVMM as its acceleration backend, just as QEMU uses KVM on Linux.
modload nvmmmodstat | grep nvmm
nvmm misc - 0 48For automatic loading at boot, add it to /etc/modules.conf:
nvmmWarning
NVMM requires hardware virtualization support. On a physical machine, make sure VT-x/AMD-V is enabled in the BIOS. Inside a VM (nested virtualization), make sure the host hypervisor enables expose hardware virtualization.
Install QEMU from pkgsrc:
cd /usr/pkgsrc/emulators/qemu
make install cleanRun a VM with NVMM acceleration — the -accel nvmm flag gives near-native speed:
qemu-system-x86_64 \
-accel nvmm \
-m 1024 \
-drive file=netbsd.qcow2,format=qcow2 \
-netdev user,id=n1 \
-device virtio-net-pci,netdev=n1qemu-system-x86_64: warning: Host doesn't support requested features...
VNC server running on 127.0.0.1:5900With -accel nvmm, the guest runs with full acceleration. Without it, QEMU falls back to pure emulation mode — much slower.
Prepare a disk image, then boot the NetBSD installer as a guest:
qemu-img create -f qcow2 netbsd.qcow2 10GFormatting 'netbsd.qcow2', fmt=qcow2 cluster_size=65536 extended_l2=offqemu-system-x86_64 -accel nvmm -m 1024 \
-cdrom NetBSD-11.0-amd64.iso \
-drive file=netbsd.qcow2,format=qcow2 \
-boot dInstall NetBSD inside the guest exactly as in episode 3 — and you're running NetBSD inside NetBSD.
Xen is a community-owned type-1 (bare-metal) hypervisor, and NetBSD is one of the BSDs with the best Xen support. Its architecture:
| Role | Meaning |
|---|---|
| dom0 | Control domain — the first domU, with full hardware access |
| domU | Guest domain — the operating system running on top of Xen |
NetBSD can act as a dom0 running Xen guests — including NetBSD, Linux, and FreeBSD guests. This makes NetBSD an attractive foundation for small server virtualization.
Conversely, NetBSD can run as a domU on top of Xen managed by another host. To run NetBSD as a domU, boot with the appropriate Xen kernel:
kernel = "/boot/xen/vmlinuz-3.14-x86_64"
ramdisk = "/boot/xen/initramfs-3.14-x86_64"
memory = 1024
vcpus = 2
disk = ['phy:/dev/vg0/nbsd-domu,xvda,w']Xen suits environments that already use Xen infrastructure, or when you need very strict isolation between domains.
| Aspect | NVMM + QEMU | Xen |
|---|---|---|
| Type | Type-2 (via QEMU) | Type-1 (bare-metal) |
| Complexity | Low — use directly | High — needs a Xen boot |
| Use case | Desktop VMs, homelab, testing | Data centers, many heavy guests |
| NetBSD integration | Native, modern | Traditional, mature |
For general needs — running a few VMs in a homelab or small server — NVMM + QEMU is the most practical choice.
NetBSD provides ready-to-use cloud images for modern platforms.
Install a plugin that provides NetBSD boxes, or use an available box:
vagrant init generic/netbsd11
vagrant upBringing machine 'default' up with 'virtualbox' provider...
==> default: Importing base box 'generic/netbsd11'...NetBSD is also published as an AMI (Amazon Machine Image) for AWS — available on the marketplace for a small fee. Once the instance is running, NetBSD on AWS uses the virtio drivers (episode 8: the virtio0 interface) and can be managed like any regular NetBSD server:
dmesg | grep -i virtiovirtio0 at pci0 dev 4 function 0: Virtio network deviceNetBSD's presence in mainstream cloud proves this system is alive — not just for enthusiasts.
In this episode 18, you've taken NetBSD into the virtualization world: understanding the NVMM hypervisor and its integration with QEMU, running guests with -accel nvmm acceleration, learning Xen's role as dom0/domU, and preparing cloud images for Vagrant and AWS AMI.
Key takeaways:
modload nvmm, then use QEMU with -accel nvmm.In the next episode, episode 19, we'll squeeze out performance: performance and optimization — tuning sysctls for the kernel, VM, and network, monitoring the system with systat and top, and comparing FFS with ZFS for storage. See you in episode 19!