<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugzilla.yoctoproject.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.6"
          urlbase="https://bugzilla.yoctoproject.org/"
          
          maintainer="it-coreprojects-helpdesk@linuxfoundation.org"
>

    <bug>
          <bug_id>14748</bug_id>
          
          <creation_ts>2022-03-01 18:29:09 +0000</creation_ts>
          <short_desc>runqemu can&apos;t pick bundled initramfs image</short_desc>
          <delta_ts>2022-12-21 15:43:34 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>7</classification_id>
          <classification>Build System, Metadata &amp; Runtime</classification>
          <product>OE-Core</product>
          <component>Scripts and Tools</component>
          <version>unspecified</version>
          <rep_platform>x86</rep_platform>
          <op_sys>Multiple</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>Medium+</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>4.2 M2</target_milestone>
          
          <blocked>14749</blocked>
          <everconfirmed>1</everconfirmed>
          <reporter name="Alejandro">alejandro</reporter>
          <assigned_to name="Jagadeesh Krishnanjanappa">workjagadeesh</assigned_to>
          <cc>pavel</cc>
    
    <cc>randy.macleod</cc>
    
    <cc>ross.burton</cc>
    
    <cc>workjagadeesh</cc>
          
          
          <cf_os>---</cf_os>
          <cf_regression_type>---</cf_regression_type>
          
          <cf_docchange>Don&apos;t know</cf_docchange>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>92696</commentid>
    <comment_count>0</comment_count>
    <who name="Alejandro">alejandro</who>
    <bug_when>2022-03-01 18:29:09 +0000</bug_when>
    <thetext>When setting:

INITRAMFS_IMAGE = &quot;core-image-minimal-initramfs&quot;                                                                                           
INITRAMFS_IMAGE_BUNDLE= &quot;1&quot;

Two kernel images are created: Image-initramfs--foo and Image--foo

The Image is the default kernel (without initramfs) and the Image-initramfs contains a bundled initramfs in it.

However, after building an image with such conf, runqemu still picks the Image by default booting in a different flow than the one the user selected.

One has to manually pass the Image-initramfs file to runqemu so it boots properly, this should be done automatically by runqemu when INITRAMFS_IMAGE_BUNDLE= &quot;1&quot;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>93030</commentid>
    <comment_count>1</comment_count>
      <attachid>4857</attachid>
    <who name="Jagadeesh Krishnanjanappa">workjagadeesh</who>
    <bug_when>2022-04-13 14:36:16 +0000</bug_when>
    <thetext>Created attachment 4857
