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 <[email protected]> Sent: Wednesday, February 11, 2026 9:09 PM To: Chen, Qi <[email protected]> Cc: [email protected] Subject: Re: [OE-core][RFC][PATCH] oeqa/selftest/sdk: add test_sdk_runqemu On Wed, 11 Feb 2026 at 07:11, ChenQi <[email protected]> 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, <[email protected]> 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 > >
-=-=-=-=-=-=-=-=-=-=-=- Links: You receive all messages sent to this group. View/Reply Online (#231003): https://lists.openembedded.org/g/openembedded-core/message/231003 Mute This Topic: https://lists.openembedded.org/mt/117685113/21656 Group Owner: [email protected] Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [[email protected]] -=-=-=-=-=-=-=-=-=-=-=-
