runqemu fixes about iptables rules and preconfigured tap
v2 cover runqemu fixes about iptables rules and preconfigured tap
From: Chen Qi <[email protected]>
The following changes since commit 44c3f72684c5c920ce8af1da54a2268047342589:
lib/oeqa/runtime: smart: add checks for smart output (2013-08-26 16:29:18 +0100)
are available in the git repository at:
git://git.pokylinux.org/poky-contrib ChenQi/runqemu-fixes
http://git.pokylinux.org/cgit.cgi/poky-contrib/log/?h=ChenQi/runqemu-fixes
Chen Qi (3):
runqemu-ifdown: clean up the remaining iptables rules
runqemu-internal: don't bring down preconfigured tap interface
runqemu-internal: provide more info if a preconfigured tap is used
scripts/runqemu-ifdown | 14 ++++++++++++++ scripts/runqemu-internal | 5 ++++- 2 files changed, 18 insertions(+), 1 deletion(-)
Signature · 1 line
1.7.9.5
PATCH v2 1/3 runqemu-ifdown: clean up the remaining iptables rules
From: Chen Qi <[email protected]>
The iptables rules for the tap interface are added by runqemu-ifup everytime we use runqemu to start a qemu target. But it's not cleaned up when runqemu exits.
This patch cleans up the remaining iptables rules for the tap interface in runqemu-ifdown.
[YOCTO #5047]
--- scripts/runqemu-ifdown | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
scripts/runqemu-ifdown +14 -0
@@ -50,3 +50,17 @@ if [ ! -e "$TUNCTL" ]; then fi $TUNCTL -d $TAP + +# cleanup the remaining iptables rules +IPTABLES=`which iptables 2> /dev/null` +if [ "x$IPTABLES" = "x" ]; then + IPTABLES=/sbin/iptables +fi +if [ ! -x "$IPTABLES" ]; then + echo "$IPTABLES cannot be executed" + exit 1 +fi +n=$[ (`echo $TAP | sed 's/tap//'` * 2) + 1 ] +dest=$[ (`echo $TAP | sed 's/tap//'` * 2) + 2 ] +$IPTABLES -D POSTROUTING -t nat -j MASQUERADE -s 192.168.7.$n/32 +$IPTABLES -D POSTROUTING -t nat -j MASQUERADE -s 192.168.7.$dest/32
Signature · 1 line
1.7.9.5
PATCH v2 2/3 runqemu-internal: don't bring down preconfigured tap interface
In reply to [email protected]From: Chen Qi <[email protected]>
runqemu-ifup and runqemu-ifdown should be pairs. If we're using a preconfigured tap interface, the runqemu-ifdown should not be invoked to bring it down.
--- scripts/runqemu-internal | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
scripts/runqemu-internal +3 -1
@@ -175,12 +175,14 @@ else POSSIBLE=`$IFCONFIG link | grep 'tap' | awk '{print $2}' | sed s/://` TAP="" LOCKFILE="" + USE_PRECONF_TAP="no" for tap in $POSSIBLE; do LOCKFILE="$LOCKDIR/$tap" echo "Acquiring lockfile for $tap..." acquire_lock $LOCKFILE if [ $? -eq 0 ]; then TAP=$tap + USE_PRECONF_TAP="yes" break fi done
@@ -215,7 +217,7 @@ else fi cleanup() { - if [ ! -e "$NOSUDO_FLAG" ]; then + if [ ! -e "$NOSUDO_FLAG" -a "$USE_PRECONF_TAP" = "no" ]; then # Redirect stderr since we could see a LD_PRELOAD warning here if pseudo is loaded # but inactive. This looks scary but is harmless sudo $QEMUIFDOWN $TAP $OECORE_NATIVE_SYSROOT 2> /dev/null
Signature · 1 line
1.7.9.5
PATCH v2 3/3 runqemu-internal: provide more info if a preconfigured tap is used
In reply to [email protected]From: Chen Qi <[email protected]>
We should provide the user more information if a preconfigured tap is used. This is because the user might have manually set up the tap interface to be used by other qemu binaries.
So at a minimum, we should let the user know how to make runqemu skip that tap interface.
[YOCTO #5047]
--- scripts/runqemu-internal | 1 + 1 file changed, 1 insertion(+)
scripts/runqemu-internal +1 -0
@@ -214,6 +214,7 @@ else fi else echo "Using preconfigured tap device '$TAP'" + echo "If this is not intended, use flock on $LOCKFILE.lock to make runqemu skip $TAP." fi cleanup() {
Signature · 1 line
1.7.9.5