Skip to content

boot,bootloader: add support for shim fallback and setting EFI boot variables on install#13511

Merged
ernestl merged 26 commits intocanonical:masterfrom
valentindavid:valentindavid/olivers-uefi-variable-branch-rebased
Jun 3, 2024
Merged

boot,bootloader: add support for shim fallback and setting EFI boot variables on install#13511
ernestl merged 26 commits intocanonical:masterfrom
valentindavid:valentindavid/olivers-uefi-variable-branch-rebased

Conversation

@valentindavid
Copy link
Copy Markdown
Member

This is #13205 rebased onto #13412

@github-actions github-actions Bot added the Run Nested -auto- Label automatically added in case nested tests need to be executed label Jan 23, 2024
@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Jan 26, 2024

Codecov Report

Attention: Patch coverage is 71.53558% with 76 lines in your changes are missing coverage. Please review.

Project coverage is 78.84%. Comparing base (953fad1) to head (4d43110).

Files Patch % Lines
boot/assets.go 31.70% 25 Missing and 3 partials ⚠️
boot/setefibootvars_linux.go 73.78% 20 Missing and 7 partials ⚠️
gadget/mountedfilesystem.go 80.00% 10 Missing and 5 partials ⚠️
bootloader/grub.go 80.64% 4 Missing and 2 partials ⚠️

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##           master   #13511      +/-   ##
==========================================
- Coverage   78.85%   78.84%   -0.02%     
==========================================
  Files        1043     1044       +1     
  Lines      134592   134848     +256     
