rust-osdev/bootimage

bootimage runner run-args

Closed this issue · 9 comments

lmatz commented

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!

Two ideas:

  • Try run-args = ["-L", "~/Code/QEMU/pc-bios"] to pass it as two string parameters instead of one.
  • Try to replace the ~ with your /home/xxx directory (normally your shell does this, but we don't invoke it in a shell).
lmatz commented

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)

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

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.

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

Sorry for the late reply

Yes, executing with quotes can invoke qemu successfully.

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

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

Perfect!