Homebrew / homebrew-core

🍻 Default formulae for the missing package manager for macOS (or Linux)
https://brew.sh
BSD 2-Clause "Simplified" License
13.61k stars 12.35k forks source link

qemu-system-aarch64: -accel hvf: invalid accelerator hvf (Apple Silicon) #70627

Closed tonyjames closed 3 years ago

tonyjames commented 3 years ago

brew gist-logs <formula> link OR brew config AND brew doctor output

$ brew config && brew doctor HOMEBREW_VERSION: 3.0.0 ORIGIN: https://github.com/Homebrew/brew HEAD: ebc7cc36a0e029d58fac8cebd1b5ff583b3fd95b Last commit: 2 days ago Core tap ORIGIN: https://github.com/Homebrew/homebrew-core Core tap HEAD: 85cf693a35a657df944e80b3b0606e3c09517784 Core tap last commit: 70 minutes ago Core tap branch: master HOMEBREW_PREFIX: /opt/homebrew HOMEBREW_CASK_OPTS: [] HOMEBREW_MAKE_JOBS: 8 HOMEBREW_NO_ANALYTICS: set Homebrew Ruby: 2.6.3 => /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/bin/ruby CPU: octa-core 64-bit arm_firestorm_icestorm Clang: 12.0 build 1200 Git: 2.24.3 => /Library/Developer/CommandLineTools/usr/bin/git Curl: 7.64.1 => /usr/bin/curl macOS: 11.2-arm64 CLT: 12.4.0.0.1.1610135815 Xcode: N/A Rosetta 2: false Your system is ready to brew.


What were you trying to do (and why)?

I am attempting to use the qemu package to create virtual machines on my M1 Mac mini. The exact command I'm running is:

qemu-system-aarch64 \ -monitor stdio \ -M virt -accel hvf \ -cpu cortex-a72 \ -smp 2 \ -m 4096 \ -device virtio-gpu-pci \ -display default,show-cursor=on \ -device qemu-xhci \ -device usb-kbd \ -device usb-tablet \ -device intel-hda \ -device hda-duplex \ -drive file=~/VMs/ubuntu/ubuntu.qcow2,if=virtio,cache=writethrough \ -cdrom ~/Downloads/ubuntu-20.04.2-live-server-arm64.iso

What happened (include all command output)?

Passing the "-accel hvf" flag to "qemu-system-aarch64" fails with the error "-accel hvf: invalid accelerator hvf". There appear to be some recent qemu patches that may help with this issue: https://patchwork.kernel.org/project/qemu-devel/list/?submitter=185121

What did you expect to happen?

VM creation should succeed.

Step-by-step reproduction instructions (by running brew commands)

brew install qemu

mkdir -p ~/VMs/ubuntu qemu-img create -f qcow2 ~/VMs/ubuntu/ubuntu.qcow2 50G qemu-system-aarch64 \ -monitor stdio \ -M virt -accel hvf \ -cpu cortex-a72 \ -smp 2 \ -m 4096 \ -device virtio-gpu-pci \ -display default,show-cursor=on \ -device qemu-xhci \ -device usb-kbd \ -device usb-tablet \ -device intel-hda \ -device hda-duplex \ -drive file=~/VMs/ubuntu/ubuntu.qcow2,if=virtio,cache=writethrough \ -cdrom ~/Downloads/ubuntu-20.04.2-live-server-arm64.iso

carlocab commented 3 years ago

Is this a problem that affects only Homebrew qemu, or is it also an issue with a non-Homebrew qemu installation?

tonyjames commented 3 years ago

Since the patches are for the upstream qemu project I would assume this is affecting non-Homebrew qemu installations as well. I'm guessing that means we'll have to wait for the patches to be accepted upstream rather than separately carrying the patches in Homebrew? Totally makes sense since Homebrew is a project with limited resources. Thanks for pointing that out.

carlocab commented 3 years ago

The patches look quite large to backport into the existing version. It might be better to just wait for a new release.

There's nothing actionable here for Homebrew at the moment, so I'm closing this. We can reopen it if circumstances change.

stweil commented 3 years ago

It is possible to run QEMU on M1 without accelerator, but that requires currently an additional configure option --enable-tcg-interpreter. Without that, Homebrew QEMU for M1 is nearly useless.