Installing QEmu
I use QEmu to have a emulated environment to test Xenomai applications without crashing the main system.
We need to enable sdl for qemu to have all display output available, edit /etc/portage/package.use:
app-emulation/qemu-softmmu sdl
To install QEmu on Gentoo we need at first gcc 3.x:
emerge =gcc-3.4.6*
gcc-config i686-pc-linux-gnu-3.4.6
source /etc/profile
emerge app-emulation/qemu
gcc-config i686-pc-linux-gnu-4.1.1
source /etc/profile
Prepare Linux for Qemu
Do as root:
echo 1024 > /proc/sys/dev/rtc/max-user-freq
Compile kernel with tun support.
CONFIG_TUN=m
CONFIG_BRIDGE=m
Install everything for bridging:
emerge net-misc/bridge-utils
emerge sys-apps/usermode-utilities
modprobe tun
modprobe bridge
Note: If you get an error message about unresolved symbols, reboot easily the system then everything should work.
Configure for bridge device now in /etc/conf.d/net:
bridge_add_eth0="br0"
config_eth0=( "null" )
config_br0=( "192.168.0.151/24" )
brctl_br0=( "setfd 0" "sethello 0" "stp off" )
routes_br0=( "default gw 192.168.0.251" )
Add the tun device to your startup config:
cd /etc/init.d
ln -s net.lo net.br0
rc-update add net.br0 default
/etc/init.d/net.eth0 stop
/etc/init.d/net.br0 start
ifconfig br0
ifconfig eth0
Configure Qemu to use a network interface edit /etc/qemu-ifup
#!/bin/sh
#
# ____Address: 192.168.0.1 (guest01)
# ____Netmask: 255.255.255.0
# ___Wildcard: 0.0.0.255
# ____Gateway: 192.168.0.251
#
if test $(sudo /sbin/ifconfig | grep -c $1) -gt 0; then
sudo /sbin/brctl delif br0 $1
sudo ifconfig $1 down
fi
sudo /sbin/ifconfig $1 0.0.0.0 promisc up
sudo /sbin/brctl addif br0 $1
chmod +x /etc/qemu-ifup
Create a persistant tun interface:
tunctl -u root -t tap0
Booting OS in Qemu
We want to boot via network so we create first the needed structure in out tftp server.
- Take the file pxelinux.0 from isolinux and copy it to the tftp root directory.
- create a directory pxelinux.cfg
- create the file pxelinux.cfg/default, see below for more details
- copy kernel to zimage
The structure of the directory is:
tftpboot/
|-- pxelinux.0
|-- pxelinux.cfg
| |-- default
| `-- zimage
`-- zimage
The file default has the following input:
DEFAULT qemu
PROMPT 1
TIMEOUT 10
LABEL qemu
KERNEL zimage
APPEND vga=0x314 install=nfs://192.168.0.151/qemu
LABEL local
LOCALBOOT 0
Now configure your dhcp server:
# settings for booting our qemu image
allow booting;
allow bootp;
next-server 192.168.0.251;
filename "pxelinux.0";
mkdir qemu
cd !$
qemu-img create disk.img 4G
qemu -localtime -hda disk.img -boot d -m 256
You should see now some output. If you get the error message
Could not initialize SDL - exiting
Be sure that $DISPLAY is set and execute on the xserver xhost + to allow all hosts to connect to your xserver.
Now download pxe iso from http://rom-o-matic.net/ .
- Choose as nic: ns8390:rtl8029 – [[0x10ec,0x8029]]
- Select ISO bootable image for without legacy floppy emulation
- Click Get ROM
Now we can boot via network with:
qemu -cdrom eb-5.4.2-ns8390.iso -boot d -net tap -net nic,macaddr=52:54:00:12:34:56
Dec 16 | Atmel | 2 min read |
Dec 16 | Compiling a kernel | 1 min read |
Dec 16 | Distcc and ccache | 4 min read |
Dec 16 | LVM2 | 3 min read |
Dec 16 | Layman | 1 min read |