* [OE-core][RFC][PATCH] oeqa/selftest/sdk: add test_sdk_runqemu
@ 2026-02-07 5:13 Qi.Chen
2026-02-09 14:05 ` Alexander Kanavin
2026-02-10 11:37 ` Alexander Kanavin
0 siblings, 2 replies; 6+ messages in thread
From: Qi.Chen @ 2026-02-07 5:13 UTC (permalink / raw)
To: openembedded-core; +Cc: alex.kanavin
From: Chen Qi <Qi.Chen@windriver.com>
Add test case to ensure runqemu works in SDK.
Using runqemu from SDK has been supported for many years. Add a
test case to ensure we have no regression.
Signed-off-by: Chen Qi <Qi.Chen@windriver.com>
---
meta/lib/oeqa/selftest/cases/sdk.py | 88 ++++++++++++++++++++++++++++-
1 file changed, 87 insertions(+), 1 deletion(-)
diff --git a/meta/lib/oeqa/selftest/cases/sdk.py b/meta/lib/oeqa/selftest/cases/sdk.py
index 3971365029..ee1e4ca420 100644
--- a/meta/lib/oeqa/selftest/cases/sdk.py
+++ b/meta/lib/oeqa/selftest/cases/sdk.py
@@ -4,7 +4,13 @@
# SPDX-License-Identifier: MIT
#
-import os.path
+import os
+import shutil
+import subprocess
+import glob
+import time
+import select
+from tempfile import TemporaryDirectory
from oeqa.selftest.case import OESelftestTestCase
from oeqa.utils.commands import bitbake, get_bb_vars
@@ -37,3 +43,83 @@ IMAGE_INSTALL:append = " selftest-hello"
path = os.path.join(vars["SDK_DEPLOY"], vars["TOOLCHAIN_OUTPUTNAME"] + ".target.manifest")
self.assertNotEqual(os.path.getsize(path), 0, msg="Target manifest is empty")
self.assertIn("selftest-hello", self.load_manifest(path))
+
+ def test_sdk_runqemu(self):
+ """Test using runqemu from SDK which has no bitbake available"""
+
+ def path_with_no_bitbake():
+ orig_paths = os.environ["PATH"].split(":")
+ new_paths = []
+ for orig_path in orig_paths:
+ if not os.access(os.path.join(orig_path, "bitbake"), os.X_OK):
+ new_paths.append(orig_path)
+ return ":".join(new_paths)
+
+ def runqemu_works_from_sdk(sdk_dir, sdk_env, machine, path, timeout=360):
+ env = os.environ.copy()
+ env["PATH"] = path
+
+ cmd = f'cd {sdk_dir}; . {sdk_env}; runqemu {machine} snapshot slirp nographic'
+ self.logger.info(f"Running {cmd}")
+ proc = subprocess.Popen(
+ ['bash', '-c', cmd],
+ stdout=subprocess.PIPE,
+ stderr=subprocess.STDOUT,
+ text=True,
+ bufsize=1,
+ env=env
+ )
+ buffer = ""
+ start = time.time()
+ while time.time() - start < timeout:
+ if proc.poll() is not None:
+ chunk = proc.stdout.read()
+ if chunk:
+ buffer += chunk
+ return ('Linux version' in buffer, "\n".join(buffer.split('\n')[-10:]))
+ ready, _, _ = select.select([proc.stdout], [], [], 0.1)
+ if ready:
+ chunk = proc.stdout.read(4096)
+ if chunk:
+ buffer += chunk
+ if "Linux version" in buffer:
+ proc.terminate()
+ return (True, "\n".join(buffer.split('\n')[-10:]))
+ time.sleep(0.1)
+ proc.terminate()
+ time.sleep(5)
+ if proc.poll() is None:
+ proc.kill()
+ return (False, "\n".join(buffer.split('\n')[-10:]))
+
+ image = "core-image-minimal"
+
+ self.write_config('QEMU_USE_KVM = "1"')
+
+ # generate image and SDK
+ bitbake(f"{image}")
+ bitbake(f"{image} -c populate_sdk")
+
+ # create a temporary destdir to test runqemu from SDK
+ with TemporaryDirectory() as tmpdir:
+ self.logger.debug(f"Created tempdir: {tmpdir}")
+ vars = get_bb_vars(["DEPLOY_DIR_IMAGE", "SDK_DEPLOY", "TOOLCHAIN_OUTPUTNAME", "MACHINE"], image)
+ machine = vars["MACHINE"]
+ image_dir = vars["DEPLOY_DIR_IMAGE"]
+ sdk_path = os.path.join(vars["SDK_DEPLOY"], vars["TOOLCHAIN_OUTPUTNAME"] + ".sh")
+ self.logger.debug(f"machine: {machine}")
+ self.logger.debug(f"image_dir: {image_dir}")
+ self.logger.debug(f"sdk_path: {sdk_path}")
+ dst_image_dir = os.path.join(tmpdir, os.path.basename(image_dir))
+ shutil.copytree(image_dir, dst_image_dir)
+ subprocess.check_call(f"{sdk_path} -d {tmpdir} -y", shell=True)
+ sdk_env = glob.glob(tmpdir + '/environment-setup-*')[0]
+ self.logger.debug(f"sdk_env: {sdk_env}")
+
+ path = path_with_no_bitbake()
+ self.logger.debug(f"path: {path}")
+
+ runqemu_works, output = runqemu_works_from_sdk(tmpdir, sdk_env, machine, path)
+ self.logger.debug(f"runqemu works in SDK: {runqemu_works}\n{output}")
+
+ self.assertTrue(runqemu_works, f"runqemu does not work in SDK\n{output}")
--
2.43.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [OE-core][RFC][PATCH] oeqa/selftest/sdk: add test_sdk_runqemu
2026-02-07 5:13 [OE-core][RFC][PATCH] oeqa/selftest/sdk: add test_sdk_runqemu Qi.Chen
@ 2026-02-09 14:05 ` Alexander Kanavin
2026-02-10 11:37 ` Alexander Kanavin
1 sibling, 0 replies; 6+ messages in thread
From: Alexander Kanavin @ 2026-02-09 14:05 UTC (permalink / raw)
To: Qi.Chen; +Cc: openembedded-core
Thanks for writing this up, I'll get to it once some more pressing
issues are taken care of.
Alex
On Sat, 7 Feb 2026 at 06:13, <Qi.Chen@windriver.com> wrote:
>
> From: Chen Qi <Qi.Chen@windriver.com>
>
> Add test case to ensure runqemu works in SDK.
>
> Using runqemu from SDK has been supported for many years. Add a
> test case to ensure we have no regression.
>
> Signed-off-by: Chen Qi <Qi.Chen@windriver.com>
> ---
> meta/lib/oeqa/selftest/cases/sdk.py | 88 ++++++++++++++++++++++++++++-
> 1 file changed, 87 insertions(+), 1 deletion(-)
>
> diff --git a/meta/lib/oeqa/selftest/cases/sdk.py b/meta/lib/oeqa/selftest/cases/sdk.py
> index 3971365029..ee1e4ca420 100644
> --- a/meta/lib/oeqa/selftest/cases/sdk.py
> +++ b/meta/lib/oeqa/selftest/cases/sdk.py
> @@ -4,7 +4,13 @@
> # SPDX-License-Identifier: MIT
> #
>
> -import os.path
> +import os
> +import shutil
> +import subprocess
> +import glob
> +import time
> +import select
> +from tempfile import TemporaryDirectory
>
> from oeqa.selftest.case import OESelftestTestCase
> from oeqa.utils.commands import bitbake, get_bb_vars
> @@ -37,3 +43,83 @@ IMAGE_INSTALL:append = " selftest-hello"
> path = os.path.join(vars["SDK_DEPLOY"], vars["TOOLCHAIN_OUTPUTNAME"] + ".target.manifest")
> self.assertNotEqual(os.path.getsize(path), 0, msg="Target manifest is empty")
> self.assertIn("selftest-hello", self.load_manifest(path))
> +
> + def test_sdk_runqemu(self):
> + """Test using runqemu from SDK which has no bitbake available"""
> +
> + def path_with_no_bitbake():
> + orig_paths = os.environ["PATH"].split(":")
> + new_paths = []
> + for orig_path in orig_paths:
> + if not os.access(os.path.join(orig_path, "bitbake"), os.X_OK):
> + new_paths.append(orig_path)
> + return ":".join(new_paths)
> +
> + def runqemu_works_from_sdk(sdk_dir, sdk_env, machine, path, timeout=360):
> + env = os.environ.copy()
> + env["PATH"] = path
> +
> + cmd = f'cd {sdk_dir}; . {sdk_env}; runqemu {machine} snapshot slirp nographic'
> + self.logger.info(f"Running {cmd}")
> + proc = subprocess.Popen(
> + ['bash', '-c', cmd],
> + stdout=subprocess.PIPE,
> + stderr=subprocess.STDOUT,
> + text=True,
> + bufsize=1,
> + env=env
> + )
> + buffer = ""
> + start = time.time()
> + while time.time() - start < timeout:
> + if proc.poll() is not None:
> + chunk = proc.stdout.read()
> + if chunk:
> + buffer += chunk
> + return ('Linux version' in buffer, "\n".join(buffer.split('\n')[-10:]))
> + ready, _, _ = select.select([proc.stdout], [], [], 0.1)
> + if ready:
> + chunk = proc.stdout.read(4096)
> + if chunk:
> + buffer += chunk
> + if "Linux version" in buffer:
> + proc.terminate()
> + return (True, "\n".join(buffer.split('\n')[-10:]))
> + time.sleep(0.1)
> + proc.terminate()
> + time.sleep(5)
> + if proc.poll() is None:
> + proc.kill()
> + return (False, "\n".join(buffer.split('\n')[-10:]))
> +
> + image = "core-image-minimal"
> +
> + self.write_config('QEMU_USE_KVM = "1"')
> +
> + # generate image and SDK
> + bitbake(f"{image}")
> + bitbake(f"{image} -c populate_sdk")
> +
> + # create a temporary destdir to test runqemu from SDK
> + with TemporaryDirectory() as tmpdir:
> + self.logger.debug(f"Created tempdir: {tmpdir}")
> + vars = get_bb_vars(["DEPLOY_DIR_IMAGE", "SDK_DEPLOY", "TOOLCHAIN_OUTPUTNAME", "MACHINE"], image)
> + machine = vars["MACHINE"]
> + image_dir = vars["DEPLOY_DIR_IMAGE"]
> + sdk_path = os.path.join(vars["SDK_DEPLOY"], vars["TOOLCHAIN_OUTPUTNAME"] + ".sh")
> + self.logger.debug(f"machine: {machine}")
> + self.logger.debug(f"image_dir: {image_dir}")
> + self.logger.debug(f"sdk_path: {sdk_path}")
> + dst_image_dir = os.path.join(tmpdir, os.path.basename(image_dir))
> + shutil.copytree(image_dir, dst_image_dir)
> + subprocess.check_call(f"{sdk_path} -d {tmpdir} -y", shell=True)
> + sdk_env = glob.glob(tmpdir + '/environment-setup-*')[0]
> + self.logger.debug(f"sdk_env: {sdk_env}")
> +
> + path = path_with_no_bitbake()
> + self.logger.debug(f"path: {path}")
> +
> + runqemu_works, output = runqemu_works_from_sdk(tmpdir, sdk_env, machine, path)
> + self.logger.debug(f"runqemu works in SDK: {runqemu_works}\n{output}")
> +
> + self.assertTrue(runqemu_works, f"runqemu does not work in SDK\n{output}")
> --
> 2.43.0
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [OE-core][RFC][PATCH] oeqa/selftest/sdk: add test_sdk_runqemu
2026-02-07 5:13 [OE-core][RFC][PATCH] oeqa/selftest/sdk: add test_sdk_runqemu Qi.Chen
2026-02-09 14:05 ` Alexander Kanavin
@ 2026-02-10 11:37 ` Alexander Kanavin
2026-02-11 6:11 ` ChenQi
1 sibling, 1 reply; 6+ messages in thread
From: Alexander Kanavin @ 2026-02-10 11:37 UTC (permalink / raw)
To: Qi.Chen; +Cc: openembedded-core
On Sat, 7 Feb 2026 at 06:13, <Qi.Chen@windriver.com> wrote:
> Add test case to ensure runqemu works in SDK.
>
> Using runqemu from SDK has been supported for many years. Add a
> test case to ensure we have no regression.
I set and ran this test. This indeed does not work:
====
alex@Zen2:~$ runqemu qemux86-64 kvm snapshot nographic
runqemu - ERROR - In order for this script to dynamically infer paths
kernels or filesystem images, you either need bitbake in your PATH
or to source oe-init-build-env before running this script.
Dynamic path inference can be avoided by passing a *.qemuboot.conf to
runqemu, i.e. `runqemu /path/to/my-image-name.qemuboot.conf`
Bitbake is needed to run 'MACHINE=qemux86-64 bitbake -e', but it is
not found in PATH. Please source the bitbake build environment.
====
The error makes sense, doesn't it? How would runqemu be able to figure
out where the image it needs to run is on the filesystem if all it has
is MACHINE value? We can try to hardcode something relative to SDK
installation, from some environment variable that SDK sets, but that
would be limiting: in the context of an SDK, images can be downloaded
and located anywhere.
On the other hand, if you pass the path to the image directory to
runqemu, it works perfectly:
====
alex@Zen2:~$ runqemu kvm slirp snapshot
/srv/storage/alex/yocto/build-64/tmp/deploy/images/qemux86-64/
runqemu - INFO - Decompressing
/srv/storage/alex/yocto/build-64/tmp/deploy/images/qemux86-64/core-image-minimal-qemux86-64.rootfs-20260210110409.ext4.zst
to /srv/storage/alex/yocto/build-64/tmp/deploy/images/qemux86-64/core-image-minimal-qemux86-64.rootfs-20260210110409.ext4
/srv/storage/alex/yocto/build-64/tmp/deploy/images/qemux86-64/core-image-minimal-qemux86-64.rootfs-20260210110409.ext4.zst:
43323392 bytes
runqemu - INFO - Continuing with the following parameters:
KERNEL: [/srv/storage/alex/yocto/build-64/tmp/deploy/images/qemux86-64/bzImage]
MACHINE: [qemux86-64]
FSTYPE: [ext4]
ROOTFS: [/srv/storage/alex/yocto/build-64/tmp/deploy/images/qemux86-64/core-image-minimal-qemux86-64.rootfs-20260210110409.ext4]
SNAPSHOT: [Enabled. Changes on rootfs won't be kept after QEMU shutdown.]
CONFFILE: [/srv/storage/alex/yocto/build-64/tmp/deploy/images/qemux86-64/core-image-minimal-qemux86-64.rootfs-20260210110409.qemuboot.conf]
....
====
So would it be okay to set the path to the image directory explicitly?
If you have several images in that directory, then you need to pass
the path to a particular some-image.qemuboot.conf file, and it will
still work:
alex@Zen2:~$ runqemu kvm slirp snapshot
/srv/storage/alex/yocto/build-64/tmp/deploy/images/qemux86-64/core-image-minimal-qemux86-64.rootfs-20260210110409.qemuboot.conf
Alex
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [OE-core][RFC][PATCH] oeqa/selftest/sdk: add test_sdk_runqemu
2026-02-10 11:37 ` Alexander Kanavin
@ 2026-02-11 6:11 ` ChenQi
2026-02-11 13:09 ` Alexander Kanavin
0 siblings, 1 reply; 6+ messages in thread
From: ChenQi @ 2026-02-11 6:11 UTC (permalink / raw)
To: Alexander Kanavin; +Cc: openembedded-core
Hi Alex,
I guess you were still in a bitbake build environment when testing
runqemu in SDK manually.
That's why your command 'runqemu kvm slirp snapshot
/path/to/images/qemux86-64' worked.
See commands and output below (Pure SDK, no bitbake environment):
"""
chenqi@HOST:/buildarea3/chenqi/SDK/Yocto [3][0] $ runqemu kvm snapshot
slirp /buildarea3/chenqi/SDK/Yocto/qemux86-64/
runqemu - ERROR - In order for this script to dynamically infer paths
kernels or filesystem images, you either need bitbake in your PATH
or to source oe-init-build-env before running this script.
Dynamic path inference can be avoided by passing a *.qemuboot.conf to
runqemu, i.e. `runqemu /path/to/my-image-name.qemuboot.conf`
Bitbake is needed to run 'MACHINE=qemux86-64 bitbake -e None', but it
is not found in PATH. Please source the bitbake build environment.
runqemu - INFO - Cleaning up
runqemu - INFO - Host uptime: 16354810.08
chenqi@HOST:/buildarea3/chenqi/SDK/Yocto [3][0] $ runqemu kvm snapshot
slirp
/buildarea3/chenqi/SDK/Yocto/qemux86-64/core-image-minimal-qemux86-64.rootfs.qemuboot.conf
runqemu - ERROR - In order for this script to dynamically infer paths
kernels or filesystem images, you either need bitbake in your PATH
or to source oe-init-build-env before running this script.
Dynamic path inference can be avoided by passing a *.qemuboot.conf to
runqemu, i.e. `runqemu /path/to/my-image-name.qemuboot.conf`
Bitbake is needed to run 'MACHINE=qemux86-64 bitbake -e None', but it
is not found in PATH. Please source the bitbake build environment.
runqemu - INFO - Cleaning up
runqemu - INFO - Host uptime: 16354858.44
chenqi@HOST:/buildarea3/chenqi/SDK/Yocto [3][0] $ which bitbake
chenqi@HOST:/buildarea3/chenqi/SDK/Yocto [3][0] $ echo $?
1
chenqi@HOST:/buildarea3/chenqi/SDK/Yocto [3][0] $ which runqemu
/buildarea3/chenqi/SDK/Yocto/sysroots/x86_64-pokysdk-linux/usr/bin/runqemu
"""
Regards,
Qi
On 2/10/26 19:37, Alexander Kanavin wrote:
> On Sat, 7 Feb 2026 at 06:13, <Qi.Chen@windriver.com> wrote:
>> Add test case to ensure runqemu works in SDK.
>>
>> Using runqemu from SDK has been supported for many years. Add a
>> test case to ensure we have no regression.
> I set and ran this test. This indeed does not work:
>
> ====
> alex@Zen2:~$ runqemu qemux86-64 kvm snapshot nographic
> runqemu - ERROR - In order for this script to dynamically infer paths
> kernels or filesystem images, you either need bitbake in your PATH
> or to source oe-init-build-env before running this script.
>
> Dynamic path inference can be avoided by passing a *.qemuboot.conf to
> runqemu, i.e. `runqemu /path/to/my-image-name.qemuboot.conf`
>
> Bitbake is needed to run 'MACHINE=qemux86-64 bitbake -e', but it is
> not found in PATH. Please source the bitbake build environment.
> ====
>
> The error makes sense, doesn't it? How would runqemu be able to figure
> out where the image it needs to run is on the filesystem if all it has
> is MACHINE value? We can try to hardcode something relative to SDK
> installation, from some environment variable that SDK sets, but that
> would be limiting: in the context of an SDK, images can be downloaded
> and located anywhere.
>
> On the other hand, if you pass the path to the image directory to
> runqemu, it works perfectly:
>
> ====
> alex@Zen2:~$ runqemu kvm slirp snapshot
> /srv/storage/alex/yocto/build-64/tmp/deploy/images/qemux86-64/
> runqemu - INFO - Decompressing
> /srv/storage/alex/yocto/build-64/tmp/deploy/images/qemux86-64/core-image-minimal-qemux86-64.rootfs-20260210110409.ext4.zst
> to /srv/storage/alex/yocto/build-64/tmp/deploy/images/qemux86-64/core-image-minimal-qemux86-64.rootfs-20260210110409.ext4
> /srv/storage/alex/yocto/build-64/tmp/deploy/images/qemux86-64/core-image-minimal-qemux86-64.rootfs-20260210110409.ext4.zst:
> 43323392 bytes
> runqemu - INFO - Continuing with the following parameters:
> KERNEL: [/srv/storage/alex/yocto/build-64/tmp/deploy/images/qemux86-64/bzImage]
> MACHINE: [qemux86-64]
> FSTYPE: [ext4]
> ROOTFS: [/srv/storage/alex/yocto/build-64/tmp/deploy/images/qemux86-64/core-image-minimal-qemux86-64.rootfs-20260210110409.ext4]
> SNAPSHOT: [Enabled. Changes on rootfs won't be kept after QEMU shutdown.]
> CONFFILE: [/srv/storage/alex/yocto/build-64/tmp/deploy/images/qemux86-64/core-image-minimal-qemux86-64.rootfs-20260210110409.qemuboot.conf]
> ....
> ====
>
> So would it be okay to set the path to the image directory explicitly?
> If you have several images in that directory, then you need to pass
> the path to a particular some-image.qemuboot.conf file, and it will
> still work:
>
> alex@Zen2:~$ runqemu kvm slirp snapshot
> /srv/storage/alex/yocto/build-64/tmp/deploy/images/qemux86-64/core-image-minimal-qemux86-64.rootfs-20260210110409.qemuboot.conf
>
> Alex
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [OE-core][RFC][PATCH] oeqa/selftest/sdk: add test_sdk_runqemu
2026-02-11 6:11 ` ChenQi
@ 2026-02-11 13:09 ` Alexander Kanavin
2026-02-12 2:25 ` Chen, Qi
0 siblings, 1 reply; 6+ messages in thread
From: Alexander Kanavin @ 2026-02-11 13:09 UTC (permalink / raw)
To: ChenQi; +Cc: openembedded-core
On Wed, 11 Feb 2026 at 07:11, ChenQi <Qi.Chen@windriver.com> wrote:
> I guess you were still in a bitbake build environment when testing
> runqemu in SDK manually.
> That's why your command 'runqemu kvm slirp snapshot
> /path/to/images/qemux86-64' worked.
Not quite. I provided the path to the original yocto build's deploy
directory, which does work. It stops working if you copy the image
directory to somewhere else.
The issue is that runqemu reads qemuboot.conf in that directory which
hardcodes build-specific paths:
staging_bindir_native =
../../../work/x86_64-linux/qemu-helper-native/1.0/recipe-sysroot-native/usr/bin
staging_dir_host =
../../../work/qemux86_64-poky-linux/core-image-minimal/1.0/recipe-sysroot
staging_dir_native =
../../../work/qemux86_64-poky-linux/core-image-minimal/1.0/recipe-sysroot-native
tune_arch = x86_64
uninative_loader =
../../../sysroots-uninative/x86_64-linux/lib/ld-linux-x86-64.so.2
Then the code checks them for existence, and tries to obtain them from
bitbake if they don't exist:
# If the STAGING_*_NATIVE directories from the config file don't exist
# and we're in a sourced OE build directory try to extract the paths
# from `bitbake -e`
havenative = os.path.exists(self.get('STAGING_DIR_NATIVE')) and \
os.path.exists(self.get('STAGING_BINDIR_NATIVE'))
if not havenative:
if not self.bitbake_e:
self.load_bitbake_env()
native_vars = ['STAGING_DIR_NATIVE']
for nv in native_vars:
s = re.search('^%s="(.*)"' % nv, self.bitbake_e, re.M)
if s and s.group(1) != self.get(nv):
logger.info('Overriding conf file setting of %s to
%s from Bitbake environment' % (nv, s.group(1)))
self.set(nv, s.group(1))
The above code indeed doesn't make sense: it gets STAGING_DIR_NATIVE
from bitbake (if bitbake is present), but then STAGING_DIR_NATIVE is
not used anywhere!
So going back to your proposed fix, is it possible to replace the
above sequence with something like this?
if not os.path.exists(self.get('STAGING_BINDIR_NATIVE')):
logger.info('tell what is happening')
if OECORE_NATIVE_SYSROOT is set:
set STAGING_BINDIR_NATIVE from OECORE_NATIVE_SYSROOT + '/usr/bin'
logger.info('tell what is happening')
else:
set STAGING_BINDIR_NATIVE from bitbake -e
This should cover all use cases:
- yocto or sdk environment or no environment at all, with image in
deploy directory (qemuboot.conf paths are valid)
- sdk environment with image in any directory (will set paths from
OECORE_NATIVE_SYSROOT)
- yocto environment with image in any directory (will ask bitbake -e for paths)
That way we can avoid reverting changes to run_bitbake_env: it should
either succeed or raise an error, and not just return nothing, as that
hides actual issues.
Alex
> See commands and output below (Pure SDK, no bitbake environment):
> """
> chenqi@HOST:/buildarea3/chenqi/SDK/Yocto [3][0] $ runqemu kvm snapshot
> slirp /buildarea3/chenqi/SDK/Yocto/qemux86-64/
> runqemu - ERROR - In order for this script to dynamically infer paths
> kernels or filesystem images, you either need bitbake in your PATH
> or to source oe-init-build-env before running this script.
>
> Dynamic path inference can be avoided by passing a *.qemuboot.conf to
> runqemu, i.e. `runqemu /path/to/my-image-name.qemuboot.conf`
>
> Bitbake is needed to run 'MACHINE=qemux86-64 bitbake -e None', but it
> is not found in PATH. Please source the bitbake build environment.
> runqemu - INFO - Cleaning up
> runqemu - INFO - Host uptime: 16354810.08
>
> chenqi@HOST:/buildarea3/chenqi/SDK/Yocto [3][0] $ runqemu kvm snapshot
> slirp
> /buildarea3/chenqi/SDK/Yocto/qemux86-64/core-image-minimal-qemux86-64.rootfs.qemuboot.conf
>
> runqemu - ERROR - In order for this script to dynamically infer paths
> kernels or filesystem images, you either need bitbake in your PATH
> or to source oe-init-build-env before running this script.
>
> Dynamic path inference can be avoided by passing a *.qemuboot.conf to
> runqemu, i.e. `runqemu /path/to/my-image-name.qemuboot.conf`
>
> Bitbake is needed to run 'MACHINE=qemux86-64 bitbake -e None', but it
> is not found in PATH. Please source the bitbake build environment.
> runqemu - INFO - Cleaning up
> runqemu - INFO - Host uptime: 16354858.44
>
> chenqi@HOST:/buildarea3/chenqi/SDK/Yocto [3][0] $ which bitbake
> chenqi@HOST:/buildarea3/chenqi/SDK/Yocto [3][0] $ echo $?
> 1
> chenqi@HOST:/buildarea3/chenqi/SDK/Yocto [3][0] $ which runqemu
> /buildarea3/chenqi/SDK/Yocto/sysroots/x86_64-pokysdk-linux/usr/bin/runqemu
> """
>
> Regards,
> Qi
>
> On 2/10/26 19:37, Alexander Kanavin wrote:
> > On Sat, 7 Feb 2026 at 06:13, <Qi.Chen@windriver.com> wrote:
> >> Add test case to ensure runqemu works in SDK.
> >>
> >> Using runqemu from SDK has been supported for many years. Add a
> >> test case to ensure we have no regression.
> > I set and ran this test. This indeed does not work:
> >
> > ====
> > alex@Zen2:~$ runqemu qemux86-64 kvm snapshot nographic
> > runqemu - ERROR - In order for this script to dynamically infer paths
> > kernels or filesystem images, you either need bitbake in your PATH
> > or to source oe-init-build-env before running this script.
> >
> > Dynamic path inference can be avoided by passing a *.qemuboot.conf to
> > runqemu, i.e. `runqemu /path/to/my-image-name.qemuboot.conf`
> >
> > Bitbake is needed to run 'MACHINE=qemux86-64 bitbake -e', but it is
> > not found in PATH. Please source the bitbake build environment.
> > ====
> >
> > The error makes sense, doesn't it? How would runqemu be able to figure
> > out where the image it needs to run is on the filesystem if all it has
> > is MACHINE value? We can try to hardcode something relative to SDK
> > installation, from some environment variable that SDK sets, but that
> > would be limiting: in the context of an SDK, images can be downloaded
> > and located anywhere.
> >
> > On the other hand, if you pass the path to the image directory to
> > runqemu, it works perfectly:
> >
> > ====
> > alex@Zen2:~$ runqemu kvm slirp snapshot
> > /srv/storage/alex/yocto/build-64/tmp/deploy/images/qemux86-64/
> > runqemu - INFO - Decompressing
> > /srv/storage/alex/yocto/build-64/tmp/deploy/images/qemux86-64/core-image-minimal-qemux86-64.rootfs-20260210110409.ext4.zst
> > to /srv/storage/alex/yocto/build-64/tmp/deploy/images/qemux86-64/core-image-minimal-qemux86-64.rootfs-20260210110409.ext4
> > /srv/storage/alex/yocto/build-64/tmp/deploy/images/qemux86-64/core-image-minimal-qemux86-64.rootfs-20260210110409.ext4.zst:
> > 43323392 bytes
> > runqemu - INFO - Continuing with the following parameters:
> > KERNEL: [/srv/storage/alex/yocto/build-64/tmp/deploy/images/qemux86-64/bzImage]
> > MACHINE: [qemux86-64]
> > FSTYPE: [ext4]
> > ROOTFS: [/srv/storage/alex/yocto/build-64/tmp/deploy/images/qemux86-64/core-image-minimal-qemux86-64.rootfs-20260210110409.ext4]
> > SNAPSHOT: [Enabled. Changes on rootfs won't be kept after QEMU shutdown.]
> > CONFFILE: [/srv/storage/alex/yocto/build-64/tmp/deploy/images/qemux86-64/core-image-minimal-qemux86-64.rootfs-20260210110409.qemuboot.conf]
> > ....
> > ====
> >
> > So would it be okay to set the path to the image directory explicitly?
> > If you have several images in that directory, then you need to pass
> > the path to a particular some-image.qemuboot.conf file, and it will
> > still work:
> >
> > alex@Zen2:~$ runqemu kvm slirp snapshot
> > /srv/storage/alex/yocto/build-64/tmp/deploy/images/qemux86-64/core-image-minimal-qemux86-64.rootfs-20260210110409.qemuboot.conf
> >
> > Alex
>
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* RE: [OE-core][RFC][PATCH] oeqa/selftest/sdk: add test_sdk_runqemu
2026-02-11 13:09 ` Alexander Kanavin
@ 2026-02-12 2:25 ` Chen, Qi
0 siblings, 0 replies; 6+ messages in thread
From: Chen, Qi @ 2026-02-12 2:25 UTC (permalink / raw)
To: Alexander Kanavin; +Cc: openembedded-core@lists.openembedded.org
Hi Alex,
Thanks for checking the codes and providing advice. I think your solution will work.
I'll try it out after Chinese New Year vacation.
Regards,
Qi
-----Original Message-----
From: Alexander Kanavin <alex.kanavin@gmail.com>
Sent: Wednesday, February 11, 2026 9:09 PM
To: Chen, Qi <Qi.Chen@windriver.com>
Cc: openembedded-core@lists.openembedded.org
Subject: Re: [OE-core][RFC][PATCH] oeqa/selftest/sdk: add test_sdk_runqemu
On Wed, 11 Feb 2026 at 07:11, ChenQi <Qi.Chen@windriver.com> wrote:
> I guess you were still in a bitbake build environment when testing
> runqemu in SDK manually.
> That's why your command 'runqemu kvm slirp snapshot
> /path/to/images/qemux86-64' worked.
Not quite. I provided the path to the original yocto build's deploy directory, which does work. It stops working if you copy the image directory to somewhere else.
The issue is that runqemu reads qemuboot.conf in that directory which hardcodes build-specific paths:
staging_bindir_native =
../../../work/x86_64-linux/qemu-helper-native/1.0/recipe-sysroot-native/usr/bin
staging_dir_host =
../../../work/qemux86_64-poky-linux/core-image-minimal/1.0/recipe-sysroot
staging_dir_native =
../../../work/qemux86_64-poky-linux/core-image-minimal/1.0/recipe-sysroot-native
tune_arch = x86_64
uninative_loader =
../../../sysroots-uninative/x86_64-linux/lib/ld-linux-x86-64.so.2
Then the code checks them for existence, and tries to obtain them from bitbake if they don't exist:
# If the STAGING_*_NATIVE directories from the config file don't exist
# and we're in a sourced OE build directory try to extract the paths
# from `bitbake -e`
havenative = os.path.exists(self.get('STAGING_DIR_NATIVE')) and \
os.path.exists(self.get('STAGING_BINDIR_NATIVE'))
if not havenative:
if not self.bitbake_e:
self.load_bitbake_env()
native_vars = ['STAGING_DIR_NATIVE']
for nv in native_vars:
s = re.search('^%s="(.*)"' % nv, self.bitbake_e, re.M)
if s and s.group(1) != self.get(nv):
logger.info('Overriding conf file setting of %s to %s from Bitbake environment' % (nv, s.group(1)))
self.set(nv, s.group(1))
The above code indeed doesn't make sense: it gets STAGING_DIR_NATIVE from bitbake (if bitbake is present), but then STAGING_DIR_NATIVE is not used anywhere!
So going back to your proposed fix, is it possible to replace the above sequence with something like this?
if not os.path.exists(self.get('STAGING_BINDIR_NATIVE')):
logger.info('tell what is happening')
if OECORE_NATIVE_SYSROOT is set:
set STAGING_BINDIR_NATIVE from OECORE_NATIVE_SYSROOT + '/usr/bin'
logger.info('tell what is happening')
else:
set STAGING_BINDIR_NATIVE from bitbake -e
This should cover all use cases:
- yocto or sdk environment or no environment at all, with image in deploy directory (qemuboot.conf paths are valid)
- sdk environment with image in any directory (will set paths from
OECORE_NATIVE_SYSROOT)
- yocto environment with image in any directory (will ask bitbake -e for paths)
That way we can avoid reverting changes to run_bitbake_env: it should either succeed or raise an error, and not just return nothing, as that hides actual issues.
Alex
> See commands and output below (Pure SDK, no bitbake environment):
> """
> chenqi@HOST:/buildarea3/chenqi/SDK/Yocto [3][0] $ runqemu kvm snapshot
> slirp /buildarea3/chenqi/SDK/Yocto/qemux86-64/
> runqemu - ERROR - In order for this script to dynamically infer paths
> kernels or filesystem images, you either need bitbake in your PATH
> or to source oe-init-build-env before running this script.
>
> Dynamic path inference can be avoided by passing a *.qemuboot.conf to
> runqemu, i.e. `runqemu /path/to/my-image-name.qemuboot.conf`
>
> Bitbake is needed to run 'MACHINE=qemux86-64 bitbake -e None', but
> it is not found in PATH. Please source the bitbake build environment.
> runqemu - INFO - Cleaning up
> runqemu - INFO - Host uptime: 16354810.08
>
> chenqi@HOST:/buildarea3/chenqi/SDK/Yocto [3][0] $ runqemu kvm snapshot
> slirp
> /buildarea3/chenqi/SDK/Yocto/qemux86-64/core-image-minimal-qemux86-64.
> rootfs.qemuboot.conf
>
> runqemu - ERROR - In order for this script to dynamically infer paths
> kernels or filesystem images, you either need bitbake in your PATH
> or to source oe-init-build-env before running this script.
>
> Dynamic path inference can be avoided by passing a *.qemuboot.conf to
> runqemu, i.e. `runqemu /path/to/my-image-name.qemuboot.conf`
>
> Bitbake is needed to run 'MACHINE=qemux86-64 bitbake -e None', but
> it is not found in PATH. Please source the bitbake build environment.
> runqemu - INFO - Cleaning up
> runqemu - INFO - Host uptime: 16354858.44
>
> chenqi@HOST:/buildarea3/chenqi/SDK/Yocto [3][0] $ which bitbake
> chenqi@HOST:/buildarea3/chenqi/SDK/Yocto [3][0] $ echo $?
> 1
> chenqi@HOST:/buildarea3/chenqi/SDK/Yocto [3][0] $ which runqemu
> /buildarea3/chenqi/SDK/Yocto/sysroots/x86_64-pokysdk-linux/usr/bin/run
> qemu
> """
>
> Regards,
> Qi
>
> On 2/10/26 19:37, Alexander Kanavin wrote:
> > On Sat, 7 Feb 2026 at 06:13, <Qi.Chen@windriver.com> wrote:
> >> Add test case to ensure runqemu works in SDK.
> >>
> >> Using runqemu from SDK has been supported for many years. Add a
> >> test case to ensure we have no regression.
> > I set and ran this test. This indeed does not work:
> >
> > ====
> > alex@Zen2:~$ runqemu qemux86-64 kvm snapshot nographic runqemu -
> > ERROR - In order for this script to dynamically infer paths
> > kernels or filesystem images, you either need bitbake in your PATH
> > or to source oe-init-build-env before running this script.
> >
> > Dynamic path inference can be avoided by passing a *.qemuboot.conf to
> > runqemu, i.e. `runqemu /path/to/my-image-name.qemuboot.conf`
> >
> > Bitbake is needed to run 'MACHINE=qemux86-64 bitbake -e', but it
> > is not found in PATH. Please source the bitbake build environment.
> > ====
> >
> > The error makes sense, doesn't it? How would runqemu be able to
> > figure out where the image it needs to run is on the filesystem if
> > all it has is MACHINE value? We can try to hardcode something
> > relative to SDK installation, from some environment variable that
> > SDK sets, but that would be limiting: in the context of an SDK,
> > images can be downloaded and located anywhere.
> >
> > On the other hand, if you pass the path to the image directory to
> > runqemu, it works perfectly:
> >
> > ====
> > alex@Zen2:~$ runqemu kvm slirp snapshot
> > /srv/storage/alex/yocto/build-64/tmp/deploy/images/qemux86-64/
> > runqemu - INFO - Decompressing
> > /srv/storage/alex/yocto/build-64/tmp/deploy/images/qemux86-64/core-i
> > mage-minimal-qemux86-64.rootfs-20260210110409.ext4.zst
> > to
> > /srv/storage/alex/yocto/build-64/tmp/deploy/images/qemux86-64/core-i
> > mage-minimal-qemux86-64.rootfs-20260210110409.ext4
> > /srv/storage/alex/yocto/build-64/tmp/deploy/images/qemux86-64/core-image-minimal-qemux86-64.rootfs-20260210110409.ext4.zst:
> > 43323392 bytes
> > runqemu - INFO - Continuing with the following parameters:
> > KERNEL:
> > [/srv/storage/alex/yocto/build-64/tmp/deploy/images/qemux86-64/bzIma
> > ge]
> > MACHINE: [qemux86-64]
> > FSTYPE: [ext4]
> > ROOTFS:
> > [/srv/storage/alex/yocto/build-64/tmp/deploy/images/qemux86-64/core-
> > image-minimal-qemux86-64.rootfs-20260210110409.ext4]
> > SNAPSHOT: [Enabled. Changes on rootfs won't be kept after QEMU
> > shutdown.]
> > CONFFILE:
> > [/srv/storage/alex/yocto/build-64/tmp/deploy/images/qemux86-64/core-
> > image-minimal-qemux86-64.rootfs-20260210110409.qemuboot.conf]
> > ....
> > ====
> >
> > So would it be okay to set the path to the image directory explicitly?
> > If you have several images in that directory, then you need to pass
> > the path to a particular some-image.qemuboot.conf file, and it will
> > still work:
> >
> > alex@Zen2:~$ runqemu kvm slirp snapshot
> > /srv/storage/alex/yocto/build-64/tmp/deploy/images/qemux86-64/core-i
> > mage-minimal-qemux86-64.rootfs-20260210110409.qemuboot.conf
> >
> > Alex
>
>
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2026-02-12 2:25 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-02-07 5:13 [OE-core][RFC][PATCH] oeqa/selftest/sdk: add test_sdk_runqemu Qi.Chen
2026-02-09 14:05 ` Alexander Kanavin
2026-02-10 11:37 ` Alexander Kanavin
2026-02-11 6:11 ` ChenQi
2026-02-11 13:09 ` Alexander Kanavin
2026-02-12 2:25 ` Chen, Qi
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox