Skip to content

Commit 94e8ac0

Browse files
committed
feat: 添加 Windows 平台下 QEMU 可执行文件的检查与路径处理
1 parent 10c5b68 commit 94e8ac0

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

ostool/src/run/qemu.rs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,22 @@ impl QemuRunner {
130130
machine = format!("{},dumpdtb=target/qemu.dtb", machine);
131131
}
132132

133-
let mut cmd = self.ctx.command(&format!("qemu-system-{arch}"));
133+
let mut qemu_executable = format!("qemu-system-{}", arch);
134+
135+
#[cfg(windows)]
136+
{
137+
println!("{}", "Checking for QEMU executable on Windows...".blue());
138+
// Windows 特殊处理
139+
let msys2 =
140+
PathBuf::from("C:\\msys64\\ucrt64\\bin").join(format!("{qemu_executable}.exe"));
141+
142+
if msys2.exists() {
143+
println!("Using QEMU executable from MSYS2: {}", msys2.display());
144+
qemu_executable = msys2.to_string_lossy().to_string();
145+
}
146+
}
147+
148+
let mut cmd = self.ctx.command(&qemu_executable);
134149
for arg in &self.config.args {
135150
cmd.arg(arg);
136151
}

0 commit comments

Comments
 (0)