Open igalic opened 1 year ago
n.b.: FreeBSD 14.0-CURRENT has extensive Netlink support. But, go being go, can't know that, because it's duplicating the libc
A bunch of that code isn't really needed inside of the agent, so selected build tags should be able to improve things.
The main catch is going to be the terminal handling code which may or may not already have FreeBSD support and the vsock code which similarly may or may not have support for FreeBSD. If those two behave, then this may be pretty trivial.
If the kernel flags in the kernel headers on FreeBSD are named differently from their Linux equivalent, I'd actually argue that a low level module like unix should not try to rename them to line up with Linux.
Instead we need a higher level module (possibly LXD) to use the correct ones based on platform with the correct build tags set on the files to have them be pulled based on OS.
But I'm also not convinced that lxd-agent needs to import all that logic to begin with, so we may be able to avoid this whole thing entirely by being a bit more clever about imports and file tagging.
I don't want to create any expectations, but:
[danilo@yoga ~]$ lxc exec -T freebsd-head -- uname -sr
FreeBSD 15.0-CURRENT
[danilo@yoga ~]$ lxc exec -T freebsd-head -- sysctl dev.vtsock
dev.vtsock.0.guest_cid: 102580108
dev.vtsock.0.%parent: virtio_pci4
dev.vtsock.0.%pnpinfo: vendor=0x00001af4 device=0x1053 subvendor=0x1af4 device_type=0x00000013
dev.vtsock.0.%location:
dev.vtsock.0.%driver: vtsock
dev.vtsock.0.%desc: VirtIO VSOCK Transport Adapter
dev.vtsock.%parent:
:smiley:
I've been working on this on my free time for several months now. It involved writing the FreeBSD drivers for the virtio_socket
device and vsock
, fixing issues in the p9fs
driver, patching the Golang x/sys
module, patching the vsock-go
module and of course the lxd-agent
itself. Now, everything is very unstable and look more like a proof of concept than anything. I'll continue to slowly work on this and maybe one day get it done.
@daniloegea amazing, thank you! :)
@daniloegea if you find that lxd-agent is dependent on something not strictly necessary, it maybe an incorrect import we can address to reduce the number of dependencies.
Required information
Issue description
I'm trying to integrate FreeBSD into cloud-init's CI. A requirement is that FreeBSD runs under LXD — that works, more or less. But I'd also like to get lxd VM agent running under FreeBSD.
Steps to reproduce
and get the following build failure: