mirror of
https://github.com/asterinas/asterinas.git
synced 2025-06-09 05:16:47 +00:00
Pass argument to qemu
This commit is contained in:
parent
eb2b951f7c
commit
9bc9aa180d
1
Makefile
1
Makefile
@ -11,7 +11,6 @@ setup:
|
|||||||
build:
|
build:
|
||||||
@make --no-print-directory -C src/ramdisk
|
@make --no-print-directory -C src/ramdisk
|
||||||
@cd src && cargo kbuild
|
@cd src && cargo kbuild
|
||||||
@cd src && cargo kimage
|
|
||||||
|
|
||||||
tools:
|
tools:
|
||||||
@cd src/services/comp-sys && cargo install --path cargo-component
|
@cd src/services/comp-sys && cargo install --path cargo-component
|
||||||
|
@ -5,7 +5,6 @@ runner = "cargo run --package jinux-boot --"
|
|||||||
[alias]
|
[alias]
|
||||||
kcheck = "check --target x86_64-custom.json -Zbuild-std=core,alloc,compiler_builtins -Zbuild-std-features=compiler-builtins-mem"
|
kcheck = "check --target x86_64-custom.json -Zbuild-std=core,alloc,compiler_builtins -Zbuild-std-features=compiler-builtins-mem"
|
||||||
kbuild = "build --target x86_64-custom.json -Zbuild-std=core,alloc,compiler_builtins -Zbuild-std-features=compiler-builtins-mem"
|
kbuild = "build --target x86_64-custom.json -Zbuild-std=core,alloc,compiler_builtins -Zbuild-std-features=compiler-builtins-mem"
|
||||||
kimage = "run --target x86_64-custom.json -Zbuild-std=core,alloc,compiler_builtins -Zbuild-std-features=compiler-builtins-mem -- --no-run"
|
|
||||||
krun = "run --target x86_64-custom.json -Zbuild-std=core,alloc,compiler_builtins -Zbuild-std-features=compiler-builtins-mem"
|
krun = "run --target x86_64-custom.json -Zbuild-std=core,alloc,compiler_builtins -Zbuild-std-features=compiler-builtins-mem"
|
||||||
ktest = "test --target x86_64-custom.json -Zbuild-std=core,alloc,compiler_builtins -Zbuild-std-features=compiler-builtins-mem"
|
ktest = "test --target x86_64-custom.json -Zbuild-std=core,alloc,compiler_builtins -Zbuild-std-features=compiler-builtins-mem"
|
||||||
component-check = "component check --target x86_64-custom.json -Zbuild-std=core,alloc,compiler_builtins -Zbuild-std-features=compiler-builtins-mem"
|
component-check = "component check --target x86_64-custom.json -Zbuild-std=core,alloc,compiler_builtins -Zbuild-std-features=compiler-builtins-mem"
|
||||||
|
@ -16,30 +16,24 @@ const COMMON_ARGS: &[&str] = &[
|
|||||||
"virtio-blk-pci,bus=pci.0,addr=0x6,drive=x0",
|
"virtio-blk-pci,bus=pci.0,addr=0x6,drive=x0",
|
||||||
"-device",
|
"-device",
|
||||||
"virtio-keyboard-pci",
|
"virtio-keyboard-pci",
|
||||||
|
"-monitor",
|
||||||
|
"vc",
|
||||||
"-serial",
|
"-serial",
|
||||||
"mon:stdio",
|
"mon:stdio",
|
||||||
"-display",
|
"-display",
|
||||||
"none",
|
"none",
|
||||||
];
|
];
|
||||||
|
|
||||||
const RUN_ARGS: &[&str] = &["-s"];
|
const RUN_ARGS: &[&str] = &[];
|
||||||
const TEST_ARGS: &[&str] = &[];
|
const TEST_ARGS: &[&str] = &[];
|
||||||
const TEST_TIMEOUT_SECS: u64 = 30;
|
const TEST_TIMEOUT_SECS: u64 = 30;
|
||||||
fn main() -> anyhow::Result<()> {
|
fn main() -> anyhow::Result<()> {
|
||||||
let mut args = std::env::args().skip(1);
|
let mut run_args = std::env::args().skip(1);
|
||||||
let kernel_binary_path = {
|
let kernel_binary_path = {
|
||||||
let path = PathBuf::from(args.next().unwrap());
|
let path = PathBuf::from(run_args.next().unwrap());
|
||||||
path.canonicalize().unwrap()
|
path.canonicalize().unwrap()
|
||||||
};
|
};
|
||||||
|
|
||||||
let no_boot = if let Some(arg) = args.next() {
|
|
||||||
match arg.as_str() {
|
|
||||||
"--no-run" => true,
|
|
||||||
other => panic!("unexpected argument `{}`", other),
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
false
|
|
||||||
};
|
|
||||||
|
|
||||||
#[cfg(feature = "limine")]
|
#[cfg(feature = "limine")]
|
||||||
call_limine_build_script(&kernel_binary_path).unwrap();
|
call_limine_build_script(&kernel_binary_path).unwrap();
|
||||||
@ -56,10 +50,6 @@ fn main() -> anyhow::Result<()> {
|
|||||||
a.join(str.add(".iso"))
|
a.join(str.add(".iso"))
|
||||||
};
|
};
|
||||||
|
|
||||||
if no_boot {
|
|
||||||
println!("Created disk image at `{}`", kernel_iso_path.display());
|
|
||||||
return Ok(());
|
|
||||||
}
|
|
||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
let mut run_cmd = Command::new("qemu-system-x86_64.exe");
|
let mut run_cmd = Command::new("qemu-system-x86_64.exe");
|
||||||
#[cfg(not(windows))]
|
#[cfg(not(windows))]
|
||||||
@ -74,7 +64,8 @@ fn main() -> anyhow::Result<()> {
|
|||||||
if binary_kind.is_test() {
|
if binary_kind.is_test() {
|
||||||
args.append(&mut TEST_ARGS.to_vec());
|
args.append(&mut TEST_ARGS.to_vec());
|
||||||
run_cmd.args(args);
|
run_cmd.args(args);
|
||||||
println!("running:{:?}", run_cmd);
|
run_cmd.args(run_args);
|
||||||
|
println!("testing:{:?}", run_cmd);
|
||||||
|
|
||||||
let exit_status = run_test_command(run_cmd)?;
|
let exit_status = run_test_command(run_cmd)?;
|
||||||
match exit_status.code() {
|
match exit_status.code() {
|
||||||
@ -84,6 +75,7 @@ fn main() -> anyhow::Result<()> {
|
|||||||
} else {
|
} else {
|
||||||
args.append(&mut RUN_ARGS.to_vec());
|
args.append(&mut RUN_ARGS.to_vec());
|
||||||
run_cmd.args(args);
|
run_cmd.args(args);
|
||||||
|
run_cmd.args(run_args);
|
||||||
println!("running:{:?}", run_cmd);
|
println!("running:{:?}", run_cmd);
|
||||||
|
|
||||||
let exit_status = run_cmd.status()?;
|
let exit_status = run_cmd.status()?;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user