1guestfs-building(1)         Virtualization Support         guestfs-building(1)
2
3
4

NAME

6       guestfs-building - How to build libguestfs from source
7

DESCRIPTION

9       This manual page describes how to build libguestfs from source.
10
11       The main steps are:
12
13       •   Install the requirements.
14
15       •   Build, either from the git repository or from a tarball.
16
17       •   Run the tests.
18
19       •   Run the tools from the source directory, or install.
20

REQUIREMENTS

22   Short cut for Fedora or Red Hat Enterprise Linux (RHEL) users
23       On Fedora, use dnf(8) to install all the requirements:
24
25        dnf builddep libguestfs
26        dnf install autoconf automake libtool gettext-devel
27
28       On systems still using yum(8), do:
29
30        yum-builddep libguestfs
31        yum install autoconf automake libtool gettext-devel
32
33   Short cut for Debian or Ubuntu users
34       Use APT to install all the requirements:
35
36        apt-get build-dep libguestfs
37        apt-get install autoconf automake libtool-bin gettext
38
39       If that command doesn't work, take a look at the Debian source package
40       http://packages.debian.org/source/libguestfs, at the list of
41       "build-depends" and "build-depends-indep", and install everything
42       listed there.
43
44   Full list of requirements
45       appliance/packagelist.in
46           Install as many package names found in this file as possible.  (It
47           is not strictly required to install all of them).
48
49           Note: If you build libguestfs followed by installing appliance
50           packages, the build will not pick them up automatically, even if
51           you do "make clean".  You have to do this command to clean the old
52           supermin appliance and force a new one to be prepared:
53
54            make -C appliance clean-supermin-appliance
55
56       qemu ≥ 1.3.0
57           Required.
58
59       qemu-img ≥ 1.3.0
60           Required.
61
62       kernel ≥ 2.6.34
63           Required.  The following features must be enabled: "virtio-pci",
64           "virtio-serial", "virtio-block", "virtio-net".
65
66       supermin ≥ 5.1.18
67           Required.  For alternatives, see "USING A PREBUILT BINARY
68           APPLIANCE" below.
69
70       glibc
71           Required.  We use the custom printf formatters extension of glibc
72           (see "DAEMON CUSTOM PRINTF FORMATTERS" in guestfs-hacking(1)).
73
74       XDR (tirpc, glibc or other)
75           Required.  We use the XDR implementation from "<rpc/xdr.h>", which
76           may come from glibc, tirpc or another library.
77
78           The "rpcgen" tool is optional, except if you want to compile from
79           git and/or patch libguestfs with new APIs.
80
81       Gcc or Clang
82           Required.  We use "__attribute__((cleanup))" which is a GCC
83           extension also supported by Clang.
84
85       Perl
86           Required.  Various build steps and tests are written in Perl.  Perl
87           is not needed at runtime except if you need to run a small number
88           of virt tools which are still written in Perl.
89
90       Perl "Pod::Man"
91       Perl "Pod::Simple"
92           Required.  Part of Perl core.
93
94       OCaml ≥ 4.01
95       OCaml findlib
96           Required.
97
98       autoconf
99       automake
100       gettext
101           Required if compiling from git.  Optional if compiling from
102           tarball.
103
104       cpio
105           Required.
106
107       gperf
108           Required.
109
110       flex
111       bison
112           Required.
113
114       Perl-compatible Regular Expressions (PCRE2) library
115           Required.
116
117       xorriso, genisoimage or mkisofs
118           One of these is Required.
119
120       libxml2
121           Required.
122
123       ncurses
124           Required.
125
126       augeas ≥ 1.2.0
127           Required.
128
129       xz  Required.
130
131       Jansson ≥ 2.7
132           Required.
133
134       po4a
135           Required if compiling from git.  Optional if compiling from
136           tarball.
137
138       hivex ≥ 1.2.7
139       ocaml-hivex
140           Required.  ocaml-hivex is the OCaml binding for hivex, which is
141           required when building the daemon.
142
143       libmagic
144           Required.  This is the library used by the file(1) command.
145
146       libvirt ≥ 0.10.2
147           Optional.  Always use the latest possible version of libvirt.
148
149       xmllint
150           Optional.  Used only for tests.
151
152       libconfig
153           Optional.  Used to parse libguestfs’s own config files, eg.
154           /etc/libguestfs-tools.conf.
155
156       libselinux
157           Optional.  Used by the libvirt backend to securely confine the
158           appliance (sVirt).
159
160       systemtap
161           Optional.  For userspace probes.
162
163       readline
164           Optional.  For nicer command line editing in guestfish(1).
165
166       acl Optional.  Library and programs for handling POSIX ACLs.
167
168       libcap
169           Optional.  Library and programs for handling Linux capabilities.
170
171       libldm
172           Optional.  Library and ldmtool(1) for handling Windows Dynamic
173           Disks.
174
175       sd-journal
176           Optional.  Library for accessing systemd journals.
177
178       gdisk
179           Optional.  GPT disk support.
180
181       netpbm
182           Optional.  Render icons from guests.
183
184       icoutils
185           Optional.  Render icons from Windows guests.
186
187       librpm
188           Optional.  To parse the list of applications from RPM-based guests.
189
190       Perl "Expect"
191           Optional.  Perl module used to test virt-rescue(1).
192
193       FUSE
194           Optional.  fusermount(1), libfuse and kernel module are all needed
195           if you want guestmount(1) and/or mount-local support.
196
197       static glibc
198           Optional.  Used only for testing.
199
200       qemu-nbd
201       nbdkit ≥ 1.12
202           Optional.  qemu-nbd is used for testing.
203
204       uml_mkcow
205           Optional.  For the UML backend.
206
207       curl
208           Optional.  Used by virt-builder for downloads.
209
210       GNU Privacy Guard (GnuPG, gpg) v1 or v2
211           Optional.  Used by virt-builder for checking digital signatures.
212
213       liblzma
214           Optional.  If available, virt-builder will use this library for
215           fast, parallel uncompression of templates.
216
217       python-evtx
218           Optional.  Used by virt-log(1) to parse Windows Event Log files.
219
220       OCaml gettext
221           Optional.  For localizing OCaml virt tools.
222
223       ocaml-ounit ≥ 2.0.0
224           Optional.  For testing the common OCaml modules.
225
226       Perl "Module::Build" ≥ 0.19
227       Perl "Test::More"
228           Optional.  Used to build and test the Perl bindings.
229
230       Python ≥ 3.6
231           Optional.  Used to build the Python bindings.  Python 2 support was
232           removed in libguestfs 1.42.1.
233
234       Python "unittest"
235           Optional.  Used to run the Python testsuite.
236
237       Ruby
238       rake
239       rubygem-minitest
240       rubygem-rdoc
241           Optional.  Used to build the Ruby bindings.
242
243       Java ≥ 1.6
244           Optional.  Java, JNI and jpackage-utils are needed for building
245           Java bindings.
246
247       GHC Optional.  Used to build the Haskell bindings.
248
249       PHP
250       phpize
251           Optional.  Used to build the PHP bindings.
252
253       glib2
254       gobject-introspection
255       gjs Optional.  Used to build and test the GObject bindings.
256
257       vala
258           Optional.  Used to build the Vala bindings.
259
260       LUA Optional.  Used to build the LUA bindings.
261
262       Erlang ≥ 23
263       ei  Optional.  Used to build the Erlang bindings.  Note that Erlang ≤
264           22 will not work unless you use libguestfs ≤ 1.42.
265
266       golang ≥ 1.1.1
267           Optional.  Used to build the Go bindings.
268
269       valgrind
270           Optional.  For testing memory problems.
271
272       libvirt-python
273           Optional.  For testing Python libvirt/libguestfs interactions.
274
275       Perl "libintl"
276           Optional.
277
278       bash-completion
279           Optional.  For tab-completion of commands in bash.
280
281       libtsk
282           Optional.  Library for filesystem forensics analysis.
283
284       yara
285           Optional.  Tool for categorizing files based on their content.
286

