Skip to content

Add nullboot.conf support with a kernel-priority field - #166

Open
julian-klode wants to merge 2 commits into
mainfrom
flavour-order
Open

julian-klode wants to merge 2 commits into
mainfrom
flavour-order

Conversation

@julian-klode

Copy link
Copy Markdown
Contributor

Field is using the same spelling as the grub one.

This allows preferring certain kernel flavours over others.

Not sure if the drop-ins appending flavour order is sensible, probably they should just override instead as it is a bit confusing coming from other configurations.

@julian-klode

Copy link
Copy Markdown
Contributor Author

Maybe we need to have

flavour-order:

and

flavour-order-append:

@julian-klode julian-klode changed the title Add nullboot.conf support with a flavour-order field Add nullboot.conf support with a kernel-priority field Sep 9, 2026
Implement nullboot.conf and nullboot.conf.d - yaml files. At this
point parse only kernel-priority (similar to GRUB_FLAVOUR_ORDER in
grub).

Assisted-by: LLM
Wrap version.Version in a WeightedVersion that carries a priority
computed from the kernel-priority configuration. Kernels with higher
priority sort first; equal priorities fall back to version order.

Assisted-by: LLM
@julian-klode

Copy link
Copy Markdown
Contributor Author

We now have

kernel-priority:
    fips: 1000
    azure-fde: 100

with unspecified suffixes defaulting to 0. I think this is a bit more cleaner, and the dict merges naturally.

This is overkill, a single preference would also get the job done preferred-kernel:, but it's arguably a bit cleaner if you ever end up entering the firmware boot menu to manually select an entry.

Comment thread efibootmgr/config.go
Comment on lines +100 to +103
for priority, res := range c.priorities {
for _, re := range res {
if re.MatchString(abi) {
return priority

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

With {fde: 100, azure-fde: 1000}, map order changes the weight for the same kernel (azure-fde matches both entries). This can prefer an older version.

Comment thread cmd/nullbootctl/main.go
log.Println("using kernel priorities:", config.KernelPriority)
}

km, err := efibootmgr.NewKernelManager(esp, kernelSourceDir, vendor, maybeBm, config)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

While running generic, prefer FIPS and run nullbootctl. Restore generic before reboot and run it again. BootNext will still select FIPS. Maybe that is a weird edge case but I think it's definitely unintended behavior.

This is not directly caused by your changes, but they make that possible.

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.

🟡 Changes recommended

Resolve the priority matching and exported API compatibility issues before approval.

Get a fresh assessment by requesting another Copilot review.

Pull request overview

Adds YAML-based /etc/nullboot.conf support for prioritizing kernel flavours during boot selection.

Changes:

  • Adds configuration and drop-in parsing.
  • Introduces priority-aware kernel ordering.
  • Updates CLI integration, dependencies, and tests.
File summaries
File Summary
go.mod Promotes the YAML dependency for direct use.
efibootmgr/reseal_test.go Updates kernel manager construction in tests.
efibootmgr/kernel.go Adds priority-aware ordering; requires API compatibility fixes and updated ordering documentation.
efibootmgr/kernel_test.go Updates and tests priority-based ordering.
efibootmgr/config.go Parses priorities and drop-ins; matching must select the highest configured priority deterministically.
efibootmgr/config_test.go Tests configuration parsing and matching.
cmd/nullbootctl/main.go Loads and passes the nullboot configuration.
Review details

Suppressed comments (3)

efibootmgr/kernel.go:139

  • This changes the ordering used by GetLatestKernelEntry from version-only to priority-then-version, but that exported method's existing doc still says it returns the entry with the "largest version" (kernel.go:329). Update the method contract to describe the priority-aware ordering so callers do not rely on the old behavior.
	// Sort descending by flavour preference group, then by version

efibootmgr/kernel.go:91

  • Adding a required config parameter to these exported constructors is a source-incompatible API change: downstream users of the efibootmgr library that do not need priorities will no longer compile. Preserve the existing NewKernelManager/NewKernel signatures and add config-aware variants (or another optional-configuration API) so this feature does not break existing callers.
// NewKernelManager returns a new kernel manager managing kernels in the
// host system. config may be nil.
func NewKernelManager(esp, sourceDir, vendor string, bootManager *BootManager, config *Configuration) (*KernelManager, error) {

efibootmgr/kernel.go:43

  • Kernel.Version is an exported field that previously had type version.Version; changing it to WeightedVersion is another source-incompatible API change, even for callers that do not use priorities. Keep the public field type stable and store the preference weight separately for internal ordering, or provide an explicit compatibility layer.
type Kernel struct {
	Version  WeightedVersion
  • Files reviewed: 7/7 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 efibootmgr/config.go
Comment on lines +100 to +107
for priority, res := range c.priorities {
for _, re := range res {
if re.MatchString(abi) {
return priority
}
}
}
return 0
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.

3 participants