[v4] wic/plugins: gate root= with rootdev check for efi, pcbios and partition

Message ID 20260528063812.2024923-1-gouravsingh@siemens.com
State Under Review
Headers show
Series [v4] wic/plugins: gate root= with rootdev check for efi, pcbios and partition | expand

Commit Message

Gourav Singh May 28, 2026, 6:38 a.m. UTC
Checks for creator.rootdev (or cr.rootdev) being None were missing
and would cause the kernel command line to contain "root=None". When
using the Discoverable Partitions Specification, no root= parameter
should appear on the kernel command line, as root=None is not valid.

This fix mirrors the same change applied to the upstream wic plugins:
https://lists.yoctoproject.org/g/yocto-patches/topic/wic_patch_v2_wic_plugins/119493445

Signed-off-by: Cedric Hombourger <cedric.hombourger@siemens.com>
Signed-off-by: Gourav Singh <gouravsingh@siemens.com>
---
 .../wic/plugins/source/bootimg-efi-isar.py    |  7 ++++---
 .../wic/plugins/source/bootimg-pcbios-isar.py | 20 ++++++++++++++-----
 scripts/lib/wic/plugins/source/bootimg-efi.py |  7 ++++---
 .../wic/plugins/source/bootimg-partition.py   | 11 ++++++++--
 .../lib/wic/plugins/source/bootimg-pcbios.py  | 10 ++++++++--
 5 files changed, 40 insertions(+), 15 deletions(-)

--
2.39.5

Comments

Jan Kiszka May 28, 2026, 6:59 a.m. UTC | #1
On 28.05.26 08:38, Gourav Singh wrote:
> Checks for creator.rootdev (or cr.rootdev) being None were missing
> and would cause the kernel command line to contain "root=None". When
> using the Discoverable Partitions Specification, no root= parameter
> should appear on the kernel command line, as root=None is not valid.
> 
> This fix mirrors the same change applied to the upstream wic plugins:
> https://lists.yoctoproject.org/g/yocto-patches/topic/wic_patch_v2_wic_plugins/119493445

I would recommend to split the upstream changes from the isar-only bits,
first bumping our imported wic bits to a well-definied upstream
revision, then adding what is needed to our forks.

Jan

