Build environment set up for libguestfs.
[libguestfs.git] / README
1 libguestfs is a library for accessing and modifying guest disk images.
2 Amongst the things this is good for: making batch configuration
3 changes to guests, getting disk used/free statistics (see also:
4 virt-df), migrating between virtualization systems (see also:
5 virt-p2v), performing partial backups, performing partial guest
6 clones, cloning guests and changing registry/UUID/hostname info, and
7 much else besides.
8
9 libguestfs uses Linux kernel and qemu code, and can access any type of
10 guest filesystem that Linux and qemu can, including but not limited
11 to: ext2/3/4, btrfs, FAT and NTFS, LVM, many different disk partition
12 schemes, qcow, qcow2, vmdk.
13
14 libguestfs provides ways to enumerate guest storage (eg. partitions,
15 LVs, what filesystem is in each LV, etc.).  It can also run commands
16 in the context of the guest.  Also you can mount guest filesystems on
17 the host (requires root privs and NFS).
18
19 libguestfs is a library that can be linked with C and C++ management
20 programs (or management programs written in other languages, if people
21 contribute the language bindings).  You can also use it from shell
22 scripts or the command line.
23
24 libguestfs was written by Richard W.M. Jones (rjones@redhat.com).
25 For discussion please use the fedora-virt mailing list:
26
27   https://www.redhat.com/mailman/listinfo/fedora-virt
28
29
30 Requirements
31 ----------------------------------------------------------------------
32
33 - nfs-utils source, unpacked
34   http://download.sourceforge.net/nfs
35
36 - Recent QEMU with vmchannel support
37
38 - Compiled Linux kernels for 32 and/or 64 bit (see note below).
39
40 - mkinitrd
41
42 - cpio
43
44 - XDR, rpcgen
45
46 - If you are running a 64 bit or non-x86 machine, see note below.
47
48 We don't support initramfs at the moment.  Patches gratefully
49 received.
50
51 Running ./configure will check you have all the requirements installed
52 on your machine.
53
54
55 Building
56 ----------------------------------------------------------------------
57
58 Unpack nfs-utils source into a directory somewhere, then create a
59 symlink daemon/nfs-utils to where you unpacked it.  For example:
60
61   pushd daemon
62   tar zxf /path/to/nfs-utils-1.1.4.tar.gz
63   ln -s nfs-utils-1.1.4 nfs-utils
64   popd
65
66 For nfs-utils 1.1.4, you may find that the patch
67 (nfs-utils-1.1.4-build.patch) helps.
68
69 Then make the library and shell tools:
70
71   ./configure
72   make
73
74 Make the daemon and NFS server:
75   mkdir daemon/build
76   pushd daemon/build
77   ../configure
78   make
79   popd
80
81 For 64 bit you'll probably want to build the 32 bit daemon and NFS
82 server too:
83
84   mkdir daemon/build-32
85   pushd daemon/build-32
86   ../configure --enable-32bit
87   make
88   popd
89
90 For complex cross-architecture environments, you may want to build
91 other versions of the daemon and NFS server as well.  See the note
92 below.
93
94 Finally run the tests:
95
96   make check
97
98 If everything works, you can install the library and tools by running
99 these commands as root:
100
101   make install
102
103   pushd daemon/build
104   make install
105   popd
106   # Repeat for each daemon/build* directory you made above.
107
108
109 Note on 64 bit and non-x86 architectures
110 ----------------------------------------------------------------------
111
112 The library runs the Linux kernel code in QEMU.  It also runs a small
113 control daemon inside QEMU.  It might also run an NFS server.  It
114 might also run programs from the guest's disk/environment (if asked to).
115
116 This leaves open the question of which QEMU do we run, eg. qemu (the
117 i386 emulator) or qemu-system-x86_64 or qemu-system-ppc64 or ...?
118
119 Several factors influence the choice:
120
121 (a) The host architecture.
122
123 (b) The guest architecture.
124
125 (c) What kernel(s) we find at runtime.
126
127 (d) What compiler(s) we find at configure time.
128
129 (e) In general, we would prefer to run a 32 bit kernel over a 64 bit
130 kernel, because that reduces the amount of system memory we have to
131 give to qemu significantly, and makes libguestfs smaller, faster and
132 use less memory.
133
134 For example, if (a) the host is x86-64, then it might be running a
135 mixture of (b) i386 and x86-64 guests.  Disk formats are stable, even
136 across 32 and 64 bit and endianness changes, so it doesn't really
137 matter what kernel we use if we just want to access files in the
138 guest.  In the absence of any other factors, we would choose an i386
139 kernel and run it in plain 'qemu', because that would use the least
140 amount of memory.
141
142 But if we wanted to enable the feature of running a guest program in
143 an x86-64 guest, then we have to run an x86-64 kernel and
144 qemu-system-x86_64 (an i386 kernel can't run 64 bit programs).  The
145 same applies if we didn't find a 32 bit kernel at runtime, or if we
146 couldn't run "gcc -m32" at configure time (because we can't compile
147 the daemon).
148
149 SO: to enable maximum features on 64 bit architectures:
150
151 (1) Ensure that "gcc -m32" can create usable binaries.
152
153 (2) Provide 32 and 64 bit kernels binaries at runtime.
154
155 If you have a really weird environment, eg. you want to run programs
156 inside PPC64 guests on your MIPS machine, then:
157
158 (3) Provide gcc cross-compiler and glibc for each architecture, and
159 cross-compile the daemon and NFS server:
160
161   mkdir daemon/build-ppc64
162   pushd daemon/build-ppc64
163   ../configure --host=ppc64-gnu-linux
164   make
165   popd
166
167
168 Copyright and license information
169 ----------------------------------------------------------------------
170
171 Copyright (C) 2009 Red Hat Inc.
172
173 The library is distributed under the LGPLv2+.  The programs are
174 distributed under the GPLv2+.  Please see the files COPYING and
175 COPYING.LIB for full license information.