Merge pull request #16853 from tmoschou/bugfix/do-not-assume-qemu-patch-version

Use the stable path for brew installed qemu firmware in machine config
pull/16863/merge
Steven Powell 2023-07-10 14:15:11 -07:00 committed by GitHub
commit eeddc24f57
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 16 deletions

View File

@ -21,7 +21,6 @@ import (
"fmt" "fmt"
"os" "os"
"os/exec" "os/exec"
"path"
"path/filepath" "path/filepath"
"runtime" "runtime"
"strings" "strings"
@ -80,27 +79,14 @@ func qemuFirmwarePath(customPath string) (string, error) {
arch := runtime.GOARCH arch := runtime.GOARCH
// For macOS, find the correct brew installation path for qemu firmware // For macOS, find the correct brew installation path for qemu firmware
if runtime.GOOS == "darwin" { if runtime.GOOS == "darwin" {
var p, fw string
switch arch { switch arch {
case "amd64": case "amd64":
p = "/usr/local/Cellar/qemu" return "/usr/local/opt/qemu/share/qemu/edk2-x86_64-code.fd", nil
fw = "share/qemu/edk2-x86_64-code.fd"
case "arm64": case "arm64":
p = "/opt/homebrew/Cellar/qemu" return "/opt/homebrew/opt/qemu/share/qemu/edk2-aarch64-code.fd", nil
fw = "share/qemu/edk2-aarch64-code.fd"
default: default:
return "", fmt.Errorf("unknown arch: %s", arch) return "", fmt.Errorf("unknown arch: %s", arch)
} }
v, err := os.ReadDir(p)
if err != nil {
return "", fmt.Errorf("lookup qemu: %v", err)
}
for _, version := range v {
if version.IsDir() {
return path.Join(p, version.Name(), fw), nil
}
}
} }
switch arch { switch arch {