Skip to content

Commit 3c7a620

Browse files
committed
install: Pick up kargs.d kernel arguments too
This was a rather important miss; we need to pick up the kargs.d files when doing a `bootc install` too. Signed-off-by: Colin Walters <[email protected]>
1 parent 0bd1956 commit 3c7a620

File tree

6 files changed

+23
-1
lines changed

6 files changed

+23
-1
lines changed

hack/Containerfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ COPY hack/provision-derived.sh /tmp
2323
RUN /tmp/provision-derived.sh "$variant" && rm -f /tmp/*.sh
2424
# Also copy in some default install configs we use for testing
2525
COPY hack/install-test-configs/* /usr/lib/bootc/install/
26+
# And some test kargs
27+
COPY hack/test-kargs /usr/lib/bootc/kargs.d/
2628
# Inject our built code
2729
COPY --from=build /out/bootc.tar.zst /tmp
2830
RUN tar -C / --zstd -xvf /tmp/bootc.tar.zst && rm -vrf /tmp/*

hack/test-kargs/10-test.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
kargs = ["kargsd-test=1", "kargsd-othertest=2"]

hack/test-kargs/20-test2.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
kargs = ["testing-kargsd=3"]

lib/src/install.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -538,6 +538,8 @@ async fn initialize_ostree_root_from_self(
538538
let sepolicy = state.load_policy()?;
539539
let sepolicy = sepolicy.as_ref();
540540

541+
let container_rootfs = &Dir::open_ambient_dir("/", cap_std::ambient_authority())?;
542+
541543
// Load a fd for the mounted target physical root
542544
let rootfs_dir = &root_setup.rootfs_fd;
543545
let rootfs = root_setup.rootfs.as_path();
@@ -640,18 +642,29 @@ async fn initialize_ostree_root_from_self(
640642
imgref: src_imageref,
641643
};
642644

645+
// Load the kargs from the /usr/lib/bootc/kargs.d from the running root,
646+
// which should be the same as the filesystem we'll deploy.
647+
let kargsd = crate::kargs::get_kargs_in_root(container_rootfs, std::env::consts::ARCH)?;
648+
let kargsd = kargsd.iter().map(|s| s.as_str());
649+
643650
let install_config_kargs = state
644651
.install_config
645652
.as_ref()
646653
.and_then(|c| c.kargs.as_ref())
647654
.into_iter()
648655
.flatten()
649656
.map(|s| s.as_str());
657+
// Final kargs, in order:
658+
// - root filesystem kargs
659+
// - install config kargs
660+
// - kargs.d from container image
661+
// - args specified on the CLI
650662
let kargs = root_setup
651663
.kargs
652664
.iter()
653665
.map(|v| v.as_str())
654666
.chain(install_config_kargs)
667+
.chain(kargsd)
655668
.chain(state.config_opts.karg.iter().flatten().map(|v| v.as_str()))
656669
.collect::<Vec<_>>();
657670
let mut options = ostree_container::deploy::DeployOpts::default();

lib/src/kargs.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ struct Config {
2222

2323
/// Load and parse all bootc kargs.d files in the specified root, returning
2424
/// a combined list.
25-
fn get_kargs_in_root(d: &Dir, sys_arch: &str) -> Result<Vec<String>> {
25+
pub(crate) fn get_kargs_in_root(d: &Dir, sys_arch: &str) -> Result<Vec<String>> {
2626
// If the directory doesn't exist, that's OK.
2727
let d = if let Some(d) = d.open_dir_optional("usr/lib/bootc/kargs.d")? {
2828
d

tests-integration/src/install.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,11 @@ pub(crate) fn run_alongside(image: &str, mut testargs: libtest_mimic::Arguments)
100100
"sudo /bin/sh -c 'grep localtestkarg=somevalue /boot/loader/entries/*.conf'"
101101
)
102102
.run()?;
103+
cmd!(
104+
sh,
105+
"sudo /bin/sh -c 'grep testing-kargsd=3 /boot/loader/entries/*.conf'"
106+
)
107+
.run()?;
103108
let deployment = &find_deployment_root()?;
104109
let cwd = sh.push_dir(format!("/proc/self/fd/{}", deployment.as_raw_fd()));
105110
cmd!(

0 commit comments

Comments
 (0)