BUILDING FROM GIT

288       You will need to install additional dependencies "autoconf",
289       "automake", "gettext", OCaml findlib and po4a when building from git.
290
291        git clone https://github.com/libguestfs/libguestfs
292        cd libguestfs
293        git submodule update --init
294        CFLAGS=-fPIC ./autogen.sh
295        make
296

BUILDING FROM TARBALLS

298       Tarballs are downloaded from http://download.libguestfs.org/.  Stable
299       tarballs are signed with the GnuPG key for "rich@annexia.org", see
300       https://pgp.mit.edu/pks/lookup?op=vindex&search=0x91738F73E1B768A0.
301       The fingerprint is "F777 4FB1 AD07 4A7E 8C87 67EA 9173 8F73 E1B7 68A0".
302
303       Download and unpack the tarball.
304
305        cd libguestfs-1.xx.yy
306        ./configure
307        make
308

RUNNING THE TESTS

310       DO NOT run the tests as root!  Libguestfs can be built and tested as
311       non-root.  Running the tests as root could even be dangerous, don't do
312       it.
313
314       To sanity check that the build worked, do:
315
316        make quickcheck
317
318       To run the basic tests, do:
319
320        make check
321
322       There are many more tests you can run.  See guestfs-hacking(1) for
323       details.
324

