fn main() {
    // Create the QEMU command
    let mut cmd = std::process::Command::new("qemu-system-x86_64");

    // Add all static QEMU options
    cmd.args([
        "-no-reboot", // Don't get stuck in a boot loop
        // Debugging support
        "-gdb",
        "tcp::1234",
        // Exit without having to implement shutdown properly
        // See https://os.phil-opp.com/testing/#exiting-qemu
        "-device",
        "isa-debug-exit,iobase=0xf4,iosize=0x04",
        // Print serial output to terminal
        "-serial",
        "stdio",
    ]);

    // Get the kernel path as determined by the build script
    let kernel_path = env!("KERNEL_PATH");

    // Point to UEFI firmware
    cmd.arg("-bios").arg(ovmf_prebuilt::ovmf_pure_efi());

    // Point to kernel binary
    cmd.arg("-drive")
        .arg(format!("format=raw,file={kernel_path}"));

    // Spawn and run QEMU
    let mut child = cmd.spawn().unwrap();
    child.wait().unwrap();
}