xtask: copy kernel config into the initramfs image

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-<version>`). This makes the running
kernel’s configuration available inside the guest for the integration tests.
reviewable/pr1359/r6
Tamir Duberstein 1 month ago
parent 8edd97888c
commit 41d08c7ff2
No known key found for this signature in database

@ -14,7 +14,7 @@ use crate::utils::kernel_assert;
#[test_log::test] #[test_log::test]
fn probe_supported_programs() { fn probe_supported_programs() {
let current = aya::util::KernelVersion::current().unwrap(); 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 { macro_rules! is_supported {
($prog_type:expr) => { ($prog_type:expr) => {

@ -319,6 +319,7 @@ pub(crate) fn run(opts: Options) -> Result<()> {
} }
let mut kernel_images = Vec::new(); let mut kernel_images = Vec::new();
let mut configs = Vec::new();
for entry in WalkDir::new(archive_dir.join("boot")) { for entry in WalkDir::new(archive_dir.join("boot")) {
let entry = entry.context("read_dir failed")?; let entry = entry.context("read_dir failed")?;
if !entry.file_type().is_file() { if !entry.file_type().is_file() {
@ -331,6 +332,10 @@ pub(crate) fn run(opts: Options) -> Result<()> {
[b'v', b'm', b'l', b'i', b'n', b'u', b'z', b'-', ..] => { [b'v', b'm', b'l', b'i', b'n', b'u', b'z', b'-', ..] => {
kernel_images.push(path) kernel_images.push(path)
} }
// "config-"
[b'c', b'o', b'n', b'f', b'i', b'g', b'-', ..] => {
configs.push(path);
}
_ => {} _ => {}
} }
} }
@ -343,6 +348,10 @@ pub(crate) fn run(opts: Options) -> Result<()> {
kernel_images kernel_images
), ),
}; };
let config = match configs.as_slice() {
[config] => config,
configs => bail!("multiple configs in {}: {:?}", archive.display(), configs),
};
let mut modules_dirs = Vec::new(); let mut modules_dirs = Vec::new();
for prefix in ["usr/lib/modules", "lib/modules"] { for prefix in ["usr/lib/modules", "lib/modules"] {
@ -479,9 +488,15 @@ pub(crate) fn run(opts: Options) -> Result<()> {
write_dir(Path::new("/bin")); write_dir(Path::new("/bin"));
write_dir(Path::new("/sbin")); write_dir(Path::new("/sbin"));
write_dir(Path::new("/boot"));
write_dir(Path::new("/lib")); write_dir(Path::new("/lib"));
write_dir(Path::new("/lib/modules")); 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)| { test_distro.iter().for_each(|(name, path)| {
if name == "init" { if name == "init" {
write_file(Path::new("/init"), path, "755 0 0"); write_file(Path::new("/init"), path, "755 0 0");

Loading…
Cancel
Save