68 Commits

Author SHA1 Message Date
Andrew Phelps
c3da5d6566 daemon: maintain functionality of original debug route for creating recovery system 2024-02-08 15:34:34 +01:00
Andrew Phelps
8af17a61ff o/devicestate: update CreateRecoverySystem to create recovery systems from validation sets 2024-02-08 15:34:34 +01:00
alfonsosanchezbeato
85812c58a7 many: use laid out types only for writing content (#13019)
* gadget,daemon: use Volume instead of LaidOutVolume when retrieving

traits (we only need the information from the gadget).

* gadget,overlord: use Volume instead of LaidOutVolume when saving

storage traits (we only actually need the gadget info).

* gadget: add function to get disk from installer gadget volume

* gadget: apply installer gadget changes to volumes

instead of applying to the laid out volumes, as in the end what the
installer is providing us is a way to fill gadget information.

* gadget: create temporary wrapper for LaidOutVolumesFromGadget

* o/devicestate: build layouts after matching disk to volumes

returned by the installer, so we make sure that the information we
have received is accurate.

* gadget/install: do not use laid out when encrypting a partition

* gadget: change so Run uses laid out types

only after the partitions have been created.

* gadget: do not use laid out structures directly in FactoryReset

* gadget: move ancillary function to gadgettest, as it is used there only

* gadget: remove some duplicated lines left by mistake

* gadget: pass around yaml index to installer

It is used by muinstaller as it calls create partition functions that
return maps that use this index as key.

* revert prev

* tests/muinstaller: update to latest snapd

* gadget: fix and test OnDiskVolumeFromGadgetVol

* gadget,overlord: set device from installer

* gadget/install: really check error returned by LayoutVolumeStructure

* gadget/install: fix nosecboot builds

* gadget,overlord: minor changes in comments

* gadget: add test for StructFromYamlIndex, add doc strings

* gadget: add some additional tests

* gadget: move up variable definition

* gadget,overlord: move OnDiskVolumeFromGadgetVol to a better place

* gadget: return OnDiskAndGadgetStructurePair pairs from buildPartitionList

* gadget: add method to copy volumes

* gadget,overlord: return a copy from ApplyInstallerVolumesToGadget

instead of modifying the passed around volumes.

* gadget,overlord: address review comments

* daemon,gadget: some renames and error/comments string changes

* gadget: move TestOnDiskVolumeFromGadgetVol to the right place

* gadget: add case for testing volume copy

* gadget/install: prevent reading twice gadget.yaml in Run

* gadget/install: remove now unneeded dummy function

* tests/muinstaller: update to latest snapd changes

* gadget/install: fix nosecboot tests

* gadget: unexport yamlIdxToStructureIdx

* gadget,overlord: some var name and comment changes

* gadget: add more unit tests for MatchDisksToGadgetVolumes

* gadget,overlord: address some review comments
2023-08-18 15:38:38 +02:00
Michael Vogt
ec484217a2 many: remove all device-setup fde-setup code (#12618)
* many: remove all `device-setup` fde-setup code

When we initially worked on the inline-cryto-engine (ICE) code we
had a design based on the fde-setup hook that would return a
`device-setup` feature as a hint that ICE should be used. It
turned out this design was impractical and we moved to a much
better approach that got merged in
https://github.com/snapcore/snapd/pull/12589
and relies on support for ICE in the kernel and cryptsetup.

With that new approach all the code that was supporting the
`device-setup` approach can be removed now.

* daemon: consider again the fde-setup hook case

* client: consider the ICE encryption type

* osu/disks,kernel: remove device-unlock support as well

---------

Co-authored-by: Samuele Pedroni <pedronis@lucediurna.net>
2023-04-05 18:03:03 +02:00
Michael Vogt
87c46856d8 daemon: improve TODO/XXX comment for getGadgetDiskMapping 2023-03-06 10:58:38 +01:00
Michael Vogt
722d410cc9 many: deal with EncryptionTypeLUKSWithICE in more places
This commit updates the if/case statements that check for
secboot.EncryptionTypeLUKS to also deal with EncryptionTypeLUKSWithICE
and add some TODO:ICE: about cleanup we can do later.
2023-03-06 10:58:38 +01:00
alfonsosanchezbeato
34da9d970b gadget: include OnDiskStructure in LaidOutStructure (#12515)
Include OnDiskStructure in LaidOutStructure so we really have all the
needed information to create partitions and content in
LaidOutStructure. Also, remove the now unneeded
onDiskAndLaidoutStructure.

* gadget: change FindDeviceForStructure input to a VolumeStructure

as we did not need the full LaidOutStructure. This also simplifies the
tests.

* gadget/install: use OnDiskStructure in ensureNodesExist

As we did not need the full laid out structure.

* gadget: include OnDiskStructure in LaidOutStructure

Include OnDiskStructure in LaidOutStructure so we really have all the
needed information to create partitions and content in
LaidOutStructure. Also, remove the now unneeded
onDiskAndLaidoutStructure.

* gadget: remove StartOffset from LaidOutStructure

It is not needed as we have the same field in OnDiskStructure, which
is contained in LaidOutStructure.

* gadget: replace access to LaidOutStructure.VolumeStructure by methods

where possible.

* gadget: set encryption info in gadget.LaidoutVolume

Pass around encryption information so we can set the encryption info
in LaidOutStructure nearer to where it is created, which simplifies
the code and fixes cases not considered before.

* tests/muinstaller: use temporarily commit from branch for the build

To be removed as soon as https://github.com/snapcore/snapd/pull/12515
is merged.
2023-02-14 10:06:13 +00:00
Miguel Pires
06d4688ffd daemon: add migrate-home action to debug/ API endpoint
Signed-off-by: Miguel Pires <miguel.pires@canonical.com>
2022-06-21 15:49:01 +01:00
Ian Johnson
a6a0b8d91b daemon/api_debug.go: automatically set DiskVolume...Options.AllowImp...Data
This makes the debug endpoint work on UC18 and UC16 devices which have this
implicit system-data role.

Also add a small check to make sure the options are non-nil in
AllDiskVolumeDeviceTraits when we provide them to
DiskTraitsFromDeviceAndValidate.

Signed-off-by: Ian Johnson <ian.johnson@canonical.com>
2022-02-20 08:55:43 -06:00
Ian Johnson
1d1edde773 cmd/snap/debug, daemon: add debug command for getting gadget vol -> disk traits
This is useful in debugging gadget asset updates.

Signed-off-by: Ian Johnson <ian.johnson@canonical.com>
2022-02-01 14:30:18 -06:00
Ian Johnson
8084dd8b33 cmd/snap, daemon: add debug command for getting OnDiskVolume dump
Signed-off-by: Ian Johnson <ian.johnson@canonical.com>
2022-01-10 16:07:32 -06:00
Samuele Pedroni
716b13b5f9 daemon: simplify SyncResponse
it doesn't take Meta anymore
2021-06-03 13:49:26 +02:00
Samuele Pedroni
25e9e2e1f9 daemon: start coalescing resp into respJSON and evaporating Meta
the cleanliness gained by having two structures with almost
the same fields is probably not enough to justify both of them,
especially because daemon is where we are supposed to build
responses, we might as well deal with the details

Meta was a quick hack, also it hasn't really grown since so we can
try to remove it now

AsyncResponse never takes anything over the result but the change id
2021-05-28 19:48:19 +02:00
Paweł Stołowski
06f8fa7566 Merge branch 'master' into debug-stacktrace 2021-05-27 12:06:22 +02:00
Samuele Pedroni
f0e0f8077a tests/nested/core/core20-create-recovery: verify that recovery system can be created at runtime
Merge pull request #10255 from bboozzoo/bboozzoo/uc20-recovery-system-debug-create
2021-05-27 12:00:24 +02:00
Paweł Stołowski
7490eb74a1 Merge branch 'master' into debug-stacktrace 2021-05-27 10:24:39 +02:00
Maciej Borzecki
4af3a049f1 daemon: tweak name of debug endpoing action
Signed-off-by: Maciej Borzecki <maciej.zenon.borzecki@canonical.com>
2021-05-27 09:42:44 +02:00
Maciej Borzecki
1dae2b5dcd Merge remote-tracking branch 'upstream/master' into bboozzoo/uc20-recovery-system-debug-create 2021-05-27 09:40:58 +02:00
Samuele Pedroni
50850d1846 daemon: tighten access to POST /v2/debug to only root
drop support for cases that have been for a long time available via
GET anyway
2021-05-26 16:17:21 +02:00
Paweł Stołowski
eac70e3598 Use plural "stacktraces". 2021-05-26 14:45:28 +02:00
Paweł Stołowski
c77ff29af1 Merge branch 'master' into debug-stacktrace 2021-05-26 12:58:21 +02:00
Paweł Stołowski
18cdd4e370 Revert "Restrict stacktrace for root, otherwise keep the rest of debug commands"
This reverts commit f901629b43.
2021-05-25 11:49:05 +02:00
Paweł Stołowski
9a73e6db2c Do not split stacktrace, just return text blob. 2021-05-25 11:21:03 +02:00
Paweł Stołowski
f901629b43 Restrict stacktrace for root, otherwise keep the rest of debug commands
with UserOK.
2021-05-25 11:18:59 +02:00
Paweł Stołowski
3416f0c87f Implement 'snap debug stacktrace command'. Restrict debug endpoint to
root only.
2021-05-25 10:40:15 +02:00