==========================================
+ Hits       106137   106321     +184     
- Misses      21839    21896      +57     
- Partials     6616     6631      +15     
Flag Coverage Δ
unittests 78.84% <71.53%> (-0.02%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@valentindavid valentindavid force-pushed the valentindavid/olivers-uefi-variable-branch-rebased branch from a17eb93 to 32f0cfc Compare February 22, 2024 15:26
@valentindavid valentindavid force-pushed the valentindavid/olivers-uefi-variable-branch-rebased branch 4 times, most recently from bd393d0 to bfc91a6 Compare March 5, 2024 15:52
@ernestl ernestl added this to the 2.62 milestone Mar 6, 2024
@valentindavid valentindavid force-pushed the valentindavid/olivers-uefi-variable-branch-rebased branch 2 times, most recently from a9b1628 to 9c899fb Compare March 12, 2024 15:33
@ernestl ernestl modified the milestones: 2.62, 2.63 Mar 13, 2024
@ernestl
Copy link
Copy Markdown
Member

ernestl commented Mar 13, 2024

@valentindavid @pedronis changed this to target 2.63 as agreed.

@valentindavid valentindavid force-pushed the valentindavid/olivers-uefi-variable-branch-rebased branch 2 times, most recently from 222b8e9 to 4a062d2 Compare March 20, 2024 09:38
@valentindavid valentindavid force-pushed the valentindavid/olivers-uefi-variable-branch-rebased branch from 9fb4819 to 54eefa6 Compare March 20, 2024 16:14
@valentindavid valentindavid force-pushed the valentindavid/olivers-uefi-variable-branch-rebased branch from 54eefa6 to 4d43110 Compare April 4, 2024 11:35
@valentindavid valentindavid force-pushed the valentindavid/olivers-uefi-variable-branch-rebased branch from 4d43110 to ac21dff Compare April 12, 2024 13:45
@valentindavid valentindavid marked this pull request as ready for review April 12, 2024 13:46
@valentindavid
Copy link
Copy Markdown
Member Author

@olivercalder Could you have a look at the commits that are on top of your two commits and see if that makes sense to you.

The main one is 7be3e78

The rest is just some refactoring. Of the tests specially. And I can squash it later.

@ernestl
Copy link
Copy Markdown
Member

ernestl commented Apr 12, 2024

Not ready for 2.63, moving to 2.64

@ernestl ernestl modified the milestones: 2.63, 2.64 Apr 12, 2024
Copy link
Copy Markdown
Member

@olivercalder olivercalder left a comment

Choose a reason for hiding this comment

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

Looks really great, thanks for all your work on this! A few questions/comments, but really nothing major.

Comment thread bootloader/grub.go Outdated
Comment thread boot/assets.go Outdated
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Potentially, should the check if assetPath != "" occur within SetEfiBootVariables, so that each caller doesn't need to make the check? I think SetEfiBootVariables currently assumes assetPath is non-nil, might be safer if it were the one to check.

Comment thread boot/assets.go Outdated
Comment thread boot/export_test.go Outdated
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

2024 now 🙃

Comment thread boot/setefibootvars_linux.go Outdated
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

nitpick: 2024 here too

Comment thread bootloader/export_test.go Outdated
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This file is no longer changed, so no need to update copyright date?

Comment thread bootloader/grub.go Outdated
Comment thread bootloader/grub.go Outdated
Comment on lines 725 to 730
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Very nice

Comment thread overlord/devicestate/handlers_gadget.go Outdated
Copy link
Copy Markdown
Contributor

@pedronis pedronis left a comment

Choose a reason for hiding this comment

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

thank you, did a pass, main remark is that new code needs more unit testing

Comment thread overlord/devicestate/handlers_gadget.go Outdated
Comment thread boot/setefibootvars_linux.go Outdated
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

even if not exported it would be good when possible to start with the function name here

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

this comment still applies

Comment thread boot/setefibootvars_linux.go Outdated
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

same

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

and same

Comment thread boot/setefibootvars_linux.go Outdated
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

this is exported mostly for testing via spread tests? maybe the doc should remark that is usually not meant to be called directly

Comment thread boot/makebootable.go Outdated
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

can the uni tests check something about this?

Comment thread boot/assets.go Outdated
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

changes in assets.go don't have matching unit tests afaict

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

There should be TestUpdateBootEntryOnInstall and TestUpdateBootEntryOnUpdate in boot/assets_test.go.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Ah sorry, that was an older comment.

Comment thread boot/setefibootvars_linux.go Outdated
Comment on lines 192 to 199
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

unit tests strangely don't seem to reach these bits

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

this seems still true

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Added 3 tests (no error, error in constructLoadOption, error in setEfiBootOptionVariable)

@pedronis pedronis requested a review from bboozzoo April 18, 2024 14:45
olivercalder and others added 25 commits May 30, 2024 16:01
The test checks that EFI boot variables exist for the following:
1. A Boot#### variable pointing to the shim file path.
2. A BootOrder variable with the #### from the above Boot#### as first.

Since the layout of EFI assets is dependent on the gadget snap, the test
downloads and unpacks the gadget, then modifies the contents so that one
variant has the shim and grub binaries in `EFI/boot/` and another
variant has the shim and grub binaries in `EFI/ubuntu/` and the fallback
binary in `EFI/boot/`.

After building a core image around that modified gadget, the VM is
booted and the test checks that the EFI variables are set correctly.
Then, the test modifies the gadget to match the other variant's initial
layout, and then installs the newly modified gadget. This should trigger
re-setting EFI boot variables as well.

Signed-off-by: Oliver Calder <oliver.calder@canonical.com>

tests: fix problems in spread test for setting EFI boot variables

Signed-off-by: Oliver Calder <oliver.calder@canonical.com>

tests: disabled TPM on EFI boot vars test and separated gadget script

Signed-off-by: Oliver Calder <oliver.calder@canonical.com>

tests: fixed EFI vars test to use correct toolbox and include all EFI assets

Signed-off-by: Oliver Calder <oliver.calder@canonical.com>

tests: modify-gadget.sh re-use existing gadget so edition is incremented

Signed-off-by: Oliver Calder <oliver.calder@canonical.com>

tests: fix mangled EFI var search string and other improvements

Signed-off-by: Oliver Calder <oliver.calder@canonical.com>

tests: polish tests for setting EFI boot variables

Notably, allow tests/nested/core/core20-set-efi-boot-variables to run on
arm64 as well as amd64, simplify setefivars.go to search for multiple
assets on multiple architectures, and allow
tests/nested/manual/core20-set-efi-boot-vars to run on any ubuntu-2*.

Signed-off-by: Oliver Calder <oliver.calder@canonical.com>
…bles

... so we can reuse the script in other tests
@valentindavid valentindavid force-pushed the valentindavid/olivers-uefi-variable-branch-rebased branch from 9677738 to e6c9868 Compare May 30, 2024 14:09
@ernestl
Copy link
Copy Markdown
Member

ernestl commented May 31, 2024

@alfonsosanchezbeato, please do a final pass

Copy link
Copy Markdown
Member

@alfonsosanchezbeato alfonsosanchezbeato left a comment

Choose a reason for hiding this comment

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

LGTM, thanks for the changes

@ernestl ernestl merged commit 2034c7e into canonical:master Jun 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Run Nested -auto- Label automatically added in case nested tests need to be executed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants