diff options
author | Richard Purdie <richard.purdie@linuxfoundation.org> | 2023-06-15 17:59:06 +0100 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2023-06-16 15:40:11 +0100 |
commit | 609fc157180778025b2f416736839a7935217731 (patch) | |
tree | 493497d19c1d82190bcf39a18c7dfe8031f60d0e /scripts | |
parent | 3ee077f991e7810bf515783058be940a4b8f6adc (diff) | |
download | poky-609fc157180778025b2f416736839a7935217731.tar.gz |
runqemu/qemu-helper: Drop tunctl
ip tuntap provides the functionality that we obtained from tunctl. We only
needed tunctl when ifconfig was more available than ip. That isn't the case
now so we can drop tunctl and all the hoops we need to jump through to build
and provide it.
(From OE-Core rev: 2abfbca690ff00cb58ce08a65cde006578ee3de9)
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/runqemu-gen-tapdevs | 26 | ||||
-rwxr-xr-x | scripts/runqemu-ifdown | 12 | ||||
-rwxr-xr-x | scripts/runqemu-ifup | 26 |
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 |
63 | fi | 59 | fi |
64 | 60 | ||
65 | TUNCTL=$STAGING_BINDIR_NATIVE/tunctl | ||
66 | ip_supports_tuntap=false | ||
67 | if interfaces=`ip tuntap list` 2>/dev/null; then | 61 | if 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:` |
70 | elif [[ ! -x "$TUNCTL" || -d "$TUNCTL" ]]; then | ||
71 | echo "Error: $TUNCTL is not an executable" | ||
72 | usage | ||
73 | elif interfaces=`ip link` 2>/dev/null; then | ||
74 | interfaces=`echo "$interfaces" | sed '/^[0-9]\+: \(docker[0-9]\+\):.*/!d; s//\1/'` | ||
75 | else | 63 | else |
76 | echo "Failed to call 'ip link'" >&2 | 64 | echo "Failed to call 'ip tuntap list'" >&2 |
77 | exit 1 | 65 | exit 1 |
78 | fi | 66 | fi |
79 | 67 | ||
80 | # Ensure we start with a clean slate | 68 | # Ensure we start with a clean slate |
81 | for tap in $interfaces; do | 69 | for 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 | ||
88 | done | 72 | done |
89 | rm -f /etc/runqemu-nosudo | 73 | rm -f /etc/runqemu-nosudo |
90 | 74 | ||
@@ -95,8 +79,8 @@ fi | |||
95 | echo "Creating $COUNT tap devices for UID: $TUID GID: $GID..." | 79 | echo "Creating $COUNT tap devices for UID: $TUID GID: $GID..." |
96 | for ((index=0; index < $COUNT; index++)); do | 80 | for ((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 |
102 | done | 86 | done |
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 | |||
34 | STAGING_BINDIR_NATIVE=$2 | 33 | STAGING_BINDIR_NATIVE=$2 |
35 | 34 | ||
36 | if !ip tuntap del $TAP mode tap 2>/dev/null; then | 35 | if !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 | ||
44 | fi | 38 | fi |
45 | 39 | ||
46 | IFCONFIG=`which ip 2> /dev/null` | 40 | IFCONFIG=`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 | ||
40 | USERID="-u $1" | 37 | USERID="-u $1" |
41 | GROUP="-g $2" | 38 | GROUP="-g $2" |
42 | STAGING_BINDIR_NATIVE=$3 | ||
43 | 39 | ||
44 | if taps=$(ip tuntap list 2>/dev/null); then | 40 | if 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 | |||
47 | fi | 43 | fi |
48 | 44 | ||
49 | if [ -z $TAP ]; then | 45 | if [ -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 | ||
68 | fi | 48 | fi |
69 | 49 | ||
70 | IFCONFIG=`which ip 2> /dev/null` | 50 | IFCONFIG=`which ip 2> /dev/null` |