Skip to content

Commit f7c34ad

Browse files
committed
fix: cargo xtask qemu
1 parent 5e3bff0 commit f7c34ad

File tree

3 files changed

+11
-5
lines changed

3 files changed

+11
-5
lines changed

.github/workflows/qemu-aarch64.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ args = [
55
"-machine",
66
"virt,virtualization=on,gic-version=3",
77
"-smp",
8-
"1",
8+
"4",
99
"-append",
1010
"root=/dev/vda rw init=/init",
1111
"-m",

xtask/src/cargo.rs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@ use ostool::run::cargo::CargoRunnerKind;
55
use crate::ctx::Context;
66

77
impl Context {
8-
pub async fn run_qemu(&mut self) -> anyhow::Result<()> {
8+
pub async fn run_qemu(&mut self, config_path: Option<PathBuf>) -> anyhow::Result<()> {
99
let build_config = self.load_config()?;
10+
1011
let arch = if build_config.target.contains("aarch64") {
1112
Arch::Aarch64
1213
} else if build_config.target.contains("x86_64") {
@@ -17,9 +18,14 @@ impl Context {
1718
build_config.target
1819
));
1920
};
21+
22+
let config_path = if let Some(path) = config_path {
23+
path
24+
} else {
25+
PathBuf::from(format!(".qemu-{arch:?}.toml").to_lowercase())
26+
};
2027

21-
let config_path = PathBuf::from(format!(".qemu-{arch:?}.toml").to_lowercase());
22-
28+
// 如果配置文件不存在,从默认位置复制
2329
if !config_path.exists() {
2430
fs::copy(
2531
PathBuf::from("scripts")

xtask/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ async fn main() -> Result<()> {
104104
Commands::Qemu(args) => {
105105
ctx.vmconfigs = args.vmconfigs;
106106
ctx.build_config_path = args.build_config;
107-
ctx.run_qemu().await?;
107+
ctx.run_qemu(args.qemu_config).await?;
108108
}
109109
Commands::Uboot(args) => {
110110
ctx.vmconfigs = args.vmconfigs;

0 commit comments

Comments
 (0)