diff mbox series

[01/11] runqemu: move all imports to the top of the file

Message ID 20261011195949.2118607-2-adrian.freihofer@siemens.com
State New
Headers show
Series runqemu: use QMP for slirp host port allocation | expand

Commit Message

AdrianF Oct. 11, 2026, 7:59 p.m. UTC
From: Adrian Freihofer <adrian.freihofer@siemens.com>

Local imports in functions are inconsistent with the rest of the module.
All of them are stdlib modules, so there is no reason to defer loading them.

Signed-off-by: Adrian Freihofer <adrian.freihofer@siemens.com>
---
 scripts/runqemu | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)
diff mbox series

Patch

diff --git a/scripts/runqemu b/scripts/runqemu
index 2c126e7f54..dee7710fb3 100755
--- a/scripts/runqemu
+++ b/scripts/runqemu
@@ -19,6 +19,10 @@  import glob
 import configparser
 import signal
 import time
+import shlex
+import socket
+import traceback
+from contextlib import closing
 
 class RunQemuError(Exception):
     """Custom exception to raise on known errors."""
@@ -258,9 +262,6 @@  class BaseConfig(object):
 
     def check_free_port(self, host, port, lockdir):
         """ Check whether the port is free or not """
-        import socket
-        from contextlib import closing
-
         lockfile = os.path.join(lockdir, str(port) + '.lock')
         if self.acquire_portlock(lockfile):
             with closing(socket.socket(socket.AF_INET, socket.SOCK_STREAM)) as sock:
@@ -1605,7 +1606,6 @@  to your build configuration.
         self.setup_vga()
 
     def start_qemu(self):
-        import shlex
         if self.kernel:
             kernel_opts = "-kernel %s" % (self.kernel)
             if self.get('QB_KERNEL_CMDLINE') == "none":
@@ -1805,7 +1805,6 @@  def main():
         logger.error(err)
         return 1
     except Exception as err:
-        import traceback
         traceback.print_exc()
         return 1
     finally: