Openembedded Core Discussions
 help / color / mirror / Atom feed
* [PATCH V2 0/3] runqemu fixes about iptables rules and preconfigured tap
@ 2013-08-28  2:52 Qi.Chen
  2013-08-28  2:52 ` [PATCH V2 1/3] runqemu-ifdown: clean up the remaining iptables rules Qi.Chen
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Qi.Chen @ 2013-08-28  2:52 UTC (permalink / raw)
  To: openembedded-core

From: Chen Qi <Qi.Chen@windriver.com>

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(-)

-- 
1.7.9.5



^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH V2 1/3] runqemu-ifdown: clean up the remaining iptables rules
  2013-08-28  2:52 [PATCH V2 0/3] runqemu fixes about iptables rules and preconfigured tap Qi.Chen
@ 2013-08-28  2:52 ` Qi.Chen
  2013-08-28  2:52 ` [PATCH V2 2/3] runqemu-internal: don't bring down preconfigured tap interface Qi.Chen
  2013-08-28  2:52 ` [PATCH V2 3/3] runqemu-internal: provide more info if a preconfigured tap is used Qi.Chen
  2 siblings, 0 replies; 4+ messages in thread
From: Qi.Chen @ 2013-08-28  2:52 UTC (permalink / raw)
  To: openembedded-core

From: Chen Qi <Qi.Chen@windriver.com>

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]

Signed-off-by: Chen Qi <Qi.Chen@windriver.com>
---
 scripts/runqemu-ifdown |   14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/scripts/runqemu-ifdown b/scripts/runqemu-ifdown
index 8b8c5a4..8f66cfa2 100755
--- a/scripts/runqemu-ifdown
+++ b/scripts/runqemu-ifdown
@@ -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
-- 
1.7.9.5



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH V2 2/3] runqemu-internal: don't bring down preconfigured tap interface
  2013-08-28  2:52 [PATCH V2 0/3] runqemu fixes about iptables rules and preconfigured tap Qi.Chen
  2013-08-28  2:52 ` [PATCH V2 1/3] runqemu-ifdown: clean up the remaining iptables rules Qi.Chen
@ 2013-08-28  2:52 ` Qi.Chen
  2013-08-28  2:52 ` [PATCH V2 3/3] runqemu-internal: provide more info if a preconfigured tap is used Qi.Chen
  2 siblings, 0 replies; 4+ messages in thread
From: Qi.Chen @ 2013-08-28  2:52 UTC (permalink / raw)
  To: openembedded-core

From: Chen Qi <Qi.Chen@windriver.com>

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.

Signed-off-by: Chen Qi <Qi.Chen@windriver.com>
---
 scripts/runqemu-internal |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/scripts/runqemu-internal b/scripts/runqemu-internal
index 8a6e551..8165e13 100755
--- a/scripts/runqemu-internal
+++ b/scripts/runqemu-internal
@@ -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
-- 
1.7.9.5



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH V2 3/3] runqemu-internal: provide more info if a preconfigured tap is used
  2013-08-28  2:52 [PATCH V2 0/3] runqemu fixes about iptables rules and preconfigured tap Qi.Chen
  2013-08-28  2:52 ` [PATCH V2 1/3] runqemu-ifdown: clean up the remaining iptables rules Qi.Chen
  2013-08-28  2:52 ` [PATCH V2 2/3] runqemu-internal: don't bring down preconfigured tap interface Qi.Chen
@ 2013-08-28  2:52 ` Qi.Chen
  2 siblings, 0 replies; 4+ messages in thread
From: Qi.Chen @ 2013-08-28  2:52 UTC (permalink / raw)
  To: openembedded-core

From: Chen Qi <Qi.Chen@windriver.com>

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]

Signed-off-by: Chen Qi <Qi.Chen@windriver.com>
---
 scripts/runqemu-internal |    1 +
 1 file changed, 1 insertion(+)

diff --git a/scripts/runqemu-internal b/scripts/runqemu-internal
index 8165e13..f9d8728 100755
--- a/scripts/runqemu-internal
+++ b/scripts/runqemu-internal
@@ -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() {
-- 
1.7.9.5



^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2013-08-28  2:51 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-08-28  2:52 [PATCH V2 0/3] runqemu fixes about iptables rules and preconfigured tap Qi.Chen
2013-08-28  2:52 ` [PATCH V2 1/3] runqemu-ifdown: clean up the remaining iptables rules Qi.Chen
2013-08-28  2:52 ` [PATCH V2 2/3] runqemu-internal: don't bring down preconfigured tap interface Qi.Chen
2013-08-28  2:52 ` [PATCH V2 3/3] runqemu-internal: provide more info if a preconfigured tap is used Qi.Chen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox