Merge pull request #16853 from tmoschou/bugfix/do-not-assume-qemu-patch-version
Use the stable path for brew installed qemu firmware in machine configpull/16863/merge
commit
eeddc24f57
|
@ -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 {
|
||||||
|
|
Loading…
Reference in New Issue