bootloader: Add a zipl bootloader backend
zipl is a bit special in that it parses the BLS config files directly *but* we need to run the command to update the "boot block". Hence, we're not generating a separate config file like the other backends. Instead, extend the bootloader interface with a `post_bls_sync` method that is run in the same place we swap the `boot/loader` symlink. We write a "stamp file" in `/boot` that says we need to run this command. The reason we use stamp file is to prevent the case where the system is interrupted after BLS file is updated, but before zipl is triggered, then zipl boot records are not updated. This opens the door to making things eventually-consistent/reconcilable by later adding a systemd unit to run `zipl` if we're interrupted via a systemd unit - I think we should eventually take this approach everywhere rather than requiring `/boot/loader` to be a symlink. Author: Colin Walters <walters@verbum.org> Tested-by: Tuan Hoang <tmhoang@linux.ibm.com> Co-Authored-By: Tuan Hoang <tmhoang@linux.ibm.com>
This commit is contained in:
1 parent
f203a4fc74
commit
c61234a428
7 files changed
+233
-2
No files matched your search
@@ -43,6 +43,7 @@
|
||||
#include "ostree.h"
|
||||
#include "ostree-sysroot-private.h"
|
||||
#include "ostree-sepolicy-private.h"
|
||||
#include "ostree-bootloader-zipl.h"
|
||||
#include "ostree-deployment-private.h"
|
||||
#include "ostree-core-private.h"
|
||||
#include "ostree-linuxfsutil.h"
|
||||
@@ -1830,6 +1831,7 @@ prepare_new_bootloader_link (OstreeSysroot *sysroot,
|
||||
/* Update the /boot/loader symlink to point to /boot/loader.$new_bootversion */
|
||||
static gboolean
|
||||
swap_bootloader (OstreeSysroot *sysroot,
|
||||
OstreeBootloader *bootloader,
|
||||
int current_bootversion,
|
||||
int new_bootversion,
|
||||
GCancellable *cancellable,
|
||||
@@ -1863,6 +1865,15 @@ swap_bootloader (OstreeSysroot *sysroot,
|
||||
if (fsync (boot_dfd) != 0)
|
||||
return glnx_throw_errno_prefix (error, "fsync(boot)");
|
||||
|
||||
/* TODO: In the future also execute this automatically via a systemd unit
|
||||
* if we detect it's necessary.
|
||||
**/
|
||||
if (bootloader)
|
||||
{
|
||||
if (!_ostree_bootloader_post_bls_sync (bootloader, cancellable, error))
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@@ -2129,7 +2140,7 @@ write_deployments_bootswap (OstreeSysroot *self,
|
||||
if (!full_system_sync (self, out_syncstats, cancellable, error))
|
||||
return FALSE;
|
||||
|
||||
if (!swap_bootloader (self, self->bootversion, new_bootversion,
|
||||
if (!swap_bootloader (self, bootloader, self->bootversion, new_bootversion,
|
||||
cancellable, error))
|
||||
return FALSE;
|
||||
|
||||
@@ -2356,6 +2367,14 @@ ostree_sysroot_write_deployments_with_options (OstreeSysroot *self,
|
||||
{
|
||||
/* No bootloader specified; do not query bootloaders to run. */
|
||||
}
|
||||
else if (g_str_equal (bootloader_config, "zipl"))
|
||||
{
|
||||
/* Because we do not mark zipl as active by default, lets creating one here,
|
||||
* which is basically the same what _ostree_sysroot_query_bootloader() does
|
||||
* for other bootloaders if being activated.
|
||||
* */
|
||||
bootloader = (OstreeBootloader*) _ostree_bootloader_zipl_new (self);
|
||||
}
|
||||
|
||||
bootloader_is_atomic = bootloader != NULL && _ostree_bootloader_is_atomic (bootloader);
|
||||
|
||||
|
||||
Reference in new issue
Block a user