As discussed here: https://lists.yoctoproject.org/g/yocto-patches/message/2762 the detection of QMP is currently based on the fact that it expects `qmp` to always be available under the same directory as where the logfiles are stored. However tools like AUH might adjust TEST_LOG_DIR to another location. This causes qemurunner to no longer boot as it cannot find qmp anymore.
This patch addresses this by using the available information with qemurunner: - we have the rootfs name for the qemu image - we have the folder structure where we expect qmp to be present. Based on this we can construct the path where qmp is actually located. For backwards-compatibility the old path detection is: - still working - always tried first before the new method. Signed-off-by: Tom Geelen <[email protected]> --- meta/lib/oeqa/utils/qemurunner.py | 39 +++++++++++++++++++++++-------- 1 file changed, 29 insertions(+), 10 deletions(-) diff --git a/meta/lib/oeqa/utils/qemurunner.py b/meta/lib/oeqa/utils/qemurunner.py index c4db0cf038..579f7a572b 100644 --- a/meta/lib/oeqa/utils/qemurunner.py +++ b/meta/lib/oeqa/utils/qemurunner.py @@ -20,6 +20,7 @@ import string import threading import codecs import tempfile +import glob from collections import defaultdict from contextlib import contextmanager import importlib @@ -186,17 +187,35 @@ class QemuRunner: return self.launch(launch_cmd, qemuparams=qemuparams, get_ip=get_ip, extra_bootparams=extra_bootparams, env=env) def launch(self, launch_cmd, get_ip = True, qemuparams = None, extra_bootparams = None, env = None): - # use logfile to determine the recipe-sysroot-native path and - # then add in the site-packages path components and add that - # to the python sys.path so the qmp module can be found. - python_path = os.path.dirname(os.path.dirname(self.logfile)) - python_path += "/recipe-sysroot-native/usr/lib/qemu-python" - sys.path.append(python_path) + # Discover qmp module location robustly. + # 1) Try path derived from logfile (historical behavior) + # 2) Fallback: search TMPDIR/work/*/<rootfs>/recipe-sysroot-4native for qemu-python or site-packages + candidates = [] + base_from_log = os.path.dirname(os.path.dirname(self.logfile)) + candidates.append(os.path.join(base_from_log, "recipe-sysroot-native", "usr", "lib", "qemu-python")) + + # We can deduce the location for qmp also from the image which is being called as we know: + # - this will have qmp in recipe-sysroot-native + # - this will need to be called as this will derive TESTIMAGE + for p in glob.glob(os.path.join(self.tmpdir, "work", "*", os.path.basename(self.rootfs).split('.')[0], "*", "recipe-sysroot-native", "usr", "lib", "qemu-python")): + candidates.append(p) + # Print all candidates to the debugger + for candidate in candidates: + self.logger.debug("qmp candidates : %s", candidate) + importlib.invalidate_caches() - try: - qmp = importlib.import_module("qmp") - except Exception as e: - self.logger.error("qemurunner: qmp module missing, please ensure it's installed in %s (%s)" % (python_path, str(e))) + qmp = None + for candidate in candidates: + if os.path.isdir(candidate): + try: + sys.path.append(candidate) + qmp = importlib.import_module("qmp") + self.logger.debug("qemurunner: loaded qmp from %s" % candidate) + break + except Exception: + continue + if not qmp: + self.logger.error("qemurunner: qmp module missing; tried paths: %s" % ", ".join(candidates)) return False # Path relative to tmpdir used as cwd for qemu below to avoid unix socket path length issues qmp_file = "." + next(tempfile._get_candidate_names()) -- 2.43.0
-=-=-=-=-=-=-=-=-=-=-=- Links: You receive all messages sent to this group. View/Reply Online (#228941): https://lists.openembedded.org/g/openembedded-core/message/228941 Mute This Topic: https://lists.openembedded.org/mt/117125913/21656 Group Owner: [email protected] Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [[email protected]] -=-=-=-=-=-=-=-=-=-=-=-