INSTALLING

326       DO NOT use "make install"!  You'll end up with conflicting versions of
327       libguestfs installed, and this causes constant headaches for users.
328       See the next section for how to use the ./run script instead.
329
330       Distro packagers can use:
331
332        make INSTALLDIRS=vendor DESTDIR=[temp-build-dir] install
333

THE ./run SCRIPT

335       You can run guestfish(1), guestmount(1) and the virt tools without
336       needing to install them by using the ./run script in the top directory.
337       This script works by setting several environment variables.
338
339       For example:
340
341        ./run guestfish [usual guestfish args ...]
342
343        ./run virt-inspector [usual virt-inspector args ...]
344
345       The ./run script adds every libguestfs binary to the $PATH, so the
346       above examples run guestfish and virt-inspector from the build
347       directory (not the globally installed guestfish if there is one).
348
349       You can use the script from any directory.  If you wanted to run your
350       own libguestfs-using program, then the following command will also
351       work:
352
353        /path/to/libguestfs/run ./my_program [...]
354
355       You can also run the C programs under valgrind like this:
356
357        ./run valgrind [valgrind opts...] virt-cat [virt-cat opts...]
358
359       or under gdb:
360
361        ./run gdb --args virt-cat [virt-cat opts...]
362
363       This also works with sudo (eg. if you need root access for libvirt or
364       to access a block device):
365
366        sudo ./run virt-cat -d LinuxGuest /etc/passwd
367
368       To set environment variables, you can either do:
369
370        LIBGUESTFS_HV=/my/qemu ./run guestfish
371
372       or:
373
374        ./run env LIBGUESTFS_HV=/my/qemu guestfish
375

local* FILES

377       Files in the top source directory that begin with the prefix local* are
378       ignored by git.  These files can contain local configuration or scripts
379       that you need to build libguestfs.
380
381       I have a file called localconfigure which is a simple wrapper around
382       autogen.sh containing local configure customizations that I need.  It
383       looks like this:
384
385        . localenv
386        ./autogen.sh \
387            -C \
388            --enable-werror \
389            "$@"
390
391       So I can use this to build libguestfs:
392
393        ./localconfigure && make
394
395       If there is a file in the top build directory called localenv, then it
396       will be sourced by "make".  This file can contain any local environment
397       variables needed, eg. for skipping tests:
398
399        # Skip this test, it is broken.
400        export SKIP_TEST_BTRFS_FSCK=1
401
402       Note that localenv is included by the top Makefile (so it’s a Makefile
403       fragment).  But if it is also sourced by your localconfigure script
404       then it is used as a shell script.
405

SELECTED ./configure SETTINGS

