Download and install the qemu package with pkg_add
Create a disk image:
- Code: Select all
# qemu-img create -f qcow virtual.hd 4G
OpenBSD Qemu appears to be incapable of booting a physical CDROM, so you’ll have to create a .iso of your install disk. After spending most of a day trying to figure this out using dd and OpenBSD, I gave up and stuck the CD in my FreeBSD workstation, dd’d it, and copied back over to the Open machine.
Networking wasn’t working using the layer 3 tunnelling offered by /dev/tun device, so you’ll need to configure a layer 2 tunnel. The following qemu-ifup script will do this for you:
- Code: Select all
#!/bin/sh
guest_gw=â€192.168.10.1″
guest_net=â€192.168.10.0″
guest_mask=â€255.255.255.0″
/sbin/ifconfig em0 alias $qemu_ip netmask $qemu_mask
/sbin/route add $guest_ip $guest_gw $guest_mask
/sbin/ifconfig $1 $guest_gw $guest_mask link0
You'll need to add IP forwarding:
- Code: Select all
sysctl -w net.inet.ip.forwarding=1
Update /etc/sysctl.conf whilst you're at it.
NAT can be configured in /etc/pf.conf by adding the following:
- Code: Select all
ext_if="em0"
table <qemu-net> persist { 192.168.10.0/24 }
nat on em0 inet from <qemu-net> to any -> em0
Use pfctl to load the pf ruleset:
- Code: Select all
# pfctl -f /etc/pf.conf
You can check the NAT configuration of pf using the following:
- Code: Select all
# pfctl -sn
Finally, launch your VM with:
- Code: Select all
# qemu -m 256 -boot d -cdrom winxp.iso -hda virtual.hd -n ./qemu-ifup
'256' refers to the RAM made available to the VM. Clearly, if you don't have 256MB to spare, specify less.
Now for the best bit... once you've done all that, built you shiny virtual XP machine and start using it, you'll quickly realise you might be better using a Linux host until we get a BSD port of the Qemu accelerator, KQEMU.
