+24
-9
@@ -64,7 +64,9 @@ fn build(image: &str) -> Result<()> {
|
||||
// Step 2: find vmlinuz
|
||||
let vmlinuz_src = mount_path.join("vmlinuz");
|
||||
if !vmlinuz_src.exists() {
|
||||
anyhow::bail!("Image missing required /vmlinuz. Place kernel at /vmlinuz in Containerfile.");
|
||||
anyhow::bail!(
|
||||
"Image missing required /vmlinuz. Place kernel at /vmlinuz in Containerfile."
|
||||
);
|
||||
}
|
||||
|
||||
// Step 3: prepare registry dir
|
||||
@@ -106,8 +108,12 @@ fn build(image: &str) -> Result<()> {
|
||||
|
||||
// Gzip initrd
|
||||
let initrd_file = fs::File::open(&initrd_raw)?;
|
||||
let mut initrd_writer = flate2::write::GzEncoder::new(File::create(&initrd_path)?, flate2::Compression::default());
|
||||
std::io::copy(&mut std::io::BufReader::new(initrd_file), &mut initrd_writer)?;
|
||||
let mut initrd_writer =
|
||||
flate2::write::GzEncoder::new(File::create(&initrd_path)?, flate2::Compression::default());
|
||||
std::io::copy(
|
||||
&mut std::io::BufReader::new(initrd_file),
|
||||
&mut initrd_writer,
|
||||
)?;
|
||||
initrd_writer.finish()?;
|
||||
fs::remove_file(&initrd_raw)?;
|
||||
println!("Created initrd -> {}", initrd_path.display());
|
||||
@@ -139,18 +145,27 @@ fn run(name: &str) -> Result<()> {
|
||||
);
|
||||
// Launch with a 5-second timeout for quick smoke verification
|
||||
let status = Command::new("timeout")
|
||||
.args(["5", "qemu-system-x86_64",
|
||||
"-m", "256",
|
||||
.args([
|
||||
"5",
|
||||
"qemu-system-x86_64",
|
||||
"-m",
|
||||
"256",
|
||||
"-nographic",
|
||||
"-kernel", vmlinuz_path.to_str().unwrap(),
|
||||
"-initrd", initrd_path.to_str().unwrap(),
|
||||
"-append", "console=ttyS0"])
|
||||
"-kernel",
|
||||
vmlinuz_path.to_str().unwrap(),
|
||||
"-initrd",
|
||||
initrd_path.to_str().unwrap(),
|
||||
"-append",
|
||||
"console=ttyS0",
|
||||
])
|
||||
.status()
|
||||
.context("Failed to launch qemu-system-x86_64")?;
|
||||
if status.success() {
|
||||
println!("QEMU exited cleanly (timeout or normal exit).");
|
||||
} else {
|
||||
println!("QEMU exited with non-zero status (timeout/expected for initrd boot without init).");
|
||||
println!(
|
||||
"QEMU exited with non-zero status (timeout/expected for initrd boot without init)."
|
||||
);
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user