[libvirt] [jenkins-ci PATCH] Add support for cross compiling libvirt via Debian

Daniel P. Berrangé berrange at redhat.com
Tue Feb 5 17:51:12 UTC 2019


On Mon, Jan 28, 2019 at 04:13:07PM +0100, Andrea Bolognani wrote:
> On Mon, 2019-01-28 at 12:03 +0000, Daniel P. Berrangé wrote:
> [...]
> >  cross-build/arch-config.csv          |  8 +++
> >  cross-build/buildenv-cross.docker.in | 96 ++++++++++++++++++++++++++++
> >  3 files changed, 105 insertions(+)
> >  create mode 100644 cross-build/arch-config.csv
> >  create mode 100644 cross-build/buildenv-cross.docker.in
> 
> You're providing a Dockerfile template and a CSV file containing
> the data that should be substituted into it, and it's fairly obvious
> how one would go about it, but I would expect you to provide a
> script and possibly a Makefile along with this... I assume you just
> forgot to commit them? :)

Sigh, yes I forgot the Makefile.

> [...]
> > +++ b/cross-build/arch-config.csv
> > @@ -0,0 +1,8 @@
> > +arm64,crossbuild-essential-arm64,aarch64-linux-gnu
> > +armel,crossbuild-essential-armel,arm-linux-gnueabi
> > +armhf,crossbuild-essential-armhf,arm-linux-gnueabihf
> > +mips64el,gcc-mips64el-linux-gnuabi64,mips64el-linux-gnuabi64
> > +mips,gcc-mips-linux-gnu,mips-linux-gnu
> > +mipsel,gcc-mipsel-linux-gnu,mipsel-linux-gnu
> > +ppc64el,crossbuild-essential-ppc64el,powerpc64le-linux-gnu
> > +s390x,gcc-multilib-s390x-linux-gnu,s390x-linux-gnu
> 
> The file format is not documented, and it really should be.
> 
> As for the architecture selection, we should drop armel (it's
> unlikely to be part of the next Debian release[1]) and possibly
> all the MIPS architectures too? I'm fairly sure nobody is actually
> running and testing libvirt on those architectures, so making them
> official targets for cross-compilation would be a bit dishonest in
> my opinion. Same possibly goes for armhf, but it's less clear-cut
> given how many Raspberry Pis are out there.

I don't want to take a stance on popularity of the architectures.
The goal was to provide containers for every architecture that
Debian currently builds libvirt, to ensure that libvirt does not
regress in its ability to build on anything that Debian targets.

> We should also use the virArch names instead of the Debian names,
> even if that means having additional logic to map between them.

I don't think virArch names offer any benefit, only the pain of
having to remap them to what we actually want to work with.

> > +++ b/cross-build/buildenv-cross.docker.in
> > @@ -0,0 +1,96 @@
> > +#
> > +# ::ARCH:: cross-compiler target
> > +#
> > +FROM debian:stretch-slim
> 
> How much smaller is the -slim variant than the regular stretch
> image? Because according to the documentation
> 
>   These tags are an experiment in providing a slimmer base (removing
>   some extra files that are normally not necessary within containers,
>   such as man pages and documentation), and are definitely subject
>   to change.
> 
> so unless the savings are very significant, I'd much rather
> stick with the regular images.

It depends what you want to measure. The debian:9-slim  is ~55 MB
while debian:9 is ~100MB (varies per arch).  IOW, the -slim variant
is half the size.

Once you add in the libvirt build deps though this difference is
significantly reduced, as the overall libvirt image is around
1000 MB for debian:9 vs  950 MB for debian:9-slim

> > +# First some common native binaries. Any program that the
> > +# build will execute needs to have a native binary package
> > +# installed. We don't want to rely on qemu-user emulation
> > +# for executing non-native binaries as that is slow & flaky
> > +RUN DEBIAN_FRONTEND=noninteractive  \
> > +    apt-get install -y --no-install-recommends \
> 
> I never considered it until now, but we might want to use
> DEBIAN_FRONTEND=noninteractive and --no-install-recommends in our
> existing Debian/Ubuntu Dockerfiles as well :)

Yes, we should.

> [...]
> > +        qemu-system-x86 \
> 
> Based on what you wrote just a few lines above, QEMU shouldn't be
> necessary, so why are you dragging it in?

The comments above were about the qemu userspace emulators,
while this is the system emulator. configure.ac checks for
existance of qemu-system-x86, though this is merely to
warn you if you try to build a QEMU version that needs QMP
while not having yajl installed. So that's not really
required. We should in fact update that check in libvirt.git
really since we mandate yajl for QEMU now, thre's no need
to check QEMU versions.

> > +        xfslibs-dev:::ARCH:: \
> > +        libssh-dev:::ARCH:: \
> > +        libgnutls28-dev:::ARCH::
> 
> How did you come up with this list of packages, anyway? It doesn't
> match the one in buildenv-debian-9.Dockerfile from the
> libvirt-dockerfiles repository.

It comes from the list of build requires listed for the
debian source package

  https://packages.debian.org/source/sid/libvirt

> On a more general note, we shouldn't have such a list at all: the
> source of truth for build dependencies are the YAML files in
> guests/vars/, and anything that needs it should obtain it from
> there.
> 
> Which leads me to an even more general point: this should be part
> of lcitool instead of its own thing. We already have (admittedly
> not great) code to generate Dockerfiles in there; cleaning it up
> and extending it so that it can support this additional variant of
> the same idea shouldn't be too difficult.

It was not entirely straightforward, as it turns out we had
some bugs in our existing package set that caused conflicts
with cross-arch installs, but I managed to resolve this.

> 
> > +# Tell libvirt which architecture we want to target
> > +ENV LIBVIRT_CONFIGURE_OPTS "--host=::ABI:: --build=x86_64-linux-gnu --target=::ABI::"
> > +
> > +# Tell pkg-config where to find the non-native .pc files
> > +ENV PKG_CONFIG_LIBDIR=/usr/lib/::ABI::/pkgconfig
> 
> I really don't like injecting this much environment into the
> container. Can we limit it to a single $ABI variable, or perhaps
> even store it on disk as, I don't know, /root/abi or something?
> Either way, we could pick up the information and prepare the above
> environment as part of the build process, eg. on the libvirt side.

I don't really see any downside to using these env vars as is.
This is pretty much a standard use for use of docker's ENV feature
and makes it easy to use these containers in the correct manner.


Regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|




More information about the libvir-list mailing list