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        autoreconf -i
295        ./configure CFLAGS=-fPIC
296        make
297

BUILDING FROM TARBALLS

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

RUNNING THE TESTS

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

INSTALLING

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

THE ./run SCRIPT

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

local* FILES

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

SELECTED ./configure SETTINGS

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

NOTES ABOUT QEMU AND KVM

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

USING CLANG (LLVM) INSTEAD OF GCC

558        export CC=clang
559        ./configure
560        make
561

USING A PREBUILT BINARY APPLIANCE

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

BUILDING A PACKAGE FOR FEDORA

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

BUILDING A PACKAGE FOR RED HAT ENTERPRISE LINUX

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

SEE ALSO

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

AUTHORS

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

LICENSE

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

BUGS

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