From 6b6458916eaa51f0dbbcfeccd740706697697ad3 Mon Sep 17 00:00:00 2001 From: Nathan Henrie Date: Sat, 7 Jan 2023 09:54:56 -0700 Subject: [PATCH] Resolve symlink path for qemu directory if possible Fixes https://github.com/containers/podman/issues/17026 Fixes https://github.com/NixOS/nixpkgs/issues/169118 [NO NEW TESTS NEEDED] Related: https://github.com/NixOS/nixpkgs/pull/163015 Signed-off-by: Nathan Henrie --- pkg/machine/qemu/options_darwin_arm64.go | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/pkg/machine/qemu/options_darwin_arm64.go b/pkg/machine/qemu/options_darwin_arm64.go index d75237938a..e9c0c5ab42 100644 --- a/pkg/machine/qemu/options_darwin_arm64.go +++ b/pkg/machine/qemu/options_darwin_arm64.go @@ -46,13 +46,23 @@ func getOvmfDir(imagePath, vmName string) string { */ 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")) - } + if err != nil { + return "" + } + execPath, err := cfg.FindHelperBinary(QemuCommand, true) + if err != nil { + return "" + } + + sharePath := func(path string) string { + return filepath.Clean(filepath.Join(filepath.Dir(path), "..", "share", "qemu")) + } + + symlinkedPath, err := filepath.EvalSymlinks(execPath) + if err != nil { + return sharePath(execPath) } - return "" + return sharePath(symlinkedPath) } /*