public inbox for openembedded-core@lists.openembedded.org
 help / color / mirror / Atom feed
* [PATCH v2] scripts/runqemu: Add possibility to disable network
@ 2023-04-18 13:33 Pavel Zhukov
  2023-04-18 13:58 ` [OE-core] " Mikko Rapeli
  0 siblings, 1 reply; 2+ messages in thread
From: Pavel Zhukov @ 2023-04-18 13:33 UTC (permalink / raw)
  To: openembedded-core; +Cc: Pavel Zhukov, pavel

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 | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/scripts/runqemu b/scripts/runqemu
index 4c06cefbff..56715c3e1e 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':
@@ -1224,7 +1228,8 @@ to your build configuration.
         self.set('NETWORK_CMD', '%s %s' % (self.network_device.replace('@MAC@', mac), qemu_tap_opt))
 
     def setup_network(self):
-        if self.get('QB_NET') == 'none':
+        if self.nonetwork or self.get('QB_NET') == 'none':
+            self.set('NETWORK_CMD', '-nic none')
             return
         if sys.stdin.isatty():
             self.saved_stty = subprocess.check_output(("stty", "-g")).decode('utf-8').strip()
-- 
2.39.2



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

* Re: [OE-core] [PATCH v2] scripts/runqemu: Add possibility to disable network
  2023-04-18 13:33 [PATCH v2] scripts/runqemu: Add possibility to disable network Pavel Zhukov
@ 2023-04-18 13:58 ` Mikko Rapeli
  0 siblings, 0 replies; 2+ messages in thread
From: Mikko Rapeli @ 2023-04-18 13:58 UTC (permalink / raw)
  To: Pavel Zhukov; +Cc: openembedded-core, pavel

Hi,

On Tue, Apr 18, 2023 at 03:33:25PM +0200, Pavel Zhukov wrote:
> 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.

Using slirp networking is also handy. Only needs localhost to be up.

But having option for no networking at all is useful too.

Cheers,

-Mikko

> Signed-off-by: Pavel Zhukov <pazhukov@suse.de>
> ---
>  scripts/runqemu | 7 ++++++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
> 
> diff --git a/scripts/runqemu b/scripts/runqemu
> index 4c06cefbff..56715c3e1e 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':
> @@ -1224,7 +1228,8 @@ to your build configuration.
>          self.set('NETWORK_CMD', '%s %s' % (self.network_device.replace('@MAC@', mac), qemu_tap_opt))
>  
>      def setup_network(self):
> -        if self.get('QB_NET') == 'none':
> +        if self.nonetwork or self.get('QB_NET') == 'none':
> +            self.set('NETWORK_CMD', '-nic none')
>              return
>          if sys.stdin.isatty():
>              self.saved_stty = subprocess.check_output(("stty", "-g")).decode('utf-8').strip()
> -- 
> 2.39.2
> 

> 
> -=-=-=-=-=-=-=-=-=-=-=-
> Links: You receive all messages sent to this group.
> View/Reply Online (#180189): https://lists.openembedded.org/g/openembedded-core/message/180189
> Mute This Topic: https://lists.openembedded.org/mt/98343907/7159507
> Group Owner: openembedded-core+owner@lists.openembedded.org
> Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [mikko.rapeli@linaro.org]
> -=-=-=-=-=-=-=-=-=-=-=-
> 



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

end of thread, other threads:[~2023-04-18 13:58 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-04-18 13:33 [PATCH v2] scripts/runqemu: Add possibility to disable network Pavel Zhukov
2023-04-18 13:58 ` [OE-core] " Mikko Rapeli

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