Virtual machines with qemu
Some hints to get a networked (bridging mode) virtual machine with qemu.
Loading the relevant kernel modules at boot time
Put the following options into /boot/loader.conf (note that the accelerator kernel module kqemu is still considered "alpha"):
kqemu_load="Yes" aio_load="Yes" bridge_load="Yes"
Setting kernel parameters at boot time
Put the following lines into your /etc/sysctl.conf (replace xl0 with the interface name on your machine):
net.link.ether.bridge.enable=1 sysctl net.link.ether.bridge.config=xl0,tap0
Example: Booting a FreeBSD ISO
Assuming you have created a directory which houses the ISO image, bios.bin, vgabios.bin and vgabios-cirrus.bin, you might want to create a script called "boot.sh" which looks something like this:
#!/bin/sh qemu -boot c -m 128 -localtime -net nic -net tap,script=qemu-ifup -L . -cdrom FreeBSD.iso
The script qemu-ifup script should look something like this:
#!/bin/sh ifconfig $1 0.0.0.0
Now you can start your virtual machine by simply running boot.sh. Bridging will be done by using /dev/tap0. The virtual machine will come up with a NE2000 compatible network interface. You can assign an IP address to it and have bidirectional networking (i.e. the virtual machine can access the network and vice versa).