All of lore.kernel.org
 help / color / mirror / Atom feed
* [meta-oe][PATCH 0/3] runqemu improve networking
@ 2015-11-14 21:35 Adrian Freihofer
  2015-11-14 21:35 ` [meta-oe][PATCH 1/3] connman: fix qemu config Adrian Freihofer
                   ` (3 more replies)
  0 siblings, 4 replies; 11+ messages in thread
From: Adrian Freihofer @ 2015-11-14 21:35 UTC (permalink / raw)
  To: openembedded-core

This patch series adds two features to runqemu:
- Support the emulation of more than one NIC
- Add a hostonly networking mode. This networking mode enables
  the user to implement different virtual networking environments
  such as a bridged network as discussed in #7887.

Note: Without the first patch connman fails if the virtual device
      provides more than one NIC.

@Aws Ismail: I'm using this since more than one year. Would be great
             if you could test this and provide feedback.

Adrian Freihofer (3):
  connman: fix qemu config
  runqemu: add support for multiple NICs
  runqemu: support hostonly net mode

 .../connman/connman-conf/qemuall/wired-setup       |  6 ++--
 scripts/runqemu                                    |  7 +++-
 scripts/runqemu-gen-tapdevs                        | 11 ++++---
 scripts/runqemu-ifdown                             | 33 +++++++++++--------
 scripts/runqemu-ifup                               | 38 +++++++++++++---------
 scripts/runqemu-internal                           | 21 +++++++-----
 6 files changed, 72 insertions(+), 44 deletions(-)

-- 
2.4.3



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

* [meta-oe][PATCH 1/3] connman: fix qemu config
  2015-11-14 21:35 [meta-oe][PATCH 0/3] runqemu improve networking Adrian Freihofer
@ 2015-11-14 21:35 ` Adrian Freihofer
  2015-11-14 21:35 ` [meta-oe][PATCH 2/3] runqemu: add support for multiple NICs Adrian Freihofer
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 11+ messages in thread
From: Adrian Freihofer @ 2015-11-14 21:35 UTC (permalink / raw)
  To: openembedded-core

If a network interface is configured by kernel boot parameters
and the image is booted in qemu, connman takes the IP settings
from /proc/cmdline for this NIC.
The regex for parsing /proc/cmdline is invalid.

Signed-off-by: Adrian Freihofer <adrian.freihofer@gmail.com>
---
 meta/recipes-connectivity/connman/connman-conf/qemuall/wired-setup | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/meta/recipes-connectivity/connman/connman-conf/qemuall/wired-setup b/meta/recipes-connectivity/connman/connman-conf/qemuall/wired-setup
index c46899e..4a61513 100644
--- a/meta/recipes-connectivity/connman/connman-conf/qemuall/wired-setup
+++ b/meta/recipes-connectivity/connman/connman-conf/qemuall/wired-setup
@@ -2,8 +2,10 @@
 
 CONFIGF=/var/lib/connman/wired.config
 
-# Extract wired network config from /proc/cmdline
-NET_CONF=`cat /proc/cmdline |sed -ne 's/^.*ip=\([^ ]*\):\([^ ]*\):\([^ ]*\):\([^ ]*\).*$/\1\/\4\/\3/p'`
+# Extract wired network config (IPv4 = <client-ip>/<netmask>/<gw-ip>) from /proc/cmdline
+# "ip=<client-ip>:<server-ip>:<gw-ip>:<netmask>:<hostname>:<device>:<autoconf>:<dns0-ip>:<dns1-ip> "
+NET_CONF=`cat /proc/cmdline |sed -ne 's/^.*ip=\([0-9.]*\):\([0-9.]*\):\([0-9.]*\):\([0-9.]*\).*$/\1\/\4\/\3/p'`
+NET_CONF=${NET_CONF=%/}
 
 # Check if eth0 is already set via kernel cmdline
 if [ "x$NET_CONF" = "x" ]; then
-- 
2.4.3



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

* [meta-oe][PATCH 2/3] runqemu: add support for multiple NICs
  2015-11-14 21:35 [meta-oe][PATCH 0/3] runqemu improve networking Adrian Freihofer
  2015-11-14 21:35 ` [meta-oe][PATCH 1/3] connman: fix qemu config Adrian Freihofer
@ 2015-11-14 21:35 ` Adrian Freihofer
  2015-11-14 21:35 ` [meta-oe][PATCH 3/3] runqemu: support hostonly net mode Adrian Freihofer
  2015-11-15  6:01 ` [meta-oe][PATCH 0/3] runqemu improve networking Aws Ismail
  3 siblings, 0 replies; 11+ messages in thread
From: Adrian Freihofer @ 2015-11-14 21:35 UTC (permalink / raw)
  To: openembedded-core

Fixes [YOCTO #6356]

Current runqemu script does not support qemu configurations with
more than one emulated NIC. If parameters for one or more
additional NICs are appended qemu ends up with an invalid
configuration.

Example to reproduce:
runqemu ... qemuparams="-net nic,model=virtio... -net tap, ..."

Signed-off-by: Adrian Freihofer <adrian.freihofer@gmail.com>
---
 scripts/runqemu-internal | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/scripts/runqemu-internal b/scripts/runqemu-internal
index 3b0e54c..7b1fdd9 100755
--- a/scripts/runqemu-internal
+++ b/scripts/runqemu-internal
@@ -257,7 +257,7 @@ else
         n1=$(($n0 * 2 + 1))
         n2=$(($n1 + 1))
 
-        KERNEL_NETWORK_CMD="ip=192.168.7.$n2::192.168.7.$n1:255.255.255.0"
+        KERNEL_NETWORK_CMD="ip=192.168.7.$n2::192.168.7.$n1:255.255.255.0::eth0:off"
         QEMU_TAP_CMD="-net tap,vlan=0,ifname=$TAP,script=no,downscript=no"
         if [ "$VHOST_ACTIVE" = "yes" ]; then
             QEMU_NETWORK_CMD="-net nic,model=virtio $QEMU_TAP_CMD,vhost=on"
-- 
2.4.3



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

* [meta-oe][PATCH 3/3] runqemu: support hostonly net mode
  2015-11-14 21:35 [meta-oe][PATCH 0/3] runqemu improve networking Adrian Freihofer
  2015-11-14 21:35 ` [meta-oe][PATCH 1/3] connman: fix qemu config Adrian Freihofer
  2015-11-14 21:35 ` [meta-oe][PATCH 2/3] runqemu: add support for multiple NICs Adrian Freihofer
@ 2015-11-14 21:35 ` Adrian Freihofer
  2015-11-15  6:01 ` [meta-oe][PATCH 0/3] runqemu improve networking Aws Ismail
  3 siblings, 0 replies; 11+ messages in thread
From: Adrian Freihofer @ 2015-11-14 21:35 UTC (permalink / raw)
  To: openembedded-core

This patch adds a "hostonly" command line parameter to runqemu.
If this parameter is passed to runqemu, runquemu does not pass
the default gateway to the kernel parameters of the virtual
device and it does not configure NAT routing on the host.

Whit NAT routing on the host becoming an optional feature it is
possible to add the tap interface(s) to a bridge as discussed in
Yocto bugzilla #7887. The user is enabled to write a script which
does something like calling runqemu-gen-tapdevs to create the tap
device(s) on the host, add the device(s) to a bridge and finally
call runqemu with hostonly parameter.
With this patchset it is possible to configure more than one
emulated NICs for the virtual device. This allows to consider the
192.168.7.x network as a dedicated (statically configured) debug
connection between host and virtual device and to setup a second
NIC to emulate a network setup specific for a particular use case.
This might be a bridged network or what ever required.

Signed-off-by: Adrian Freihofer <adrian.freihofer@gmail.com>
---
 scripts/runqemu             |  7 ++++++-
 scripts/runqemu-gen-tapdevs | 11 +++++++----
 scripts/runqemu-ifdown      | 33 +++++++++++++++++++--------------
 scripts/runqemu-ifup        | 38 +++++++++++++++++++++++---------------
 scripts/runqemu-internal    | 21 +++++++++++++--------
 5 files changed, 68 insertions(+), 42 deletions(-)

diff --git a/scripts/runqemu b/scripts/runqemu
index e01d276..dc3c041 100755
--- a/scripts/runqemu
+++ b/scripts/runqemu
@@ -31,6 +31,7 @@ usage() {
     echo "  VM - boot a virtual machine image (= a file representing a full disk with boot loader)"
     echo "  Simplified QEMU command-line options can be passed with:"
     echo "    nographic - disables video console"
+    echo "    hostonly - disables route to internet on eth0"
     echo "    serial - enables a serial console on /dev/ttyS0"
     echo "    kvm - enables KVM when running qemux86/qemux86-64 (VT-capable CPU required)"
     echo "    kvm-vhost - enables KVM with vhost support when running qemux86/qemux86-64 (VT-capable CPU required)"
@@ -74,6 +75,7 @@ KVM_ENABLED="no"
 KVM_ACTIVE="no"
 VHOST_ENABLED="no"
 VHOST_ACTIVE="no"
+NETMODE="nat"
 
 # Determine whether the file is a kernel or QEMU image, and set the
 # appropriate variables
@@ -179,7 +181,10 @@ while true; do
             VHOST_ENABLED="yes"
             ;;
         "slirp")
-            SLIRP_ENABLED="yes"
+            NETMODE="slirp"
+            ;;
+        "hostonly")
+            NETMODE="hostonly"
             ;;
         "publicvnc")
             SCRIPT_QEMU_OPT="$SCRIPT_QEMU_OPT -vnc 0.0.0.0:0"
diff --git a/scripts/runqemu-gen-tapdevs b/scripts/runqemu-gen-tapdevs
index d3b27be..d2f6e80 100755
--- a/scripts/runqemu-gen-tapdevs
+++ b/scripts/runqemu-gen-tapdevs
@@ -23,11 +23,13 @@
 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 
 usage() {
-	echo "Usage: sudo $0 <uid> <gid> <num> <native-sysroot-basedir>"
+	echo "Usage: sudo $0 <uid> <gid> <num> <native-sysroot-basedir> <netmode>"
         echo "Where <uid> is the numeric user id the tap devices will be owned by"
 	echo "Where <gid> is the numeric group id the tap devices will be owned by"
 	echo "<num> is the number of tap devices to create (0 to remove all)"
 	echo "<native-sysroot-basedir> is the path to the build system's native sysroot"
+	echo "<netmode> is optional and defaults to nat. If netmode is set to hostonly,"
+	echo "          qemu is started without internet gateway."
 	exit 1
 }
 
@@ -36,7 +38,7 @@ if [ $EUID -ne 0 ]; then
 	exit
 fi
 
