mirror of
https://github.com/asterinas/asterinas.git
synced 2025-06-22 17:03:23 +00:00
Runner should return error if qemu itself fails
This commit is contained in:
committed by
Tate, Hongliang Tian
parent
079b139298
commit
7b390d9f8a
@ -112,8 +112,13 @@ fn main() {
|
||||
let exit_status = qemu_cmd.status().unwrap();
|
||||
if !exit_status.success() {
|
||||
// FIXME: Exit code manipulation is not needed when using non-x86 QEMU
|
||||
let exit_code = exit_status.code().unwrap_or(0b10) >> 1;
|
||||
std::process::exit(exit_code);
|
||||
let qemu_exit_code = exit_status.code().unwrap();
|
||||
let kernel_exit_code = qemu_exit_code >> 1;
|
||||
match kernel_exit_code {
|
||||
0x10 /*jinux_frame::QemuExitCode::Success*/ => { std::process::exit(0); },
|
||||
0x20 /*jinux_frame::QemuExitCode::Failed*/ => { std::process::exit(1); },
|
||||
_ => { std::process::exit(qemu_exit_code) },
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -147,15 +147,17 @@ pub fn panic_handler() {
|
||||
// }
|
||||
}
|
||||
|
||||
/// The exit code of x86 QEMU. In `qemu-system-x86_64` the exit code will be
|
||||
/// `(code << 1) | 1`. So you could never let QEMU invoke `exit(0)`. Check
|
||||
/// if the result is `0b01` instead.
|
||||
/// The exit code of x86 QEMU isa debug device. In `qemu-system-x86_64` the
|
||||
/// exit code will be `(code << 1) | 1`. So you could never let QEMU invoke
|
||||
/// `exit(0)`. We also need to check if the exit code is returned by the
|
||||
/// kernel, so we couldn't use 0 as exit_success because this may conflict
|
||||
/// with QEMU return value 1, which indicates that QEMU itself fails.
|
||||
#[cfg(target_arch = "x86_64")]
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
#[repr(u32)]
|
||||
pub enum QemuExitCode {
|
||||
Success = 0b0,
|
||||
Failed = 0b1,
|
||||
Success = 0x10,
|
||||
Failed = 0x20,
|
||||
}
|
||||
|
||||
pub fn exit_qemu(exit_code: QemuExitCode) -> ! {
|
||||
|
Reference in New Issue
Block a user