diff mbox series

[PATCHv4,3/3] runqemu: Add QB_KERNEL_NO_NETWORK_CONFIG variable

Message ID 20190703170223.6228-3-anibal.limon@linaro.org
State New
Headers show
Series [PATCHv4,1/3] runqemu: Allow to store more than one lock for network interfaces | expand

Commit Message

Anibal Limon July 3, 2019, 5:02 p.m. UTC
To let user choice if wants to have network configured via Kernel
cmdline.

Signed-off-by: Aníbal Limón <anibal.limon@linaro.org>
---
 meta/classes/qemuboot.bbclass |  3 +++
 scripts/runqemu               | 24 +++++++++++++-----------
 2 files changed, 16 insertions(+), 11 deletions(-)
diff mbox series

Patch

diff --git a/meta/classes/qemuboot.bbclass b/meta/classes/qemuboot.bbclass
index 15a9e63f2b..5df63a6a61 100644
--- a/meta/classes/qemuboot.bbclass
+++ b/meta/classes/qemuboot.bbclass
@@ -41,6 +41,8 @@ 
 #             "-netdev tap,id=net0,ifname=@TAP@,script=no,downscript=no"
 #              Note, runqemu will replace "@TAP@" with the one which is used, such as tap0, tap1 ...
 #
+# QB_KERNEL_NO_NETWORK_CONFIG: disable auto network configuration via kernel cmdline possible values 'True' and 'False'
+#
 # QB_SLIRP_OPT: network option for SLIRP mode, e.g., -netdev user,id=net0"
 #
 # QB_ROOTFS_OPT: used as rootfs, e.g.,
@@ -63,6 +65,7 @@  QB_DEFAULT_KERNEL ?= "${KERNEL_IMAGETYPE}"
 QB_DEFAULT_FSTYPE ?= "ext4"
 QB_OPT_APPEND ?= "-show-cursor"
 QB_NETWORK_DEVICE ?= "-device virtio-net-pci,netdev=net0,mac=@MAC@"
+QB_KERNEL_NO_NETWORK_CONFIG ?= "False"
 
 # This should be kept align with ROOT_VM
 QB_DRIVE_TYPE ?= "/dev/sd"
diff --git a/scripts/runqemu b/scripts/runqemu
index 0134f86b4c..10f7296c91 100755
--- a/scripts/runqemu
+++ b/scripts/runqemu
@@ -1069,17 +1069,19 @@  class BaseConfig(object):
             gateway = tapnum * 2 + 1
             client = gateway + 1
 
-            # XXX: Linux qemuarm and qemuppc dosen't configure the interface 
-            # if device is specified in ip (ethN), so if only one tap device is
-            # requested don't specify ethN.
-            if tap_no == 1:
-                netconf = "192.168.7.%s::192.168.7.%s:255.255.255.0" % (client, gateway)
-                logger.info("Network configuration: %s", netconf)
-                self.kernel_cmdline_script += " ip=%s" % netconf
-            elif tap_idx == 0:
-                netconf = "192.168.7.%s::192.168.7.%s:255.255.255.0::eth%d" % (client, gateway, tap_idx)
-                logger.info("Network configuration: %s", netconf)
-                self.kernel_cmdline_script += " ip=%s" % netconf
+            no_network = self.get('QB_KERNEL_NO_NETWORK_CONFIG')
+            if no_network and not no_network.lower() == 'true':
+                # XXX: Linux qemuarm and qemuppc dosen't configure the interface 
+                # if device is specified in ip (ethN), so if only one tap device is
+                # requested don't specify ethN.
+                if tap_no == 1:
+                    netconf = "192.168.7.%s::192.168.7.%s:255.255.255.0" % (client, gateway)
+                    logger.info("Network configuration: %s", netconf)
+                    self.kernel_cmdline_script += " ip=%s" % netconf
+                elif tap_idx == 0:
+                    netconf = "192.168.7.%s::192.168.7.%s:255.255.255.0::eth%d" % (client, gateway, tap_idx)
+                    logger.info("Network configuration: %s", netconf)
+                    self.kernel_cmdline_script += " ip=%s" % netconf
 
             mac = "%s%02x" % (self.mac_tap, client)
             qemu_tap_opt = qemu_tap_opt.replace('@TAP@', tap, 1)