123 Commits

Author SHA1 Message Date
Valentin David
7e3b1bb83e boot: lock the modeenv while reading revisions
`ubuntu-core-20-64:tests/core/system-snap-refresh` fails because
of this.
2023-10-26 16:20:07 +01:00
Valentin David
597529deac gadget: add kernel parameters from "append" in gadget yaml 2023-10-26 09:34:20 +02:00
Valentin David
7ab5e25a69 boot: update cmdline variables also when updating gadget
Since the cmdline variable will contain default arguments for
the edition, we need to update the variable if we change of edition.
2023-10-18 11:20:15 +02:00
Valentin David
33f5a54f40 boot: only use variable snapd_full_cmdline_args
We know what are the default the default command line so that we can
compute measurement, so there is not much reason to use
`snapd_extra_cmdline_args`. Always using `snapd_full_cmdline_args`
will allow us to filter part of the default command line.

There is a potential bug when filtering all arguments, `grub.cfg` will
just revert to the all the default. We will need to fix it when we
introduce the filtering.
2023-10-18 11:20:15 +02:00
Samuele Pedroni
d0cfb81163 boot,o/devicestate: protect with a mutex modifying modeeenv and sealing/releasing (#13185)
this should allow to release the global state lock while doing resealing/sealing proper as those are slow operations in fact

* boot: use loadModeenv a bit more consistently and some XXXs

* boot: take a lock around read modeenv/modify(/reaseal) etc

* boot: do not seal without the modeenv associated lock

* boot: do not reseal without the modeenv associated lock

* boot,o/devicestate: introduce Unlocker to unlock global state

have boot.DeviceChange make use of it for a start

* boot: explain a bit more modeenvMu

* overlord: introduce state.Unlocker convenience method

* boot: check that the lock is taken also in bootStateUpdate20.commit
2023-09-20 18:26:12 +02:00
Philip Meulengracht
994c4e7eec many: carry bootloader options in rebootinfo
Instead of carrying an interface, carry the bootloader options we need to find it later.
2023-07-18 14:57:02 +02:00
Alfonso Sánchez-Beato
cd49a62ea5 boot: introduce parameter for optional kernel command line
in functions used to update it.
2023-02-27 15:47:07 +01:00
Michael Vogt
9175d834df boot: on classic+modes MarkBootSuccessfull does not need a base
This commit fixes a a bug in master that will prevent
`MarkBootSuccessful` from working. The issue is that on classic+modes
the modeenv no longer contains a `base=` field but the
MarkBootSuccessful code will fail if it is missing. This results
in a system that never marks the boot as successful on classic+modes.
2023-02-08 17:44:40 +01:00
Miguel Pires
d097436c1c many: fix formatting w/ gofmt 1.19
Go 1.19 includes some changes to gofmt which intend to make lists and
heading clearer when rendered (https://go.dev/doc/go1.19). This commit
is the result of running the new gofmt and manually fixing some of it.
This was necessary because the new gofmt assumed lines beginning w/ tabs
to start lists or examples. While this is often true in our codebase,
we occasionally also use tabs to indent the lines after a TODO or FIXME
prefix or in yaml (e.g., excerpts of a snap.yaml). This meant that a lot of the
reformatted comments were broken and had to be fixed manually.

Signed-off-by: Miguel Pires <miguel.pires@canonical.com>
2023-01-16 14:23:11 +01:00
Samuele Pedroni
6854896d63 boot: SnapTypeParticipatesInBoot calls IsClassicBoot on its own 2022-11-30 13:31:45 +01:00
Samuele Pedroni
9c7891074b boot: fix InUse for classic with modes 2022-11-30 13:31:45 +01:00
Alberto Mardegan
c4012a2f3b boot: rewrite switch in SnapTypeParticipatesInBoot()
The existing switch looks hard to read for a couple of reasons:

1. The empty case is non obvious for someone coming from other
   programming languages, and is influenced by the return value of the
   function
2. It's confusing to have a default case that returns the opposite value
   of the return value of the function

Rewrite the function to prefer a `switch` with more explicit case, and a
`return` statement that matches the default case (now removed).
2022-09-22 12:26:35 +03:00
Samuele Pedroni
3c7b93c5cc boot: apply boot logic also for classic with modes boot snaps
this introduces also a helper SnapTypeParticipatesInBoot that
can be used to make decisions combining snap type and model
information
2022-09-20 17:06:44 +02:00
Alfonso Sánchez-Beato
56187a6665 Merge branch 'master' into mount-gadget-in-run-folder 2022-07-13 09:13:21 +01:00
alfonsosanchezbeato
91622c094b many: introduce IsUndo flag in LinkContext
* many: introduce IsUndo flag in LinkContext

Some times LinkSnap is called in an undo task when we want to revert
to a previous snap revision. Introduce a flag to make LinkSnap and
boot code aware of when this happen, as some of the logic for snap
installations should not be applied when doing a revert. Specifically,
avoid the "try" logic that applies to kernels and bases: we are
reverting to a known snap that is expected to work, and making the
current snap the fallback provokes failures as we are removing it (and
also probably we are removing it because it has failed).

* tests: check that kernel with failing post-refresh is reverted

Check that a kernel with failing post-refresh hook is reverted
properly. In this case a second reboot to go back to the previous
kernel is needed.

* tests: check that base with failing post-refresh is reverted

Check that a base with failing post-refresh hook is reverted
properly. In this case a second reboot to go back to the previous
base is needed.

* boot,overlord: replace isUndo flags with NextBootContext

Replace isUndo flags with the NextBootContext struct, so we have
further information in the type and we can add flags in the future.

* boot: some style changes as suggested by review

* overlord: SetNextBoot call in maybeUndoRemodelBootChanges as undo type

* boot: add tests for the IsUndoingInstall true case

* overlord: fix remodel test for undos

* boot,overlord: implement the undo install for core16/18

* tests: added method to repack kernel snap also for core16/18

* tests: run revert after boot tests for UC16/18 too

* tests/nested/core/base-revert-after-boot: fix var usage

* tests: consider right channel/snap for uc16 in revert tests

* boot: minor stylistic changes

* boot: add tests for the undoing install case for core16/18

* boot,overlord: rename IsUndoingInstall to BootWithoutTry

* boot: use constant instead of literal for status
2022-07-11 17:49:06 +02:00
Alfonso Sánchez-Beato
a6a2b85ca1 boot: clarify come comments 2022-07-06 09:58:04 +01:00
Alfonso Sánchez-Beato
5767dfd2f4 boot: clarify comment 2022-07-04 12:04:14 +01:00
Alfonso Sánchez-Beato
cfc72eca33 boot: update modenv when the gadget is refreshed 2022-06-23 12:04:26 +02:00
Maciej Borzecki
a303865ee6 boot: tweak naming
Signed-off-by: Maciej Borzecki <maciej.zenon.borzecki@canonical.com>
2022-06-15 10:36:00 +02:00
Maciej Borzecki
6baaae47a7 boot: tweak error message
Signed-off-by: Maciej Borzecki <maciej.zenon.borzecki@canonical.com>
2022-06-14 12:12:56 +02:00
Maciej Borzecki
5dce1f31a7 boot: post factory reset cleanup
Signed-off-by: Maciej Borzecki <maciej.zenon.borzecki@canonical.com>
2022-06-13 15:12:58 +02:00
Samuele Pedroni
5967930d46 many: use pre-UC20 instead of non-UC20+ as is less clunky 2022-04-29 14:43:39 +02:00
Samuele Pedroni
b8e364fa47 many: switch to UC20+ in user messages (instead of UC20) 2022-04-29 14:30:24 +02:00
Alfonso Sánchez-Beato
b849263ac6 Merge branch 'master' into reboot-from-bootpkg 2022-02-21 15:37:32 +01:00
Ian Johnson
af77b3fb0d many: move boot.Device to snap.Device
This is a purely mechanical change because it touches so many files, the real
interesting parts we need that prompted this will be followups.

Signed-off-by: Ian Johnson <ian.johnson@canonical.com>
2022-02-18 11:59:29 -06:00