Skip to content

Commit 98cf695

Browse files
committed
Use the stable path for brew installed qemu firmware in machine config
Previously, machine config had hard coded the homebrew cellar path with the patch version of qemu available at the time of machine creation, and was prone to breaking anytime qemu was updated and the machine is restarted. This change replaces the firmware path to use the prefix as reported by 'brew --prefix qemu' (e.g. /opt/homebrew/opt/qemu on M1) which is a symlink the the latest installed version of qemu (e.g. /opt/homebrew/Cellar/qemu/<x.y.z>)
1 parent f23e93b commit 98cf695

File tree

1 file changed

+2
-16
lines changed
  • pkg/minikube/registry/drvs/qemu2

1 file changed

+2
-16
lines changed

Diff for: pkg/minikube/registry/drvs/qemu2/qemu2.go

+2-16
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ import (
2121
"fmt"
2222
"os"
2323
"os/exec"
24-
"path"
2524
"path/filepath"
2625
"runtime"
2726
"strings"
@@ -80,27 +79,14 @@ func qemuFirmwarePath(customPath string) (string, error) {
8079
arch := runtime.GOARCH
8180
// For macOS, find the correct brew installation path for qemu firmware
8281
if runtime.GOOS == "darwin" {
83-
var p, fw string
8482
switch arch {
8583
case "amd64":
86-
p = "/usr/local/Cellar/qemu"
87-
fw = "share/qemu/edk2-x86_64-code.fd"
84+
return "/usr/local/opt/qemu/share/qemu/edk2-x86_64-code.fd", nil
8885
case "arm64":
89-
p = "/opt/homebrew/Cellar/qemu"
90-
fw = "share/qemu/edk2-aarch64-code.fd"
86+
return "/opt/homebrew/opt/qemu/share/qemu/edk2-aarch64-code.fd", nil
9187
default:
9288
return "", fmt.Errorf("unknown arch: %s", arch)
9389
}
94-
95-
v, err := os.ReadDir(p)
96-
if err != nil {
97-
return "", fmt.Errorf("lookup qemu: %v", err)
98-
}
99-
for _, version := range v {
100-
if version.IsDir() {
101-
return path.Join(p, version.Name(), fw), nil
102-
}
103-
}
10490
}
10591

10692
switch arch {

0 commit comments

Comments
 (0)