Skip to content

Commit

Permalink
Add networking (bridge) support to Qemu, ping works! :-)
Browse files Browse the repository at this point in the history
- Use the Qemu bridge helper to connect a tap to `virbr0` as
  a non-priviliged user
- Update README with requirements and a few instructions for
  how to get `qemu-bridge-helper` working
- Disable ifplugd, instead ...
- Use BusyBox `ifup` to bring up Debian style `/etc/network/interfaces`
- Convert `udhcpc` script `/share/udhcpc/default.script` to use `logger`
- Add PCI support and a few PCI NIC drivers to kernel, default: RTL8139
- Disable kernel `CONFIG_VIRTIO_CONSOLE`, messes up regular console!

Signed-off-by: Joachim Nilsson <[email protected]>
  • Loading branch information
troglobit committed Jan 10, 2015
1 parent 7aeabd0 commit 4107e42
Show file tree
Hide file tree
Showing 7 changed files with 348 additions and 45 deletions.
8 changes: 5 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,11 @@ all: staging kernel packages ramdisk
# +=> -hda hda.img
run:
@echo " QEMU Starting $(NAME) ... (Use Ctrl-a c quit to exit Qemu)"
@qemu-system-arm -nographic -m 128M -M versatilepb \
-kernel $(IMAGEDIR)/zImage \
-initrd $(IMAGEDIR)/initramfs.gz \
@qemu-system-arm -nographic -m 128M -M versatilepb -usb \
-device rtl8139,netdev=nic0 \
-netdev bridge,id=nic0,br=virbr0,helper=/usr/lib/qemu-bridge-helper \
-kernel $(IMAGEDIR)/zImage \
-initrd $(IMAGEDIR)/initramfs.gz \
-append "root=/dev/ram console=ttyAMA0,115200 quiet"

staging:
Expand Down
30 changes: 28 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,40 @@ Ubuntu 14.04:
* gcc-arm-linux-gnueabi
* curl
* make
* gcc
* gcc (or clang, for the menuconfig interface)
* quilt
* qemu-system-arm
* (install libvirt-bin and virt-manager as well!)
* probably more, gzip?, mkimge?


Running
-------

TroglOS uses Qemu to run the resulting kernel + image. For networking
you may need to do the following to your host system:

sudo chmod 4755 /usr/lib/qemu-bridge-helper
sudo dpkg-statoverride --add root root 4755 /usr/lib/qemu-bridge-helper

The first command makes the Qemu helper "suid root", which means we're
allowed to manipulate the network to gain external network access. The
last command is for Debian/Ubuntu system, it makes sure to record your
change so that any Qemu package upgrades will overwrite our mode change.

Now you need to tell Qemu what bridges in the system you are allowed to
connect to, edit/create the file `/etc/qemu/bridge.conf` and add:

allow virbr0

Assuming you have a `virbr0` interface in your system. If you've run
anything in [virt-manager](http://virt-manager.org/) prior to this then
you're set, otherwise you're unfortunately on your own.

Clone this repository, then type `make`. When the build has completed,
start Qemu with `make run` -- Have fun!


Upgrading Linux
---------------

Expand All @@ -40,4 +67,3 @@ the kernel and give you a set of questions for all new features.

Make sure to do a `make kernel_saveconfig`, and possibly add the new
`kernel/config-X.ZZ` to GIT.

9 changes: 4 additions & 5 deletions initramfs/etc/init.d/rcS
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ mkdir -p /etc/network/if-up.d
mkdir -p /etc/network/if-pre-up.d

# Logs to /var/log/messages
hostname `cat /etc/hostname`
hostname -F /etc/hostname
syslogd

# make home directory for root user
Expand All @@ -24,13 +24,12 @@ mkdir -p /dev/pts && \
# Start kernel logger now that syslogd likely is up
klogd

# Setup loopback device, no networking without it
ip addr add 127.0.0.1/8 dev lo
ip link set lo up

cat <<EOF >/etc/httpd.conf
H:/http
I:index.html
/cgi-bin:root:$passwd
EOF

# Bring up all /etc/network/interfaces
ifup -a 2>&1 >/dev/null &

2 changes: 1 addition & 1 deletion initramfs/etc/inittab
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

::respawn:/sbin/inetd -f
#::respawn:sh -c "sleep 3; exec /sbin/udhcpc -i eth0 -p /var/run/udhcpc.pid -f"
::respawn:/sbin/ifplugd -n -a -i eth0 -I -l 2>/dev/null
#::respawn:/sbin/ifplugd -n -a -i eth0 -I -l 2>/dev/null

::respawn:/sbin/httpd -r "Administrator Login" -f

Expand Down
3 changes: 3 additions & 0 deletions initramfs/etc/shutdown
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/sh

true
11 changes: 4 additions & 7 deletions initramfs/share/udhcpc/default.script
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/bin/sh
# udhcpc script edited by Tim Riker <[email protected]>
# Reduced verbosity and use logger --Troglobit

RESOLV_CONF="/etc/resolv.conf"

Expand All @@ -12,32 +13,28 @@ BROADCAST="broadcast +"

case "$1" in
deconfig)
echo "Setting IP address 0.0.0.0 on $interface"
logger -t "udhcpc" -p daemon.info "$interface: Resetting ..."
ifconfig $interface 0.0.0.0
;;

renew|bound)
echo "Setting IP address $ip on $interface"
logger -t "udhcpc" -p daemon.info "$interface: Set/Renew IP $ip mask $mask $BROADCAST router ${router%% *}"
ifconfig $interface $ip $NETMASK $BROADCAST

if [ -n "$router" ] ; then
echo "Deleting routers"
while route del default gw 0.0.0.0 dev $interface ; do
while route del default gw 0.0.0.0 dev $interface 2>/dev/null; do
:
done

metric=0
for i in $router ; do
echo "Adding router $i"
route add default gw $i dev $interface metric $((metric++))
done
fi

echo "Recreating $RESOLV_CONF"
echo -n > $RESOLV_CONF-$$
[ -n "$domain" ] && echo "search $domain" >> $RESOLV_CONF-$$
for i in $dns ; do
echo " Adding DNS server $i"
echo "nameserver $i" >> $RESOLV_CONF-$$
done
mv $RESOLV_CONF-$$ $RESOLV_CONF
Expand Down
Loading

0 comments on commit 4107e42

Please sign in to comment.