> 
> Signed-off-by: Cedric Hombourger <cedric.hombourger@siemens.com>
> Signed-off-by: Gourav Singh <gouravsingh@siemens.com>
> ---
>  .../wic/plugins/source/bootimg-efi-isar.py    |  7 ++++---
>  .../wic/plugins/source/bootimg-pcbios-isar.py | 20 ++++++++++++++-----
>  scripts/lib/wic/plugins/source/bootimg-efi.py |  7 ++++---
>  .../wic/plugins/source/bootimg-partition.py   | 11 ++++++++--
>  .../lib/wic/plugins/source/bootimg-pcbios.py  | 10 ++++++++--
>  5 files changed, 40 insertions(+), 15 deletions(-)
> 
> diff --git a/meta/scripts/lib/wic/plugins/source/bootimg-efi-isar.py b/meta/scripts/lib/wic/plugins/source/bootimg-efi-isar.py
> index 6bc78d42..28b6af63 100644
> --- a/meta/scripts/lib/wic/plugins/source/bootimg-efi-isar.py
> +++ b/meta/scripts/lib/wic/plugins/source/bootimg-efi-isar.py
> @@ -104,7 +104,7 @@ class BootimgEFIPlugin(SourcePlugin):
>                          (get_bitbake_var("KERNEL_IMAGETYPE"), get_bitbake_var("INITRAMFS_LINK_NAME"))
> 
>              label = source_params.get('label')
> -            label_conf = "root=%s" % creator.rootdev
> +            label_conf = "root=%s" % creator.rootdev if creator.rootdev else ""
>              if label:
>                  label_conf = "LABEL=%s" % label
> 
> @@ -201,7 +201,8 @@ class BootimgEFIPlugin(SourcePlugin):
>              boot_conf += "linux /%s\n" % kernel
> 
>              label = source_params.get('label')
> -            label_conf = "LABEL=Boot root=%s" % creator.rootdev
> +            label_conf = "LABEL=Boot"
> +            label_conf += (" root=%s" % creator.rootdev) if creator.rootdev else ""
>              if label:
>                  label_conf = "LABEL=%s" % label
> 
> @@ -366,7 +367,7 @@ class BootimgEFIPlugin(SourcePlugin):
> 
>              with tempfile.TemporaryDirectory() as tmp_dir:
>                  label = source_params.get('label')
> -                label_conf = "root=%s" % creator.rootdev
> +                label_conf = "root=%s" % creator.rootdev if creator.rootdev else ""
>                  if label:
>                      label_conf = "LABEL=%s" % label
> 
> diff --git a/meta/scripts/lib/wic/plugins/source/bootimg-pcbios-isar.py b/meta/scripts/lib/wic/plugins/source/bootimg-pcbios-isar.py
> index d5040b72..bb126df8 100644
> --- a/meta/scripts/lib/wic/plugins/source/bootimg-pcbios-isar.py
> +++ b/meta/scripts/lib/wic/plugins/source/bootimg-pcbios-isar.py
> @@ -140,14 +140,24 @@ class BootimgPcbiosIsarPlugin(SourcePlugin):
> 
>              syslinux_conf += "KERNEL " + kernel + "\n"
> 
> -            syslinux_conf += "APPEND label=boot root=%s %s\n" % \
> -                             (creator.rootdev, bootloader.append)
> +            parts = ["label=boot"]
> +            if creator.rootdev:
> +                parts.append("root=%s" % creator.rootdev)
> +            if bootloader.append:
> +                parts.append(bootloader.append)
> +
> +            syslinux_conf += "APPEND %s\n" % " ".join(parts)
> 
>              # if we are using an initrd, smuggle it in
>              if initrd:
> -                syslinux_conf = syslinux_conf.replace(
> -                    " root=%s " % (creator.rootdev),
> -                    " root=%s initrd=%s " % (creator.rootdev, initrd))
> +                if creator.rootdev:
> +                    syslinux_conf = syslinux_conf.replace(
> +                            "root=%s" % creator.rootdev,
> +                            "root=%s initrd=%s" % (creator.rootdev, initrd))
> +                else:
> +                    syslinux_conf = syslinux_conf.replace(
> +                            " label=boot ",
> +                            " label=boot initrd=%s " % initrd)
> 
>          logger.debug("Writing syslinux config %s/hdd/boot/syslinux.cfg",
>                       cr_workdir)
> diff --git a/scripts/lib/wic/plugins/source/bootimg-efi.py b/scripts/lib/wic/plugins/source/bootimg-efi.py
> index 13a9cddf..c18a1e71 100644
> --- a/scripts/lib/wic/plugins/source/bootimg-efi.py
> +++ b/scripts/lib/wic/plugins/source/bootimg-efi.py
> @@ -95,7 +95,7 @@ class BootimgEFIPlugin(SourcePlugin):
>                          (get_bitbake_var("KERNEL_IMAGETYPE"), get_bitbake_var("INITRAMFS_LINK_NAME"))
> 
>              label = source_params.get('label')
> -            label_conf = "root=%s" % creator.rootdev
> +            label_conf = "root=%s" % creator.rootdev if creator.rootdev else ""
>              if label:
>                  label_conf = "LABEL=%s" % label
> 
> @@ -180,7 +180,8 @@ class BootimgEFIPlugin(SourcePlugin):
>              boot_conf += "linux /%s\n" % kernel
> 
>              label = source_params.get('label')
> -            label_conf = "LABEL=Boot root=%s" % creator.rootdev
> +            label_conf = "LABEL=Boot"
> +            label_conf += (" root=%s" % creator.rootdev) if creator.rootdev else ""
>              if label:
>                  label_conf = "LABEL=%s" % label
> 
> @@ -316,7 +317,7 @@ class BootimgEFIPlugin(SourcePlugin):
> 
>              with tempfile.TemporaryDirectory() as tmp_dir:
>                  label = source_params.get('label')
> -                label_conf = "root=%s" % creator.rootdev
> +                label_conf = "root=%s" % creator.rootdev if creator.rootdev else ""
>                  if label:
>                      label_conf = "LABEL=%s" % label
> 
> diff --git a/scripts/lib/wic/plugins/source/bootimg-partition.py b/scripts/lib/wic/plugins/source/bootimg-partition.py
> index 94183174..ebddcb90 100644
> --- a/scripts/lib/wic/plugins/source/bootimg-partition.py
> +++ b/scripts/lib/wic/plugins/source/bootimg-partition.py
> @@ -153,8 +153,15 @@ class BootimgPartitionPlugin(SourcePlugin):
>              if has_dtb:
>                  extlinux_conf += "   fdtdir %s\n" % fdt_dir
>              bootloader = cr.ks.bootloader
> -            extlinux_conf += "append root=%s rootwait %s\n" \
> -                             % (cr.rootdev, bootloader.append if bootloader.append else '')
> +
> +            # Check if rootdev exists
> +            parts = ["rootwait"]
> +            if cr.rootdev:
> +                parts.insert(0, "root=%s" % cr.rootdev)
> +            if bootloader.append:
> +                parts.append(bootloader.append)
> +
> +            extlinux_conf += "append %s\n" % " ".join(parts)
> 
>          install_cmd = "install -d %s/extlinux/" % hdddir
>          exec_cmd(install_cmd)
> diff --git a/scripts/lib/wic/plugins/source/bootimg-pcbios.py b/scripts/lib/wic/plugins/source/bootimg-pcbios.py
> index a207a835..5d5d5c23 100644
> --- a/scripts/lib/wic/plugins/source/bootimg-pcbios.py
> +++ b/scripts/lib/wic/plugins/source/bootimg-pcbios.py
> @@ -125,8 +125,14 @@ class BootimgPcbiosPlugin(SourcePlugin):
>              kernel = "/" + get_bitbake_var("KERNEL_IMAGETYPE")
>              syslinux_conf += "KERNEL " + kernel + "\n"
> 
> -            syslinux_conf += "APPEND label=boot root=%s %s\n" % \
> -                             (creator.rootdev, bootloader.append)
> +            # Check if rootdev exists
> +            parts = ["label=boot"]
> +            if creator.rootdev:
> +                parts.append("root=%s" % creator.rootdev)
> +            if bootloader.append:
> +                parts.append(bootloader.append)
> +
> +            syslinux_conf += "APPEND %s\n" % " ".join(parts)
> 
>          logger.debug("Writing syslinux config %s/hdd/boot/syslinux.cfg",
>                       cr_workdir)
> --
> 2.39.5
>

