mirror of
https://github.com/containers/podman.git
synced 2025-06-21 01:19:15 +08:00
Merge pull request #14324 from anjannath/qemu-test
[macos: podman-machine] look for firmware (edk2-code-fd) based on the path of qemu binary
This commit is contained in:
@ -4,6 +4,8 @@ import (
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
|
||||
"github.com/containers/common/pkg/config"
|
||||
)
|
||||
|
||||
var (
|
||||
@ -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
|
||||
@ -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",
|
||||
|
Reference in New Issue
Block a user