rust-osdev / bootimage

Tool to create bootable disk images from a Rust OS kernel.
Apache License 2.0
767 stars 67 forks source link

bootimage runner run-args #42

Closed lmatz closed 5 years ago

lmatz commented 5 years ago

Hi! I am executing bootimage runner on MacOS, and my bios-256k.bin of QEMU is not under normal path, so I have to manually add "-L ~/XXX/QEMU/pc-bios" to the qemu-system-x86_64 command and it can successfully run it. However, when I try to use [package.metadata.bootimage]'s run-args = ["-L ~/Code/QEMU/pc-bios"] to invoke cargo xrun, it shows

Running: qemu-system-x86_64 -drive format=raw,file=target/minikernel/debug/bootimage-minikernel.bin -L ~/Code/QEMU/pc-bios Error: Failed to execute "qemu-system-x86_64" "-drive" "format=raw,file=target/minikernel/debug/bootimage-minikernel.bin" "-L ~/Code/QEMU/pc-bios": No such file or directory (os error 2)

Am I doing it the wrong way? Thanks!

phil-opp commented 5 years ago

Two ideas:

lmatz commented 5 years ago

Thanks for the ideas, I tried both at the same time.

[package.metadata.bootimage] run-args = ["-L", "/Users/XXX/Code/QEMU/pc-bios"]

However, the error still exists:

Running: qemu-system-x86_64 -drive format=raw,file=target/minikernel/debug/bootimage-minikernel.bin -L /Users/XXX/Code/QEMU/pc-bios Error: Failed to execute "qemu-system-x86_64" "-drive" "format=raw,file=target/minikernel/debug/bootimage-minikernel.bin" "-L" "/Users/XXX/Code/QEMU/pc-bios": No such file or directory (os error 2)

phil-opp commented 5 years ago

Have you tried executing the printed run command manually:

qemu-system-x86_64 -drive format=raw,file=target/minikernel/debug/bootimage-minikernel.bin -L /Users/XXX/Code/QEMU/pc-bios

Maybe directly invoking QEMU gives a better error message.

The error message sounds like either the path to your pc-bios or the path to your bootimage-minikernel.bin are wrong. Could you check whether both files exist at the printed locations?

lmatz commented 5 years ago

Directly executing this command would successfully invoke the qemu, and no errors in qemu or shell pops out.

These two paths indeed exist. I am also really confused about this.

phil-opp commented 5 years ago

That's strange. Could you also try it with the quotes:

"qemu-system-x86_64" "-drive" "format=raw,file=target/minikernel/debug/bootimage-minikernel.bin" "-L" "/Users/XXX/Code/QEMU/pc-bios"
lmatz commented 5 years ago

Sorry for the late reply

Yes, executing with quotes can invoke qemu successfully.

phil-opp commented 5 years ago

Ah, I think I interpreted the error message wrong. The "No such file or directory" might refer to the QEMU executable. Are you sure that it's in your PATH?

lmatz commented 5 years ago

Oh, after I change the qemu path in PATH variable to be the absolute path instead of "~/XXX", it works! Thank you!

phil-opp commented 5 years ago

Perfect!