-if [ $# -ne 4 ]; then
+if [ "$#" -lt 4 -o "$#" -gt 5 ]; then
 	echo "Error: Incorrect number of arguments"
 	usage
 fi
@@ -45,6 +47,7 @@ TUID=$1
 GID=$2
 COUNT=$3
 SYSROOT=$4
+NETMODE=${5:-nat}
 
 TUNCTL=$SYSROOT/usr/bin/tunctl
 if [[ ! -x "$TUNCTL" || -d "$TUNCTL" ]]; then
@@ -75,10 +78,10 @@ for tap in `$IFCONFIG link | grep tap | awk '{ print \$2 }' | sed s/://`; do
 	$TUNCTL -d $tap
 done
 
-echo "Creating $COUNT tap devices for UID: $TUID GID: $GID..."
+echo "Creating $COUNT tap devices for UID: $TUID GID: $GID netmode: $NETMODE..."
 for ((index=0; index < $COUNT; index++)); do
 	echo "Creating tap$index"
-	ifup=`$RUNQEMU_IFUP $TUID $GID $SYSROOT 2>&1`
+	ifup=`$RUNQEMU_IFUP $TUID $GID $SYSROOT $NETMODE 2>&1`
 	if [ $? -ne 0 ]; then
 		echo "Error running tunctl: $ifup"
 		exit 1
diff --git a/scripts/runqemu-ifdown b/scripts/runqemu-ifdown
index 8f66cfa..41e6c1b 100755
--- a/scripts/runqemu-ifdown
+++ b/scripts/runqemu-ifdown
@@ -27,7 +27,8 @@
 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 
 usage() {
-	echo "sudo $(basename $0) <tap-dev> <native-sysroot-basedir>"
+	echo "sudo $(basename $0) <tap-dev> <native-sysroot-basedir> <netmode>"
+	echo "netmode is optional. Supported are nat (default) or hostonly."
 }
 
 if [ $EUID -ne 0 ]; then
@@ -35,13 +36,14 @@ if [ $EUID -ne 0 ]; then
 	exit 1
 fi
 
-if [ $# -ne 2 ]; then
+if [ "$#" -lt 2 -o "$#" -gt 3 ]; then
 	usage
 	exit 1
 fi
 
 TAP=$1
 NATIVE_SYSROOT_DIR=$2
+NETMODE=${3:-nat}
 
 TUNCTL=$NATIVE_SYSROOT_DIR/usr/bin/tunctl
 if [ ! -e "$TUNCTL" ]; then
@@ -51,16 +53,19 @@ 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
+
+if [ "$NETMODE" == "nat" ]; then
+	# 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
 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
diff --git a/scripts/runqemu-ifup b/scripts/runqemu-ifup
index d9bd894..92abfaf 100755
--- a/scripts/runqemu-ifup
+++ b/scripts/runqemu-ifup
@@ -34,7 +34,8 @@
 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 
 usage() {
-	echo "sudo $(basename $0) <uid> <gid> <native-sysroot-basedir>"
+	echo "sudo $(basename $0) <uid> <gid> <native-sysroot-basedir> <netmode>"
+	echo "netmode is optional. Supported are nat (default) or hostonly."
 }
 
 if [ $EUID -ne 0 ]; then
@@ -42,7 +43,7 @@ if [ $EUID -ne 0 ]; then
 	exit 1
 fi
 
-if [ $# -ne 3 ]; then
+if [ "$#" -lt 3 -o "$#" -gt 4 ]; then
 	usage
 	exit 1
 fi
@@ -50,6 +51,7 @@ fi
 USERID="-u $1"
 GROUP="-g $2"
 NATIVE_SYSROOT_DIR=$3
+NETMODE=${4:-nat}
 
 TUNCTL=$NATIVE_SYSROOT_DIR/usr/bin/tunctl
 if [ ! -x "$TUNCTL" ]; then
@@ -80,13 +82,16 @@ if [ ! -x "$IFCONFIG" ]; then
 	exit 1
 fi
 
-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
+
+if [ "$NETMODE" == "nat" ]; then
+	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
 fi
 
 n=$[ (`echo $TAP | sed 's/tap//'` * 2) + 1 ]
@@ -111,11 +116,14 @@ if [ $STATUS -ne 0 ]; then
     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
-$IPTABLES -A POSTROUTING -t nat -j MASQUERADE -s 192.168.7.$dest/32
-echo 1 > /proc/sys/net/ipv4/ip_forward
-echo 1 > /proc/sys/net/ipv4/conf/$TAP/proxy_arp
-$IPTABLES -P FORWARD ACCEPT
+
+if [ "$NETMODE" == "nat" ]; then
+	# setup NAT for tap0 interface to have internet access in QEMU
+	$IPTABLES -A POSTROUTING -t nat -j MASQUERADE -s 192.168.7.$n/32
+	$IPTABLES -A POSTROUTING -t nat -j MASQUERADE -s 192.168.7.$dest/32
+	echo 1 > /proc/sys/net/ipv4/ip_forward
+	echo 1 > /proc/sys/net/ipv4/conf/$TAP/proxy_arp
+	$IPTABLES -P FORWARD ACCEPT
+fi
 
 echo $TAP
diff --git a/scripts/runqemu-internal b/scripts/runqemu-internal
index 7b1fdd9..b234cd9 100755
--- a/scripts/runqemu-internal
+++ b/scripts/runqemu-internal
@@ -116,7 +116,7 @@ NFSRUNNING="false"
 #capture original stty values
 ORIG_STTY=$(stty -g)
 
-if [ "$SLIRP_ENABLED" = "yes" ]; then
+if [ "$NETMODE" = "slirp" ]; then
     KERNEL_NETWORK_CMD="ip=dhcp"
     QEMU_TAP_CMD=""
     QEMU_UI_OPTIONS="-show-cursor -usb -usbdevice wacom-tablet"
@@ -204,10 +204,10 @@ else
             echo "Setting up tap interface under sudo"
             # Redirect stderr since we could see a LD_PRELOAD warning here if pseudo is loaded
             # but inactive. This looks scary but is harmless
-            tap=`sudo $QEMUIFUP $USERID $GROUPID $OECORE_NATIVE_SYSROOT 2> /dev/null`
+            tap=`sudo $QEMUIFUP $USERID $GROUPID $OECORE_NATIVE_SYSROOT $NETMODE 2> /dev/null`
             if [ $? -ne 0 ]; then
                 # Re-run standalone to see verbose errors
-                sudo $QEMUIFUP $USERID $GROUPID $OECORE_NATIVE_SYSROOT
+                sudo $QEMUIFUP $USERID $GROUPID $OECORE_NATIVE_SYSROOT $NETMODE
                 return 1
             fi
             LOCKFILE="$LOCKDIR/$tap"
@@ -225,7 +225,7 @@ else
             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
+                sudo $QEMUIFDOWN $TAP $OECORE_NATIVE_SYSROOT $NETMODE 2> /dev/null
             fi
             echo "Releasing lockfile of preconfigured tap device '$TAP'"
             release_lock $LOCKFILE
@@ -257,7 +257,12 @@ else
         n1=$(($n0 * 2 + 1))
         n2=$(($n1 + 1))
 
-        KERNEL_NETWORK_CMD="ip=192.168.7.$n2::192.168.7.$n1:255.255.255.0::eth0:off"
+        #ip=<client-ip>:<server-ip>:<gw-ip>:<netmask>:<hostname>:<device>:<autoconf>:<dns0-ip>:<dns1-ip>
+        if [ "$NETMODE" == "hostonly" ]; then  # Do not define the gateway
+            KERNEL_NETWORK_CMD="ip=192.168.7.$n2:::255.255.255.0::eth0:off"
+        else  # Default to nat
+            KERNEL_NETWORK_CMD="ip=192.168.7.$n2::192.168.7.$n1:255.255.255.0::eth0:off"
+        fi
         QEMU_TAP_CMD="-net tap,vlan=0,ifname=$TAP,script=no,downscript=no"
         if [ "$VHOST_ACTIVE" = "yes" ]; then
             QEMU_NETWORK_CMD="-net nic,model=virtio $QEMU_TAP_CMD,vhost=on"
@@ -315,7 +320,7 @@ fi
 
 if [ "$NFS_SERVER" = "" ]; then
     NFS_SERVER="192.168.7.1"
-    if [ "$SLIRP_ENABLED" = "yes" ]; then
+    if [ "$NETMODE" = "slirp" ]; then
 	NFS_SERVER="10.0.2.2"
     fi
 fi
@@ -516,7 +521,7 @@ if [ "$MACHINE" = "qemuppc" ]; then
     MACHINE_SUBTYPE=mac99
     CPU_SUBTYPE=G4
     QEMU_UI_OPTIONS="$QEMU_UI_OPTIONS"
-    if [ "$SLIRP_ENABLED" = "yes" ]; then
+    if [ "$NETMODE" = "slirp" ]; then
         QEMU_NETWORK_CMD=""
     else
         QEMU_NETWORK_CMD="-net nic,model=pcnet $QEMU_TAP_CMD"
@@ -734,7 +739,7 @@ else
     LD_PRELOAD="$GL_LD_PRELOAD" $QEMUBIN -kernel $KERNEL $QEMUOPTIONS $SERIALOPTS -no-reboot $SCRIPT_QEMU_OPT $SCRIPT_QEMU_EXTRA_OPT --append "$KERNCMDLINE $SCRIPT_KERNEL_OPT"
 fi
 ret=$?
-if [ "$SLIRP_ENABLED" != "yes" ]; then
+if [ "$NETMODE" != "slirp ]; then
         cleanup
 fi
 
-- 
2.4.3



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

* Re: [meta-oe][PATCH 0/3] runqemu improve networking
  2015-11-14 21:35 [meta-oe][PATCH 0/3] runqemu improve networking Adrian Freihofer
                   ` (2 preceding siblings ...)
  2015-11-14 21:35 ` [meta-oe][PATCH 3/3] runqemu: support hostonly net mode Adrian Freihofer
@ 2015-11-15  6:01 ` Aws Ismail
  2015-11-16 22:16   ` Aws Ismail
  3 siblings, 1 reply; 11+ messages in thread
From: Aws Ismail @ 2015-11-15  6:01 UTC (permalink / raw)
  To: Adrian Freihofer; +Cc: openembedded-core

Thanks Adrian for the patchset. I will test it and get back to you.

Aws\

On Sat, Nov 14, 2015 at 4:35 PM, Adrian Freihofer
<adrian.freihofer@gmail.com> wrote:
> This patch series adds two features to runqemu:
> - Support the emulation of more than one NIC
> - Add a hostonly networking mode. This networking mode enables
>   the user to implement different virtual networking environments
>   such as a bridged network as discussed in #7887.
>
> Note: Without the first patch connman fails if the virtual device
>       provides more than one NIC.
>
> @Aws Ismail: I'm using this since more than one year. Would be great
>              if you could test this and provide feedback.
>
> Adrian Freihofer (3):
>   connman: fix qemu config
>   runqemu: add support for multiple NICs
>   runqemu: support hostonly net mode
>
>  .../connman/connman-conf/qemuall/wired-setup       |  6 ++--
>  scripts/runqemu                                    |  7 +++-
>  scripts/runqemu-gen-tapdevs                        | 11 ++++---
>  scripts/runqemu-ifdown                             | 33 +++++++++++--------
>  scripts/runqemu-ifup                               | 38 +++++++++++++---------
>  scripts/runqemu-internal                           | 21 +++++++-----
>  6 files changed, 72 insertions(+), 44 deletions(-)
>
> --
> 2.4.3
>


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

* Re: [meta-oe][PATCH 0/3] runqemu improve networking
  2015-11-15  6:01 ` [meta-oe][PATCH 0/3] runqemu improve networking Aws Ismail
@ 2015-11-16 22:16   ` Aws Ismail
  2015-11-17 12:24     ` Adrian Freihofer
  0 siblings, 1 reply; 11+ messages in thread
From: Aws Ismail @ 2015-11-16 22:16 UTC (permalink / raw)
  To: Adrian Freihofer; +Cc: openembedded-core

Hi Adrian,

What's the runqemu line you are running with ?

I am passing -net nic -net nic to the qemuparams line which works
fine, but the the two devices come up with no IP addresses.

My full qemu line is:

ROOTFS=<path to qemu.ext4> runqemu qemux86-64 nographic
qemuparams="-cpu host --enable-kvm -m 4096 -net nic -net nic"

Aws\

On Sun, Nov 15, 2015 at 1:01 AM, Aws Ismail <aws.ismail@gmail.com> wrote:
> Thanks Adrian for the patchset. I will test it and get back to you.
>
> Aws\
>
> On Sat, Nov 14, 2015 at 4:35 PM, Adrian Freihofer
> <adrian.freihofer@gmail.com> wrote:
>> This patch series adds two features to runqemu:
>> - Support the emulation of more than one NIC
>> - Add a hostonly networking mode. This networking mode enables
>>   the user to implement different virtual networking environments
>>   such as a bridged network as discussed in #7887.
>>
>> Note: Without the first patch connman fails if the virtual device
>>       provides more than one NIC.
>>
>> @Aws Ismail: I'm using this since more than one year. Would be great
>>              if you could test this and provide feedback.
>>
>> Adrian Freihofer (3):
>>   connman: fix qemu config
>>   runqemu: add support for multiple NICs
>>   runqemu: support hostonly net mode
>>
>>  .../connman/connman-conf/qemuall/wired-setup       |  6 ++--
>>  scripts/runqemu                                    |  7 +++-
>>  scripts/runqemu-gen-tapdevs                        | 11 ++++---
>>  scripts/runqemu-ifdown                             | 33 +++++++++++--------
>>  scripts/runqemu-ifup                               | 38 +++++++++++++---------
>>  scripts/runqemu-internal                           | 21 +++++++-----
>>  6 files changed, 72 insertions(+), 44 deletions(-)
>>
>> --
>> 2.4.3
>>


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

* Re: [meta-oe][PATCH 0/3] runqemu improve networking
  2015-11-16 22:16   ` Aws Ismail
@ 2015-11-17 12:24     ` Adrian Freihofer
  2015-11-17 19:40       ` Aws Ismail
  0 siblings, 1 reply; 11+ messages in thread
From: Adrian Freihofer @ 2015-11-17 12:24 UTC (permalink / raw)
  To: Aws Ismail; +Cc: openembedded-core

Hi Aws

The interfaces of my virtual device are configured as:
eth0: static IP, 192.168.7.2 (This IP is hard coded in many scripts of poky.)
      This interface is for debugging purpose, it is not available
      on my physical devices running in a productive environment.
      The interface is configured by the kernel command line
      provided by the runqemu script. This interface should
      (or must in case of NFS rootfs) be ignored by connman, networkmanager
      or what ever manages the network settings of your device.
eth1: Configured by connman or networkmanager running on the virtual device.
      The part of the setup depends on the particular use case you need
      to emulate. In my setup the tap interfaces of the host ar part
      of a bridge. On the bridge a dnsmasq instance serves IP addresses.
      This part of my setup is not published. It is verry specific. But based
      on my patch set it should be easy to do something similar fitting your
      use case. The simplest approach might be a static IP address e.g.
      assigned by a bbappend file e.g. for connman.

runqemu is started with additional parameters to create eth1:
runqemu hostonly qemuparams="-device virtio-net-pci,netdev=netif1,mac=${macaddr1} -netdev
tap,id=netif1,ifname=${HOST_TAP_NAME},script=no,downscript=no"

Regards,
Adrian

On Mon, 2015-11-16 at 17:16 -0500, Aws Ismail wrote:
> Hi Adrian,
> 
> What's the runqemu line you are running with ?
> 
> I am passing -net nic -net nic to the qemuparams line which works
> fine, but the the two devices come up with no IP addresses.
> 
> My full qemu line is:
> 
> ROOTFS=<path to qemu.ext4> runqemu qemux86-64 nographic
> qemuparams="-cpu host --enable-kvm -m 4096 -net nic -net nic"
> 
> Aws\
> 
> On Sun, Nov 15, 2015 at 1:01 AM, Aws Ismail <aws.ismail@gmail.com> wrote:
> > Thanks Adrian for the patchset. I will test it and get back to you.
> > 
> > Aws\
> > 
> > On Sat, Nov 14, 2015 at 4:35 PM, Adrian Freihofer
> > <adrian.freihofer@gmail.com> wrote:
> > > This patch series adds two features to runqemu:
> > > - Support the emulation of more than one NIC
> > > - Add a hostonly networking mode. This networking mode enables
> > >   the user to implement different virtual networking environments
> > >   such as a bridged network as discussed in #7887.
> > > 
> > > Note: Without the first patch connman fails if the virtual device
> > >       provides more than one NIC.
> > > 
> > > @Aws Ismail: I'm using this since more than one year. Would be great
> > >              if you could test this and provide feedback.
> > > 
> > > Adrian Freihofer (3):
> > >   connman: fix qemu config
> > >   runqemu: add support for multiple NICs
> > >   runqemu: support hostonly net mode
> > > 
> > >  .../connman/connman-conf/qemuall/wired-setup       |  6 ++--
> > >  scripts/runqemu                                    |  7 +++-
> > >  scripts/runqemu-gen-tapdevs                        | 11 ++++---
> > >  scripts/runqemu-ifdown                             | 33 +++++++++++--------
> > >  scripts/runqemu-ifup                               | 38 +++++++++++++---------
> > >  scripts/runqemu-internal                           | 21 +++++++-----
> > >  6 files changed, 72 insertions(+), 44 deletions(-)
> > > 
> > > --
> > > 2.4.3
> > > 


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

* Re: [meta-oe][PATCH 0/3] runqemu improve networking
  2015-11-17 12:24     ` Adrian Freihofer
@ 2015-11-17 19:40       ` Aws Ismail
  2015-11-18  2:22         ` Aws Ismail
  0 siblings, 1 reply; 11+ messages in thread
From: Aws Ismail @ 2015-11-17 19:40 UTC (permalink / raw)
  To: Adrian Freihofer; +Cc: openembedded-core

Thanks Adrian for the explanation. I have tested it now and it works
fine in my case. I think this should be merged upstream because it is
an important feature to have specially if the user is planning to use
the VM for extended use.


Tested-by: Aws Ismail <aws.ismail@gmail.com>



On Tue, Nov 17, 2015 at 7:24 AM, Adrian Freihofer
<adrian.freihofer@gmail.com> wrote:
> Hi Aws
>
> The interfaces of my virtual device are configured as:
> eth0: static IP, 192.168.7.2 (This IP is hard coded in many scripts of poky.)
>       This interface is for debugging purpose, it is not available
>       on my physical devices running in a productive environment.
>       The interface is configured by the kernel command line
>       provided by the runqemu script. This interface should
>       (or must in case of NFS rootfs) be ignored by connman, networkmanager
>       or what ever manages the network settings of your device.
> eth1: Configured by connman or networkmanager running on the virtual device.
>       The part of the setup depends on the particular use case you need
>       to emulate. In my setup the tap interfaces of the host ar part
>       of a bridge. On the bridge a dnsmasq instance serves IP addresses.
>       This part of my setup is not published. It is verry specific. But based
>       on my patch set it should be easy to do something similar fitting your
>       use case. The simplest approach might be a static IP address e.g.
>       assigned by a bbappend file e.g. for connman.
>
> runqemu is started with additional parameters to create eth1:
> runqemu hostonly qemuparams="-device virtio-net-pci,netdev=netif1,mac=${macaddr1} -netdev
> tap,id=netif1,ifname=${HOST_TAP_NAME},script=no,downscript=no"
>
> Regards,
> Adrian
>
> On Mon, 2015-11-16 at 17:16 -0500, Aws Ismail wrote:
>> Hi Adrian,
>>
>> What's the runqemu line you are running with ?
>>
>> I am passing -net nic -net nic to the qemuparams line which works
>> fine, but the the two devices come up with no IP addresses.
>>
>> My full qemu line is:
>>
>> ROOTFS=<path to qemu.ext4> runqemu qemux86-64 nographic
>> qemuparams="-cpu host --enable-kvm -m 4096 -net nic -net nic"
>>
>> Aws\
>>
>> On Sun, Nov 15, 2015 at 1:01 AM, Aws Ismail <aws.ismail@gmail.com> wrote:
>> > Thanks Adrian for the patchset. I will test it and get back to you.
>> >
>> > Aws\
>> >
>> > On Sat, Nov 14, 2015 at 4:35 PM, Adrian Freihofer
>> > <adrian.freihofer@gmail.com> wrote:
>> > > This patch series adds two features to runqemu:
>> > > - Support the emulation of more than one NIC
>> > > - Add a hostonly networking mode. This networking mode enables
>> > >   the user to implement different virtual networking environments
>> > >   such as a bridged network as discussed in #7887.
>> > >
>> > > Note: Without the first patch connman fails if the virtual device
>> > >       provides more than one NIC.
>> > >
>> > > @Aws Ismail: I'm using this since more than one year. Would be great
>> > >              if you could test this and provide feedback.
>> > >
>> > > Adrian Freihofer (3):
>> > >   connman: fix qemu config
>> > >   runqemu: add support for multiple NICs
>> > >   runqemu: support hostonly net mode
>> > >
>> > >  .../connman/connman-conf/qemuall/wired-setup       |  6 ++--
>> > >  scripts/runqemu                                    |  7 +++-
>> > >  scripts/runqemu-gen-tapdevs                        | 11 ++++---
>> > >  scripts/runqemu-ifdown                             | 33 +++++++++++--------
>> > >  scripts/runqemu-ifup                               | 38 +++++++++++++---------
>> > >  scripts/runqemu-internal                           | 21 +++++++-----
>> > >  6 files changed, 72 insertions(+), 44 deletions(-)
>> > >
>> > > --
>> > > 2.4.3
>> > >


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

* Re: [meta-oe][PATCH 0/3] runqemu improve networking
  2015-11-17 19:40       ` Aws Ismail
@ 2015-11-18  2:22         ` Aws Ismail
  2015-11-18 11:36           ` Adrian Freihofer
  0 siblings, 1 reply; 11+ messages in thread
From: Aws Ismail @ 2015-11-18  2:22 UTC (permalink / raw)
  To: Adrian Freihofer; +Cc: openembedded-core

Adrian,

I just have to add one last note here. I had to use
runqemu-gen-tapdevs before runqemu to create the multiple tap devices
(3 in total, tap0 is the default one you've mentioned, and then tap1
and tap2). For example, I did this:

sudo runqemu-gen-tapdevs <my uid> <my guid> 3 <path to my build's
native sysroot>

My thinking was that runqemu would do that for me since I am asking
for two new extra netdev's but apparently not.

On Tue, Nov 17, 2015 at 2:40 PM, Aws Ismail <aws.ismail@gmail.com> wrote:
> Thanks Adrian for the explanation. I have tested it now and it works
> fine in my case. I think this should be merged upstream because it is
> an important feature to have specially if the user is planning to use
> the VM for extended use.
>
>
> Tested-by: Aws Ismail <aws.ismail@gmail.com>
>
>
>
> On Tue, Nov 17, 2015 at 7:24 AM, Adrian Freihofer
> <adrian.freihofer@gmail.com> wrote:
>> Hi Aws
>>
>> The interfaces of my virtual device are configured as:
>> eth0: static IP, 192.168.7.2 (This IP is hard coded in many scripts of poky.)
>>       This interface is for debugging purpose, it is not available
>>       on my physical devices running in a productive environment.
>>       The interface is configured by the kernel command line
>>       provided by the runqemu script. This interface should
>>       (or must in case of NFS rootfs) be ignored by connman, networkmanager
>>       or what ever manages the network settings of your device.
>> eth1: Configured by connman or networkmanager running on the virtual device.
>>       The part of the setup depends on the particular use case you need
>>       to emulate. In my setup the tap interfaces of the host ar part
>>       of a bridge. On the bridge a dnsmasq instance serves IP addresses.
>>       This part of my setup is not published. It is verry specific. But based
>>       on my patch set it should be easy to do something similar fitting your
>>       use case. The simplest approach might be a static IP address e.g.
>>       assigned by a bbappend file e.g. for connman.
>>
>> runqemu is started with additional parameters to create eth1:
>> runqemu hostonly qemuparams="-device virtio-net-pci,netdev=netif1,mac=${macaddr1} -netdev
>> tap,id=netif1,ifname=${HOST_TAP_NAME},script=no,downscript=no"
>>
>> Regards,
>> Adrian
>>
>> On Mon, 2015-11-16 at 17:16 -0500, Aws Ismail wrote:
>>> Hi Adrian,
>>>
>>> What's the runqemu line you are running with ?
>>>
>>> I am passing -net nic -net nic to the qemuparams line which works
>>> fine, but the the two devices come up with no IP addresses.
>>>
>>> My full qemu line is:
>>>
>>> ROOTFS=<path to qemu.ext4> runqemu qemux86-64 nographic
>>> qemuparams="-cpu host --enable-kvm -m 4096 -net nic -net nic"
>>>
>>> Aws\
>>>
>>> On Sun, Nov 15, 2015 at 1:01 AM, Aws Ismail <aws.ismail@gmail.com> wrote:
>>> > Thanks Adrian for the patchset. I will test it and get back to you.
>>> >
>>> > Aws\
>>> >
>>> > On Sat, Nov 14, 2015 at 4:35 PM, Adrian Freihofer
>>> > <adrian.freihofer@gmail.com> wrote:
>>> > > This patch series adds two features to runqemu:
>>> > > - Support the emulation of more than one NIC
>>> > > - Add a hostonly networking mode. This networking mode enables
>>> > >   the user to implement different virtual networking environments
>>> > >   such as a bridged network as discussed in #7887.
>>> > >
>>> > > Note: Without the first patch connman fails if the virtual device
>>> > >       provides more than one NIC.
>>> > >
>>> > > @Aws Ismail: I'm using this since more than one year. Would be great
>>> > >              if you could test this and provide feedback.
>>> > >
>>> > > Adrian Freihofer (3):
>>> > >   connman: fix qemu config
>>> > >   runqemu: add support for multiple NICs
>>> > >   runqemu: support hostonly net mode
>>> > >
>>> > >  .../connman/connman-conf/qemuall/wired-setup       |  6 ++--
>>> > >  scripts/runqemu                                    |  7 +++-
>>> > >  scripts/runqemu-gen-tapdevs                        | 11 ++++---
>>> > >  scripts/runqemu-ifdown                             | 33 +++++++++++--------
>>> > >  scripts/runqemu-ifup                               | 38 +++++++++++++---------
>>> > >  scripts/runqemu-internal                           | 21 +++++++-----
>>> > >  6 files changed, 72 insertions(+), 44 deletions(-)
>>> > >
>>> > > --
>>> > > 2.4.3
>>> > >


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

* Re: [meta-oe][PATCH 0/3] runqemu improve networking
  2015-11-18  2:22         ` Aws Ismail
@ 2015-11-18 11:36           ` Adrian Freihofer
  2015-11-18 22:11             ` Aws Ismail
  0 siblings, 1 reply; 11+ messages in thread
From: Adrian Freihofer @ 2015-11-18 11:36 UTC (permalink / raw)
  To: Aws Ismail; +Cc: openembedded-core

Hi Aws

Creating tap devices, routes or changing the iptables requires extended permissions. runqemu-gen-tapdevs does the part
of the setup which requires to be done with extended permissions. runqemu does the part which is allowed to be done by a
regular user. Normally the tap devices can be "recycled" for many runs of runqemu. This allows to call runqemu-gen
-tapdevs once at boot as the only command running with sudo on the host.

runqemu-gen-tapdevs changes the iptables of the host. It configures a NAT rule to get the virtual device connected to
the Internet. For most use cases this is fine. But the NAT route prevents use cases where for example a bridged setup is
required. Therefore my patchset adds an optional parameter netmode, which makes runqemu-gen-tapdevs skipping the NAT
setup. If I remember correctly, runqemu-gen-tapdevs creates the NAT route for each tap interface. This is probabely not
what you want if you are going to connect more than one tap interface to one qemu instance. If you call runqemu-gen
-tapdevs with netmode set to hostonly, the virtual devices will not have a route to the internet. If a route from a
virtual device to the Internet is still required you need to setup the NAT route on one of the tap interfaces (e.g.
write a wrapper script around runqemu-gen-tapdevs). Instead of setting up the route on a tap interface it might be
better to add the tap interface to a bridge and to setup the route on the bridge.

Basic idea of a wrapper script (sudo):
# Setup a bridge with route to the Internet and dhcp/DNS server or what ever needed
ip link add ${bridge_name} type bridge
ip link set ${bridge_name} up
# Create the tap for the hostonly connection (IP 192.168.7.2)
runqemu-gen-tapdevs ${MYUID} ${MYGID} 1 ${sysroot_dir} hostonly
# Create second tap interface connected to the bridge
ip tuntap add ${tap_name} mode tap
ip link set ${tap_name} up
ip link set ${tap_name} master ${bridge_name}


# Finally qemu can be started (without sudo)
runqemu hostonly qemuparams="-device virtio-net-pci,netdev=netif1,mac=${macaddr1} -netdev
tap,id=netif1,ifname=${tap_name},script=no,downscript=no"


Regards,
Adrian

On Tue, 2015-11-17 at 21:22 -0500, Aws Ismail wrote:
> Adrian,
> 
> I just have to add one last note here. I had to use
> runqemu-gen-tapdevs before runqemu to create the multiple tap devices
> (3 in total, tap0 is the default one you've mentioned, and then tap1
> and tap2). For example, I did this:
> 
> sudo runqemu-gen-tapdevs <my uid> <my guid> 3 <path to my build's
> native sysroot>
> 
> My thinking was that runqemu would do that for me since I am asking
> for two new extra netdev's but apparently not.
> 
> On Tue, Nov 17, 2015 at 2:40 PM, Aws Ismail <aws.ismail@gmail.com> wrote:
> > Thanks Adrian for the explanation. I have tested it now and it works
> > fine in my case. I think this should be merged upstream because it is
> > an important feature to have specially if the user is planning to use
> > the VM for extended use.
> > 
> > 
> > Tested-by: Aws Ismail <aws.ismail@gmail.com>
> > 
> > 
> > 
> > On Tue, Nov 17, 2015 at 7:24 AM, Adrian Freihofer
> > <adrian.freihofer@gmail.com> wrote:
> > > Hi Aws
> > > 
> > > The interfaces of my virtual device are configured as:
> > > eth0: static IP, 192.168.7.2 (This IP is hard coded in many scripts of poky.)
> > >       This interface is for debugging purpose, it is not available
> > >       on my physical devices running in a productive environment.
> > >       The interface is configured by the kernel command line
> > >       provided by the runqemu script. This interface should
> > >       (or must in case of NFS rootfs) be ignored by connman, networkmanager
> > >       or what ever manages the network settings of your device.
> > > eth1: Configured by connman or networkmanager running on the virtual device.
> > >       The part of the setup depends on the particular use case you need
> > >       to emulate. In my setup the tap interfaces of the host ar part
> > >       of a bridge. On the bridge a dnsmasq instance serves IP addresses.
> > >       This part of my setup is not published. It is verry specific. But based
> > >       on my patch set it should be easy to do something similar fitting your
> > >       use case. The simplest approach might be a static IP address e.g.
> > >       assigned by a bbappend file e.g. for connman.
> > > 
> > > runqemu is started with additional parameters to create eth1:
> > > runqemu hostonly qemuparams="-device virtio-net-pci,netdev=netif1,mac=${macaddr1} -netdev
> > > tap,id=netif1,ifname=${HOST_TAP_NAME},script=no,downscript=no"
> > > 
> > > Regards,
> > > Adrian
> > > 
> > > On Mon, 2015-11-16 at 17:16 -0500, Aws Ismail wrote:
> > > > Hi Adrian,
> > > > 
> > > > What's the runqemu line you are running with ?
> > > > 
> > > > I am passing -net nic -net nic to the qemuparams line which works
> > > > fine, but the the two devices come up with no IP addresses.
> > > > 
> > > > My full qemu line is:
> > > > 
> > > > ROOTFS=<path to qemu.ext4> runqemu qemux86-64 nographic
> > > > qemuparams="-cpu host --enable-kvm -m 4096 -net nic -net nic"
> > > > 
> > > > Aws\
> > > > 
> > > > On Sun, Nov 15, 2015 at 1:01 AM, Aws Ismail <aws.ismail@gmail.com> wrote:
> > > > > Thanks Adrian for the patchset. I will test it and get back to you.
> > > > > 
> > > > > Aws\
> > > > > 
> > > > > On Sat, Nov 14, 2015 at 4:35 PM, Adrian Freihofer
> > > > > <adrian.freihofer@gmail.com> wrote:
> > > > > > This patch series adds two features to runqemu:
> > > > > > - Support the emulation of more than one NIC
> > > > > > - Add a hostonly networking mode. This networking mode enables
> > > > > >   the user to implement different virtual networking environments
> > > > > >   such as a bridged network as discussed in #7887.
> > > > > > 
> > > > > > Note: Without the first patch connman fails if the virtual device
> > > > > >       provides more than one NIC.
> > > > > > 
> > > > > > @Aws Ismail: I'm using this since more than one year. Would be great
> > > > > >              if you could test this and provide feedback.
> > > > > > 
> > > > > > Adrian Freihofer (3):
> > > > > >   connman: fix qemu config
> > > > > >   runqemu: add support for multiple NICs
> > > > > >   runqemu: support hostonly net mode
> > > > > > 
> > > > > >  .../connman/connman-conf/qemuall/wired-setup       |  6 ++--
> > > > > >  scripts/runqemu                                    |  7 +++-
> > > > > >  scripts/runqemu-gen-tapdevs                        | 11 ++++---
> > > > > >  scripts/runqemu-ifdown                             | 33 +++++++++++--------
> > > > > >  scripts/runqemu-ifup                               | 38 +++++++++++++---------
> > > > > >  scripts/runqemu-internal                           | 21 +++++++-----
> > > > > >  6 files changed, 72 insertions(+), 44 deletions(-)
> > > > > > 
> > > > > > --
> > > > > > 2.4.3
> > > > > > 


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

* Re: [meta-oe][PATCH 0/3] runqemu improve networking
  2015-11-18 11:36           ` Adrian Freihofer
@ 2015-11-18 22:11             ` Aws Ismail
  0 siblings, 0 replies; 11+ messages in thread
From: Aws Ismail @ 2015-11-18 22:11 UTC (permalink / raw)
  To: Adrian Freihofer; +Cc: openembedded-core

Thanks Adrian once again..

On Wed, Nov 18, 2015 at 6:36 AM, Adrian Freihofer
<adrian.freihofer@gmail.com> wrote:
> Hi Aws
>
> Creating tap devices, routes or changing the iptables requires extended permissions. runqemu-gen-tapdevs does the part
> of the setup which requires to be done with extended permissions. runqemu does the part which is allowed to be done by a
> regular user. Normally the tap devices can be "recycled" for many runs of runqemu. This allows to call runqemu-gen
> -tapdevs once at boot as the only command running with sudo on the host.
>
> runqemu-gen-tapdevs changes the iptables of the host. It configures a NAT rule to get the virtual device connected to
> the Internet. For most use cases this is fine. But the NAT route prevents use cases where for example a bridged setup is
> required. Therefore my patchset adds an optional parameter netmode, which makes runqemu-gen-tapdevs skipping the NAT
> setup. If I remember correctly, runqemu-gen-tapdevs creates the NAT route for each tap interface. This is probabely not
> what you want if you are going to connect more than one tap interface to one qemu instance. If you call runqemu-gen
> -tapdevs with netmode set to hostonly, the virtual devices will not have a route to the internet. If a route from a
> virtual device to the Internet is still required you need to setup the NAT route on one of the tap interfaces (e.g.
> write a wrapper script around runqemu-gen-tapdevs). Instead of setting up the route on a tap interface it might be
> better to add the tap interface to a bridge and to setup the route on the bridge.
>
> Basic idea of a wrapper script (sudo):
> # Setup a bridge with route to the Internet and dhcp/DNS server or what ever needed
> ip link add ${bridge_name} type bridge
> ip link set ${bridge_name} up
> # Create the tap for the hostonly connection (IP 192.168.7.2)
> runqemu-gen-tapdevs ${MYUID} ${MYGID} 1 ${sysroot_dir} hostonly
> # Create second tap interface connected to the bridge
> ip tuntap add ${tap_name} mode tap
> ip link set ${tap_name} up
> ip link set ${tap_name} master ${bridge_name}
>
>
> # Finally qemu can be started (without sudo)
> runqemu hostonly qemuparams="-device virtio-net-pci,netdev=netif1,mac=${macaddr1} -netdev
> tap,id=netif1,ifname=${tap_name},script=no,downscript=no"
>
>
> Regards,
> Adrian
>
> On Tue, 2015-11-17 at 21:22 -0500, Aws Ismail wrote:
>> Adrian,
>>
>> I just have to add one last note here. I had to use
>> runqemu-gen-tapdevs before runqemu to create the multiple tap devices
>> (3 in total, tap0 is the default one you've mentioned, and then tap1
>> and tap2). For example, I did this:
>>
>> sudo runqemu-gen-tapdevs <my uid> <my guid> 3 <path to my build's
>> native sysroot>
>>
>> My thinking was that runqemu would do that for me since I am asking
>> for two new extra netdev's but apparently not.
>>
>> On Tue, Nov 17, 2015 at 2:40 PM, Aws Ismail <aws.ismail@gmail.com> wrote:
>> > Thanks Adrian for the explanation. I have tested it now and it works
>> > fine in my case. I think this should be merged upstream because it is
>> > an important feature to have specially if the user is planning to use
>> > the VM for extended use.
>> >
>> >
>> > Tested-by: Aws Ismail <aws.ismail@gmail.com>
>> >
>> >
>> >
>> > On Tue, Nov 17, 2015 at 7:24 AM, Adrian Freihofer
>> > <adrian.freihofer@gmail.com> wrote:
>> > > Hi Aws
>> > >
>> > > The interfaces of my virtual device are configured as:
>> > > eth0: static IP, 192.168.7.2 (This IP is hard coded in many scripts of poky.)
>> > >       This interface is for debugging purpose, it is not available
>> > >       on my physical devices running in a productive environment.
>> > >       The interface is configured by the kernel command line
>> > >       provided by the runqemu script. This interface should
>> > >       (or must in case of NFS rootfs) be ignored by connman, networkmanager
>> > >       or what ever manages the network settings of your device.
>> > > eth1: Configured by connman or networkmanager running on the virtual device.
>> > >       The part of the setup depends on the particular use case you need
>> > >       to emulate. In my setup the tap interfaces of the host ar part
>> > >       of a bridge. On the bridge a dnsmasq instance serves IP addresses.
>> > >       This part of my setup is not published. It is verry specific. But based
>> > >       on my patch set it should be easy to do something similar fitting your
>> > >       use case. The simplest approach might be a static IP address e.g.
>> > >       assigned by a bbappend file e.g. for connman.
>> > >
>> > > runqemu is started with additional parameters to create eth1:
>> > > runqemu hostonly qemuparams="-device virtio-net-pci,netdev=netif1,mac=${macaddr1} -netdev
>> > > tap,id=netif1,ifname=${HOST_TAP_NAME},script=no,downscript=no"
>> > >
>> > > Regards,
>> > > Adrian
>> > >
>> > > On Mon, 2015-11-16 at 17:16 -0500, Aws Ismail wrote:
>> > > > Hi Adrian,
>> > > >
>> > > > What's the runqemu line you are running with ?
>> > > >
>> > > > I am passing -net nic -net nic to the qemuparams line which works
>> > > > fine, but the the two devices come up with no IP addresses.
>> > > >
>> > > > My full qemu line is:
>> > > >
>> > > > ROOTFS=<path to qemu.ext4> runqemu qemux86-64 nographic
>> > > > qemuparams="-cpu host --enable-kvm -m 4096 -net nic -net nic"
>> > > >
>> > > > Aws\
>> > > >
>> > > > On Sun, Nov 15, 2015 at 1:01 AM, Aws Ismail <aws.ismail@gmail.com> wrote:
>> > > > > Thanks Adrian for the patchset. I will test it and get back to you.
>> > > > >
>> > > > > Aws\
>> > > > >
>> > > > > On Sat, Nov 14, 2015 at 4:35 PM, Adrian Freihofer
>> > > > > <adrian.freihofer@gmail.com> wrote:
>> > > > > > This patch series adds two features to runqemu:
>> > > > > > - Support the emulation of more than one NIC
>> > > > > > - Add a hostonly networking mode. This networking mode enables
>> > > > > >   the user to implement different virtual networking environments
>> > > > > >   such as a bridged network as discussed in #7887.
>> > > > > >
>> > > > > > Note: Without the first patch connman fails if the virtual device
>> > > > > >       provides more than one NIC.
>> > > > > >
>> > > > > > @Aws Ismail: I'm using this since more than one year. Would be great
>> > > > > >              if you could test this and provide feedback.
>> > > > > >
>> > > > > > Adrian Freihofer (3):
>> > > > > >   connman: fix qemu config
>> > > > > >   runqemu: add support for multiple NICs
>> > > > > >   runqemu: support hostonly net mode
>> > > > > >
>> > > > > >  .../connman/connman-conf/qemuall/wired-setup       |  6 ++--
>> > > > > >  scripts/runqemu                                    |  7 +++-
>> > > > > >  scripts/runqemu-gen-tapdevs                        | 11 ++++---
>> > > > > >  scripts/runqemu-ifdown                             | 33 +++++++++++--------
>> > > > > >  scripts/runqemu-ifup                               | 38 +++++++++++++---------
>> > > > > >  scripts/runqemu-internal                           | 21 +++++++-----
>> > > > > >  6 files changed, 72 insertions(+), 44 deletions(-)
>> > > > > >
>> > > > > > --
>> > > > > > 2.4.3
>> > > > > >


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

end of thread, other threads:[~2015-11-18 22:11 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-11-14 21:35 [meta-oe][PATCH 0/3] runqemu improve networking Adrian Freihofer
2015-11-14 21:35 ` [meta-oe][PATCH 1/3] connman: fix qemu config Adrian Freihofer
2015-11-14 21:35 ` [meta-oe][PATCH 2/3] runqemu: add support for multiple NICs Adrian Freihofer
2015-11-14 21:35 ` [meta-oe][PATCH 3/3] runqemu: support hostonly net mode Adrian Freihofer
2015-11-15  6:01 ` [meta-oe][PATCH 0/3] runqemu improve networking Aws Ismail
2015-11-16 22:16   ` Aws Ismail
2015-11-17 12:24     ` Adrian Freihofer
2015-11-17 19:40       ` Aws Ismail
2015-11-18  2:22         ` Aws Ismail
2015-11-18 11:36           ` Adrian Freihofer
2015-11-18 22:11             ` Aws Ismail

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.