Patch

diff --git a/meta/scripts/lib/wic/plugins/source/bootimg-efi-isar.py b/meta/scripts/lib/wic/plugins/source/bootimg-efi-isar.py
index 6bc78d42..28b6af63 100644
--- a/meta/scripts/lib/wic/plugins/source/bootimg-efi-isar.py
+++ b/meta/scripts/lib/wic/plugins/source/bootimg-efi-isar.py
@@ -104,7 +104,7 @@  class BootimgEFIPlugin(SourcePlugin):
                         (get_bitbake_var("KERNEL_IMAGETYPE"), get_bitbake_var("INITRAMFS_LINK_NAME"))

             label = source_params.get('label')
-            label_conf = "root=%s" % creator.rootdev
+            label_conf = "root=%s" % creator.rootdev if creator.rootdev else ""
             if label:
                 label_conf = "LABEL=%s" % label

@@ -201,7 +201,8 @@  class BootimgEFIPlugin(SourcePlugin):
             boot_conf += "linux /%s\n" % kernel

             label = source_params.get('label')
-            label_conf = "LABEL=Boot root=%s" % creator.rootdev
+            label_conf = "LABEL=Boot"
+            label_conf += (" root=%s" % creator.rootdev) if creator.rootdev else ""
             if label:
                 label_conf = "LABEL=%s" % label

@@ -366,7 +367,7 @@  class BootimgEFIPlugin(SourcePlugin):

             with tempfile.TemporaryDirectory() as tmp_dir:
                 label = source_params.get('label')
-                label_conf = "root=%s" % creator.rootdev
+                label_conf = "root=%s" % creator.rootdev if creator.rootdev else ""
                 if label:
                     label_conf = "LABEL=%s" % label

diff --git a/meta/scripts/lib/wic/plugins/source/bootimg-pcbios-isar.py b/meta/scripts/lib/wic/plugins/source/bootimg-pcbios-isar.py
index d5040b72..bb126df8 100644
--- a/meta/scripts/lib/wic/plugins/source/bootimg-pcbios-isar.py
+++ b/meta/scripts/lib/wic/plugins/source/bootimg-pcbios-isar.py
@@ -140,14 +140,24 @@  class BootimgPcbiosIsarPlugin(SourcePlugin):

             syslinux_conf += "KERNEL " + kernel + "\n"

-            syslinux_conf += "APPEND label=boot root=%s %s\n" % \
-                             (creator.rootdev, bootloader.append)
+            parts = ["label=boot"]
+            if creator.rootdev:
+                parts.append("root=%s" % creator.rootdev)
+            if bootloader.append:
+                parts.append(bootloader.append)
+
+            syslinux_conf += "APPEND %s\n" % " ".join(parts)

             # if we are using an initrd, smuggle it in
             if initrd:
