main.rs
1 use std::process::Stdio; 2 3 fn main() { 4 // read env variables that were set in build script 5 let uefi_path = env!("UEFI_PATH"); 6 let bios_path = env!("BIOS_PATH"); 7 8 println!("{uefi_path} \n {bios_path}"); 9 10 // choose whether to start the UEFI or BIOS image 11 let uefi = true; 12 13 let mut cmd = std::process::Command::new("qemu-system-x86_64"); 14 cmd.arg("-serial").arg("stdio"); 15 cmd.stdout(Stdio::inherit()); 16 if uefi { 17 cmd.arg("-bios").arg(ovmf_prebuilt::ovmf_pure_efi()); 18 cmd.arg("-drive") 19 .arg(format!("format=raw,file={uefi_path}")); 20 } else { 21 cmd.arg("-drive") 22 .arg(format!("format=raw,file={bios_path}")); 23 } 24 let mut child = cmd.spawn().unwrap(); 25 child.wait().unwrap(); 26 }