mirror of
https://github.com/containers/podman
synced 2024-10-21 17:53:44 +00:00
QEMU Apple Silicon: Find BIOS FD wherever
QEmu normally install BIOS images under `/usr/local` prefix, but Homebrew installs them under `/opt/homebrew`. This change searches both locations and then puts back to an unpathed name if it doesn't find the BIOS. (I imitated other architectures' implemenations in that failback behavior.) [NO TESTS NEEDED] Signed-off-by: Jonathan Springer <jonpspri@gmail.com>
This commit is contained in:
parent
c20227bd16
commit
8b4f99ac20
|
@ -1,6 +1,7 @@
|
||||||
package qemu
|
package qemu
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
)
|
)
|
||||||
|
@ -16,7 +17,7 @@ func (v *MachineVM) addArchOptions() []string {
|
||||||
"-accel", "tcg",
|
"-accel", "tcg",
|
||||||
"-cpu", "cortex-a57",
|
"-cpu", "cortex-a57",
|
||||||
"-M", "virt,highmem=off",
|
"-M", "virt,highmem=off",
|
||||||
"-drive", "file=/usr/local/share/qemu/edk2-aarch64-code.fd,if=pflash,format=raw,readonly=on",
|
"-drive", "file=" + getEdk2CodeFd("edk2-aarch64-code.fd") + ",if=pflash,format=raw,readonly=on",
|
||||||
"-drive", "file=" + ovmfDir + ",if=pflash,format=raw"}
|
"-drive", "file=" + ovmfDir + ",if=pflash,format=raw"}
|
||||||
return opts
|
return opts
|
||||||
}
|
}
|
||||||
|
@ -35,3 +36,23 @@ func (v *MachineVM) archRemovalFiles() []string {
|
||||||
func getOvmfDir(imagePath, vmName string) string {
|
func getOvmfDir(imagePath, vmName string) string {
|
||||||
return filepath.Join(filepath.Dir(imagePath), vmName+"_ovmf_vars.fd")
|
return filepath.Join(filepath.Dir(imagePath), vmName+"_ovmf_vars.fd")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* QEmu can be installed in multiple locations on MacOS, especially on
|
||||||
|
* Apple Silicon systems. A build from source will likely install it in
|
||||||
|
* /usr/local/bin, whereas Homebrew package management standard is to
|
||||||
|
* install in /opt/homebrew
|
||||||
|
*/
|
||||||
|
func getEdk2CodeFd(name string) string {
|
||||||
|
dirs := []string{
|
||||||
|
"/usr/local/share/qemu",
|
||||||
|
"/opt/homebrew/share/qemu",
|
||||||
|
}
|
||||||
|
for _, dir := range dirs {
|
||||||
|
fullpath := filepath.Join(dir, name)
|
||||||
|
if _, err := os.Stat(fullpath); err == nil {
|
||||||
|
return fullpath
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return name
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue