Building libvirt library without libvirtd or virsh

Pavel Hrdina phrdina at redhat.com
Thu Oct 8 10:17:31 UTC 2020


On Thu, Oct 08, 2020 at 09:38:22AM +0200, Martin Kletzander wrote:
> On Wed, Oct 07, 2020 at 04:50:26PM -0700, Román González wrote:
> > Hello there,
> > 
> > I'm trying to play with musl and libvirt to see if I'm able to build a
> > libvirt client binary without dynamic lib dependencies. I have two
> > questions:
> > 
> > 1) to your knowledge, is this exercise futile?
> > 
> > 2) Do you know if there is a way to *only* compile the library bits?
> > 
> > I want to reduce the number of dependencies in the build, and only
> > construct the libvirt libraries, not libvirtd nor virsh.
> > 
> 
> You can disable building the daemon with -Ddriver_libvirtd=disabled (if I am
> reading the code correctly).  I do not think there is something similar for the
> clients, but I might be wrong.  Pavel (Cc'd) would definitely know or at least
> be able to find it out more easily.  If it is not possible now then it should
> not be that difficult to add such option, I think.

Correct, using that option you can disable libvirtd which should reduce
some dependencies but there is no option to disable virsh. We can
possibly introduce an option to disable libvirt clients but that would
save you only readline as a dependency which you can disable by using
-Dreadline=disabled .

If you want to do a minimal build of libvirt you can run meson with
--auto-features=disabled which will disable most of the features and you
can explicitly enable only the things that you want to use (this is what
most distributions are doing when building packages). I just noticed
that there are some build options where this doesn't work so I'll post
patches to fix them.

The last part I have to ask what do you mean by "without dynamic lib
dependencies"? If you mean that libvirt.so should be statically linked
that is not currently possible. We would have to add option to make it
possible and update all dependency() and find_library() calls in all
meson.build files to look only for static libraries.

In addition I think we should add build options which would allow users
to disable tests, documentation, examples and other bits that end-users
don't have to use.

Pavel
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/libvirt-users/attachments/20201008/8b68be68/attachment.sig>


More information about the libvirt-users mailing list