Switch to stable -blockdev/-device flags and enable -nodefaults

This commit is contained in:
pjht 2024-08-21 14:33:11 -05:00
parent 5fe044cbec
commit fc4301f132
Signed by: pjht
GPG Key ID: 7B5F6AFBEC7EE78E

View File

@ -1,25 +1,33 @@
fn main() { fn main() {
// read env variables that were set in build script // read env variables that were set in build script
let uefi_path = env!("UEFI_PATH"); let uefi_path = env!("UEFI_PATH");
// let bios_path = env!("BIOS_PATH"); //let bios_path = env!("BIOS_PATH");
let mut cmd = std::process::Command::new("qemu-system-x86_64"); let mut cmd = std::process::Command::new("qemu-system-x86_64");
cmd.arg("-nographic"); cmd.arg("-nographic");
cmd.arg("-nodefaults");
cmd.arg("-m").arg("4G"); cmd.arg("-m").arg("4G");
cmd.arg("-device")
.arg("isa-debug-exit,iobase=0xf4,iosize=0x04");
cmd.arg("--no-reboot"); cmd.arg("--no-reboot");
cmd.arg("--machine").arg("type=q35,accel=kvm"); cmd.arg("--machine")
.arg("type=q35,accel=kvm,sata=false,smbus=false");
cmd.arg("-bios").arg(ovmf_prebuilt::ovmf_pure_efi()); cmd.arg("-bios").arg(ovmf_prebuilt::ovmf_pure_efi());
cmd.arg("-drive")
.arg(format!("format=raw,file={uefi_path},if=ide,index=0"));
//.arg(format!("format=raw,file={bios_path}"));
cmd.arg("-drive")
.arg("format=raw,file=ext2.img,if=ide,index=1");
//cmd.arg("-s");
//cmd.arg("-S");
cmd.arg("-serial").arg("mon:stdio"); cmd.arg("-serial").arg("mon:stdio");
cmd.arg("-serial").arg("file:capture.pcapng"); cmd.arg("-serial").arg("file:capture.pcapng");
cmd.arg("-device").arg("ahci,id=ahci");
//cmd.arg("-device").arg("VGA");
cmd.arg("-blockdev").arg(format!(
"driver=raw,node-name=boot,file.driver=file,file.filename={uefi_path}"
));
//cmd.arg("-blockdev").arg(format!(
// "driver=raw,node-name=boot,file.driver=file,file.filename={bios_path}"
//));
cmd.arg("-device").arg("ide-hd,drive=boot,bus=ahci.0");
cmd.arg("-blockdev").arg(format!(
"driver=raw,node-name=fs,file.driver=file,file.filename=ext2.img"
));
cmd.arg("-device").arg("ide-hd,drive=fs,bus=ahci.1");
cmd.arg("-device")
.arg("isa-debug-exit,iobase=0xf4,iosize=0x04");
let mut child = cmd.spawn().unwrap(); let mut child = cmd.spawn().unwrap();
child.wait().unwrap(); child.wait().unwrap();
} }