Qemu on FreeBSD as host

Qemu is a very fast generic and open source processor emulator by Fabrice Bellard. It runs under Windows 2000, Windows XP, GNU/Linux (RedHat, Debian) and FreeBSD "host" systems. After reading this page you should know:

Installation notes

The installation of Qemu is pretty fast and easy. You can just install it from the Ports. The two Qemu ports we have in the Ports tree as of this writing are "emulators/qemu" and "emulators/qemu-devel". Installing "qemu-devel" for example should be as easy as:

Note: It may be a good idea to enable the KQEMU accelerator when you install one of the Qemu ports (otherwise qemu is much slower):

Running Qemu

To successfully run Qemu, you should make sure that you have:

You can add the following to /boot/loader.conf:

If you forget to load aio, then Qemu may crash with an error message of:

The if_tap and if_bridge modules are mandatory only when you plan to connect the "hosted" FreeBSD system with your existing network. If you don't need networking inside Qemu, it's ok to fire it up without these two networking modules in the host kernel.

You can enable autoloading of kqemu (and aio) at boot by adding a line to your /etc/rc.conf file:

Networking on FreeBSD 8

In FreeBSD 8.x, a couple of features have been introduced to make unprivileged tap networking setup easier. In particular, you do without the ifup script. All in all, the configuration is as follows:

# SET THIS TO YOUR MAIN INTERFACE
iface=em0

echo "Make configuration persistent through reboots:"
echo net.link.tap.user_open=1 >> /etc/sysctl.conf
echo net.link.tap.up_on_open=1 >> /etc/sysctl.conf
echo chmod 0660 /dev/tap0 >> /etc/rc.local # this should be done with devfs(8)
echo 'cloned_interfaces="tap0 bridge0"' >> /etc/rc.conf
echo 'ifconfig_bridge0="addm '$iface' addm tap0 up"' >> /etc/rc.conf
echo 'Actually configure everything (unless you want to reboot at this point):'
/etc/rc.d/sysctl start
ifconfig bridge0 create
ifconfig tap0 create
ifconfig bridge0 addm $iface addm tap0 up
chmod 0660 /dev/tap0

# Run the instance
qemu-system-x86_64 -net nic,model=e1000 -net tap,name=tap0,script=no -cdrom 8.0-BETA3-amd64-bootonly.iso

The last command can be run from under any member of group wheel.

Networking on FreeBSD 7

Contributed by: Marten Vijn.

Default, network is configured inside of the emulator; not visible from outside. if you use fxp0, then:

Also, /usr/local/etc/qemu-ifup script is needed. Networking Default, network is configured inside of the emulator; not visible from outside. This is not absolutely confotable! There are pros and cons: you must be the root and your qemu virtual machine is visible from outside. Assume you know your network interface name. In this case it is fxp0. you can check this by:

First, as root,

create /usr/local/etc/qemu-ifup script as

and make this script runnable.

To do this at every boot time, write /etc/sysctl.conf

and in /boot/loader.conf

Invoke qemu by:

This was originally taken from freebsd vde helpp Qemu as VNC server Display writing is very slow in QEMU, so run qemu as vnc server is very useful.

Run vncviewer like (you can install via /usr/ports/net/tightvnc)

% vncviewer :1

You should wait for while until Windows starts up. Full Screen mode (slow) QEmu uses SDL to output the screen. Modern video card supports VESA 2.0, so you can use SDL with VESA 2.0. While using SDL you need additional settings. First, reconfigure kernel with this configuration.

save as /usr/src/sys/i386/conf/MAHO or something like that. Then,

# made cleandepend ; make depend ; make ; make install

you need additional setting:

and you can run with full-screen in the console. Again, you must be the root. As far as I tested,

DOESN'T WORK (FOR ME). Unfortunately this is very slow, slower than X11 mode... Summary (My setting and command line) As summary, I present my setting for qemu 0.8.0.

/boot/loader.conf

bridge_load="YES" snd_driver_load="YES" snd_pcm_load="YES"

/etc/sysctl.conf

net.link.ether.bridge.enable=1

/etc/qemu-ifup (chmod 755 /etc/qemu-ifup)

Reconfigure kernel with this configuration file

and additional enviromnent variable:

I don't want to be the root

Links

Contributors

qemu (last edited 2012-11-09 21:09:30 by AlfredPerlstein)