diff mbox series

scripts/runqemu: Add possibility to disable network

Message ID 20230418132936.3860394-1-pazhukov@suse.de
State New
Headers show
Series scripts/runqemu: Add possibility to disable network | expand

Commit Message

pazhukov April 18, 2023, 1:29 p.m. UTC
Default network configuration requires tun/tap module and while being
usable it conflicts with tap devices created by VPN clients sometimes
and requires root permissions to use . While it's possible to work
this around it's not always feasible if network is not required
Add nonetwork option which can be specified if the network connectivity is
not needed and SDL/serial is enough to communicate with the image.

Signed-off-by: Pavel Zhukov <pazhukov@suse.de>
---
 scripts/runqemu | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/scripts/runqemu b/scripts/runqemu
index 4c06cefbff..f953891c9d 100755
--- a/scripts/runqemu
+++ b/scripts/runqemu
@@ -66,6 +66,7 @@  of the following environment variables (in any order):
   MACHINE - the machine name (optional, autodetected from KERNEL filename if unspecified)
   Simplified QEMU command-line options can be passed with:
     nographic - disable video console
+    nonetwork - disable network connectivity
     novga - Disable VGA emulation completely
     sdl - choose the SDL UI frontend
     gtk - choose the Gtk UI frontend
@@ -178,6 +179,7 @@  class BaseConfig(object):
         self.serialconsole = False
         self.serialstdio = False
         self.nographic = False
+        self.nonetwork = False
         self.sdl = False
         self.gtk = False
         self.gl = False
@@ -495,6 +497,8 @@  to your build configuration.
                 self.check_arg_fstype(arg)
             elif arg == 'nographic':
                 self.nographic = True
+            elif arg == "nonetwork":
+                self.nonetwork = True
             elif arg == 'sdl':
                 self.sdl = True
             elif arg == 'gtk':
@@ -1223,6 +1227,10 @@  to your build configuration.
 
         self.set('NETWORK_CMD', '%s %s' % (self.network_device.replace('@MAC@', mac), qemu_tap_opt))
 
+    def setup_nonetwork(self):
+        self.set('NETWORK_CMD', '-nic none')
+        return
+
     def setup_network(self):
         if self.get('QB_NET') == 'none':
             return
@@ -1717,7 +1725,10 @@  def main():
         # Check whether the combos is valid or not
         config.validate_combos()
         config.print_config()
-        config.setup_network()
+        if config.nonetwork:
+            config.setup_nonetwork()
+        else:
+            config.setup_network()
         config.setup_rootfs()
         config.setup_final()
         config.setup_cmd()