From 18f890f9bb7ea76646c5be53b9a8ff8f3698b8c7 Mon Sep 17 00:00:00 2001 From: Colin Walters Date: Tue, 5 Aug 2025 09:52:34 -0400 Subject: [PATCH 1/2] Rename kargs.rs -> bootc_kargs.rs It's confusing we have both kargs.rs and kernel.rs where the latter is also handling kernel arguments. Clarify what this does. Signed-off-by: Colin Walters --- crates/lib/src/{kargs.rs => bootc_kargs.rs} | 2 ++ crates/lib/src/deploy.rs | 2 +- crates/lib/src/install.rs | 2 +- crates/lib/src/install/completion.rs | 2 +- crates/lib/src/lib.rs | 2 +- crates/lib/src/lints.rs | 2 +- 6 files changed, 7 insertions(+), 5 deletions(-) rename crates/lib/src/{kargs.rs => bootc_kargs.rs} (98%) diff --git a/crates/lib/src/kargs.rs b/crates/lib/src/bootc_kargs.rs similarity index 98% rename from crates/lib/src/kargs.rs rename to crates/lib/src/bootc_kargs.rs index 790ba919b..028b6a5d9 100644 --- a/crates/lib/src/kargs.rs +++ b/crates/lib/src/bootc_kargs.rs @@ -1,3 +1,4 @@ +//! This module handles the bootc-owned kernel argument lists in `/usr/lib/bootc/kargs.d`. use anyhow::{Context, Result}; use camino::Utf8Path; use cap_std_ext::cap_std::fs::Dir; @@ -15,6 +16,7 @@ use serde::Deserialize; use crate::deploy::ImageState; use crate::store::Storage; +/// The relative path to the kernel arguments which may be embedded in an image. const KARGS_PATH: &str = "usr/lib/bootc/kargs.d"; /// The kargs.d configuration file. diff --git a/crates/lib/src/deploy.rs b/crates/lib/src/deploy.rs index 7be49acb9..b003e70f7 100644 --- a/crates/lib/src/deploy.rs +++ b/crates/lib/src/deploy.rs @@ -538,7 +538,7 @@ async fn deploy( // is a distinct minor issue, but not super important as right now the install path // doesn't use this API). let override_kargs = if let Some(deployment) = merge_deployment { - Some(crate::kargs::get_kargs(sysroot, &deployment, image)?) + Some(crate::bootc_kargs::get_kargs(sysroot, &deployment, image)?) } else { None }; diff --git a/crates/lib/src/install.rs b/crates/lib/src/install.rs index 876e61a1a..1ccfc9e58 100644 --- a/crates/lib/src/install.rs +++ b/crates/lib/src/install.rs @@ -817,7 +817,7 @@ async fn install_container( .repo() .read_commit(pulled_image.ostree_commit.as_str(), gio::Cancellable::NONE)? .0; - let kargsd = crate::kargs::get_kargs_from_ostree_root( + let kargsd = crate::bootc_kargs::get_kargs_from_ostree_root( &sysroot.repo(), merged_ostree_root.downcast_ref().unwrap(), std::env::consts::ARCH, diff --git a/crates/lib/src/install/completion.rs b/crates/lib/src/install/completion.rs index 58157fca2..cddff28d9 100644 --- a/crates/lib/src/install/completion.rs +++ b/crates/lib/src/install/completion.rs @@ -65,7 +65,7 @@ fn reconcile_kargs(sysroot: &ostree::Sysroot, deployment: &ostree::Deployment) - .flatten() .map(|s| s.as_str()) .collect::>(); - let kargsd = crate::kargs::get_kargs_in_root(deployment_root, std::env::consts::ARCH)?; + let kargsd = crate::bootc_kargs::get_kargs_in_root(deployment_root, std::env::consts::ARCH)?; let kargsd = kargsd.iter().map(|s| s.as_str()).collect::>(); current_kargs.append_argv(&install_config_kargs); diff --git a/crates/lib/src/lib.rs b/crates/lib/src/lib.rs index dcf1841ab..87fa4d5a6 100644 --- a/crates/lib/src/lib.rs +++ b/crates/lib/src/lib.rs @@ -4,6 +4,7 @@ //! to provide a fully "container native" tool for using //! bootable container images. +pub(crate) mod bootc_kargs; mod boundimage; mod cfsctl; pub mod cli; @@ -15,7 +16,6 @@ mod image; mod imgstorage; pub(crate) mod journal; mod k8sapitypes; -pub(crate) mod kargs; mod lints; mod lsm; pub(crate) mod metadata; diff --git a/crates/lib/src/lints.rs b/crates/lib/src/lints.rs index 9dff48cb4..ad326b0cc 100644 --- a/crates/lib/src/lints.rs +++ b/crates/lib/src/lints.rs @@ -465,7 +465,7 @@ static LINT_KARGS: Lint = Lint::new_fatal( check_parse_kargs, ); fn check_parse_kargs(root: &Dir, _config: &LintExecutionConfig) -> LintResult { - let args = crate::kargs::get_kargs_in_root(root, ARCH)?; + let args = crate::bootc_kargs::get_kargs_in_root(root, ARCH)?; tracing::debug!("found kargs: {args:?}"); lint_ok() } From 1cbfdc8c8798beeac2fa94a6ce588a59925bbc40 Mon Sep 17 00:00:00 2001 From: Colin Walters Date: Tue, 5 Aug 2025 09:55:12 -0400 Subject: [PATCH 2/2] Rename kernel.rs -> kernel_cmdline.rs To clarify what this does more. Signed-off-by: Colin Walters --- crates/lib/src/install.rs | 11 ++++++----- crates/lib/src/{kernel.rs => kernel_cmdline.rs} | 0 crates/lib/src/lib.rs | 2 +- 3 files changed, 7 insertions(+), 6 deletions(-) rename crates/lib/src/{kernel.rs => kernel_cmdline.rs} (100%) diff --git a/crates/lib/src/install.rs b/crates/lib/src/install.rs index 1ccfc9e58..2afc12616 100644 --- a/crates/lib/src/install.rs +++ b/crates/lib/src/install.rs @@ -55,7 +55,7 @@ use self::baseline::InstallBlockDeviceOpts; use crate::boundimage::{BoundImage, ResolvedBoundImage}; use crate::containerenv::ContainerExecutionInfo; use crate::deploy::{prepare_for_pull, pull_from_prepared, PreparedImportMeta, PreparedPullResult}; -use crate::kernel::Cmdline; +use crate::kernel_cmdline::Cmdline; use crate::lsm; use crate::progress_jsonl::ProgressWriter; use crate::spec::ImageReference; @@ -1668,10 +1668,11 @@ fn find_root_args_to_inherit(cmdline: &Cmdline, root_info: &Filesystem) -> Resul .context("Parsing root= karg")?; // If we have a root= karg, then use that let (mount_spec, kargs) = if let Some(root) = root { - let rootflags = cmdline.find(crate::kernel::ROOTFLAGS); - let inherit_kargs = cmdline - .iter() - .filter(|arg| arg.key.starts_with(crate::kernel::INITRD_ARG_PREFIX)); + let rootflags = cmdline.find(crate::kernel_cmdline::ROOTFLAGS); + let inherit_kargs = cmdline.iter().filter(|arg| { + arg.key + .starts_with(crate::kernel_cmdline::INITRD_ARG_PREFIX) + }); ( root.to_owned(), rootflags diff --git a/crates/lib/src/kernel.rs b/crates/lib/src/kernel_cmdline.rs similarity index 100% rename from crates/lib/src/kernel.rs rename to crates/lib/src/kernel_cmdline.rs diff --git a/crates/lib/src/lib.rs b/crates/lib/src/lib.rs index 87fa4d5a6..a60d0bc30 100644 --- a/crates/lib/src/lib.rs +++ b/crates/lib/src/lib.rs @@ -34,7 +34,7 @@ mod docgen; mod bootloader; mod containerenv; mod install; -mod kernel; +mod kernel_cmdline; #[cfg(feature = "grub")] pub(crate) mod parsers;