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.04
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       curl
205           Optional.  Used by virt-builder for downloads.
206
207       GNU Privacy Guard (GnuPG, gpg) v1 or v2
208           Optional.  Used by virt-builder for checking digital signatures.
209
210       liblzma
211           Optional.  If available, virt-builder will use this library for
212           fast, parallel uncompression of templates.
213
214       python-evtx
215           Optional.  Used by virt-log(1) to parse Windows Event Log files.
216
217       OCaml gettext
218           Optional.  For localizing OCaml virt tools.
219
220       ocaml-ounit ≥ 2.0.0
221           Optional.  For testing the common OCaml modules.
222
223       Perl "Module::Build" ≥ 0.19
224       Perl "Test::More"
225           Optional.  Used to build and test the Perl bindings.
226
227       Python ≥ 3.6
228           Optional.  Used to build the Python bindings.  Python 2 support was
229           removed in libguestfs 1.42.1.
230
231       Python "unittest"
232           Optional.  Used to run the Python testsuite.
233
234       Ruby
235       rake
236       rubygem-minitest
237       rubygem-rdoc
238           Optional.  Used to build the Ruby bindings.
239
240       Java ≥ 1.6
241           Optional.  Java, JNI and jpackage-utils are needed for building
242           Java bindings.
243
244       GHC Optional.  Used to build the Haskell bindings.
245
246       PHP
247       phpize
248           Optional.  Used to build the PHP bindings.
249
250       glib2
251       gobject-introspection
252       gjs Optional.  Used to build and test the GObject bindings.
253
254       vala
255           Optional.  Used to build the Vala bindings.
256
257       LUA Optional.  Used to build the LUA bindings.
258
259       Erlang ≥ 23
260       ei  Optional.  Used to build the Erlang bindings.  Note that Erlang ≤
261           22 will not work unless you use libguestfs ≤ 1.42.
262
263       golang ≥ 1.1.1
264           Optional.  Used to build the Go bindings.
265
266       valgrind
267           Optional.  For testing memory problems.
268
269       libvirt-python
270           Optional.  For testing Python libvirt/libguestfs interactions.
271
272       Perl "libintl"
273           Optional.
274
275       bash-completion
276           Optional.  For tab-completion of commands in bash.
277
278       libtsk
279           Optional.  Library for filesystem forensics analysis.
280
281       yara ≥ 4.0.0
282           Optional.  Tool for categorizing files based on their content.
283

BUILDING FROM GIT

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

BUILDING FROM TARBALLS

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

RUNNING THE TESTS

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

INSTALLING

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

THE ./run SCRIPT

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

local* FILES

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

SELECTED ./configure SETTINGS

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

NOTES ABOUT QEMU AND KVM

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

USING CLANG (LLVM) INSTEAD OF GCC

555        export CC=clang
556        ./configure
557        make
558

USING A PREBUILT BINARY APPLIANCE

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

BUILDING A PACKAGE FOR FEDORA

583       The Fedora spec file is stored under:
584       http://pkgs.fedoraproject.org/cgit/rpms/libguestfs.git/
585
586       Libguestfs is built in Fedora using the ordinary Fedora build system
587       (Koji).
588

BUILDING A PACKAGE FOR RED HAT ENTERPRISE LINUX

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

SEE ALSO

609       guestfs(3), guestfs-examples(3), guestfs-hacking(1),
610       guestfs-internals(1), guestfs-performance(1), guestfs-release-notes(1),
611       guestfs-testing(1), libguestfs-test-tool(1),
612       libguestfs-make-fixed-appliance(1), http://libguestfs.org/.
613

AUTHORS

615       Richard W.M. Jones ("rjones at redhat dot com")
616
618       Copyright (C) 2009-2020 Red Hat Inc.
619

LICENSE

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

BUGS

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