OpenBSD Virtualization

I've been interested in the new OpenBSD hypervisor, vmm for a while at this point, and today between classes I finally got the chance to play around with it. There's not much documentation out there aside from the (admittedly very helpful, enough to get me running) man pages. For this I'm just going to run through how to set up an initial vm tutorial style, but first there's the main caveat: vmm only runs OpenBSD. You can throw any userland you like on top of it, but your kernel is OpenBSD. I think someone was working on NetBSD too but I don't remember hearing anything about after that. The upshot of this is that you can't use vmm to run Linux or Windows in a vm and have your software compatibility checked off. Vmm is server virtualization, where you break it up into a bunch of identical hosts, not desktop virtualization. Also, you need to do all this stuff as root; there isn't a single command in here you can run even as wheel, as far as I know.

With that taken care of we get into the actual tutorial. First you're going to need a computer with virtualization extensions. If your computer was made this decade there's a pretty good chance you have them. Check your BIOS because you probably have to explicitly enable it in there anyway. Now boot into OpenBSD, and now it's time to compile a kernel. The default build of the kernel doesn't include vmm support yet, but it's not hard to add:

cd /usr/src/sys/arch/amd64/conf

Now you have a kernel config file for VMM. You're going to want to go in there and look for the vmm line, it should be this:
#vmm0 at mainbus0
Go ahead and uncomment that line.
If you have a multicore computer you're also going to want to go to the bottom of your custom config and add the stuff from GENERIC.MP too, that way you can actually use your multiple processors. Now create your configuration for real.
config VMM
cd ../compile/VMM
cp bsd /bsd.vmm
Now it's reboot time. Get into the bootloader and...
boot /bsd.vmm
If you've managed to boot then you're probably all set. Make yourself a directory for your vm, it's time to actually play with a vm.
vmctl create foo.img 5G
Yay, now you have a disk image. I'm pretty sure this is just a raw disk image but I haven't run a hex editor on it, so you should be able to just loop mount and put stuff on. Now we should probably install OpenBSD on our vm. Go ahead and grab your install59.fs, or 60.fs, or whatever it is when you're reading this, then we'll actually start our vm. I'll just say install.fs for these purposes:
vmctl start "vmname" -m memory_amount -d foo.img -d install.fs -k /bsd.rd
It'll come back with something about how it started vm x on /dev/ttyp#. We don't care so much about the ttyp#, we just want to connect to our vm.
vmctl console x
This should be pretty familiar now, just install OpenBSD as you would normally. You'll be installing via disk if you've never done that before, but it autodetects just about everything. Now you should have an installed OpenBSD vm, I'd probably consider copying this vm image and stowing it somewhere so that you don't need to reinstall anymore, just copy the vanilla vm image. You can do whatever you want now, but not using the internet; I haven't figured out how to get that working over my wifi yet, but I'll update the post when I do so that the tutorial's more complete.