diff options
Diffstat (limited to 'scripts/runqemu-ifup')
-rwxr-xr-x | scripts/runqemu-ifup | 33 |
1 files changed, 19 insertions, 14 deletions
diff --git a/scripts/runqemu-ifup b/scripts/runqemu-ifup index b5a3db964b..bb661740c5 100755 --- a/scripts/runqemu-ifup +++ b/scripts/runqemu-ifup @@ -20,18 +20,8 @@ # # Copyright (c) 2006-2011 Linux Foundation # -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License version 2 as -# published by the Free Software Foundation. +# SPDX-License-Identifier: GPL-2.0-only # -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License along -# with this program; if not, write to the Free Software Foundation, Inc., -# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. usage() { echo "sudo $(basename $0) <uid> <gid> <native-sysroot-basedir>" @@ -49,11 +39,11 @@ fi USERID="-u $1" GROUP="-g $2" -NATIVE_SYSROOT_DIR=$3 +STAGING_BINDIR_NATIVE=$3 -TUNCTL=$NATIVE_SYSROOT_DIR/usr/bin/tunctl +TUNCTL=$STAGING_BINDIR_NATIVE/tunctl if [ ! -x "$TUNCTL" ]; then - echo "Error: Unable to find tunctl binary in '$NATIVE_SYSROOT_DIR/usr/bin', please bitbake qemu-helper-native" + echo "Error: Unable to find tunctl binary in '$STAGING_BINDIR_NATIVE', please bitbake qemu-helper-native" exit 1 fi @@ -91,10 +81,25 @@ fi n=$[ (`echo $TAP | sed 's/tap//'` * 2) + 1 ] $IFCONFIG addr add 192.168.7.$n/32 broadcast 192.168.7.255 dev $TAP +STATUS=$? +if [ $STATUS -ne 0 ]; then + echo "Failed to set up IP addressing on $TAP" + exit 1 +fi $IFCONFIG link set dev $TAP up +STATUS=$? +if [ $STATUS -ne 0 ]; then + echo "Failed to bring up $TAP" + exit 1 +fi dest=$[ (`echo $TAP | sed 's/tap//'` * 2) + 2 ] $IFCONFIG route add to 192.168.7.$dest dev $TAP +STATUS=$? +if [ $STATUS -ne 0 ]; then + echo "Failed to add route to 192.168.7.$dest using $TAP" + exit 1 +fi # setup NAT for tap0 interface to have internet access in QEMU $IPTABLES -A POSTROUTING -t nat -j MASQUERADE -s 192.168.7.$n/32 |