1guestfs-building(1) Virtualization Support guestfs-building(1)
2
3
4
6 guestfs-building - How to build libguestfs from source
7
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
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
27 On systems still using yum(8), do:
28
29 yum-builddep libguestfs
30
31 Short cut for Debian or Ubuntu users
32 Use APT to install all the requirements:
33
34 apt-get build-dep libguestfs
35
36 If that command doesn't work, take a look at the Debian source package
37 http://packages.debian.org/source/libguestfs, at the list of
38 "build-depends" and "build-depends-indep", and install everything
39 listed there.
40
41 Full list of requirements
42 appliance/packagelist.in
43 Install as many package names found in this file as possible. (It
44 is not strictly required to install all of them).
45
46 Note: If you build libguestfs followed by installing appliance
47 packages, the build will not pick them up automatically, even if
48 you do "make clean". You have to do this command to clean the old
49 supermin appliance and force a new one to be prepared:
50
51 make -C appliance clean-supermin-appliance
52
53 qemu ≥ 1.3.0
54 Required.
55
56 qemu-img ≥ 1.3.0
57 Required. Virt-p2v and virt-v2v requires qemu-img ≥ 2.2.0.
58
59 kernel ≥ 2.6.34
60 Required. The following features must be enabled: "virtio-pci",
61 "virtio-serial", "virtio-block", "virtio-net".
62
63 supermin ≥ 5.1.0
64 Required. For alternatives, see "USING A PREBUILT BINARY
65 APPLIANCE" below.
66
67 glibc
68 Required. We use the custom printf formatters extension of glibc
69 (see "DAEMON CUSTOM PRINTF FORMATTERS" in guestfs-hacking(1)).
70
71 XDR (tirpc, glibc or other)
72 Required. We use the XDR implementation from "<rpc/xdr.h>", which
73 may come from glibc, tirpc or another library.
74
75 The "rpcgen" tool is optional, except if you want to compile from
76 git and/or patch libguestfs with new APIs.
77
78 Gcc or Clang
79 Required. We use "__attribute__((cleanup))" which is a GCC
80 extension also supported by Clang.
81
82 Perl
83 Required. Various build steps and tests are written in Perl. Perl
84 is not needed at runtime except if you need to run a small number
85 of virt tools which are still written in Perl.
86
87 Perl "Pod::Man"
88 Perl "Pod::Simple"
89 Required. Part of Perl core.
90
91 OCaml ≥ 4.01
92 OCaml findlib
93 Required.
94
95 autoconf
96 automake
97 gettext
98 Required if compiling from git. Optional if compiling from
99 tarball.
100
101 cpio
102 Required.
103
104 gperf
105 Required.
106
107 flex
108 bison
109 Required.
110
111 Perl-compatible Regular Expressions (PCRE) library
112 Required.
113
114 genisoimage
115 Required.
116
117 libxml2
118 Required.
119
120 ncurses
121 Required.
122
123 augeas ≥ 1.0.0
124 Required.
125
126 xz Required.
127
128 yajl ≥ 2.0.4
129 Required.
130
131 po4a
132 Required if compiling from git. Optional if compiling from
133 tarball.
134
135 hivex ≥ 1.2.7
136 ocaml-hivex
137 Required. ocaml-hivex is the OCaml binding for hivex, which is
138 required when building the daemon.
139
140 libmagic
141 Required. This is the library used by the file(1) command.
142
143 libvirt ≥ 0.10.2
144 Optional. Always use the latest possible version of libvirt.
145
146 xmllint
147 Optional. Used only for tests.
148
149 libconfig
150 Optional. Used to parse libguestfs’s own config files, eg.
151 /etc/libguestfs-tools.conf.
152
153 libselinux
154 Optional. Used by the libvirt backend to securely confine the
155 appliance (sVirt).
156
157 Berkeley DB utils (db_dump, db_load, etc)
158 Optional. Usually found in a package called "db-utils",
159 "db4-utils", "db4.X-utils" etc.
160
161 systemtap
162 Optional. For userspace probes.
163
164 readline
165 Optional. For nicer command line editing in guestfish(1).
166
167 acl Optional. Library and programs for handling POSIX ACLs.
168
169 libcap
170 Optional. Library and programs for handling Linux capabilities.
171
172 libldm
173 Optional. Library and ldmtool(1) for handling Windows Dynamic
174 Disks.
175
176 sd-journal
177 Optional. Library for accessing systemd journals.
178
179 gdisk
180 Optional. GPT disk support.
181
182 netpbm
183 Optional. Render icons from guests.
184
185 icoutils
186 Optional. Render icons from Windows guests.
187
188 Perl "Expect"
189 Optional. Perl module used to test virt-rescue(1).
190
191 FUSE
192 Optional. fusermount(1), libfuse and kernel module are all needed
193 if you want guestmount(1) and/or mount-local support.
194
195 static glibc
196 Optional. Used only for testing.
197
198 qemu-nbd
199 nbdkit
200 Optional. qemu-nbd is used for testing.
201
202 virt-p2v(1) requires either qemu-nbd or nbdkit, but these only need
203 to be present on the virt-p2v ISO, they do not need to be installed
204 at compile time.
205
206 uml_mkcow
207 Optional. For the UML backend.
208
209 curl
210 Optional. Used by virt-builder for downloads.
211
212 GNU Privacy Guard (GnuPG, gpg) v1 or v2
213 Optional. Used by virt-builder for checking digital signatures.
214
215 liblzma
216 Optional. If available, virt-builder will use this library for
217 fast, parallel uncompression of templates.
218
219 Gtk ≥ 2.24, or 3
220 Optional.
221
222 Used by the virt-p2v graphical user interface.
223
224 Either Gtk 2 or Gtk 3 can be used. If you want to select a
225 specific version of Gtk, use "./configure --with-gtk=2" or
226 "./configure --with-gtk=3".
227
228 D-Bus
229 Optional.
230
231 If the D-Bus low level C API is available, virt-p2v can send a
232 D-Bus message to logind to inhibit power saving (sleep, suspend,
233 etc) during P2V conversions.
234
235 If this API is not available at build time, then very long
236 conversions might be interrupted if the physical machine goes to
237 sleep.
238
239 zip
240 unzip
241 Optional. Used by virt-v2v to handle OVA files.
242
243 python-evtx
244 Optional. Used by virt-log(1) to parse Windows Event Log files.
245
246 OCaml gettext
247 Optional. For localizing OCaml virt tools.
248
249 ocaml-ounit ≥ 2.0.0
250 Optional. For testing the common OCaml modules.
251
252 ocaml-libvirt ≥ 0.6.1.5
253 Optional. For building the optional virt-v2v test harness.
254
255 Perl "Module::Build" ≥ 0.19
256 Perl "Test::More"
257 Optional. Used to build and test the Perl bindings.
258
259 Python ≥ 2.2
260 Optional. Used to build the Python bindings. For building Python
261 2 or Python 3 bindings, see "BUILDING PYTHON 2 AND PYTHON 3
262 BINDINGS" below.
263
264 Python "unittest"
265 Optional. Used to run the Python testsuite.
266
267 Ruby
268 rake
269 rubygem-minitest
270 rubygem-rdoc
271 Optional. Used to build the Ruby bindings.
272
273 Java ≥ 1.6
274 Optional. Java, JNI and jpackage-utils are needed for building
275 Java bindings.
276
277 GHC Optional. Used to build the Haskell bindings.
278
279 PHP
280 phpize
281 Optional. Used to build the PHP bindings.
282
283 glib2
284 gobject-introspection
285 gjs Optional. Used to build and test the GObject bindings.
286
287 LUA Optional. Used to build the LUA bindings.
288
289 Erlang
290 erl_interface
291 Optional. Used to build the Erlang bindings.
292
293 golang ≥ 1.1.1
294 Optional. Used to build the Go bindings.
295
296 valgrind
297 Optional. For testing memory problems.
298
299 Perl "Sys::Virt"
300 Optional.
301
302 libvirt-python
303 Optional. For testing Python libvirt/libguestfs interactions.
304
305 Perl "Win::Hivex"
306 Optional. Used by the virt-win-reg(1) tool.
307
308 Perl "Pod::Usage"
309 Optional. Used by some Perl virt tools.
310
311 Perl "libintl"
312 Optional.
313
314 bash-completion
315 Optional. For tab-completion of commands in bash.
316
317 libtsk
318 Optional. Library for filesystem forensics analysis.
319
320 yara
321 Optional. Tool for categorizing files based on their content.
322
324 You will need to install additional dependencies "autoconf",
325 "automake", "gettext", OCaml findlib and po4a when building from git.
326
327 git clone https://github.com/libguestfs/libguestfs
328 cd libguestfs
329 ./autogen.sh
330 make
331
333 Tarballs are downloaded from http://download.libguestfs.org/. Stable
334 tarballs are signed with the GnuPG key for "rich@annexia.org", see
335 https://pgp.mit.edu/pks/lookup?op=vindex&search=0x91738F73E1B768A0.
336 The fingerprint is "F777 4FB1 AD07 4A7E 8C87 67EA 9173 8F73 E1B7 68A0".
337
338 Download and unpack the tarball.
339
340 cd libguestfs-1.xx.yy
341 ./configure
342 make
343
345 DO NOT run the tests as root! Libguestfs can be built and tested as
346 non-root. Running the tests as root could even be dangerous, don't do
347 it.
348
349 To sanity check that the build worked, do:
350
351 make quickcheck
352
353 To run the basic tests, do:
354
355 make check
356
357 There are many more tests you can run. See guestfs-hacking(1) for
358 details.
359
361 DO NOT use "make install"! You'll end up with conflicting versions of
362 libguestfs installed, and this causes constant headaches for users.
363 See the next section for how to use the ./run script instead.
364
365 Distro packagers can use:
366
367 make INSTALLDIRS=vendor DESTDIR=[temp-build-dir] install
368
370 You can run guestfish(1), guestmount(1) and the virt tools without
371 needing to install them by using the ./run script in the top directory.
372 This script works by setting several environment variables.
373
374 For example:
375
376 ./run guestfish [usual guestfish args ...]
377
378 ./run virt-inspector [usual virt-inspector args ...]
379
380 The ./run script adds every libguestfs binary to the $PATH, so the
381 above examples run guestfish and virt-inspector from the build
382 directory (not the globally installed guestfish if there is one).
383
384 You can use the script from any directory. If you wanted to run your
385 own libguestfs-using program, then the following command will also
386 work:
387
388 /path/to/libguestfs/run ./my_program [...]
389
390 You can also run the C programs under valgrind like this:
391
392 ./run valgrind [valgrind opts...] virt-cat [virt-cat opts...]
393
394 or under gdb:
395
396 ./run gdb --args virt-cat [virt-cat opts...]
397
398 This also works with sudo (eg. if you need root access for libvirt or
399 to access a block device):
400
401 sudo ./run virt-cat -d LinuxGuest /etc/passwd
402
403 To set environment variables, you can either do:
404
405 LIBGUESTFS_HV=/my/qemu ./run guestfish
406
407 or:
408
409 ./run env LIBGUESTFS_HV=/my/qemu guestfish
410
412 Files in the top source directory that begin with the prefix local* are
413 ignored by git. These files can contain local configuration or scripts
414 that you need to build libguestfs.
415
416 I have a file called localconfigure which is a simple wrapper around
417 autogen.sh containing local configure customizations that I need. It
418 looks like this:
419
420 . localenv
421 ./autogen.sh \
422 -C \
423 --enable-werror \
424 "$@"
425
426 So I can use this to build libguestfs:
427
428 ./localconfigure && make
429
430 If there is a file in the top build directory called localenv, then it
431 will be sourced by "make". This file can contain any local environment
432 variables needed, eg. for skipping tests:
433
434 # Use an alternate python binary.
435 export PYTHON=python3
436 # Skip this test, it is broken.
437 export SKIP_TEST_BTRFS_FSCK=1
438
439 Note that localenv is included by the top Makefile (so it’s a Makefile
440 fragment). But if it is also sourced by your localconfigure script
441 then it is used as a shell script.
442
444 There are many "./configure" options. Use:
445
446 ./configure --help
447
448 to list them all. This section covers some of the more important ones.
449
450 --disable-appliance --disable-daemon
451 See "USING A PREBUILT BINARY APPLIANCE" below.
452
453 --disable-erlang
454 --disable-gobject
455 --disable-golang
456 --disable-haskell
457 --disable-lua
458 --disable-ocaml
459 --disable-perl
460 --disable-php
461 --disable-python
462 --disable-ruby
463 Disable specific language bindings, even if "./configure" finds all
464 the necessary libraries are installed so that they could be
465 compiled.
466
467 Note that disabling OCaml (bindings) or Perl will have the knock-on
468 effect of disabling parts of the test suite and some tools.
469
470 OCaml is required to build libguestfs and this requirement cannot
471 be removed. Using --disable-ocaml only disables the bindings and
472 OCaml tools.
473
474 --disable-fuse
475 Disable FUSE support in the API and the guestmount(1) tool.
476
477 --disable-gnulib-tests
478 On some platforms the GNUlib test suite can be flaky. This
479 disables it, since errors in the GNUlib test suite are often not
480 important.
481
482 --disable-static
483 Don’t build a static linked version of the libguestfs library.
484
485 --enable-install-daemon
486 Normally guestfsd(8) is not installed by "make install", since that
487 wouldn't be useful (instead it is "installed" inside the supermin
488 appliance). However if packagers are building "libguestfs live"
489 then they should use this option.
490
491 --enable-werror
492 This turns compiler warnings into errors (ie. "-Werror"). Use this
493 for development, especially when submitting patches. It should
494 generally not be used for production or distro builds.
495
496 --with-default-backend=libvirt
497 This controls the default method that libguestfs uses to run qemu
498 (see "BACKEND" in guestfs(3)). If not specified, the default
499 backend is "direct", which means libguestfs runs qemu directly.
500
501 Fedora and Red Hat Enterprise Linux (RHEL) ≥ 7 use this flag to
502 change the default backend to "libvirt", because (especially in
503 RHEL) the policy is not to allow any program to run qemu except via
504 libvirt.
505
506 Note that despite this setting, all backends are built into
507 libguestfs, and you can override the backend at runtime by setting
508 the $LIBGUESTFS_BACKEND environment variable (or using API
509 methods).
510
511 --with-distro=REDHAT|DEBIAN|...
512 Libguestfs needs to know which Linux distro is in use so it can
513 choose package names for the appliance correctly (see for example
514 appliance/packagelist.in). It normally does this automatically.
515
516 However if you can building or packaging libguestfs on a new distro
517 then you can use --with-distro to specify that the distro is
518 similar to an existing one (eg. --with-distro=REDHAT if the distro
519 is a new Red Hat or CentOS derivative).
520
521 Note that if your distro is completely new then it may still
522 require upstream modifications.
523
524 --with-extra="distroname=version,libvirt,..."
525 --with-extra="local"
526 This option controls the "extra" field returned by
527 "guestfs_version" in guestfs(3) and also printed by virt tools'
528 --version option. It is a free text field, but a good idea is to
529 encode a comma-separated list of facts such as the distro name and
530 version, whether libvirt is the default backend, and anything else
531 that may help with debugging problems raised by users.
532
533 For custom and/or local builds, this can be set to "local" to
534 indicate this is not a distro build.
535
536 --without-libvirt
537 Compile libguestfs without libvirt support, even if libvirt
538 development libraries are installed.
539
540 --with-gtk=2
541 This option forces virt-p2v to be built against Gtk 2, which is
542 currently the most widely tested configuration.
543
544 --with-qemu="bin1 bin2 ..."
545 Provide an alternate qemu binary (or list of binaries). This can
546 be overridden at runtime by setting the "LIBGUESTFS_HV" environment
547 variable.
548
549 --with-supermin-packager-config=yum.conf
550 This passes the --packager-config option to supermin(1).
551
552 The most common use for this is to build the appliance using an
553 alternate repository (instead of using the installed
554 yum/dnf/apt/etc configuration to find and download packages). You
555 might need to use this if you want to build libguestfs without
556 having a network connection. Examples of using this can be found
557 in the Fedora "libguestfs.spec" file (see "BUILDING A PACKAGE FOR
558 FEDORA" below for resources).
559
560 --with-supermin-extra-options="--opt1 --opt2 ..."
561 Pass additional options to supermin(1). See appliance/make.sh.in
562 to understand precisely what this does.
563
564 PYTHON
565 This environment variable may be set to point to a python binary
566 (eg. "python3"). When "./configure" runs, it inspects this python
567 binary to find the version of Python, the location of Python
568 libraries and so on. See "BUILDING PYTHON 2 AND PYTHON 3 BINDINGS"
569 below.
570
571 SUPERMIN
572 This environment variable can be set to choose an alternative
573 supermin(1) binary. This might be used, for example, if you want
574 to use a newer upstream version of supermin than is packaged for
575 your distro, or if supermin is not packaged at all. On RHEL 7, you
576 must set "SUPERMIN=/usr/bin/supermin5" when compiling libguestfs.
577
579 A common problem is with broken or incompatible qemu releases.
580
581 Different versions of qemu have problems booting the appliance for
582 different reasons. This varies between versions of qemu, and Linux
583 distributions which add their own patches.
584
585 If you find a problem, you could try using your own qemu built from
586 source (qemu is very easy to build from source), with a "qemu wrapper".
587 See "QEMU WRAPPERS" in guestfs(3).
588
589 By default the configure script will look for qemu-kvm (KVM support).
590 KVM is much faster than using plain qemu.
591
592 You may also need to enable KVM support for non-root users, by
593 following these instructions:
594 http://www.linux-kvm.org/page/FAQ#How_can_I_use_kvm_with_a_non-privileged_user.3F
595
596 On some systems, this will work too:
597
598 chmod 0666 /dev/kvm
599
600 On some systems, the chmod will not survive a reboot, and you will need
601 to make edits to the udev configuration.
602
604 export CC=clang
605 ./configure
606 make
607
609 To understand what the libguestfs appliance means, see
610 guestfs-internals(1).
611
612 If you are using non-Linux, or a Linux distribution that does not have
613 supermin(1) support, or simply if you don't want to build your own
614 libguestfs appliance, then you can use one of the prebuilt binary
615 appliances that we supply:
616 http://libguestfs.org/download/binaries/appliance
617
618 Build libguestfs like this:
619
620 ./configure --disable-appliance --disable-daemon
621 make
622
623 Set $LIBGUESTFS_PATH to the path where you unpacked the appliance
624 tarball, eg:
625
626 export LIBGUESTFS_PATH=/usr/local/lib/guestfs/appliance
627
628 and run the libguestfs programs and virt tools in the normal way, eg.
629 using the ./run script (see above).
630
632 The ./configure script detects the currently installed version of
633 Python using whatever program is called "python" in the current $PATH.
634 Libguestfs will build Python 2 or Python 3 bindings as appropriate.
635
636 You can override this behaviour by specifying an alternate Python
637 binary, eg:
638
639 PYTHON=/usr/bin/python3 ./configure
640
641 To build parallel Python 2 and Python 3 bindings, you will need to
642 build libguestfs twice. The second time, you can disable all the other
643 bindings and tools and just build the Python bindings. See the Fedora
644 spec file (see below) for a complete example of how to do this.
645
647 The Fedora spec file is stored under:
648 http://pkgs.fedoraproject.org/cgit/rpms/libguestfs.git/
649
650 Libguestfs is built in Fedora using the ordinary Fedora build system
651 (Koji).
652
654 Red Hat Enterprise Linux (RHEL) builds of libguestfs are heavily
655 patched. There are broadly two types of patches we apply:
656
657 · We disable many features that we do not wish to support for RHEL
658 customers. For example, the "libguestfs live" feature is disabled.
659
660 · We backport upstream features.
661
662 The patches we apply to RHEL releases are available publically in the
663 upstream git repository, in a branch called "rhel-x.y"
664
665 For example, the RHEL 7.3 patches are available here:
666 https://github.com/libguestfs/libguestfs/commits/rhel-7.3
667
668 The sources and spec files for RHEL versions of libguestfs are
669 available on https://git.centos.org/project/rpms, and see also
670 https://wiki.centos.org/Sources.
671
673 (This section only applies on the x86-64 architecture.)
674
675 Building a 32 bit virt-p2v (i686) binary improves compatibility with
676 older hardware. See virt-p2v-make-disk(1) for details. Although
677 virt-p2v is a simple Gtk application, it is not especially easy to
678 build just virt-p2v as a 32 bit application on a 64 bit host. Usually
679 the simplest way is to use a 32 bit chroot or even a 32 bit virtual
680 machine to build libguestfs.
681
682 On Fedora you can use the mock(1) tool. For example:
683
684 fedpkg mockbuild --root fedora-23-i386
685
686 This will result in a virt-v2v-*.i686.rpm file which can be unpacked to
687 extract the 32 bit virt-p2v binary.
688
689 The binary may be compressed to either p2v/virt-p2v.i686.xz, or
690 $libdir/virt-p2v/virt-p2v.i686.xz or
691 $VIRT_P2V_DATA_DIR/virt-p2v.i686.xz as appropriate. This enables the
692 virt-p2v-make-disk(1) --arch option.
693
695 guestfs(3), guestfs-examples(3), guestfs-hacking(1),
696 guestfs-internals(1), guestfs-performance(1), guestfs-release-notes(1),
697 guestfs-testing(1), libguestfs-test-tool(1),
698 libguestfs-make-fixed-appliance(1), http://libguestfs.org/.
699
701 Richard W.M. Jones ("rjones at redhat dot com")
702
704 Copyright (C) 2009-2018 Red Hat Inc.
705
707 This library is free software; you can redistribute it and/or modify it
708 under the terms of the GNU Lesser General Public License as published
709 by the Free Software Foundation; either version 2 of the License, or
710 (at your option) any later version.
711
712 This library is distributed in the hope that it will be useful, but
713 WITHOUT ANY WARRANTY; without even the implied warranty of
714 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
715 Lesser General Public License for more details.
716
717 You should have received a copy of the GNU Lesser General Public
718 License along with this library; if not, write to the Free Software
719 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
720 02110-1301 USA
721
723 To get a list of bugs against libguestfs, use this link:
724 https://bugzilla.redhat.com/buglist.cgi?component=libguestfs&product=Virtualization+Tools
725
726 To report a new bug against libguestfs, use this link:
727 https://bugzilla.redhat.com/enter_bug.cgi?component=libguestfs&product=Virtualization+Tools
728
729 When reporting a bug, please supply:
730
731 · The version of libguestfs.
732
733 · Where you got libguestfs (eg. which Linux distro, compiled from
734 source, etc)
735
736 · Describe the bug accurately and give a way to reproduce it.
737
738 · Run libguestfs-test-tool(1) and paste the complete, unedited output
739 into the bug report.
740
741
742
743libguestfs-1.38.2 2018-05-15 guestfs-building(1)