summaryrefslogtreecommitdiffstats
path: root/meta/classes-recipe
diff options
context:
space:
mode:
authorChen Qi <Qi.Chen@windriver.com>2025-04-29 12:29:40 +0800
committerRichard Purdie <richard.purdie@linuxfoundation.org>2025-05-01 14:22:54 +0100
commit0d5afd177864cc248f345701805592c5c9c82a70 (patch)
tree8cc28c806023eebf88e94a7117952d37af4cca3d /meta/classes-recipe
parentc07ded97d7303c2db56dd3ae8b362dbe7f7aa554 (diff)
downloadpoky-0d5afd177864cc248f345701805592c5c9c82a70.tar.gz
lib/classes/conf: refactor qemu.bbclass functions into library functions
Move the functions in qemu.bbclass to meta/lib/oe/qemu.py as they are generally useful. The qemu.bbclass is still kept, and recipes can continue to use functions from it, though they have become wrapper functions on qemu.py functions. Note that the QEMU_OPTIONS settings are still kept in qemu.bbclass. This sets a clear barrier for people to use qemu user mode. (From OE-Core rev: 7b3563b3b3901c96c3e498799a83ab8cabcf84b4) Signed-off-by: Chen Qi <Qi.Chen@windriver.com> Signed-off-by: Mathieu Dubois-Briand <mathieu.dubois-briand@bootlin.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/classes-recipe')
-rw-r--r--meta/classes-recipe/qemu.bbclass42
1 files changed, 3 insertions, 39 deletions
diff --git a/meta/classes-recipe/qemu.bbclass b/meta/classes-recipe/qemu.bbclass
index e9fe757c7f..f83faf8049 100644
--- a/meta/classes-recipe/qemu.bbclass
+++ b/meta/classes-recipe/qemu.bbclass
@@ -10,48 +10,13 @@
10# 10#
11 11
12def qemu_target_binary(data): 12def qemu_target_binary(data):
13 package_arch = data.getVar("PACKAGE_ARCH") 13 return oe.qemu.qemu_target_binary(data)
14 qemu_target_binary = (data.getVar("QEMU_TARGET_BINARY_%s" % package_arch) or "")
15 if qemu_target_binary:
16 return qemu_target_binary
17
18 target_arch = data.getVar("TARGET_ARCH")
19 if target_arch in ("i486", "i586", "i686"):
20 target_arch = "i386"
21 elif target_arch == "powerpc":
22 target_arch = "ppc"
23 elif target_arch == "powerpc64":
24 target_arch = "ppc64"
25 elif target_arch == "powerpc64le":
26 target_arch = "ppc64le"
27
28 return "qemu-" + target_arch
29 14
30def qemu_wrapper_cmdline(data, rootfs_path, library_paths): 15def qemu_wrapper_cmdline(data, rootfs_path, library_paths):
31 import string 16 return oe.qemu.qemu_wrapper_cmdline(data, rootfs_path, library_paths)
32
33 qemu_binary = qemu_target_binary(data)
34 if qemu_binary == "qemu-allarch":
35 qemu_binary = "qemuwrapper"
36
37 qemu_options = data.getVar("QEMU_OPTIONS") or ""
38
39 return "PSEUDO_UNLOAD=1 " + qemu_binary + " " + qemu_options + " -L " + rootfs_path\
40 + " -E LD_LIBRARY_PATH=" + ":".join(library_paths) + " "
41 17
42# Next function will return a string containing the command that is needed to
43# to run a certain binary through qemu. For example, in order to make a certain
44# postinstall scriptlet run at do_rootfs time and running the postinstall is
45# architecture dependent, we can run it through qemu. For example, in the
46# postinstall scriptlet, we could use the following:
47#
48# ${@qemu_run_binary(d, '$D', '/usr/bin/test_app')} [test_app arguments]
49#
50def qemu_run_binary(data, rootfs_path, binary): 18def qemu_run_binary(data, rootfs_path, binary):
51 libdir = rootfs_path + data.getVar("libdir", False) 19 return oe.qemu.qemu_run_binary(data, rootfs_path, binary)
52 base_libdir = rootfs_path + data.getVar("base_libdir", False)
53
54 return qemu_wrapper_cmdline(data, rootfs_path, [libdir, base_libdir]) + rootfs_path + binary
55 20
56# QEMU_EXTRAOPTIONS is not meant to be directly used, the extensions are 21# QEMU_EXTRAOPTIONS is not meant to be directly used, the extensions are
57# PACKAGE_ARCH, *NOT* overrides. 22# PACKAGE_ARCH, *NOT* overrides.
@@ -59,6 +24,5 @@ def qemu_run_binary(data, rootfs_path, binary):
59# enough and a PACKAGE_ARCH specific -cpu option is needed (hence we have to do 24# enough and a PACKAGE_ARCH specific -cpu option is needed (hence we have to do
60# this dance). For others (e.g. arm) a -cpu option is not necessary, since the 25# this dance). For others (e.g. arm) a -cpu option is not necessary, since the
61# qemu-arm default CPU supports all required architecture levels. 26# qemu-arm default CPU supports all required architecture levels.
62
63QEMU_OPTIONS = "-r ${OLDEST_KERNEL} ${@d.getVar("QEMU_EXTRAOPTIONS:tune-%s" % d.getVar('TUNE_PKGARCH')) or ""}" 27QEMU_OPTIONS = "-r ${OLDEST_KERNEL} ${@d.getVar("QEMU_EXTRAOPTIONS:tune-%s" % d.getVar('TUNE_PKGARCH')) or ""}"
64QEMU_OPTIONS[vardeps] += "QEMU_EXTRAOPTIONS:tune-${TUNE_PKGARCH}" 28QEMU_OPTIONS[vardeps] += "QEMU_EXTRAOPTIONS:tune-${TUNE_PKGARCH}"