Skip to content

Composefs-native backend #1314

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
8b56e8f
install/composefs: Move UKI write logic to bootc
Johan-Liebert1 Jul 23, 2025
734f43d
install: Add cmdline kargs to RootSetup
Johan-Liebert1 Jul 23, 2025
b0e43a8
install/composefs: Use atomic writes
Johan-Liebert1 Jul 23, 2025
cf70d5f
cli/composefs: Change composefs options
Johan-Liebert1 Jul 24, 2025
ca9307d
Write nom parser for Grub menuentries
Johan-Liebert1 Jul 26, 2025
c89efab
composefs/status: Read UKI entries to check for queued rollback
Johan-Liebert1 Jul 27, 2025
07ad2d3
parser/grub: Use String instead of &str
Johan-Liebert1 Jul 27, 2025
5737058
composefs/rollback: Handle UKI rollback
Johan-Liebert1 Jul 27, 2025
2c63434
composefs/state: Use atomic writes for origin and staged deployment f…
Johan-Liebert1 Jul 28, 2025
425b439
composefs/boot/bls: Handle duplicate VMLinuz + Initrd
Johan-Liebert1 Jul 28, 2025
5870f28
parser/bls: `impl Display` for BLSConfig
Johan-Liebert1 Jul 28, 2025
4ff4098
lib/composefs: Centralize constants
Johan-Liebert1 Jul 29, 2025
09d77a5
composefs/state: Name state directory `default`
Johan-Liebert1 Jul 29, 2025
4c31ddf
parser/bls: Add tests for bls parser
Johan-Liebert1 Jul 29, 2025
1e73eaa
install/composefs/uki: Write only staged + booted menuentry on upgrade
Johan-Liebert1 Jul 31, 2025
782a3d6
rollback/composefs: Print whether we are reverting the queued rollback
Johan-Liebert1 Jul 31, 2025
f0ffe64
refactor: Pass boot dir to boot entry readers
Johan-Liebert1 Aug 1, 2025
3d2385d
test: Add tests for reading boot entries
Johan-Liebert1 Aug 1, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 11 additions & 37 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions crates/lib/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,7 @@ tini = "1.3.0"
comfy-table = "7.1.1"
thiserror = { workspace = true }
canon-json = { workspace = true }
openat = "0.1.21"
openat-ext = "0.2.3"
nom = "8.0.0"

[dev-dependencies]
similar-asserts = { workspace = true }
Expand Down
88 changes: 0 additions & 88 deletions crates/lib/src/bls_config.rs

This file was deleted.

43 changes: 34 additions & 9 deletions crates/lib/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use ostree_container::store::PrepareResult;
use ostree_ext::composefs::fsverity;
use ostree_ext::composefs::fsverity::FsVerityHashValue;
use ostree_ext::container as ostree_container;
use ostree_ext::container_utils::{composefs_booted, ostree_booted};
use ostree_ext::container_utils::ostree_booted;
use ostree_ext::keyfileext::KeyFileExt;
use ostree_ext::ostree;
use schemars::schema_for;
Expand All @@ -36,7 +36,7 @@ use crate::progress_jsonl::{ProgressWriter, RawProgressFd};
use crate::spec::Host;
use crate::spec::ImageReference;
use crate::status::composefs_deployment_status;
use crate::utils::sigpolicy_from_opt;
use crate::utils::{composefs_booted, sigpolicy_from_opt};

/// Shared progress options
#[derive(Debug, Parser, PartialEq, Eq)]
Expand Down Expand Up @@ -798,13 +798,29 @@ async fn upgrade_composefs(_opts: UpgradeOpts) -> Result<()> {
};

let boot_type = BootType::from(&entry);
let mut boot_digest = None;

match boot_type {
BootType::Bls => setup_composefs_bls_boot(BootSetupType::Upgrade, repo, &id, entry),
BootType::Uki => setup_composefs_uki_boot(BootSetupType::Upgrade, repo, &id, entry),
}?;
BootType::Bls => {
boot_digest = Some(setup_composefs_bls_boot(
BootSetupType::Upgrade,
repo,
&id,
entry,
)?)
}

