Barrelfish inside qemu
With networking Using RTL8029 driver
RTL8029 network driver can be used from the QEMU. But before using, build time option support_qemu_networking should be enabled. This option will reduce the requirement of the memory, hence QEMU can boot. Otherwise, the network initialization code will fail due to lack of memory.
In the build directory, edit the hake/Config.hs file to enable the support_qemu_networking option. The change should look like following.
-- Enable QEMU networking. (ie. make network work in small memory) support_qemu_networking :: Bool support_qemu_networking = True
Changes in the menu.lst
The menu.lst should be modified to enable following modules.
rtl8029: The device driver for rtl8029 card.
netd: The network control daemon needed by Barrelfish to work correctly.
Following is the sample menu.lst which should work.
title Barrelfish in QEMU root (nd) kernel /x86_64/sbin/elver loglevel=4 module /x86_64/sbin/cpu loglevel=4 module /x86_64/sbin/init # Domains spawned by init module /x86_64/sbin/mem_serv module /x86_64/sbin/monitor # Special boot time domains spawned by monitor module /x86_64/sbin/chips boot module /x86_64/sbin/ramfsd boot module /x86_64/sbin/skb boot modulenounzip /skb_ramfs.cpio.gz nospawn module /x86_64/sbin/pci boot module /x86_64/sbin/spawnd boot #bootapic-x86_64=1-15 module /x86_64/sbin/startd boot ## For networking ## For qemu, enable rtl8029 module /x86_64/sbin/rtl8029 module /x86_64/sbin/netd cardname=rtl8029
Best way to run this is to use make sim which will run the QEMU with following options.
qemu-system-x86_64 -smp 2 -m 1024 -net nic,model=ne2k_pci -net user -fda $(SRCDIR)/tools/grub-qemu.img -tftp $(PWD)
The last few lines of the output of make sim command should look something like bellow.
startd.0: starting app /x86_64/sbin/netd on core 0 spawnd.0: spawning /x86_64/sbin/netd on core 0 Initializing RTL8029(AS)... RTL8029AS identified RTL base is 49408 My MAC address: 52:54:00:12:34:56 chips: client waiting for timer chips: notifying client about timer Interface up! IP address 10.0.2.15
Networking with QEMU
Currently, this driver is used with QEMU's inbuilt userspace network stack which provides it's own DHCP server and NATing. With this setup, it is possible to connect to outside servers. But this setup is not suitable for incoming connections as NATing does not allow incoming connections.
If you want to use multiple qemu instances and a virtual network between them, the only way is to use vde2 (deb packages vde2 and libvdeplug2). Also, make sure to compile qemu with --enable-vde.
Create a virtual network with a vde2-switch. If you want to observe the traffic on this network with wireshark, use the –x option to make the virtual switch behave like a hub.
auto mytap iface mytap inet static address 10.0.2.4 netmask 255.255.255.0 broadcast 10.0.2.255 gateway 10.0.2.2 vde2-switch -x -t mytap
Use the following command to start one qemu instance
qemu-system-x86_64 -smp 2 -m 1500 -net user,tftp=$(PWD),dhcpstart=10.0.2.11 -net nic,macaddr=50:50:50:50:50:51,model=ne2k_pci -net vde,sock=/var/run/vde2/mytap.ctl -fda $(SRCDIR)/tools/grub-qemu.img -nographic
This enables both, qemu's inbuilt userspace network stack and the network provided by the vde2 virtual network. Qemu’s inbuilt network stack is used to still provide the tftp functionality to the virtual machine. Provide a tftp server (like tftpd) by the host system also works, but leads to much longer loading times.
For the second (and any further) instance of qemu, just make sure to increase the dhcpstart address (so the second instance gets another ip) and assign another mac address to it by changing the corresponding parameters. We adapted our symbolic_targets.mk file a little bit for this purpose:
ifeq ($(ARCH),x86_64) ifeq ($(M),1) QEMU_CMD=rm -f menu.lst && cp menu1.lst menu.lst && qemu-system-x86_64 -smp 2 -m 1500 -net user,tftp=$(PWD),dhcpstart=10.0.2.11 -net nic,macaddr=50:50:50:50:50:51,model=ne2k_pci -net vde,sock=/var/run/vde2/mytap.ctl -fda $(SRCDIR)/tools/grub-qemu.img -nographic else ifeq ($(M),2) QEMU_CMD=rm -f menu.lst && cp menu2.lst menu.lst && qemu-system-x86_64 -smp 2 -m 1500 -net user,tftp=$(PWD),dhcpstart=10.0.2.12 -net nic,macaddr=50:50:50:50:50:52,model=ne2k_pci -net vde,sock=/var/run/vde2/mytap.ctl -fda $(SRCDIR)/tools/grub-qemu.img -nographic endif GDB=x86_64-pc-linux-gdb endif
This lets you start two different instances with "make M=1 sim" and "make M=2 sim". Note: Due to the limitations of the qemus built-in tftp server they must be started sequentially rather than at the same time.
If you are running out of memory, edit the values for MEMP_NUM_PBUF and PBUF_POOL_SIZE in include/lwipopts.h.
This driver is not tested much. So there might be problems with it.
Tip: To quit the QEMU, use CTRL+A X (CTRL+A followed by X) key sequence.