-
Notifications
You must be signed in to change notification settings - Fork 604
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
FreeBSD Support (host) #892
Comments
Thanks, would it be possible to patch QEMU to use bhyve as the accelerator just like KVM/HVF/NVMM ? |
I'm not sure. But I did a bit more research and it looks like per this forum post you can build the QEMU port with the KQEMU kernel module to provide acceleration. So I'm gonna give that a try and see if that helps with the speed issue. |
KQEMU is dead |
Ah, I did not realize that. Looking through the documentation it doesn't look like there is any alternative accelerator to KQEMU specifically that would work for FreeBSD. I see why you leapt to utilizing Bhyve for acceleration. Unfortunately, at the moment I don't know enough about QEMU to patch it to work with Bhyve and searching around online hasn't yielded any results for me on how to do that. I'll try to do some more digging (perhaps reach out to the #qemu IRC channel) and see what I can come up with. |
Presumably you could write a FreeBSD-specific "driver", similar to macOS Virtualization.framework ? Like #889 This looks helpful: Examples for Xen and Bhyve |
@heywoodlh : you should be able to use "max", for the emulator: $ qemu-system-x86_64 -cpu help
Not sure it would help with performance, but it would not hurt to have the CPU extensions. Probably need a sibling function to |
@afbjorklund yeah, I've tried it with |
Always ironic since BSD doesn't support containers, but it does support jails. But that's another story*... * https://github.com/containerd/nerdctl/blob/master/docs/freebsd.md And https://wiki.freebsd.org/LinuxJails I guess bhyve is your best VM bet, now that kqemu doesn't seem to be supported by modern versions ? |
@heywoodlh Note also that: "Vultr cloud servers do not support nested virtualization." So I guess you would have to go for the Bare Metal option, if you want to start Linux VMs ? Just looking at https://www.vultr.com/ 🐻 🤘 |
Shoot, thanks for checking that -- for some reason I thought Vultr had enabled nested virtualization! I'll test on a bare metal instance and see how performance is there. |
Spoke too soon: looks like you can't deploy FreeBSD on Baremetal on Vultr. So I'll test on some actual hardware. Will follow up with how it goes! |
This comment was marked as off-topic.
This comment was marked as off-topic.
I made a PR to avoid cpuType := map[Arch]string{
AARCH64: "cortex-a72",
// Since https://github.com/lima-vm/lima/pull/494, we use qemu64 cpu for better emulation of x86_64.
X8664: "qemu64",
RISCV64: "rv64", // FIXME: what is the right choice for riscv64?
} I think the Cortex-A72 is equivalent to a Raspberry Pi. Previously it was using |
It was broken on NetBSD too, CI only tests Mac and Linux. This code was: |
If I remember correctly, it had support for docker-machine and virtualbox https://cgit.freebsd.org/ports/tree/sysutils/docker-machine https://cgit.freebsd.org/ports/tree/emulators/virtualbox-ose |
I was now able to compile and run qemu and lima on FreeBSD 13.1 :
Worked OK - even on arm64, but timed out (10m) while creating the VM... Was running it on the Raspberry*, so took minutes instead of seconds. * my old BSD box was broken
Some observations:
I don't think it will be very useful, without hardware acceleration available ? Even if it "just" runs 10x slower rather than 100x like here, it is still not usable. So the best would be to have another VM driver, for virtualbox or for bhyve. Using jails would be nicer from a technical perspective, to avoid the extra layer. Then again, WSL1 (syscalls) was replaced by WSL2 (virtual machine) 🤷 |
What happened to this eventually? Is FreeBSD a supported platform now? @heywoodlh do you know if there are any plans to add this to FreeBSD ports? Can't see anything in freshports. In any case I made it run in DragonFly BSD as well (with some tweaks to the vendor software etc):
I'm quite impressed on how well lima-vm works in DragonFly BSD, I was expecting a lot of pain but it wasn't the case :-D |
Outside of doing the initial work to get Lima working on FreeBSD, I haven't really touched this since. I don't really use FreeBSD, I was mostly pursuing this as an experiment. I eventually got Lima working on a FreeBSD running on normal hardware and it seemed to work pretty okay for me. Additionally, I have received feedback from readers of my blog that it worked for them as well. I know I'm not going to put any more effort into this, such as building a FreeBSD port for this. But, if somebody did that, this could potentially make it easier to use Linux containers in Lima/QEMU on FreeBSD. Anyway, if you or anyone does more work on getting Lima running (better) on BSD, I would absolutely be interested and would hope you would update this issue. 😀 |
Same here, I sympathize with the "cause" - but don't really use FreeBSD anywhere anymore. Once upon a time, it was used an Open Source escape route when Apple closed down Darwin... |
Nice, does that work with hardware acceleration? |
I think it supports "nvmm" ? |
Yep, I had to do some vendor/lima patching that I'll upstream soon.
And the actual qemu process:
I must say it's pretty snappy! |
Do you plan to submit a PR? |
Ooops, I forgot about this one, sorry! If I recall correctly I had to patch vendors before being able to actually use it. |
Building with
Probably just missing a "go:build" EDIT: the first error is "normal", you need a cross-compiler and headers I think ?
So there are some extra steps in order to cross-compile from Linux, unlike Darwin. |
|
Possibly, but then we need to isolate host agent into a separate binary first ? |
I don't get that include error, not sure which Go version you're using. I've fixed locally some vendor stuff but I'm stuck here now:
Maybe need to add a |
The error was on Linux, but using (go1.20 something) What is "vendor stuff" ? |
I mean some of the dependencies that the build process download and place in GOPATH. I had to modify them manually (and do some cache cleaning after making the changes). I would need to upstream those changes before Lima can be built directly, unless I'm missing something. |
Right, like |
Yes, exactly 😄 In any case I was able to build it locally and it's able to start up some containers. I don't know how much functionality is missing tho. I'll see if I can fix the dependencies before submitting the PR. |
In any case, DragonFly BSD supports NVMM (which can be used with the QEMU driver) but FreeBSD has BHYVE which would need a driver. I'm kind of hijacking the FreeBSD issue, wouldn't it make sense to create a different one for DragonFly? |
Or if possible a listen_bsd.go for all of them, unless it varies ? Can you open an upstream issue for it (gvproxy), as well ? |
Yeah, I'm planning on going through all the failing deps. I'll handle the gvproxy too. |
I think that's all the upstream PRs needed, being the gvisor vsock one required for the BSDs as well. Now we wait I guess 😃 |
An alternative is to use libvirt which has a bhyve driver https://libvirt.org/drvbhyve.html |
libvirt seems too complicated |
Quick update on DragonFly BSD, still getting an error:
|
Just tested latest |
Description
FreeBSD lacks support for containerization generally but it does support QEMU. I was able to get Lima running on FreeBSD 13.0 but it doesn't work out of the box. I suspect that it wouldn't be difficult to fine-tune to get it up and running. And I feel that Lima could bring Docker support to a platform that currently lacks it which would be awesome.
I wrote-up a bit more detail on how I got Lima running on FreeBSD 13.0 here: https://the-empire.systems/freebsd-docker-2022
It's extremely slow but it works! I'm sure that I could have added something to QEMU's settings to make it perform better but I'm ignorant to the features that would help in this situation.
Installing Lima on FreeBSD 13.0:
For some reason, compiling Lima fails with:
pkg/sshutil/sshutil_others.go:14:19: undefined: err
Adding the following to the
detectAESAcceleration()
function inpkg/sshutil/sshutil_others.go
fixes it:Once
err
is defined, Lima compiles just fine withgmake
:Not sure why that fails just on FreeBSD but nothing else.
Not sure how necessary this actually is but the version of QEMU packaged with the FreeBSD repos is 6.2.0 so upgrading to 7.0 seemed like a good idea.
FreeBSD doesn't have
-cpu host
(unlike Linux and MacOS) available so I had to manually specify the processor on my machine (I was using an Intel VPS with Vultr):Problems needed to be solved before it's usable on FreeBSD:
-cpu host
would really help with this)undefined: err
inpkg/sshutil/sshutil_others.go
for FreeBSD (could be as simple as defining that variable if the OS is FreeBSD)-cpu host
if OS is FreeBSDIt would be so nice to be able to interact with containers while on FreeBSD. Please let me know if you have any questions or if this is not something desired to support.
The text was updated successfully, but these errors were encountered: