diff options
Diffstat (limited to 'scripts/runqemu-gen-tapdevs')
| -rwxr-xr-x | scripts/runqemu-gen-tapdevs | 107 |
1 files changed, 0 insertions, 107 deletions
diff --git a/scripts/runqemu-gen-tapdevs b/scripts/runqemu-gen-tapdevs deleted file mode 100755 index a00c79c442..0000000000 --- a/scripts/runqemu-gen-tapdevs +++ /dev/null | |||
| @@ -1,107 +0,0 @@ | |||
| 1 | #!/bin/bash | ||
| 2 | # | ||
| 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 | ||
| 5 | # | ||
| 6 | # Copyright (C) 2010 Intel Corp. | ||
| 7 | # | ||
| 8 | # SPDX-License-Identifier: GPL-2.0-only | ||
| 9 | # | ||
| 10 | |||
| 11 | gid=`id -g` | ||
| 12 | if [ -n "$SUDO_GID" ]; then | ||
| 13 | gid=$SUDO_GID | ||
| 14 | fi | ||
| 15 | |||
| 16 | usage() { | ||
| 17 | echo "Usage: sudo $0 <gid> <num>" | ||
| 18 | echo "Where <gid> is the numeric group id the tap devices will be owned by" | ||
| 19 | echo "<num> is the number of tap devices to create (0 to remove all)" | ||
| 20 | echo "For example:" | ||
| 21 | echo "$ bitbake qemu-helper-native" | ||
| 22 | echo "$ sudo $0 $gid 4" | ||
| 23 | echo "" | ||
| 24 | exit 1 | ||
| 25 | } | ||
| 26 | |||
| 27 | # Allow passing 4 arguments for backward compatibility with warning | ||
| 28 | if [ $# -gt 4 ]; then | ||
| 29 | echo "Error: Incorrect number of arguments" | ||
| 30 | usage | ||
| 31 | fi | ||
| 32 | if [ $# -gt 3 ]; then | ||
| 33 | echo "Warning: Ignoring the <native-sysroot-basedir> parameter. It is no longer needed." | ||
| 34 | fi | ||
| 35 | if [ $# -gt 2 ]; then | ||
| 36 | echo "Warning: Ignoring the <uid> parameter. It is no longer needed." | ||
| 37 | GID=$2 | ||
| 38 | COUNT=$3 | ||
| 39 | elif [ $# -eq 2 ]; then | ||
| 40 | GID=$1 | ||
| 41 | COUNT=$2 | ||
| 42 | else | ||
| 43 | echo "Error: Incorrect number of arguments" | ||
| 44 | usage | ||
| 45 | fi | ||
| 46 | |||
| 47 | |||
| 48 | if [ -z "$OE_TAP_NAME" ]; then | ||
| 49 | OE_TAP_NAME=tap | ||
| 50 | fi | ||
| 51 | |||
| 52 | # check if COUNT is a number and >= 0 | ||
| 53 | if ! [ $COUNT -ge 0 ]; then | ||
| 54 | echo "Error: Incorrect count: $COUNT" | ||
| 55 | exit 1 | ||
| 56 | fi | ||
| 57 | |||
| 58 | if [ $EUID -ne 0 ]; then | ||
| 59 | echo "Error: This script must be run with root privileges" | ||
| 60 | exit | ||
| 61 | fi | ||
| 62 | |||
| 63 | SCRIPT_DIR=`dirname $0` | ||
| 64 | RUNQEMU_IFUP="$SCRIPT_DIR/runqemu-ifup" | ||
| 65 | if [ ! -x "$RUNQEMU_IFUP" ]; then | ||
| 66 | echo "Error: Unable to find the runqemu-ifup script in $SCRIPT_DIR" | ||
| 67 | exit 1 | ||
| 68 | fi | ||
| 69 | |||
| 70 | if interfaces=`ip tuntap list` 2>/dev/null; then | ||
| 71 | interfaces=`echo "$interfaces" |cut -f1 -d: |grep -E "^$OE_TAP_NAME.*"` | ||
| 72 | else | ||
| 73 | echo "Failed to call 'ip tuntap list'" >&2 | ||
| 74 | exit 1 | ||
| 75 | fi | ||
| 76 | |||
| 77 | # Ensure we start with a clean slate | ||
| 78 | for tap in $interfaces; do | ||
| 79 | echo "Note: Destroying pre-existing tap interface $tap..." | ||
| 80 | ip tuntap del $tap mode tap | ||
| 81 | done | ||
| 82 | rm -f /etc/runqemu-nosudo | ||
| 83 | |||
| 84 | if [ $COUNT -eq 0 ]; then | ||
| 85 | exit 0 | ||
| 86 | fi | ||
| 87 | |||
| 88 | echo "Creating $COUNT tap devices for GID: $GID..." | ||
| 89 | for ((index=0; index < $COUNT; index++)); do | ||
| 90 | echo "Creating $OE_TAP_NAME$index" | ||
| 91 | if ! ifup=`$RUNQEMU_IFUP $GID 2>&1`; then | ||
| 92 | echo "Error bringing up interface: $ifup" | ||
| 93 | exit 1 | ||
| 94 | fi | ||
| 95 | done | ||
| 96 | |||
| 97 | echo "Note: For systems running NetworkManager, it's recommended" | ||
| 98 | echo "Note: that the tap devices be set as unmanaged in the" | ||
| 99 | echo "Note: NetworkManager.conf file. Add the following lines to" | ||
| 100 | echo "Note: /etc/NetworkManager/NetworkManager.conf" | ||
| 101 | echo "[keyfile]" | ||
| 102 | echo "unmanaged-devices=interface-name:$OE_TAP_NAME*" | ||
| 103 | |||
| 104 | # The runqemu script will check for this file, and if it exists, | ||
| 105 | # will use the existing bank of tap devices without creating | ||
| 106 | # additional ones via sudo. | ||
| 107 | touch /etc/runqemu-nosudo | ||
