From 9ba87c661b3f02b72c970a9d084b019c0aa96e18 Mon Sep 17 00:00:00 2001 From: Tamir Duberstein Date: Tue, 7 Oct 2025 09:06:44 -0700 Subject: [PATCH] xtask: copy kernel config into the initramfs image MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When preparing the VM initramfs detect the `config-*` file that ships alongside the vmlinuz/modules in each kernel archive and install it under `/boot` (both as `/boot/config` and `/boot/config-`). This makes the running kernel’s configuration available inside the guest for the integration tests. --- test/integration-test/src/tests/feature_probe.rs | 2 +- xtask/src/run.rs | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/test/integration-test/src/tests/feature_probe.rs b/test/integration-test/src/tests/feature_probe.rs index c177c805..dd76759f 100644 --- a/test/integration-test/src/tests/feature_probe.rs +++ b/test/integration-test/src/tests/feature_probe.rs @@ -14,7 +14,7 @@ use crate::utils::kernel_assert; #[test_log::test] fn probe_supported_programs() { let current = aya::util::KernelVersion::current().unwrap(); - let kernel_config = kernel_config().unwrap_or_default(); + let kernel_config = kernel_config().unwrap(); macro_rules! is_supported { ($prog_type:expr) => { diff --git a/xtask/src/run.rs b/xtask/src/run.rs index 7174e58d..79433217 100644 --- a/xtask/src/run.rs +++ b/xtask/src/run.rs @@ -318,6 +318,7 @@ pub(crate) fn run(opts: Options) -> Result<()> { } let mut kernel_images = Vec::new(); + let mut configs = Vec::new(); for entry in WalkDir::new(&archive_dir) { let entry = entry.with_context(|| { format!("failed to read entry in {}", archive_dir.display()) @@ -345,6 +346,10 @@ pub(crate) fn run(opts: Options) -> Result<()> { .to_os_string(); kernel_images.push((path, kernel_version)) } + // "config-" + [b'c', b'o', b'n', b'f', b'i', b'g', b'-', ..] => { + configs.push(path); + } _ => {} } } @@ -358,6 +363,10 @@ pub(crate) fn run(opts: Options) -> Result<()> { kernel_images ), }; + let config = match configs.as_slice() { + [config] => config, + configs => bail!("multiple configs in {}: {:?}", archive.display(), configs), + }; let mut modules_dirs = Vec::new(); for entry in WalkDir::new(&archive_dir) { @@ -487,9 +496,15 @@ pub(crate) fn run(opts: Options) -> Result<()> { write_dir(Path::new("/bin")); write_dir(Path::new("/sbin")); + write_dir(Path::new("/boot")); write_dir(Path::new("/lib")); write_dir(Path::new("/lib/modules")); + write_file(Path::new("/boot/config"), config, "644 0 0"); + if let Some(name) = config.file_name() { + write_file(&Path::new("/boot").join(name), config, "644 0 0"); + } + test_distro.iter().for_each(|(name, path)| { if name == "init" { write_file(Path::new("/init"), path, "755 0 0");