Skip to content

feat(kernel): kernel.cmdline and kernel.cmdline_extra in project config - #252

Open
mobileoverlord wants to merge 1 commit into
mainfrom
jschneck/kernel-cmdline
Open

feat(kernel): kernel.cmdline and kernel.cmdline_extra in project config#252
mobileoverlord wants to merge 1 commit into
mainfrom
jschneck/kernel-cmdline

Conversation

@mobileoverlord

Copy link
Copy Markdown
Contributor

What

Adds kernel.cmdline and kernel.cmdline_extra to project config, so the kernel command line is something a project sets rather than something baked into a BSP layer.

kernel:
  version: "6.18.37-rt*"
  cmdline_extra: "isolcpus=4-6 nohz_full=4-6"   # append
  # cmdline: "root=... console=..."             # replace outright

Both are resolved per-runtime with a global fallback and exported to the build and provision hooks as AVOCADO_KERNEL_CMDLINE / AVOCADO_KERNEL_CMDLINE_EXTRA.

Why

The command line was reachable only through the machine configuration (CONSOLE_CMDLINE, KERNEL_CMDLINE_EXTRA). Anything a project needs on it — isolcpus for a latency test, earlycon while bringing a board up — meant editing a BSP layer and rebuilding a feed. That is the wrong seam: those values are properties of the project, not of the machine, and two projects on the same target legitimately want different ones.

This came out of the rubikpi3 RT/KVM work, where tuning the command line per experiment otherwise required a full Yocto rebuild per iteration.

How

cmdline replaces, cmdline_extra appends. Append is the one to reach for; replace drops root= and console= unless restated, which on most boards means a device that flashes and boots to a dead console. They are rejected together at validate time rather than letting one silently win.

The platform hook is where these take effect — meta-avocado-qcom's avocado-build-rubikpi3 reads them when it rebuilds the UKI around the pinned kernel.

Results

  • 3804 tests pass, including 5 new ones covering the resolver and the mutual exclusion
  • clippy clean, cargo fmt clean
  • exercised on hardware: cmdline_extra: "earlycon" reached the booted kernel's /proc/cmdline on a rubikpi3 via the UKI rebuild path

Note

Without this, references/rubikpi3-rt-kvm-ivshmem does not load — it sets cmdline_extra, and a CLI lacking the field reads it as an entry name in the kernel named-map form and refuses the file:

kernel: cannot mix singleton form (with config field keys like `package`,
`version`, `compile`, `install`, `image`) and named-map form

The kernel command line was reachable only from the Yocto machine
configuration (CONSOLE_CMDLINE / KERNEL_CMDLINE_EXTRA), so anything a
project needs on it -- isolcpus, nohz_full, earlycon while bringing a
board up -- had to be baked into a BSP layer and a feed rebuilt. That is
the wrong seam: those values are properties of the project, not of the
machine, and two projects on the same target want different ones.

Adds two mutually exclusive fields, resolved per-runtime with a global
fallback:

  kernel:
    cmdline_extra: "isolcpus=4-6 nohz_full=4-6"   # append
    cmdline: "root=... console=..."               # replace outright

and exports the result to the build and provision hooks as
AVOCADO_KERNEL_CMDLINE / AVOCADO_KERNEL_CMDLINE_EXTRA, which is where a
platform hook can act on it (meta-avocado-qcom's avocado-build-rubikpi3
rebuilds the UKI around them).

Append is the field to reach for; replace drops root= and console= on the
floor unless restated, which on most boards means a device that flashes
and boots to a dead console. They are rejected together at validate time
rather than silently letting one win.

Claude-Session: https://claude.ai/code/session_01BFkqZ1vpWd23TeC7dFFjdW
Copilot AI lite review requested due to automatic review settings September 7, 2026 21:29

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The functional changes are small, tested, and localized; the remaining feedback is a documentation correction.

Pull request overview

This PR makes kernel command-line configuration a first-class project setting by adding kernel.cmdline (replace) and kernel.cmdline_extra (append) to the YAML config, resolving them per-runtime with a top-level fallback, and exporting the resolved values to build/provision hooks via environment variables.

Changes:

  • Extend KernelConfig with cmdline / cmdline_extra, including mutual-exclusion validation and singleton-vs-named-map deserialization support.
  • Add Config::effective_kernel_cmdline() to resolve (replace, append) with runtime-over-top-level precedence.
  • Export AVOCADO_KERNEL_CMDLINE / AVOCADO_KERNEL_CMDLINE_EXTRA to both runtime build and provision hook environments.
File summaries
File Description
src/utils/config.rs Adds config fields + validation, implements per-runtime cmdline resolver, and includes tests.
src/commands/runtime/build.rs Exports resolved kernel cmdline vars for platform build hooks (e.g., UKI bake-in).
src/commands/runtime/provision.rs Exports resolved kernel cmdline vars for provision-time image assembly hooks.
Review details
  • Files reviewed: 3/3 changed files
  • Comments generated: 1
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/utils/config.rs
Comment on lines 1604 to 1608
/// Resolve a runtime's `kernel:` field to a concrete [`KernelConfig`],
/// following named refs to the top-level `kernel.<name>` map.
///
/// Returns `None` when the runtime doesn't exist, has no `kernel:` field,
/// or the named ref doesn't resolve. (Phase 0e adds load-time validation
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants