mirror of
https://github.com/asterinas/asterinas.git
synced 2025-06-23 01:13: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();
|
let exit_status = qemu_cmd.status().unwrap();
|
||||||
if !exit_status.success() {
|
if !exit_status.success() {
|
||||||
// FIXME: Exit code manipulation is not needed when using non-x86 QEMU
|
// FIXME: Exit code manipulation is not needed when using non-x86 QEMU
|
||||||
let exit_code = exit_status.code().unwrap_or(0b10) >> 1;
|
let qemu_exit_code = exit_status.code().unwrap();
|
||||||
std::process::exit(exit_code);
|
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
|
/// The exit code of x86 QEMU isa debug device. In `qemu-system-x86_64` the
|
||||||
/// `(code << 1) | 1`. So you could never let QEMU invoke `exit(0)`. Check
|
/// exit code will be `(code << 1) | 1`. So you could never let QEMU invoke
|
||||||
/// if the result is `0b01` instead.
|
/// `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")]
|
#[cfg(target_arch = "x86_64")]
|
||||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||||
#[repr(u32)]
|
#[repr(u32)]
|
||||||
pub enum QemuExitCode {
|
pub enum QemuExitCode {
|
||||||
Success = 0b0,
|
Success = 0x10,
|
||||||
Failed = 0b1,
|
Failed = 0x20,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn exit_qemu(exit_code: QemuExitCode) -> ! {
|
pub fn exit_qemu(exit_code: QemuExitCode) -> ! {
|
||||||
|
Reference in New Issue
Block a user