-                syslinux_conf = syslinux_conf.replace(
-                    " root=%s " % (creator.rootdev),
-                    " root=%s initrd=%s " % (creator.rootdev, initrd))
+                if creator.rootdev:
+                    syslinux_conf = syslinux_conf.replace(
+                            "root=%s" % creator.rootdev,
+                            "root=%s initrd=%s" % (creator.rootdev, initrd))
+                else:
+                    syslinux_conf = syslinux_conf.replace(
+                            " label=boot ",
+                            " label=boot initrd=%s " % initrd)

         logger.debug("Writing syslinux config %s/hdd/boot/syslinux.cfg",
                      cr_workdir)
diff --git a/scripts/lib/wic/plugins/source/bootimg-efi.py b/scripts/lib/wic/plugins/source/bootimg-efi.py
index 13a9cddf..c18a1e71 100644
--- a/scripts/lib/wic/plugins/source/bootimg-efi.py
+++ b/scripts/lib/wic/plugins/source/bootimg-efi.py
@@ -95,7 +95,7 @@  class BootimgEFIPlugin(SourcePlugin):
                         (get_bitbake_var("KERNEL_IMAGETYPE"), get_bitbake_var("INITRAMFS_LINK_NAME"))

             label = source_params.get('label')
-            label_conf = "root=%s" % creator.rootdev
+            label_conf = "root=%s" % creator.rootdev if creator.rootdev else ""
             if label:
                 label_conf = "LABEL=%s" % label

@@ -180,7 +180,8 @@  class BootimgEFIPlugin(SourcePlugin):
             boot_conf += "linux /%s\n" % kernel

             label = source_params.get('label')
-            label_conf = "LABEL=Boot root=%s" % creator.rootdev
+            label_conf = "LABEL=Boot"
+            label_conf += (" root=%s" % creator.rootdev) if creator.rootdev else ""
             if label:
                 label_conf = "LABEL=%s" % label

@@ -316,7 +317,7 @@  class BootimgEFIPlugin(SourcePlugin):

             with tempfile.TemporaryDirectory() as tmp_dir:
                 label = source_params.get('label')
-                label_conf = "root=%s" % creator.rootdev
+                label_conf = "root=%s" % creator.rootdev if creator.rootdev else ""
                 if label:
                     label_conf = "LABEL=%s" % label

diff --git a/scripts/lib/wic/plugins/source/bootimg-partition.py b/scripts/lib/wic/plugins/source/bootimg-partition.py
index 94183174..ebddcb90 100644
--- a/scripts/lib/wic/plugins/source/bootimg-partition.py
+++ b/scripts/lib/wic/plugins/source/bootimg-partition.py
@@ -153,8 +153,15 @@  class BootimgPartitionPlugin(SourcePlugin):
             if has_dtb:
                 extlinux_conf += "   fdtdir %s\n" % fdt_dir
             bootloader = cr.ks.bootloader
-            extlinux_conf += "append root=%s rootwait %s\n" \
-                             % (cr.rootdev, bootloader.append if bootloader.append else '')
+
+            # Check if rootdev exists
+            parts = ["rootwait"]
+            if cr.rootdev:
+                parts.insert(0, "root=%s" % cr.rootdev)
+            if bootloader.append:
+                parts.append(bootloader.append)
+
+            extlinux_conf += "append %s\n" % " ".join(parts)

         install_cmd = "install -d %s/extlinux/" % hdddir
         exec_cmd(install_cmd)
diff --git a/scripts/lib/wic/plugins/source/bootimg-pcbios.py b/scripts/lib/wic/plugins/source/bootimg-pcbios.py
index a207a835..5d5d5c23 100644
--- a/scripts/lib/wic/plugins/source/bootimg-pcbios.py
+++ b/scripts/lib/wic/plugins/source/bootimg-pcbios.py
@@ -125,8 +125,14 @@  class BootimgPcbiosPlugin(SourcePlugin):
             kernel = "/" + get_bitbake_var("KERNEL_IMAGETYPE")
             syslinux_conf += "KERNEL " + kernel + "\n"

-            syslinux_conf += "APPEND label=boot root=%s %s\n" % \
-                             (creator.rootdev, bootloader.append)
+            # Check if rootdev exists
+            parts = ["label=boot"]
+            if creator.rootdev:
+                parts.append("root=%s" % creator.rootdev)
+            if bootloader.append:
+                parts.append(bootloader.append)
+
+            syslinux_conf += "APPEND %s\n" % " ".join(parts)

         logger.debug("Writing syslinux config %s/hdd/boot/syslinux.cfg",
                      cr_workdir)