[Concept,09/11] scripts: build-efi: Allow enabling networking

Message ID 20251023094308.3406453-10-sjg@u-boot.org
State New
Headers
Series Bootstage and script enhancements |

Commit Message

Simon Glass Oct. 23, 2025, 9:42 a.m. UTC
  From: Simon Glass <sjg@chromium.org>

Provide a -N/--net flag to enable networking for the guest.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 scripts/build-efi | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
  

Patch

diff --git a/scripts/build-efi b/scripts/build-efi
index 359f8ff4052..340ff5ac445 100755
--- a/scripts/build-efi
+++ b/scripts/build-efi
@@ -49,6 +49,8 @@  def parse_args():
                         help='Create a partition table')
     parser.add_argument('-c', '--spice', action='store_true',
                         help='Enable SPICE for clipboard sharing')
+    parser.add_argument('-N', '--net', action='store_true',
+                        help='Enable networking (with SSH forwarding on port 2222)')
     parser.add_argument('-v', '--verbose', action='store_true',
                         help='Show executed commands')
 
@@ -142,7 +144,11 @@  class BuildEfi:
 
         cmd = [qemu]
         cmd += '-m', mem
-        cmd += '-nic', 'none'
+        if self.args.net:
+            cmd += '-netdev', 'user,id=net0,hostfwd=tcp::2222-:22'
+            cmd += '-device', 'virtio-net-pci,netdev=net0'
+        else:
+            cmd += '-nic', 'none'
         cmd += extra
         self.helper.add_qemu_args(self.args, cmd, base_hd=1)
         tout.info(' '.join(cmd))