# HG changeset patch # User Paul Boddie # Date 1275167010 -7200 # Node ID d2c8f4011ea7bd071fbf3ff8a95cfff57c349193 # Parent 6adfbd9871dec5d9dd54aaf3fec517ae5dd418b7 Added networking support. Updated the release notes. diff -r 6adfbd9871de -r d2c8f4011ea7 README.txt --- a/README.txt Wed May 12 02:14:32 2010 +0200 +++ b/README.txt Sat May 29 23:03:30 2010 +0200 @@ -39,12 +39,12 @@ DISTNAME, exposing derivatives of these variables by default. * Added explicit keyring package installation. * Added -do scripts for configuring and entering the chroot. - * Added support for UML instance construction from distribution - installations. * Removed specific apt- and dpkg-related scripts, replacing them with the general -do scripts. * Added --root options to certain scripts in order to support normal chroot installations. + * Added support for UML instance construction from distribution + installations, along with networking support and a uml-net script. Configuration ------------- @@ -235,6 +235,20 @@ NOTE: Add Linux build process. +Enabling Networking for UML Instances +------------------------------------- + +To enable networking for a UML instance, use the uml-net script: + +sudo uml-net --start $USER + +Here, $USER should be expanded to the name of the user running the above +command, not the root user. + +To stop networking, use the same script: + +sudo uml-net --stop + Entering or Starting UML Instances ---------------------------------- diff -r 6adfbd9871de -r d2c8f4011ea7 uml-do --- a/uml-do Wed May 12 02:14:32 2010 +0200 +++ b/uml-do Sat May 29 23:03:30 2010 +0200 @@ -21,7 +21,18 @@ export UML_MEMORY=$1 export THIS_DIR=`dirname $0` +# Discard the memory argument. + +shift 1 + +# Test for networking. + +if [[ $1 == '--net' ]]; then + export UML_NETWORKING="$NETDEVICE=tuntap,$TUNDEVICE,fe:fd:0:0:0:1,$HOSTADDRESS" + xhost +$GUESTADDRESS + shift 1 +fi + # Now we start the virtual machine... -shift 1 -$THIS_DIR/linux ubd0=$IMAGE ubd1=$SWAPIMAGE mem=$UML_MEMORY $* +$THIS_DIR/linux ubd0=$IMAGE ubd1=$SWAPIMAGE mem=$UML_MEMORY $UML_NETWORKING $* diff -r 6adfbd9871de -r d2c8f4011ea7 uml-net --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/uml-net Sat May 29 23:03:30 2010 +0200 @@ -0,0 +1,28 @@ +#!/bin/bash +# Usage: uml-net ( --start | --stop ) + +# Configuration: +if [ -e userinstall-defaults-uml ]; then + source userinstall-defaults-uml +elif [ -e /etc/default/userinstall-uml ]; then + source /etc/default/userinstall-uml +else + echo "No defaults found for userinstall (UML)." + exit 1 +fi + +if [[ $1 == "--start" ]]; then + chgrp adm /dev/net/tun + tunctl -u $2 -t $TUNDEVICE + ifconfig $TUNDEVICE $HOSTADDRESS up + bash -c "echo 1 > /proc/sys/net/ipv4/ip_forward" + iptables -t nat -I POSTROUTING -o $NETDEVICE -j MASQUERADE + iptables -I FORWARD -i $TUNDEVICE -j ACCEPT + iptables -I FORWARD -o $TUNDEVICE -j ACCEPT + +elif [[ $1 == "--stop" ]]; then + iptables -t nat -D POSTROUTING 1 + iptables -D FORWARD 1 + iptables -D FORWARD 1 + tunctl -d $TUNDEVICE +fi diff -r 6adfbd9871de -r d2c8f4011ea7 userinstall-defaults-uml --- a/userinstall-defaults-uml Wed May 12 02:14:32 2010 +0200 +++ b/userinstall-defaults-uml Sat May 29 23:03:30 2010 +0200 @@ -13,3 +13,14 @@ # Configuration details for building a UML instance. export UMLROOT=$HOME/.userinstall-uml + +# Optional settings. +# Guest: the extra address provided for communication with the UML instance +# Host: the address used inside the UML instance +# Devices: the tunnelling device (or interface) used by the actual machine, plus +# the device (or interface) used inside the UML instance + +export GUESTADDRESS=192.168.0.254 +export HOSTADDRESS=192.168.0.99 +export TUNDEVICE=tap0 +export NETDEVICE=eth0