summaryrefslogtreecommitdiff
path: root/pkg/machine/qemu/options_darwin_arm64.go
diff options
context:
space:
mode:
authorJonathan Springer <jonpspri@gmail.com>2021-09-06 08:18:50 -0400
committerJonathan Springer <jonpspri@gmail.com>2021-09-07 09:01:26 -0400
commit8b4f99ac2030584312afcea448b0e06bfa0c5530 (patch)
tree8bc82fbb36e2487452722f119705d3ac89d22f12 /pkg/machine/qemu/options_darwin_arm64.go
parentc20227bd16cae98247955b14f6dfea33a26c6a0b (diff)
downloadpodman-8b4f99ac2030584312afcea448b0e06bfa0c5530.tar.gz
podman-8b4f99ac2030584312afcea448b0e06bfa0c5530.tar.bz2
podman-8b4f99ac2030584312afcea448b0e06bfa0c5530.zip
QEMU Apple Silicon: Find BIOS FD wherever
QEmu normally install BIOS images under `/usr/local` prefix, but Homebrew installs them under `/opt/homebrew`. This change searches both locations and then puts back to an unpathed name if it doesn't find the BIOS. (I imitated other architectures' implemenations in that failback behavior.) [NO TESTS NEEDED] Signed-off-by: Jonathan Springer <jonpspri@gmail.com>
Diffstat (limited to 'pkg/machine/qemu/options_darwin_arm64.go')
-rw-r--r--pkg/machine/qemu/options_darwin_arm64.go23
1 files changed, 22 insertions, 1 deletions
diff --git a/pkg/machine/qemu/options_darwin_arm64.go b/pkg/machine/qemu/options_darwin_arm64.go
index 8c651584e..43cd3d69d 100644
--- a/pkg/machine/qemu/options_darwin_arm64.go
+++ b/pkg/machine/qemu/options_darwin_arm64.go
@@ -1,6 +1,7 @@
package qemu
import (
+ "os"
"os/exec"
"path/filepath"
)
@@ -16,7 +17,7 @@ func (v *MachineVM) addArchOptions() []string {
"-accel", "tcg",
"-cpu", "cortex-a57",
"-M", "virt,highmem=off",
- "-drive", "file=/usr/local/share/qemu/edk2-aarch64-code.fd,if=pflash,format=raw,readonly=on",
+ "-drive", "file=" + getEdk2CodeFd("edk2-aarch64-code.fd") + ",if=pflash,format=raw,readonly=on",
"-drive", "file=" + ovmfDir + ",if=pflash,format=raw"}
return opts
}
@@ -35,3 +36,23 @@ func (v *MachineVM) archRemovalFiles() []string {
func getOvmfDir(imagePath, vmName string) string {
return filepath.Join(filepath.Dir(imagePath), vmName+"_ovmf_vars.fd")
}
+
+/*
+ * QEmu can be installed in multiple locations on MacOS, especially on
+ * Apple Silicon systems. A build from source will likely install it in
+ * /usr/local/bin, whereas Homebrew package management standard is to
+ * install in /opt/homebrew
+ */
+func getEdk2CodeFd(name string) string {
+ dirs := []string{
+ "/usr/local/share/qemu",
+ "/opt/homebrew/share/qemu",
+ }
+ for _, dir := range dirs {
+ fullpath := filepath.Join(dir, name)
+ if _, err := os.Stat(fullpath); err == nil {
+ return fullpath
+ }
+ }
+ return name
+}