write_composefs_state(&Utf8PathBuf::from("/sysroot"), id, imgref, true, boot_type)?;
BootType::Uki => setup_composefs_uki_boot(BootSetupType::Upgrade, repo, &id, entry)?,
};

write_composefs_state(
&Utf8PathBuf::from("/sysroot"),
id,
imgref,
true,
boot_type,
boot_digest,
)?;

Ok(())
}
Expand Down Expand Up @@ -966,18 +982,27 @@ async fn switch_composefs(opts: SwitchOpts) -> Result<()> {
};

let boot_type = BootType::from(&entry);
let mut boot_digest = None;

match boot_type {
BootType::Bls => setup_composefs_bls_boot(BootSetupType::Upgrade, repo, &id, entry),
BootType::Uki => setup_composefs_uki_boot(BootSetupType::Upgrade, repo, &id, entry),
}?;
BootType::Bls => {
boot_digest = Some(setup_composefs_bls_boot(
BootSetupType::Upgrade,
repo,
&id,
entry,
)?)
}
BootType::Uki => setup_composefs_uki_boot(BootSetupType::Upgrade, repo, &id, entry)?,
};

write_composefs_state(
&Utf8PathBuf::from("/sysroot"),
id,
&target_imgref,
true,
boot_type,
boot_digest,
)?;

Ok(())
Expand Down
38 changes: 38 additions & 0 deletions crates/lib/src/composefs_consts.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/// composefs= paramter in kernel cmdline
pub const COMPOSEFS_CMDLINE: &str = "composefs=";
/// composefs=? paramter in kernel cmdline. The `?` signifies that the fs-verity validation is
/// optional in case the filesystem doesn't support it.
pub const COMPOSEFS_INSECURE_CMDLINE: &str = "composefs=?";

/// Directory to store transient state, such as staged deployemnts etc
pub(crate) const COMPOSEFS_TRANSIENT_STATE_DIR: &str = "/run/composefs";
/// File created in /run/composefs to record a staged-deployment
pub(crate) const COMPOSEFS_STAGED_DEPLOYMENT_FNAME: &str = "staged-deployment";

/// Absolute path to composefs-native state directory
pub(crate) const STATE_DIR_ABS: &str = "/sysroot/state/deploy";
/// Relative path to composefs-native state directory. Relative to /sysroot
pub(crate) const STATE_DIR_RELATIVE: &str = "state/deploy";
/// Relative path to the shared 'var' directory. Relative to /sysroot
pub(crate) const SHARED_VAR_PATH: &str = "state/os/default/var";

/// Section in .origin file to store boot related metadata
pub(crate) const ORIGIN_KEY_BOOT: &str = "boot";
/// Whether the deployment was booted with BLS or UKI
pub(crate) const ORIGIN_KEY_BOOT_TYPE: &str = "boot_type";
/// Key to store the SHA256 sum of vmlinuz + initrd for a deployment
pub(crate) const ORIGIN_KEY_BOOT_DIGEST: &str = "digest";

/// Filename for `loader/entries`
pub(crate) const BOOT_LOADER_ENTRIES: &str = "entries";
/// Filename for staged boot loader entries
pub(crate) const STAGED_BOOT_LOADER_ENTRIES: &str = "entries.staged";
/// Filename for rollback boot loader entries
pub(crate) const ROLLBACK_BOOT_LOADER_ENTRIES: &str = STAGED_BOOT_LOADER_ENTRIES;

/// Filename for grub user config
pub(crate) const USER_CFG: &str = "user.cfg";
/// Filename for staged grub user config
pub(crate) const USER_CFG_STAGED: &str = "user.cfg.staged";
/// Filename for rollback grub user config
pub(crate) const USER_CFG_ROLLBACK: &str = USER_CFG_STAGED;
Loading