[SRU][canonical-kernel-snaps/main][kernel-snaps-uc24.04/pc][PATCH 0/2] add configure hook, eol component support

Aaron Jauregui aaron.jauregui at canonical.com
Tue Jun 17 04:05:19 UTC 2025


BugLink: https://bugs.launchpad.net/bugs/2114786

This covers two features: Support for EOL Nvidia driver components for the pc-kernel, and a configuration hook for the pc-kernel. These two bits of functionality are unfortunately quite closely intertwined, thus placed together.

[Impact]
Add a configure hook to the pc-kernel snap to be able to switch between
installed graphics drivers on a system. This gives the system the
ability to switch between multiple installed graphics components without
having to reinstall (and re-pull from store) the selected driver if it's
already present. Drivers can be selected manually with snap set
nvidia-stream=<driver> and selection is intended to be done by
ubuntu-drivers once components are available on hybrid.

EOL components are also handled by this hook. Installed components are
checked for an "eol" file after being installed. If one is found, the
component number specified inside the eol file is installed. This
behaviour is also triggered if an existing eol component is loaded.

Implement a preprocessing script to allow the snapcraft.yaml to shift
along with the changes and updates in streams as new streams are added
and old streams are EOL'd. Snap does not have a built-in concept of EOL
or a mechanism to handle this case. Shifting to a template preprocessing
model to build the snapcraft.yaml, along with the configure hook to handle
behaviour at runtime, allows for new and EOL drivers to be specified with
much less hassle.

[Fix]
Configure hook installs components based off the nvidia-stream snap
variable by pulling nvidia-<nvidia-stream>-ko and
nvidia-<nvidia-stream>-server. Setting nvidia-stream to nouveau triggers
a special case where only the nouveau-ko component is installed. If
components are already on the system they are "loaded" into the graphics
directory by rerunning their install hook.

If a non-supported value is provided the script will fail and
no changes will be made to the system or the previous value of
nvidia-stream. Also changed generic module install hook to follow symlinks
when installing graphics drivers to support rerunning install hook.

Nvidia component streams are read from the new file nvidia_streams. Each
line of nvidia_streams contains either a single stream version or an EOL
stream and the target replacement version separated by whitespace. e.g.:
550
549 580
Where 550 is valid and 549 is EOL and to be upgraded to 580. EOL components
contain a single file named "eol" containing the replacement stream number.
The logic to handle installation of the new driver components is handled by
the configure hook.

If the preprocessing script is not run, the snapcraft.yaml is still
valid and will build as normal (assuming existing templated values are
resolved) with a nouveau component and no Nvidia driver components.

[Test case]
Built, booted, verified installing all specified components (through the
configure hook) in the following configurations:

- No preprocessing script, only nouveau present
- With 550-erd components, generated by the preprocessing script
- With 550-erd, 570-erd, and 549-erd (EOL, pointing at 570-erd) generated
  by the preprocessing script.

In all of these cases, installing drivers from the store as well as switching
currently installed drivers was tested for all listed component sets.

[Where things could go wrong]
The pc-kernel configure hook runs on every install by default, analogous
to an install hook. Note that if nvidia-stream is set to an invalid
value and the pc-kernel is refreshed the configure hook will fail and
cause the entire pc-kernel refresh to fail.

The configure hook is entirely optional on ubuntu core and will do
nothing if nvidia-stream is not set.

The templating logic is purely for builds and thus does not affect any
runtime behaviour.

Aaron Jauregui (2):
  snapcraft.yaml: add pc-kernel configure hook
  snapcraft.yaml: Template support for Nvidia components

 nvidia-templates/comp-tmpl     |  11 ++++
 nvidia-templates/eol-comp-tmpl |   9 +++
 nvidia-templates/eol-part-tmpl |  19 ++++++
 nvidia-templates/part-tmpl     |  81 ++++++++++++++++++++++++++
 nvidia_streams                 |   1 +
 snapcraft.yaml                 | 103 +++++----------------------------
 snapcraft.yaml.gen             |  37 ++++++++++++
 7 files changed, 171 insertions(+), 90 deletions(-)
 create mode 100644 nvidia-templates/comp-tmpl
 create mode 100644 nvidia-templates/eol-comp-tmpl
 create mode 100644 nvidia-templates/eol-part-tmpl
 create mode 100644 nvidia-templates/part-tmpl
 create mode 100644 nvidia_streams
 create mode 100755 snapcraft.yaml.gen

Aaron Jauregui (1):
  nvidia-hooks: add pc-kernel configure hook

 hooks/module/install.module         |  4 ++--
 hooks/module/post-refresh.module    |  4 ++--
 hooks/pc-kernel/configure.pc-kernel | 37 +++++++++++++++++++++++++++++
 3 files changed, 41 insertions(+), 4 deletions(-)
 create mode 100755 hooks/pc-kernel/configure.pc-kernel

-- 
2.43.0




More information about the kernel-team mailing list