summaryrefslogtreecommitdiffstats
path: root/scripts/poky-qemu-ifup
diff options
context:
space:
mode:
authorJeff Dike <jdike@x86_64.user-mode-linux.org>2010-07-21 11:04:59 -0400
committerRichard Purdie <rpurdie@linux.intel.com>2010-08-20 16:20:09 +0100
commitc791544bb02e852644c55401018bc17ec1b9b40e (patch)
tree33d510d91af137a96b1782b9fe8d901867d604f4 /scripts/poky-qemu-ifup
parentb5b3825ce6df45b16e1f3e15001da213bc8b0a55 (diff)
downloadpoky-c791544bb02e852644c55401018bc17ec1b9b40e.tar.gz
qemu: Use a TAP device instead of slirp for networking
With this patch, a persistent TAP device is set up by poky-qemu-ifup, which is now run before qemu. The qemu command line now uses the device that was constructed (rather than the hard-coded tap0) and it is told not to run any networking scripts. When qemu shuts down, poky-qemu-ifdown removes the TAP device. sudo use - sudo is used to run poky-qemu-ifup. sudo is no longer used to run qemu, as qemu no longer needs privileges to set up networking. poky-qemu-ifdown is run without privileges, as you can remove a TAP device which you own. Signed-off-by: Jeff Dike <jdike@linux.intel.com>
Diffstat (limited to 'scripts/poky-qemu-ifup')
-rwxr-xr-xscripts/poky-qemu-ifup10
1 files changed, 9 insertions, 1 deletions
diff --git a/scripts/poky-qemu-ifup b/scripts/poky-qemu-ifup
index cb1891e271..e7f689d251 100755
--- a/scripts/poky-qemu-ifup
+++ b/scripts/poky-qemu-ifup
@@ -17,6 +17,12 @@
17# with this program; if not, write to the Free Software Foundation, Inc., 17# with this program; if not, write to the Free Software Foundation, Inc.,
18# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 18# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 19
20USER=$1
21
22TUNCTL=`which tunctl`
23[ "$TUNCTL" = "" ] && TUNCTL=/usr/sbin/tunctl
24
25TAP=`$TUNCTL -b -u $USER`
20 26
21IFCONFIG=`which ifconfig` 27IFCONFIG=`which ifconfig`
22if [ "x$IFCONFIG" = "x" ]; then 28if [ "x$IFCONFIG" = "x" ]; then
@@ -24,7 +30,7 @@ if [ "x$IFCONFIG" = "x" ]; then
24 IFCONFIG=/sbin/ifconfig 30 IFCONFIG=/sbin/ifconfig
25fi 31fi
26 32
27$IFCONFIG tap0 192.168.7.1 33$IFCONFIG $TAP 192.168.7.1
28 34
29# setup NAT for tap0 interface to have internet access in QEMU 35# setup NAT for tap0 interface to have internet access in QEMU
30IPTABLES=`which iptables` 36IPTABLES=`which iptables`
@@ -35,3 +41,5 @@ fi
35$IPTABLES -A POSTROUTING -t nat -j MASQUERADE -s 192.168.7.0/24 41$IPTABLES -A POSTROUTING -t nat -j MASQUERADE -s 192.168.7.0/24
36echo 1 > /proc/sys/net/ipv4/ip_forward 42echo 1 > /proc/sys/net/ipv4/ip_forward
37$IPTABLES -P FORWARD ACCEPT 43$IPTABLES -P FORWARD ACCEPT
44
45echo $TAP