summaryrefslogtreecommitdiffstats
path: root/scripts/runqemu
diff options
context:
space:
mode:
authorJoshua Watt <JPEWhacker@gmail.com>2022-10-21 14:23:44 -0500
committerRichard Purdie <richard.purdie@linuxfoundation.org>2022-10-26 12:28:39 +0100
commit8b2348a75ec38a1d235c907b2de399bae7bbfaef (patch)
tree335093016147d99e1c660920d8e763088a14de3e /scripts/runqemu
parent8dd2fa2205b90403edd09a1edec66fc409641831 (diff)
downloadpoky-8b2348a75ec38a1d235c907b2de399bae7bbfaef.tar.gz
runqemu: Do not perturb script environment
Instead of changing the script environment to affect the child processes, make a copy of the environment with modifications and pass that to subprocess. Specifically, when dri rendering is enabled, LD_PRELOAD was being passed to all processes created by the script which resulted in other commands (e.g. stty) exiting with a failure like: /bin/sh: symbol lookup error: sysroots-uninative/x86_64-linux/lib/librt.so.1: undefined symbol: __libc_unwind_link_get, version GLIBC_PRIVATE Making a copy of the environment fixes this because the LD_PRELOAD is now only passed to qemu itself. (From OE-Core rev: 2232599d330bd5f2a9e206b490196569ad855de8) Signed-off-by: Joshua Watt <JPEWhacker@gmail.com> Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'scripts/runqemu')
-rwxr-xr-xscripts/runqemu26
1 files changed, 14 insertions, 12 deletions
diff --git a/scripts/runqemu b/scripts/runqemu
index 189fc3da91..a6ea578564 100755
--- a/scripts/runqemu
+++ b/scripts/runqemu
@@ -210,6 +210,7 @@ class BaseConfig(object):
210 self.mac_tap = "52:54:00:12:34:" 210 self.mac_tap = "52:54:00:12:34:"
211 self.mac_slirp = "52:54:00:12:35:" 211 self.mac_slirp = "52:54:00:12:35:"
212 # pid of the actual qemu process 212 # pid of the actual qemu process
213 self.qemu_environ = os.environ.copy()
213 self.qemupid = None 214 self.qemupid = None
214 # avoid cleanup twice 215 # avoid cleanup twice
215 self.cleaned = False 216 self.cleaned = False
@@ -449,18 +450,19 @@ class BaseConfig(object):
449 # As runqemu can be run within bitbake (when using testimage, for example), 450 # As runqemu can be run within bitbake (when using testimage, for example),
450 # we need to ensure that we run host pkg-config, and that it does not 451 # we need to ensure that we run host pkg-config, and that it does not
451 # get mis-directed to native build paths set by bitbake. 452 # get mis-directed to native build paths set by bitbake.
453 env = os.environ.copy()
452 try: 454 try:
453 del os.environ['PKG_CONFIG_PATH'] 455 del env['PKG_CONFIG_PATH']
454 del os.environ['PKG_CONFIG_DIR'] 456 del env['PKG_CONFIG_DIR']
455 del os.environ['PKG_CONFIG_LIBDIR'] 457 del env['PKG_CONFIG_LIBDIR']
456 del os.environ['PKG_CONFIG_SYSROOT_DIR'] 458 del env['PKG_CONFIG_SYSROOT_DIR']
457 except KeyError: 459 except KeyError:
458 pass 460 pass
459 try: 461 try:
460 dripath = subprocess.check_output("PATH=/bin:/usr/bin:$PATH pkg-config --variable=dridriverdir dri", shell=True) 462 dripath = subprocess.check_output("PATH=/bin:/usr/bin:$PATH pkg-config --variable=dridriverdir dri", shell=True, env=env)
461 except subprocess.CalledProcessError as e: 463 except subprocess.CalledProcessError as e:
462 raise RunQemuError("Could not determine the path to dri drivers on the host via pkg-config.\nPlease install Mesa development files (particularly, dri.pc) on the host machine.") 464 raise RunQemuError("Could not determine the path to dri drivers on the host via pkg-config.\nPlease install Mesa development files (particularly, dri.pc) on the host machine.")
463 os.environ['LIBGL_DRIVERS_PATH'] = dripath.decode('utf-8').strip() 465 self.qemu_environ['LIBGL_DRIVERS_PATH'] = dripath.decode('utf-8').strip()
464 466
465 # This preloads uninative libc pieces and therefore ensures that RPATH/RUNPATH 467 # This preloads uninative libc pieces and therefore ensures that RPATH/RUNPATH
466 # in host mesa drivers doesn't trick uninative into loading host libc. 468 # in host mesa drivers doesn't trick uninative into loading host libc.
@@ -468,7 +470,7 @@ class BaseConfig(object):
468 uninative_path = os.path.dirname(self.get("UNINATIVE_LOADER")) 470 uninative_path = os.path.dirname(self.get("UNINATIVE_LOADER"))
469 if os.path.exists(uninative_path): 471 if os.path.exists(uninative_path):
470 preload_paths = [os.path.join(uninative_path, i) for i in preload_items] 472 preload_paths = [os.path.join(uninative_path, i) for i in preload_items]
471 os.environ['LD_PRELOAD'] = " ".join(preload_paths) 473 self.qemu_environ['LD_PRELOAD'] = " ".join(preload_paths)
472 474
473 def check_args(self): 475 def check_args(self):
474 for debug in ("-d", "--debug"): 476 for debug in ("-d", "--debug"):
@@ -482,8 +484,8 @@ class BaseConfig(object):
482 sys.argv.remove(quiet) 484 sys.argv.remove(quiet)
483 485
484 if 'gl' not in sys.argv[1:] and 'gl-es' not in sys.argv[1:]: 486 if 'gl' not in sys.argv[1:] and 'gl-es' not in sys.argv[1:]:
485 os.environ['SDL_RENDER_DRIVER'] = 'software' 487 self.qemu_environ['SDL_RENDER_DRIVER'] = 'software'
486 os.environ['SDL_FRAMEBUFFER_ACCELERATION'] = 'false' 488 self.qemu_environ['SDL_FRAMEBUFFER_ACCELERATION'] = 'false'
487 489
488 unknown_arg = "" 490 unknown_arg = ""
489 for arg in sys.argv[1:]: 491 for arg in sys.argv[1:]:
@@ -1369,7 +1371,7 @@ class BaseConfig(object):
1369 # need our font setup and show-cusor below so we need to see what qemu --help says 1371 # need our font setup and show-cusor below so we need to see what qemu --help says
1370 # is supported so we can pass our correct config in. 1372 # is supported so we can pass our correct config in.
1371 if not self.nographic and not self.sdl and not self.gtk and not self.publicvnc and not self.egl_headless == True: 1373 if not self.nographic and not self.sdl and not self.gtk and not self.publicvnc and not self.egl_headless == True:
1372 output = subprocess.check_output([self.qemu_bin, "--help"], universal_newlines=True) 1374 output = subprocess.check_output([self.qemu_bin, "--help"], universal_newlines=True, env=self.qemu_environ)
1373 if "-display gtk" in output: 1375 if "-display gtk" in output:
1374 self.gtk = True 1376 self.gtk = True
1375 elif "-display sdl" in output: 1377 elif "-display sdl" in output:
@@ -1393,7 +1395,7 @@ class BaseConfig(object):
1393 if self.sdl == True: 1395 if self.sdl == True:
1394 self.qemu_opt += 'sdl,' 1396 self.qemu_opt += 'sdl,'
1395 elif self.gtk == True: 1397 elif self.gtk == True:
1396 os.environ['FONTCONFIG_PATH'] = '/etc/fonts' 1398 self.qemu_environ['FONTCONFIG_PATH'] = '/etc/fonts'
1397 self.qemu_opt += 'gtk,' 1399 self.qemu_opt += 'gtk,'
1398 1400
1399 if self.gl == True: 1401 if self.gl == True:
@@ -1514,7 +1516,7 @@ class BaseConfig(object):
1514 if len(self.portlocks): 1516 if len(self.portlocks):
1515 for descriptor in self.portlocks.values(): 1517 for descriptor in self.portlocks.values():
1516 pass_fds.append(descriptor.fileno()) 1518 pass_fds.append(descriptor.fileno())
1517 process = subprocess.Popen(cmds, stderr=subprocess.PIPE, pass_fds=pass_fds) 1519 process = subprocess.Popen(cmds, stderr=subprocess.PIPE, pass_fds=pass_fds, env=self.qemu_environ)
1518 self.qemupid = process.pid 1520 self.qemupid = process.pid
1519 retcode = process.wait() 1521 retcode = process.wait()
1520 if retcode: 1522 if retcode: