summaryrefslogtreecommitdiff
path: root/scripts/runqemu-gen-tapdevs
diff options
context:
space:
mode:
authorRobert Yang <liezhi.yang@windriver.com>2016-09-19 02:18:58 -0700
committerRichard Purdie <richard.purdie@linuxfoundation.org>2016-09-20 15:10:36 +0100
commit3d4bf5b0ea581e3e9b388328b086d03f9174fd61 (patch)
treeb01fbc66ec8783aacec7bc61e25afb78cac9a92e /scripts/runqemu-gen-tapdevs
parent63d6d014a0a3da8bf5689b27d1155492e2fdb0f2 (diff)
downloadopenembedded-core-3d4bf5b0ea581e3e9b388328b086d03f9174fd61.tar.gz
openembedded-core-3d4bf5b0ea581e3e9b388328b086d03f9174fd61.tar.bz2
openembedded-core-3d4bf5b0ea581e3e9b388328b086d03f9174fd61.zip
runqemu-gen-tapdevs: remove /etc/runqemu-nosudo when remove taps
It creats /etc/runqemu-nosudo when creats taps, so should remove it when remove taps. Signed-off-by: Robert Yang <liezhi.yang@windriver.com> Signed-off-by: Ross Burton <ross.burton@intel.com>
Diffstat (limited to 'scripts/runqemu-gen-tapdevs')
-rwxr-xr-xscripts/runqemu-gen-tapdevs46
1 files changed, 26 insertions, 20 deletions
diff --git a/scripts/runqemu-gen-tapdevs b/scripts/runqemu-gen-tapdevs
index 624deacb70..bfb60f44ae 100755
--- a/scripts/runqemu-gen-tapdevs
+++ b/scripts/runqemu-gen-tapdevs
@@ -69,32 +69,38 @@ if [ ! -x "$IFCONFIG" ]; then
exit 1
fi
-# Ensure we start with a clean slate
-for tap in `$IFCONFIG link | grep tap | awk '{ print \$2 }' | sed s/://`; do
- echo "Note: Destroying pre-existing tap interface $tap..."
- $TUNCTL -d $tap
-done
-
-echo "Creating $COUNT tap devices for UID: $TUID GID: $GID..."
-for ((index=0; index < $COUNT; index++)); do
- echo "Creating tap$index"
- ifup=`$RUNQEMU_IFUP $TUID $GID $SYSROOT 2>&1`
- if [ $? -ne 0 ]; then
- echo "Error running tunctl: $ifup"
- exit 1
- fi
-done
+if [ $COUNT -ge 0 ]; then
+ # Ensure we start with a clean slate
+ for tap in `$IFCONFIG link | grep tap | awk '{ print \$2 }' | sed s/://`; do
+ echo "Note: Destroying pre-existing tap interface $tap..."
+ $TUNCTL -d $tap
+ done
+ rm -f /etc/runqemu-nosudo
+else
+ echo "Error: Incorrect count: $COUNT"
+ exit 1
+fi
if [ $COUNT -gt 0 ]; then
+ echo "Creating $COUNT tap devices for UID: $TUID GID: $GID..."
+ for ((index=0; index < $COUNT; index++)); do
+ echo "Creating tap$index"
+ ifup=`$RUNQEMU_IFUP $TUID $GID $SYSROOT 2>&1`
+ if [ $? -ne 0 ]; then
+ echo "Error running tunctl: $ifup"
+ exit 1
+ fi
+ done
+
echo "Note: For systems running NetworkManager, it's recommended"
echo "Note: that the tap devices be set as unmanaged in the"
echo "Note: NetworkManager.conf file. Add the following lines to"
echo "Note: /etc/NetworkManager/NetworkManager.conf"
echo "[keyfile]"
echo "unmanaged-devices=interface-name:tap*"
-fi
-# The runqemu script will check for this file, and if it exists,
-# will use the existing bank of tap devices without creating
-# additional ones via sudo.
-touch /etc/runqemu-nosudo
+ # The runqemu script will check for this file, and if it exists,
+ # will use the existing bank of tap devices without creating
+ # additional ones via sudo.
+ touch /etc/runqemu-nosudo
+fi