summaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/runqemu-gen-tapdevs26
-rwxr-xr-xscripts/runqemu-ifdown12
-rwxr-xr-xscripts/runqemu-ifup26
3 files changed, 11 insertions, 53 deletions
diff --git a/scripts/runqemu-gen-tapdevs b/scripts/runqemu-gen-tapdevs
index ffb82adce6..4f8ea979d2 100755
--- a/scripts/runqemu-gen-tapdevs
+++ b/scripts/runqemu-gen-tapdevs
@@ -1,11 +1,7 @@
1#!/bin/bash 1#!/bin/bash
2# 2#
3# Create a "bank" of tap network devices that can be used by the 3# Create a "bank" of tap network devices that can be used by the
4# runqemu script. This script needs to be run as root, and will 4# runqemu script. This script needs to be run as root
5# use the tunctl binary from the build system sysroot. Note: many Linux
6# distros these days still use an older version of tunctl which does not
7# support the group permissions option, hence the need to use the build
8# system provided version.
9# 5#
10# Copyright (C) 2010 Intel Corp. 6# Copyright (C) 2010 Intel Corp.
11# 7#
@@ -62,29 +58,17 @@ if [ ! -x "$RUNQEMU_IFUP" ]; then
62 exit 1 58 exit 1
63fi 59fi
64 60
65TUNCTL=$STAGING_BINDIR_NATIVE/tunctl
66ip_supports_tuntap=false
67if interfaces=`ip tuntap list` 2>/dev/null; then 61if interfaces=`ip tuntap list` 2>/dev/null; then
68 ip_supports_tuntap=true
69 interfaces=`echo "$interfaces |cut -f1 -d:` 62 interfaces=`echo "$interfaces |cut -f1 -d:`
70elif [[ ! -x "$TUNCTL" || -d "$TUNCTL" ]]; then
71 echo "Error: $TUNCTL is not an executable"
72 usage
73elif interfaces=`ip link` 2>/dev/null; then
74 interfaces=`echo "$interfaces" | sed '/^[0-9]\+: \(docker[0-9]\+\):.*/!d; s//\1/'`
75else 63else
76 echo "Failed to call 'ip link'" >&2 64 echo "Failed to call 'ip tuntap list'" >&2
77 exit 1 65 exit 1
78fi 66fi
79 67
80# Ensure we start with a clean slate 68# Ensure we start with a clean slate
81for tap in $interfaces; do 69for tap in $interfaces; do
82 echo "Note: Destroying pre-existing tap interface $tap..." 70 echo "Note: Destroying pre-existing tap interface $tap..."
83 if $ip_supports_tuntap; then 71 ip tuntap del $tap mode tap
84 ip tuntap del $tap mode tap
85 else
86 $TUNCTL -d $tap
87 fi
88done 72done
89rm -f /etc/runqemu-nosudo 73rm -f /etc/runqemu-nosudo
90 74
@@ -95,8 +79,8 @@ fi
95echo "Creating $COUNT tap devices for UID: $TUID GID: $GID..." 79echo "Creating $COUNT tap devices for UID: $TUID GID: $GID..."
96for ((index=0; index < $COUNT; index++)); do 80for ((index=0; index < $COUNT; index++)); do
97 echo "Creating tap$index" 81 echo "Creating tap$index"
98 if ! ifup=`$RUNQEMU_IFUP $TUID $GID $STAGING_BINDIR_NATIVE 2>&1`; then 82 if ! ifup=`$RUNQEMU_IFUP $TUID $GID 2>&1`; then
99 echo "Error running tunctl: $ifup" 83 echo "Error bringing up interface: $ifup"
100 exit 1 84 exit 1
101 fi 85 fi
102done 86done
diff --git a/scripts/runqemu-ifdown b/scripts/runqemu-ifdown
index f72166b32b..98ac7f07b3 100755
--- a/scripts/runqemu-ifdown
+++ b/scripts/runqemu-ifdown
@@ -1,8 +1,7 @@
1#!/bin/bash 1#!/bin/bash
2# 2#
3# QEMU network configuration script to bring down tap devices. This 3# QEMU network configuration script to bring down tap devices. This
4# utility needs to be run as root, and will use the tunctl binary 4# utility needs to be run as root, and will use the ip utility
5# from the native sysroot.
6# 5#
7# If you find yourself calling this script a lot, you can add the 6# If you find yourself calling this script a lot, you can add the
8# the following to your /etc/sudoers file to be able to run this 7# the following to your /etc/sudoers file to be able to run this
@@ -34,13 +33,8 @@ TAP=$1
34STAGING_BINDIR_NATIVE=$2 33STAGING_BINDIR_NATIVE=$2
35 34
36if !ip tuntap del $TAP mode tap 2>/dev/null; then 35if !ip tuntap del $TAP mode tap 2>/dev/null; then
37 TUNCTL=$STAGING_BINDIR_NATIVE/tunctl 36 echo "Error: Unable to run up tuntap del"
38 if [ ! -e "$TUNCTL" ]; then 37 exit 1
39 echo "Error: Unable to find tunctl binary in '$STAGING_BINDIR_NATIVE', please bitbake qemu-helper-native"
40 exit 1
41 fi
42
43 $TUNCTL -d $TAP
44fi 38fi
45 39
46IFCONFIG=`which ip 2> /dev/null` 40IFCONFIG=`which ip 2> /dev/null`
diff --git a/scripts/runqemu-ifup b/scripts/runqemu-ifup
index 5fdcddeeda..237bf2a07b 100755
--- a/scripts/runqemu-ifup
+++ b/scripts/runqemu-ifup
@@ -1,10 +1,7 @@
1#!/bin/bash 1#!/bin/bash
2# 2#
3# QEMU network interface configuration script. This utility needs to 3# QEMU network interface configuration script. This utility needs to
4# be run as root, and will use the tunctl binary from a native sysroot. 4# be run as root, and will use the ip utility
5# Note: many Linux distros these days still use an older version of
6# tunctl which does not support the group permissions option, hence
7# the need to use build system's version.
8# 5#
9# If you find yourself calling this script a lot, you can add the 6# If you find yourself calling this script a lot, you can add the
10# the following to your /etc/sudoers file to be able to run this 7# the following to your /etc/sudoers file to be able to run this
@@ -39,7 +36,6 @@ fi
39 36
40USERID="-u $1" 37USERID="-u $1"
41GROUP="-g $2" 38GROUP="-g $2"
42STAGING_BINDIR_NATIVE=$3
43 39
44if taps=$(ip tuntap list 2>/dev/null); then 40if taps=$(ip tuntap list 2>/dev/null); then
45 tap_no=$(( $(echo "$taps" |sort -r |sed 's/^tap//; s/:.*//; q') + 1 )) 41 tap_no=$(( $(echo "$taps" |sort -r |sed 's/^tap//; s/:.*//; q') + 1 ))
@@ -47,24 +43,8 @@ if taps=$(ip tuntap list 2>/dev/null); then
47fi 43fi
48 44
49if [ -z $TAP ]; then 45if [ -z $TAP ]; then
50 TUNCTL=$STAGING_BINDIR_NATIVE/tunctl 46 echo "Error: Unable to find a tap device to use"
51 if [ ! -x "$TUNCTL" ]; then 47 exit 1
52 echo "Error: Unable to find tunctl binary in '$STAGING_BINDIR_NATIVE', please bitbake qemu-helper-native"
53 exit 1
54 fi
55
56 TAP=`$TUNCTL -b $GROUP 2>&1`
57 STATUS=$?
58 if [ $STATUS -ne 0 ]; then
59 # If tunctl -g fails, try using tunctl -u, for older host kernels
60 # which do not support the TUNSETGROUP ioctl
61 TAP=`$TUNCTL -b $USERID 2>&1`
62 STATUS=$?
63 if [ $STATUS -ne 0 ]; then
64 echo "tunctl failed:"
65 exit 1
66 fi
67 fi
68fi 48fi
69 49
70IFCONFIG=`which ip 2> /dev/null` 50IFCONFIG=`which ip 2> /dev/null`