407       There are many "./configure" options.  Use:
408
409        ./configure --help
410
411       to list them all.  This section covers some of the more important ones.
412
413       --disable-appliance --disable-daemon
414           See "USING A PREBUILT BINARY APPLIANCE" below.
415
416       --disable-erlang
417       --disable-gobject
418       --disable-golang
419       --disable-haskell
420       --disable-lua
421       --disable-ocaml
422       --disable-perl
423       --disable-php
424       --disable-python
425       --disable-ruby
426           Disable specific language bindings, even if "./configure" finds all
427           the necessary libraries are installed so that they could be
428           compiled.
429
430           Note that disabling OCaml (bindings) or Perl will have the knock-on
431           effect of disabling parts of the test suite and some tools.
432
433           OCaml is required to build libguestfs and this requirement cannot
434           be removed.  Using --disable-ocaml only disables the bindings and
435           OCaml tools.
436
437       --disable-fuse
438           Disable FUSE support in the API and the guestmount(1) tool.
439
440       --disable-gnulib-tests
441           On some platforms the GNUlib test suite can be flaky.  This
442           disables it, since errors in the GNUlib test suite are often not
443           important.
444
445       --disable-static
446           Don’t build a static linked version of the libguestfs library.
447
448       --enable-install-daemon
449           Normally guestfsd(8) is not installed by "make install", since that
450           wouldn't be useful (instead it is "installed" inside the supermin
451           appliance).  However if packagers are building "libguestfs live"
452           then they should use this option.
453
454       --enable-werror
455           This turns compiler warnings into errors (ie. "-Werror").  Use this
456           for development, especially when submitting patches.  It should
457           generally not be used for production or distro builds.
458
459       --with-default-backend=libvirt
460           This controls the default method that libguestfs uses to run qemu
461           (see "BACKEND" in guestfs(3)).  If not specified, the default
462           backend is "direct", which means libguestfs runs qemu directly.
463
464           Fedora and Red Hat Enterprise Linux (RHEL) ≥ 7 use this flag to
465           change the default backend to "libvirt", because (especially in
466           RHEL) the policy is not to allow any program to run qemu except via
467           libvirt.
468
469           Note that despite this setting, all backends are built into
470           libguestfs, and you can override the backend at runtime by setting
471           the $LIBGUESTFS_BACKEND environment variable (or using API
472           methods).
473
474       --with-distro=REDHAT|DEBIAN|...
475           Libguestfs needs to know which Linux distro is in use so it can
476           choose package names for the appliance correctly (see for example
477           appliance/packagelist.in).  It normally does this automatically.
478
479           However if you can building or packaging libguestfs on a new distro
480           then you can use --with-distro to specify that the distro is
481           similar to an existing one (eg. --with-distro=REDHAT if the distro
482           is a new Red Hat or CentOS derivative).
483
484           Note that if your distro is completely new then it may still
485           require upstream modifications.
486
487       --with-extra="distroname=version,libvirt,..."
488       --with-extra="local"
489           This option controls the "extra" field returned by
490           "guestfs_version" in guestfs(3) and also printed by virt tools'
491           --version option.  It is a free text field, but a good idea is to
492           encode a comma-separated list of facts such as the distro name and
493           version, whether libvirt is the default backend, and anything else
494           that may help with debugging problems raised by users.
495
496           For custom and/or local builds, this can be set to "local" to
497           indicate this is not a distro build.
498
499       --without-libvirt
500           Compile libguestfs without libvirt support, even if libvirt
501           development libraries are installed.
502
503       --with-qemu="bin1 bin2 ..."
504           Provide an alternate qemu binary (or list of binaries).  This can
505           be overridden at runtime by setting the "LIBGUESTFS_HV" environment
506           variable.
507
508       --with-supermin-packager-config=yum.conf
509           This passes the --packager-config option to supermin(1).
510
511           The most common use for this is to build the appliance using an
512           alternate repository (instead of using the installed
513           yum/dnf/apt/etc configuration to find and download packages).  You
514           might need to use this if you want to build libguestfs without
515           having a network connection.  Examples of using this can be found
516           in the Fedora "libguestfs.spec" file (see "BUILDING A PACKAGE FOR
517           FEDORA" below for resources).
518
519       --with-supermin-extra-options="--opt1 --opt2 ..."
520           Pass additional options to supermin(1).  See appliance/make.sh.in
521           to understand precisely what this does.
522
523       PYTHON
524           This environment variable may be set to point to a python binary
525           (eg. "python3").  When "./configure" runs, it inspects this python
526           binary to find the version of Python, the location of Python
527           libraries and so on.
528
529       SUPERMIN
530           This environment variable can be set to choose an alternative
531           supermin(1) binary.  This might be used, for example, if you want
532           to use a newer upstream version of supermin than is packaged for
533           your distro, or if supermin is not packaged at all.  On RHEL 7, you
534           must set "SUPERMIN=/usr/bin/supermin5" when compiling libguestfs.
535

NOTES ABOUT QEMU AND KVM

537       A common problem is with broken or incompatible qemu releases.
538
539       Different versions of qemu have problems booting the appliance for
540       different reasons.  This varies between versions of qemu, and Linux
541       distributions which add their own patches.
542
543       If you find a problem, you could try using your own qemu built from
544       source (qemu is very easy to build from source), with a "qemu wrapper".
545       See "QEMU WRAPPERS" in guestfs(3).
546
547       By default the configure script will look for qemu-kvm (KVM support).
548       KVM is much faster than using plain qemu.
549
550       You may also need to enable KVM support for non-root users, by
551       following these instructions:
552       http://www.linux-kvm.org/page/FAQ#How_can_I_use_kvm_with_a_non-privileged_user.3F
553
554       On some systems, this will work too:
555
556        chmod 0666 /dev/kvm
557
558       On some systems, the chmod will not survive a reboot, and you will need
559       to make edits to the udev configuration.
560

USING CLANG (LLVM) INSTEAD OF GCC

562        export CC=clang
563        ./configure
564        make
565

USING A PREBUILT BINARY APPLIANCE

567       To understand what the libguestfs appliance means, see
568       guestfs-internals(1).
569
570       If you are using non-Linux, or a Linux distribution that does not have
571       supermin(1) support, or simply if you don't want to build your own
572       libguestfs appliance, then you can use one of the prebuilt binary
573       appliances that we supply:
574       http://libguestfs.org/download/binaries/appliance
575
576       Build libguestfs like this:
577
578        ./configure --disable-appliance --disable-daemon
579        make
580
581       Set $LIBGUESTFS_PATH to the path where you unpacked the appliance
582       tarball, eg:
583
584        export LIBGUESTFS_PATH=/usr/local/lib/guestfs/appliance
585
586       and run the libguestfs programs and virt tools in the normal way, eg.
587       using the ./run script (see above).
588

BUILDING A PACKAGE FOR FEDORA

590       The Fedora spec file is stored under:
591       http://pkgs.fedoraproject.org/cgit/rpms/libguestfs.git/
592
593       Libguestfs is built in Fedora using the ordinary Fedora build system
594       (Koji).
595

BUILDING A PACKAGE FOR RED HAT ENTERPRISE LINUX

597       Red Hat Enterprise Linux (RHEL) builds of libguestfs are heavily
598       patched.  There are broadly two types of patches we apply:
599
600       •   We disable many features that we do not wish to support for RHEL
601           customers.  For example, the "libguestfs live" feature is disabled.
602
603       •   We backport upstream features.
604
605       The patches we apply to RHEL releases are available publically in the
606       upstream git repository, in a branch called "rhel-x.y"
607
608       For example, the RHEL 7.3 patches are available here:
609       https://github.com/libguestfs/libguestfs/commits/rhel-7.3
610
611       The sources and spec files for RHEL versions of libguestfs are
612       available on https://git.centos.org/project/rpms, and see also
613       https://wiki.centos.org/Sources.
614

SEE ALSO

616       guestfs(3), guestfs-examples(3), guestfs-hacking(1),
617       guestfs-internals(1), guestfs-performance(1), guestfs-release-notes(1),
618       guestfs-testing(1), libguestfs-test-tool(1),
619       libguestfs-make-fixed-appliance(1), http://libguestfs.org/.
620

AUTHORS

622       Richard W.M. Jones ("rjones at redhat dot com")
623
625       Copyright (C) 2009-2020 Red Hat Inc.
626

LICENSE

628       This library is free software; you can redistribute it and/or modify it
629       under the terms of the GNU Lesser General Public License as published
630       by the Free Software Foundation; either version 2 of the License, or
631       (at your option) any later version.
632
633       This library is distributed in the hope that it will be useful, but
634       WITHOUT ANY WARRANTY; without even the implied warranty of
635       MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
636       Lesser General Public License for more details.
637
638       You should have received a copy of the GNU Lesser General Public
639       License along with this library; if not, write to the Free Software
640       Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
641       02110-1301 USA
642

BUGS

644       To get a list of bugs against libguestfs, use this link:
645       https://bugzilla.redhat.com/buglist.cgi?component=libguestfs&product=Virtualization+Tools
646
647       To report a new bug against libguestfs, use this link:
648       https://bugzilla.redhat.com/enter_bug.cgi?component=libguestfs&product=Virtualization+Tools
649
650       When reporting a bug, please supply:
651
652       •   The version of libguestfs.
653
654       •   Where you got libguestfs (eg. which Linux distro, compiled from
655           source, etc)
656
657       •   Describe the bug accurately and give a way to reproduce it.
658
659       •   Run libguestfs-test-tool(1) and paste the complete, unedited output
660           into the bug report.
661
662
663
664libguestfs-1.45.4                 2021-04-03               guestfs-building(1)
Impressum