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/r14
Tamir Duberstein 1 week ago
parent 5f046899b5
commit 9ba87c661b
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) => {

@ -318,6 +318,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) { for entry in WalkDir::new(&archive_dir) {
let entry = entry.with_context(|| { let entry = entry.with_context(|| {
format!("failed to read entry in {}", archive_dir.display()) format!("failed to read entry in {}", archive_dir.display())
@ -345,6 +346,10 @@ pub(crate) fn run(opts: Options) -> Result<()> {
.to_os_string(); .to_os_string();
kernel_images.push((path, kernel_version)) 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 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 entry in WalkDir::new(&archive_dir) { 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("/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