Questions about building from source

Hello,

I’m looking into building LXD from source into .deb packages. While working on the build, I noticed a few things that I cannot figure out or find information on the doc/installing.md page.

  1. What dependencies are required to run VMs with LXD?

After I compiled lxd & ran it, I saw the following error message:

Dec 16 14:40:05 test-lxd lxd[2205]: t=2021-12-16T14:40:05+0000
lvl=warn msg="Instance type not operational" driver=qemu 
err="vhost_vsock kernel module not loaded: Failed to run: \
modprobe -b vhost_vsock: modprobe: ERROR: could not insert 'vhost_vsock':\
Device or resource busy" type=virtual-machine

I assume qemu package might be the only thing required, but wanted to double check, as I don’t have a bare metal host to test right now.

  1. Looking at the Makefile , I noticed a few references to $(DEBUG), but I’m unable to find the definition of these in the Makefile. Is this supposed to be reference to the -w flag or is it something else?

  2. On upgrades, does lxd itself handle database migrations or is it handled by other tools/scripts that come with the snap version?

  3. In the compile output, I found 2 binaries - deps and macroon-identity. What are they used for?

1 Like

That error usually means that you’re running LXD itself inside of a VM and that parent VM is running a kernel which doesn’t support nesting vhost-vsock.

We’ve seen Linux 5.8 and higher usually handling that fine, so you may just need to update your kernel.

I’m not too sure what DEBUG is about in our Makefile, it looks to me like a way to pass additional arguments by setting DEBUG in the environment to some Go arguments.

LXD does handle DB updates itself automatically.

Not sure what deps refers to in this case, but we have macaroon-identity and a devlxd test binary which are only used as part of the testsuite.

Right. It’s a test Ubuntu Focal VM with 5.4.0 kernel. Might test it again in a VM via 5.8 later. I just wanted to double check if any additional packages are required to be installed to be able to create VMs, as I didn’t notice anything specific mentioned in the “install from source docs”.

Okay. Thanks!

Awesome! Thanks!

Well, not deps, but rather things that showed up after I ran my slightly modified build command:

CC="$(CC)" CGO_LDFLAGS_ALLOW="$(CGO_LDFLAGS_ALLOW)" $(GO) build -v -tags "${TAG_SQLITE3}" -o target/ ./...

If they are part of the test-suite, I can ignore and not include them in my package. Thanks!


One other thing I stumbled upon yesterday, but can’t seem to replicate right now is that whenever I had the following set:

CGO_LDFLAGS_ALLOW ?= (-Wl,-wrap,pthread_create)|(-Wl,-z,now)

The go build command from above would fail with the following error:

invalid flag in #cgo LDFLAGS: -Wl,-z,now

The error was raised while working on github.com/canonical/go-dqlite/internal/bindings. I did confirm that the libs from make deps are present and the TAG_SQLITE3 output was properly evaluated. When I changed the value to CGO_LDFLAGS_ALLOW=-Wl,-z,now the build was passing.

Earlier today I tried another build with the value set to: (-Wl,-wrap,pthread_create)|(-Wl,-z,now) and the build completed successfully, without making any changes to the environment. I wondering if this was something you might have encountered before.