Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,12 @@ Install libkrun, erofs-utils, e2fsprogs on your host
> Use brew to install libkrun, erofs-utils, and e2fsprogs
>
> ```
> brew tap slp/krunkit
> brew install libkrun-efi erofs-utils e2fsprogs
> brew tap slp/krun
> brew install libkrun erofs-utils e2fsprogs
> ```
>
> `libkrun-efi` fails to load with the 1.16.0 release. Both `libkrun` and `libkrun-efi`
> may be installed at the same time, but you may need to run `brew link libkrun`.

Run containerd with the shim and nerdbox components in the PATH:

Expand Down
16 changes: 10 additions & 6 deletions internal/vm/libkrun/instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (
"os"
"path/filepath"
"runtime"
"strings"
"sync"
"sync/atomic"
"syscall"
Expand Down Expand Up @@ -62,9 +63,9 @@ func (*vmManager) NewInstance(ctx context.Context, state string) (vm.Instance, e
if len(p2) == 0 {
p2 = []string{"/usr/local/lib", "/usr/lib", "/lib"}
}
sharedName := "libkrun.so"
sharedNames := []string{"libkrun.so"}
if runtime.GOOS == "darwin" {
sharedName = "libkrun-efi.dylib"
sharedNames = []string{"libkrun.dylib", "libkrun-efi.dylib"}
p2 = append(p2, "/opt/homebrew/lib")
}

Expand All @@ -75,9 +76,12 @@ func (*vmManager) NewInstance(ctx context.Context, state string) (vm.Instance, e
}
var path string
if krunPath == "" {
path = filepath.Join(dir, sharedName)
if _, err := os.Stat(path); err == nil {
krunPath = path
for _, sharedName := range sharedNames {
path = filepath.Join(dir, sharedName)
if _, err := os.Stat(path); err == nil {
krunPath = path
break
}
}
}
if kernelPath == "" {
Expand All @@ -94,7 +98,7 @@ func (*vmManager) NewInstance(ctx context.Context, state string) (vm.Instance, e
}
}
if krunPath == "" {
return nil, fmt.Errorf("%s not found in PATH or LIBKRUN_PATH", sharedName)
return nil, fmt.Errorf("%s not found in PATH or LIBKRUN_PATH", strings.Join(sharedNames, " or "))
}
if kernelPath == "" {
return nil, fmt.Errorf("nerdbox-kernel not found in PATH or LIBKRUN_PATH")
Expand Down
Loading