lima-vm / lima-vm/lima

Building Lima on Haiku

Open
#5,459 2 comments 1 reaction 0 assignees View on GitHub
enhancement expert priority/low
Dominant language
Go
Stars
21.9k
Forks
957
Avg merge
2d 6h
Merged PRs (30d)
53

Description

### Description

As posted by @AkihiroSuda in Slack:

> Haiku now supports Go and QEMU, so probably it is easy to port Lima too?
> https://www.haiku-os.org/get-haiku/r1beta6/release-notes/

It uses the same accel as other BSD.

> Haiku now supports “NVMM”, the NetBSD Virtual Machine Monitor (which originated on NetBSD, but already had been ported to at least DragonFlyBSD as well before Haiku). This provides support for hardware virtualization to QEMU on most x86_64 systems supporting Intel VT-x or AMD-V.

For now it is only for amd64, it is not available for arm64 yet:

> “Not just yet…”
> Unfortunately, not all the development work merged over the last two years has made it into this release, as some of it remains experimental and disabled by default. Here are some of the more interesting features which are still in development:

> ARM64
> Thanks to the efforts of a variety of different contributors, the ARM64 port now boots all the way to the desktop under virtualization! (One contributor even has an unmerged branch that gets it booting to the desktop on Apple M1 hardware.) There’s still a lot of work to be done, but overall this is very significant progress over the state of the code under R1/beta5.

But it is not expected to run as a guest VM in Lima, only host.

----

I think the hypervisor changes will be easy enough:

```diff
diff --git a/pkg/driver/qemu/qemu.go b/pkg/driver/qemu/qemu.go
index 7400b78..9a18885 100644
--- a/pkg/driver/qemu/qemu.go
+++ b/pkg/driver/qemu/qemu.go
@@ -1189,6 +1189,8 @@ func Accel(arch limatype.Arch) string {
return "nvmm"
case "dragonfly":
return "nvmm"
+ case "haiku":
+ return "nvmm"
case "windows":
return "whpx"
}
```

But there are some "unix" go build errors left to fix:

```
/HaikuHome/lima> make -k native
rm -rf _output vendor
CGO_ENABLED=1 GOOS="haiku" GOARCH="amd64" CC="cc" go build -ldflags="-s=true -w=true -X github.com/lima-vm/lima/v2/pkg/version.Version=87c24e9.m" -tags '' -o _output/bin/limactl ./cmd/limactl
# github.com/sirupsen/logrus
/boot/home/go/pkg/mod/github.com/sirupsen/logrus@v1.10.1/terminal_check_notappengine.go:17:10: undefined: isTerminal
# google.golang.org/grpc/internal
/boot/home/go/pkg/mod/google.golang.org/grpc@v1.83.1/internal/tcp_keepalive_unix.go:50:10: undefined: unix.SetsockoptInt
/boot/home/go/pkg/mod/google.golang.org/grpc@v1.83.1/internal/tcp_keepalive_unix.go:50:38: undefined: unix.SOL_SOCKET
/boot/home/go/pkg/mod/google.golang.org/grpc@v1.83.1/internal/tcp_keepalive_unix.go:50:55: undefined: unix.SO_KEEPALIVE
# github.com/djherbis/times
/boot/home/go/pkg/mod/github.com/djherbis/times@v1.6.0/times.go:11:9: undefined: getTimespec
/boot/home/go/pkg/mod/github.com/djherbis/times@v1.6.0/times.go:21:9: undefined: getTimespec
/boot/home/go/pkg/mod/github.com/djherbis/times@v1.6.0/use_generic_stat.go:23:9: undefined: getTimespec
# github.com/u-root/uio/rand
/boot/home/go/pkg/mod/github.com/u-root/uio@v0.0.0-20240224005618-d2acac8f3701/rand/random.go:60:18: undefined: defaultContextReader
# github.com/digitalocean/go-qemu/qmp
/boot/home/go/pkg/mod/github.com/digitalocean/go-qemu@v0.0.0-20221209210016-f035778c97f7/qmp/socket_unix.go:26:14: undefined: unix.UnixRights
# github.com/AlecAivazis/survey/v2/terminal
/boot/home/go/pkg/mod/github.com/!alec!aivazis/survey/v2@v2.3.7/terminal/runereader_posix.go:48:26: undefined: syscall.Syscall6
/boot/home/go/pkg/mod/github.com/!alec!aivazis/survey/v2@v2.3.7/terminal/runereader_posix.go:48:81: undefined: ioctlReadTermios
/boot/home/go/pkg/mod/github.com/!alec!aivazis/survey/v2@v2.3.7/terminal/runereader_posix.go:60:26: undefined: syscall.Syscall6
/boot/home/go/pkg/mod/github.com/!alec!aivazis/survey/v2@v2.3.7/terminal/runereader_posix.go:60:81: undefined: ioctlWriteTermios
/boot/home/go/pkg/mod/github.com/!alec!aivazis/survey/v2@v2.3.7/terminal/runereader_posix.go:68:26: undefined: syscall.Syscall6
/boot/home/go/pkg/mod/github.com/!alec!aivazis/survey/v2@v2.3.7/terminal/runereader_posix.go:68:81: undefined: ioctlWriteTermios
# github.com/pkg/sftp
/boot/home/go/pkg/mod/github.com/pkg/sftp@v1.13.11/attrs.go:116:2: undefined: fileStatFromInfoOs
/boot/home/go/pkg/mod/github.com/pkg/sftp@v1.13.11/ls_formatting.go:70:24: undefined: lsLinksUIDGID
make: *** [Makefile:311: _output/bin/limactl] Error 1
mkdir -p _output/bin
cp -a cmd/lima _output/bin/lima
go build -ldflags="-s=true -w=true -X github.com/lima-vm/lima/v2/pkg/version.Version=87c24e9.m" -o _output/libexec/lima/limactl-mcp ./cmd/limactl-mcp
# github.com/sirupsen/logrus
/boot/home/go/pkg/mod/github.com/sirupsen/logrus@v1.10.1/terminal_check_notappengine.go:17:10: undefined: isTerminal
# github.com/pkg/sftp
/boot/home/go/pkg/mod/github.com/pkg/sftp@v1.13.11/attrs.go:116:2: undefined: fileStatFromInfoOs
/boot/home/go/pkg/mod/github.com/pkg/sftp@v1.13.11/ls_formatting.go:70:24: undefined: lsLinksUIDGID
make: *** [Makefile:325: _output/libexec/lima/limactl-mcp] Error 1
cp -aL cmd/limactl-url-fedora-rawhide _output/libexec/lima/limactl-url-fedora-rawhide
cp -a cmd/nerdctl.lima _output/bin/nerdctl.lima
cp -a cmd/apptainer.lima _output/bin/apptainer.lima
cp -a cmd/docker.lima _output/bin/docker.lima
cp -a cmd/podman.lima _output/bin/podman.lima
cp -a cmd/kubectl.lima _output/bin/kubectl.lima
mkdir -p _output/share/lima
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-s=true -w=true -X github.com/lima-vm/lima/v2/pkg/version.Version=87c24e9.m" -o _output/share/lima/lima-guestagent.Linux-x86_64 ./cmd/lima-guestagent
chmod 644 _output/share/lima/lima-guestagent.Linux-x86_64
+ gzip -n _output/share/lima/lima-guestagent.Linux-x86_64
```

Contributor guide

Open the contributing guide

Research direction

Start with pkg/driver/qemu/qemu.go and the Makefile native target, then reproduce the listed CGO_ENABLED=1 GOOS=haiku GOARCH=amd64 build on Haiku. Investigate the reported undefined symbols in the listed dependencies and verify that the native limactl and limactl-mcp builds complete successfully, with the Haiku QEMU accelerator selected.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
build-system, operating-systems
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.