Physical to Virtual with Snap-LXD missing dependencies

Hi,

I followed the following manuals:
https://singularo.com/speed-your-development-converting-your-vm-lxd-container
and

got to the step:
go get -v github.com/lxc/lxd/lxd-p2c
run into the error
fatal error: dqlite.h: No such file or directory

installed:

apt install golang-go
apt install lxd-dev
apt install lxd-tools
apt install libacl
sudo add-apt-repository ppa:dqlite/stable
apt install libdqlite-dev

did a
snap refresh lxd --edge

now I get:

gopkg.in/lxc/go-lxc.v2
# pkg-config --cflags  -- lxc
Package lxc was not found in the pkg-config search path.
Perhaps you should add the directory containing `lxc.pc'
to the PKG_CONFIG_PATH environment variable
No package 'lxc' found
pkg-config: exit status 1

OS is ubuntu 20.04 VERSION=“20.04.2 LTS (Focal Fossa)”

snap list lxd
Name  Version      Rev    Tracking     Publisher   Notes
lxd   git-538ac3d  19678  latest/edge  canonical✓  -

the only remark on that error this is there:

which it just states that lxd.lxc-to-lxd is here and fine.


told me that i should install lxc-devel however there is no snap package for it.

The Task is to convert a KVM Image to and LXD Container which should then migrated to a PROD machine via File with ZFS on it.

thanks for help

Hi!

This is a dqlite issue with building lxd. Your steps above look OK, and I managed to compile lxd-p2c just now in a ubuntu:20.04 LXD container. I’ll show you my steps.

We are compiling an instance of lxd-p2c on Ubuntu 20.04 amd64. I recreated these from my history, therefore if you can verify I have not introduced a typo, it would be great.

$ lxc launch ubuntu: mycontainer             # Currently, the default container in the `ubuntu:` repo is 20.04.
Creating mycontainer
Starting mycontainer
$ lxc shell mycontainer
root@mycontainer:~# snap install go --classic
...
root@mycontainer:~# add-apt-repository ppa:dqlite/stable
...
root@mycontainer:~# apt install -y build-essential acl libacl1-dev libcap-dev liblxc1 liblxc-dev libsqlite3-dev libudev-dev libuv1-dev libdqlite-dev
...
root@mycontainer:~# go get github.com/lxc/lxd/lxd-p2c
root@mycontainer:~# cd go/bin/
root@mycontainer:~/go/bin# ls
lxd-p2c
root@mycontainer:~/go/bin# ls -l
total 14809
-rwxr-xr-x 1 root root 23676680 Mar  5 14:01 lxd-p2c
root@mycontainer:~/go/bin# file lxd-p2c 
lxd-p2c: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, BuildID[sha1]=1cf3a1151e634a691506a1b9bf76f1789bff0877, for GNU/Linux 3.2.0, not stripped
root@mycontainer:~/go/bin#

If you were to compile lxd-p2c on, let’s say, an Ubuntu 16.04 i386 server, you could launch such a container in order to create the lxd-p2c executable. Such a container image would be ubuntu:16.04/i386.

lxd-p2c should be built statically with make lxd-p2c.

It’s also directly available as a binary from every build at https://github.com/lxc/lxd/actions (needs a Github account).

Hi
thanks it worked now the missing part was this:

After that the go get worked.
However the manual compilation from that package did not create an additional lxd-p2c binary, only the other ones. However the file that was in the go/bin directory did an awesome job.

thanks for the fast help :slight_smile:

I used go get without the -d parameter. This means that Go will build, by default, a shared executable and place it inside ~/go/bin/.

I got @stgraber’s reply and created this post, https://blog.simos.info/how-to-compile-lxd-p2c-to-migrate-physical-servers-to-lxd-containers/

1 Like