Skip to content

bootloader: Add bootc loader-entries set-options-for-source support#827

Open
jmarrero wants to merge 1 commit intoredhat-performance:masterfrom
jmarrero:kargs-source
Open

bootloader: Add bootc loader-entries set-options-for-source support#827
jmarrero wants to merge 1 commit intoredhat-performance:masterfrom
jmarrero:kargs-source

Conversation

@jmarrero
Copy link
Copy Markdown

@jmarrero jmarrero commented Feb 27, 2026

On bootc systems with transient /etc, the state file
/etc/tuned/bootcmdline is lost after each reboot. This causes
TuneD to lose track of which kernel arguments it previously
set, leading to kargs stacking up on every reboot cycle.

bootc loader-entries set-options-for-source solves this by
recording kargs ownership directly in the BLS config on /boot,
which persists across reboots regardless of /etc transience.
With --source tuned, bootc automatically removes all previous
kargs from the "tuned" source and replaces them with the new
set, eliminating the need for TuneD to maintain its own state
for diffing.

This commit adds bootc source tracking to the bootloader plugin:

  1. Detect set-options-for-source availability by checking
    "bootc loader-entries set-options-for-source --help" exit
    code during plugin init.

  2. When available, use "bootc loader-entries
    set-options-for-source --source tuned --options ..." for
    applying kargs and the same command without --options for
    clearing all TuneD-owned kargs on profile removal.

  3. The bootc path is a top-level dispatch branch, checked
    before rpm-ostree. Fallback chain: bootc -> rpm-ostree
    legacy --delete/--append -> GRUB2. All existing code paths
    are unchanged.

  4. Continue writing to /etc/tuned/bootcmdline as best-effort
    for diagnostics and backward compatibility, but do not
    depend on it for correctness when bootc source tracking
    is available.

  5. Ensure the bootloader plugin is always loaded on bootc
    systems, even for profiles without a [bootloader] section.
    Without this, switching from a profile with kargs (e.g.
    network-latency) to one without (e.g. throughput-performance)
    after a reboot would leave stale kargs behind, because the
    bootloader plugin would never be instantiated and its
    unapply/clear logic would never run. The daemon now injects
    a synthetic bootloader unit when bootc source tracking is
    available, and the plugin declares the empty kargs state to
    bootc so stale kargs from a previous profile are cleared.

  6. Add 20 unit tests covering: bootc detection (3), apply (3),
    removal (2), init flag derivation (2), top-level dispatch (5),
    stale kargs clearing (2), and daemon bootloader unit
    injection (3).

Requires: bootc with loader-entries set-options-for-source
(bootc PR #2114) and ostree >= 2026.1
See: bootc-dev/bootc#899
See: bootc-dev/bootc#2114

Assisted-by: OpenCode (Claude Opus 4.6)
Signed-off-by: Joseph Marrero Corchado jmarrero@redhat.com

@jmarrero jmarrero force-pushed the kargs-source branch 2 times, most recently from 2abd119 to eaebb85 Compare April 17, 2026 11:28
@jmarrero jmarrero changed the title bootloader: Add rpm-ostree kargs --source=tuned support bootloader: Add bootc loader-entries set-options-for-source support Apr 17, 2026
@jmarrero jmarrero marked this pull request as ready for review April 24, 2026 17:30
On bootc systems with transient /etc, the state file
/etc/tuned/bootcmdline is lost after each reboot. This causes
TuneD to lose track of which kernel arguments it previously
set, leading to kargs stacking up on every reboot cycle.

bootc loader-entries set-options-for-source solves this by
recording kargs ownership directly in the BLS config on /boot,
which persists across reboots regardless of /etc transience.
With --source tuned, bootc automatically removes all previous
kargs from the "tuned" source and replaces them with the new
set, eliminating the need for TuneD to maintain its own state
for diffing.

This commit adds bootc source tracking to the bootloader plugin:

1. Detect set-options-for-source availability by checking
   "bootc loader-entries set-options-for-source --help" exit
   code during plugin init.

2. When available, use "bootc loader-entries
   set-options-for-source --source tuned --options ..." for
   applying kargs and the same command without --options for
   clearing all TuneD-owned kargs on profile removal.

3. The bootc path is a top-level dispatch branch, checked
   before rpm-ostree. Fallback chain: bootc -> rpm-ostree
   legacy --delete/--append -> GRUB2. All existing code paths
   are unchanged.

4. Continue writing to /etc/tuned/bootcmdline as best-effort
   for diagnostics and backward compatibility, but do not
   depend on it for correctness when bootc source tracking
   is available.

5. Ensure the bootloader plugin is always loaded on bootc
   systems, even for profiles without a [bootloader] section.
   Without this, switching from a profile with kargs (e.g.
   network-latency) to one without (e.g. throughput-performance)
   after a reboot would leave stale kargs behind, because the
   bootloader plugin would never be instantiated and its
   unapply/clear logic would never run. The daemon now injects
   a synthetic bootloader unit when bootc source tracking is
   available, and the plugin declares the empty kargs state to
   bootc so stale kargs from a previous profile are cleared.

6. Add 20 unit tests covering: bootc detection (3), apply (3),
   removal (2), init flag derivation (2), top-level dispatch (5),
   stale kargs clearing (2), and daemon bootloader unit
   injection (3).

Requires: bootc with loader-entries set-options-for-source
          (bootc PR #2114) and ostree >= 2026.1
See: bootc-dev/bootc#899
See: bootc-dev/bootc#2114

Assisted-by: OpenCode (Claude Opus 4.6)
Signed-off-by: Joseph Marrero Corchado <jmarrero@redhat.com>
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.

1 participant