bin/admin-upgrade: add kexec support
authorMary Strodl <ipadlover8322@gmail.com>
Thu, 12 Dec 2024 14:30:59 +0000 (09:30 -0500)
committerMary Strodl <ipadlover8322@gmail.com>
Mon, 23 Dec 2024 18:59:37 +0000 (13:59 -0500)
commitb04cb8f40f6b972ce04ade95c9b9c5cad56ae6a2
tree0a72bcd313c7baa39711f85e0a34ef483ae04f3a
parent8aaea0c65ddcf32d4f52efb707185c25354c5e42
bin/admin-upgrade: add kexec support

Adds a new `--kexec` flag to `ostree admin upgrade` which will cause
the deployment to be loaded into kexec after the upgrade completes.
It is particularly useful in conjunction with the `--reboot` flag to
perform a reboot into the new deployment without waiting for the
(often slow) firmware initialization to take place. (And in my case,
allows me to avoid a normal reboot, which can be unreliable on my
hardware).

After an image has been loaded (using the `kexec_file_load` syscall),
the `systemctl-reboot` command (which is called when the existing
`-r` flag is included) will trigger a kexec on the loaded image
rather than a normal reboot. From `systemctl(1)`:

  If a new kernel has been loaded via kexec --load, a kexec will be
  performed instead of a reboot, unless "SYSTEMCTL_SKIP_AUTO_KEXEC=1"
  has been set. If a new root file system has been set up on
  "/run/nextroot/", a soft-reboot will be performed instead of a
  reboot, unless "SYSTEMCTL_SKIP_AUTO_SOFT_REBOOT=1" has been set.

A good in-depth technical explanation of kexec can be found here:
https://web.archive.org/web/20090505132901/http://www.ibm.com/developerworks/linux/library/l-kexec.html

My implementation uses the `kexec_file_load` syscall rather than the
older `kexec_load` syscall, which allows the kernel to verify the
signatures of the new kernel. It is supported on Linux 3.17 and
newer. I assume this probably won't be an issue, but if it is, it's
not that hard to put a preprocessor directive around the kexec stuff
to disable it for older kernels. Even RHEL is new enough now to
not be an issue :)

Closes: #435
Makefile-libostree.am
apidoc/ostree-sections.txt
man/ostree-admin-switch.xml
man/ostree-admin-upgrade.xml
src/libostree/libostree-devel.sym
src/libostree/ostree-sysroot-deploy.c
src/libostree/ostree-sysroot-upgrader.c
src/libostree/ostree-sysroot-upgrader.h
src/libostree/ostree-sysroot.h
src/ostree/ot-admin-builtin-switch.c
src/ostree/ot-admin-builtin-upgrade.c