Skip to content

Commit

Permalink
look for firmware based on the path of qemu binary
Browse files Browse the repository at this point in the history
this allows users to use a qemu installation that is
not in the default /usr/local/bin location

a user can configure engine.helper_binaries_dir key
or update PATH to include the installation location
to find the qemu binary

[NO NEW TESTS NEEDED]

Signed-off-by: Anjan Nath <[email protected]>
  • Loading branch information
anjannath committed May 23, 2022
1 parent 12964c7 commit 8fbb933
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions pkg/machine/qemu/options_darwin_arm64.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import (
"os"
"os/exec"
"path/filepath"

"github.com/containers/common/pkg/config"
)

var (
Expand Down Expand Up @@ -37,6 +39,22 @@ func getOvmfDir(imagePath, vmName string) string {
return filepath.Join(filepath.Dir(imagePath), vmName+"_ovmf_vars.fd")
}

/*
* When QEmu is installed in a non-default location in the system
* we can use the qemu-system-* binary path to figure the install
* location for Qemu and use it to look for edk2-code-fd
*/
func getEdk2CodeFdPathFromQemuBinaryPath() string {
cfg, err := config.Default()
if err == nil {
execPath, err := cfg.FindHelperBinary(QemuCommand, true)
if err == nil {
return filepath.Clean(filepath.Join(filepath.Dir(execPath), "..", "share", "qemu"))
}
}
return ""
}

/*
* QEmu can be installed in multiple locations on MacOS, especially on
* Apple Silicon systems. A build from source will likely install it in
Expand All @@ -45,6 +63,7 @@ func getOvmfDir(imagePath, vmName string) string {
*/
func getEdk2CodeFd(name string) string {
dirs := []string{
getEdk2CodeFdPathFromQemuBinaryPath(),
"/opt/homebrew/opt/podman/libexec/share/qemu",
"/usr/local/share/qemu",
"/opt/homebrew/share/qemu",
Expand Down

0 comments on commit 8fbb933

Please sign in to comment.