From f9b34fe76fe8a1f39c4897f2d53703858a5c6527 Mon Sep 17 00:00:00 2001 From: Tamir Duberstein Date: Thu, 24 Oct 2024 09:55:09 -0400 Subject: [PATCH] qemu: remove bios argument I did this for arm64 because we'd get a black screen without it but I have now confirmed that console=ttyAMA0 solves that problem. I don't remember why I did it for x86. --- .github/workflows/ci.yml | 5 ++-- xtask/src/run.rs | 54 ++++++---------------------------------- 2 files changed, 10 insertions(+), 49 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7704179b..40ad9f95 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -213,7 +213,7 @@ jobs: run: | set -euxo pipefail sudo apt update - sudo apt -y install gcc-multilib locate qemu-system-{arm,x86} + sudo apt -y install gcc-multilib qemu-system-{arm,x86} echo /usr/lib/llvm-15/bin >> $GITHUB_PATH - name: Install prerequisites @@ -230,8 +230,7 @@ jobs: find /usr/local/bin -type l -exec sh -c 'readlink -f "$1" \ | grep -q ^/Library/Frameworks/Python.framework/Versions/' _ {} \; -exec rm -v {} \; HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK=1 \ - brew install dpkg findutils gnu-tar llvm pkg-config qemu - echo $(brew --prefix)/opt/findutils/libexec/gnubin >> $GITHUB_PATH + brew install dpkg gnu-tar llvm pkg-config qemu echo $(brew --prefix)/opt/gnu-tar/libexec/gnubin >> $GITHUB_PATH echo $(brew --prefix)/opt/llvm/bin >> $GITHUB_PATH diff --git a/xtask/src/run.rs b/xtask/src/run.rs index 8bba7a53..7af5da75 100644 --- a/xtask/src/run.rs +++ b/xtask/src/run.rs @@ -257,10 +257,10 @@ pub fn run(opts: Options) -> Result<()> { .ok_or_else(|| anyhow!("failed to parse {cmd:?} stdout: {stdout}"))?; let guest_arch = guest_arch.trim(); - let (guest_arch, machine, cpu) = match guest_arch { - "ARM64" => ("aarch64", Some("virt"), Some("cortex-a57")), - "x86" => ("x86_64", Some("q35"), Some("qemu64")), - guest_arch => (guest_arch, None, None), + let (guest_arch, machine, cpu, console) = match guest_arch { + "ARM64" => ("aarch64", Some("virt"), Some("max"), "ttyAMA0"), + "x86" => ("x86_64", None, None, "ttyS0"), + guest_arch => (guest_arch, None, None, "ttyS0"), }; let target = format!("{guest_arch}-unknown-linux-musl"); @@ -355,6 +355,9 @@ pub fn run(opts: Options) -> Result<()> { if let Some(machine) = machine { qemu.args(["-machine", machine]); } + if let Some(cpu) = cpu { + qemu.args(["-cpu", cpu]); + } if guest_arch == ARCH { match OS { "linux" => { @@ -377,10 +380,8 @@ pub fn run(opts: Options) -> Result<()> { } os => bail!("unsupported OS: {os}"), } - } else if let Some(cpu) = cpu { - qemu.args(["-cpu", cpu]); } - let console = OsString::from("ttyS0"); + let console = OsString::from(console); let mut kernel_args = std::iter::once(("console", &console)) .chain(run_args.clone().map(|run_arg| ("init.arg", run_arg))) .enumerate() @@ -406,45 +407,6 @@ pub fn run(opts: Options) -> Result<()> { .arg(&kernel_image) .arg("-initrd") .arg(&initrd_image); - if guest_arch == "aarch64" { - match OS { - "linux" => { - let mut cmd = Command::new("locate"); - let output = cmd - .arg("QEMU_EFI.fd") - .output() - .with_context(|| format!("failed to run {cmd:?}"))?; - let Output { status, .. } = &output; - if status.code() != Some(0) { - bail!("{qemu:?} failed: {output:?}") - } - let Output { stdout, .. } = output; - let bios = String::from_utf8(stdout) - .with_context(|| format!("failed to parse output of {cmd:?}"))?; - qemu.args(["-bios", bios.trim()]); - } - "macos" => { - let mut cmd = Command::new("brew"); - let output = cmd - .args(["list", "qemu", "-1", "-v"]) - .output() - .with_context(|| format!("failed to run {cmd:?}"))?; - let Output { status, .. } = &output; - if status.code() != Some(0) { - bail!("{qemu:?} failed: {output:?}") - } - let Output { stdout, .. } = output; - let output = String::from_utf8(stdout) - .with_context(|| format!("failed to parse output of {cmd:?}"))?; - const NAME: &str = "edk2-aarch64-code.fd"; - let bios = output.lines().find(|line| line.contains(NAME)).ok_or_else( - || anyhow!("failed to find {NAME} in output of {cmd:?}: {output}"), - )?; - qemu.args(["-bios", bios.trim()]); - } - os => bail!("unsupported OS: {os}"), - }; - } let mut qemu_child = qemu .stdin(Stdio::piped()) .stdout(Stdio::piped())