runqemu to boot bundled initramfs kernel image</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>93031</commentid>
    <comment_count>2</comment_count>
    <who name="Jagadeesh Krishnanjanappa">workjagadeesh</who>
    <bug_when>2022-04-13 14:37:40 +0000</bug_when>
    <thetext>The attached patch ([runqemu_14748.patch|https://bugzilla.yoctoproject.org/attachment.cgi?id=4857&amp;action=diff]) picks the bundled initramfs kernel image (e.g., Image-initramfs-qemux86-64.bin) if INITRAMFS_IMAGE_BUNDLE is set to 1 in config files.

Let me know if this fixes the issue. If yes, then I will submit for review/commit.

Regards,
Jagadeesh</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>93097</commentid>
    <comment_count>3</comment_count>
    <who name="Jagadeesh Krishnanjanappa">workjagadeesh</who>
    <bug_when>2022-04-16 03:59:00 +0000</bug_when>
    <thetext>Hi Alejandro,

By any chance did you try the attached patch?

Regards,
Jagadeesh</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>94251</commentid>
    <comment_count>4</comment_count>
    <who name="Randy MacLeod">randy.macleod</who>
    <bug_when>2022-10-27 13:57:59 +0000</bug_when>
    <thetext> Alejandro, By any chance did you try the attached patch?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>94505</commentid>
    <comment_count>5</comment_count>
    <who name="Randy MacLeod">randy.macleod</who>
    <bug_when>2022-12-08 16:10:52 +0000</bug_when>
    <thetext>Pavel is going to check the patch.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>94508</commentid>
    <comment_count>6</comment_count>
    <who name="Alejandro">alejandro</who>
    <bug_when>2022-12-08 18:29:42 +0000</bug_when>
    <thetext>To give some context:
- No the provided patch doesnt work.

- The patch successfully sets QB_DEFAULT_KERNEL (although it has an extra .bin in it), and this QB_DEFAULT_KERNEL variable is written properly to the qemuboot.conf file, e.g.:

```
[config_bsp]                                                                                         
deploy_dir_image = .                                                                                 
image_link_name = core-image-minimal-qemuarm64                                                       
image_name = core-image-minimal-qemuarm64-20221129175938                                             
kernel_imagetype = Image                                                                             
machine = qemuarm64                                                                                                     
qb_default_fstype = ext4                                                                             
qb_default_kernel = Image-initramfs-qemuarm64
```

However, `runqemu` does not seem to pick up the kernel using QB_DEFAULT_KERNEL

```
$ runqemu nographic
runqemu - INFO - Running bitbake -e ...
runqemu - INFO - Continuing with the following parameters:
KERNEL: builds/qemuarm64/tmp/deploy/images/qemuarm64/Image]
MACHINE: [qemuarm64]
```

It seems that runqemu specifically grabs the KERNEL_IMAGETYPE variable while starting up:

kernel_match_name = &quot;%s/%s&quot; % (deploy_dir_image, kernel_name)                            
kernel_match_link = &quot;%s/%s&quot; % (deploy_dir_image, self.get(&apos;KERNEL_IMAGETYPE&apos;))                       kernel_startswith = &quot;%s/%s*&quot; % (deploy_dir_image, self.get(&apos;KERNEL_IMAGETYPE&apos;))          
cmds = (kernel_match_name, kernel_match_link, kernel_startswith)
self.kernel = get_first_file(cmds)


The problem is actually that get_first_file function call:
It makes a choice between:
- Image-initramfs-qemuarm64
- Image
- Image*

Since the Image file exists as well, it prefers to use that one instead of Image-initramfs-&lt;machine&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>94511</commentid>
    <comment_count>7</comment_count>
    <who name="Jagadeesh Krishnanjanappa">workjagadeesh</who>
    <bug_when>2022-12-10 03:35:40 +0000</bug_when>
    <thetext>Just want to add clarifications on the previous pacth.

For qemux86-64, after applying the patch I added the following lines
in the conf/local.conf file and built the Linux kernel recipe.

INITRAMFS_IMAGE = &quot;core-image-minimal-initramfs&quot;                                      
IMAGE_FSTYPES:append = &quot; ext4&quot;
INITRAMFS_IMAGE_BUNDLE= &quot;1&quot;


Ran &quot;runqemu nographic&quot; and verified that the runqemu script 
is picking the initramfs bzImage while booting.
---
runqemu - INFO - Running bitbake -e ...
runqemu - INFO - Continuing with the following parameters:
KERNEL: [.../poky_master/build/tmp/deploy/images/qemux86-64/bzImage-initramfs-qemux86-64.bin]
MACHINE: [qemux86-64]
FSTYPE: [ext4]
ROOTFS: [.../poky_master/build/tmp/deploy/images/qemux86-64/core-image-minimal-initramfs-qemux86-64-20221210031718.ext4]
CONFFILE: [.../poky_master/build/tmp/deploy/images/qemux86-64/core-image-minimal-initramfs-qemux86-64-20221210031718.qemuboot.conf]
--

Also, in the check_kernel() function, the get_first_file() is
called with the following 3 arguments at line 744, and get_first_file() takes
the file that is first found.


 732         # QB_DEFAULT_KERNEL is always a full file path
 733         kernel_name = os.path.basename(self.get(&apos;QB_DEFAULT_KERNEL&apos;))
 734
 735         # The user didn&apos;t want a kernel to be loaded
 736         if kernel_name == &quot;none&quot; and not self.kernel:
 737             return
 738
 739         deploy_dir_image = self.get(&apos;DEPLOY_DIR_IMAGE&apos;)
 740         if not self.kernel:
 741             kernel_match_name = &quot;%s/%s&quot; % (deploy_dir_image, kernel_name)
 742             kernel_match_link = &quot;%s/%s&quot; % (deploy_dir_image, self.get(&apos;KERNEL_IMA     GETYPE&apos;))
 743             kernel_startswith = &quot;%s/%s*&quot; % (deploy_dir_image, self.get(&apos;KERNEL_IM     AGETYPE&apos;))
 744             cmds = (kernel_match_name, kernel_match_link, kernel_startswith)
 745             self.kernel = get_first_file(cmds)

In line 741 kernel_name is assigned with QB_DEFAULT_KERNEL value that is
${KERNEL_IMAGETYPE}-${INITRAMFS_LINK_NAME}.bin (bzImage-initramfs-qemux86-64.bin).

The above information is found for qemux86-64 and I am yet to try qemuarm64.

Regards,
Jagadeesh</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>94513</commentid>
    <comment_count>8</comment_count>
    <who name="Jagadeesh Krishnanjanappa">workjagadeesh</who>
    <bug_when>2022-12-11 14:18:07 +0000</bug_when>
    <thetext>Same behavior is observed with qemuarm64.

-- snip --
runqemu - INFO - Running bitbake -e ...
runqemu - INFO - Continuing with the following parameters:
KERNEL: [.../poky_master/build/tmp/deploy/images/qemuarm64/Image-initramfs-qemuarm64.bin]
MACHINE: [qemuarm64]
FSTYPE: [ext4]
ROOTFS: [.../poky_master/build/tmp/deploy/images/qemuarm64/core-image-minimal-initramfs-qemuarm64-20221210164439.ext4]
CONFFILE: [.../poky_master/build/tmp/deploy/images/qemuarm64/core-image-minimal-initramfs-qemuarm64-20221210164439.qemuboot.conf]

-- snip --

Regards,
Jagadeesh</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>94515</commentid>
    <comment_count>9</comment_count>
    <who name="Alejandro">alejandro</who>
    <bug_when>2022-12-12 17:23:16 +0000</bug_when>
    <thetext>I just tested this again and it seems that you are right, I think the confusing part was the extra &quot;.bin&quot; which is inconsistent between the Image link and the Image-initramfs link (the Image link doesnt have it, but the Image-initramfs link does), either way I had manually removed that from the patch and all the flow was exactly the same, the only difference was the the get_first_file() function wouldn&apos;t return the Image-initramfs link (since it needed the .bin)

It seems to be working for me, I apologize for the confusion:
$ runqemu nographic                                                                                                                 runqemu - INFO - Running bitbake -e ...
runqemu - INFO - Continuing with the following parameters:
KERNEL: [poky/builds/qemuarm64/tmp/deploy/images/qemuarm64/Image-initramfs-qemuarm64.bin]
MACHINE: [qemuarm64]
FSTYPE: [ext4]
ROOTFS: [poky/builds/qemuarm64/tmp/deploy/images/qemuarm64/core-image-minimal-qemuarm64-20221212171948.rootfs.ext4]</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>94523</commentid>
    <comment_count>10</comment_count>
    <who name="Jagadeesh Krishnanjanappa">workjagadeesh</who>
    <bug_when>2022-12-13 15:04:22 +0000</bug_when>
    <thetext>Taking the bug.

Alejandro,

No worries.

I just pushed the patch for review and merge in the OE-core mailing list.

Regards,
Jagadeesh</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>94524</commentid>
    <comment_count>11</comment_count>
    <who name="Jagadeesh Krishnanjanappa">workjagadeesh</who>
    <bug_when>2022-12-13 15:05:29 +0000</bug_when>
    <thetext>patchwork link: https://patchwork.yoctoproject.org/project/oe-core/patch/20221213145836.326-1-workjagadeesh@gmail.com/</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>94563</commentid>
    <comment_count>12</comment_count>
    <who name="Jagadeesh Krishnanjanappa">workjagadeesh</who>
    <bug_when>2022-12-21 15:43:34 +0000</bug_when>
    <thetext>Should be resolved with https://git.openembedded.org/openembedded-core/commit/?h=master-next&amp;id=52371624313184e1a825519160c3833e282df8b9

Thanks,
Jagadeesh</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="1"
              isprivate="0"
          >
            <attachid>4857</attachid>
            <date>2022-04-13 14:36:16 +0000</date>
            <delta_ts>2022-04-13 14:36:16 +0000</delta_ts>
            <desc>runqemu to boot bundled initramfs kernel image</desc>
            <filename>runqemu_14748.patch</filename>
            <type>text/plain</type>
            <size>970</size>
            <attacher name="Jagadeesh Krishnanjanappa">workjagadeesh</attacher>
            
              <data encoding="base64">ZGlmZiAtLWdpdCBhL21ldGEvY2xhc3Nlcy9xZW11Ym9vdC5iYmNsYXNzIGIvbWV0YS9jbGFzc2Vz
L3FlbXVib290LmJiY2xhc3MKaW5kZXggYWQ4NDg5OTAyYS4uZjJlYmU5NGNhNCAxMDA2NDQKLS0t
IGEvbWV0YS9jbGFzc2VzL3FlbXVib290LmJiY2xhc3MKKysrIGIvbWV0YS9jbGFzc2VzL3FlbXVi
b290LmJiY2xhc3MKQEAgLTcsNiArNyw3IEBACiAjIFFCX09QVF9BUFBFTkQ6IG9wdGlvbnMgdG8g
Y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