inspector: Fix documentation of -x option in usage.
[libguestfs.git] / HACKING
1 PLEASE LOOK AT THE TOP OF EACH FILE BEFORE EDITING TO SEE WHETHER IT
2 IS AUTOMATICALLY GENERATED OR NOT.
3
4 Adding a new action
5 ----------------------------------------------------------------------
6
7 All action functions are generated automatically, so there are only
8 two files you need to edit:
9
10 (1) generator/generator_actions.ml: Add your new action, parameters,
11 description, etc. to the big list at the top of this file.
12
13 (2) Edit/create a C file in daemon/ subdirectory which implements your
14 'do_action' function.  Take a look at one of the numerous examples
15 there.
16
17 Formatting
18 ----------------------------------------------------------------------
19
20 Try to use GNU / Emacs default formatting, following the convention
21 used elsewhere in the source.
22
23 Please make sure that the code compiles without warnings.
24
25 Please test any changes.
26
27 Useful targets:
28   make syntax-check    Checks the syntax of the C code.
29   make check           Runs the test suite.
30
31 Enable warnings, and fix any you find:
32   ./configure --enable-gcc-warnings
33
34 Code indentation
35 ----------------------------------------------------------------------
36 Our C source code generally adheres to some basic code-formatting
37 conventions.  The existing code base is not totally consistent on this
38 front, but we do prefer that contributed code be formatted similarly.
39 In short, use spaces-not-TABs for indentation, use 2 spaces for each
40 indentation level, and other than that, follow the K&R style.
41
42 If you use Emacs, add the following to one of one of your start-up files
43 (e.g., ~/.emacs), to help ensure that you get indentation right:
44
45   ;;; In libguestfs, indent with spaces everywhere (not TABs).
46   ;;; Exceptions: Makefile and ChangeLog modes.
47   (add-hook 'find-file-hook
48       '(lambda () (if (and buffer-file-name
49                            (string-match "/libguestfs\\>" (buffer-file-name))
50                            (not (string-equal mode-name "Change Log"))
51                            (not (string-equal mode-name "Makefile")))
52                       (setq indent-tabs-mode nil))))
53
54   ;;; When editing C sources in libguestfs, use this style.
55   (defun libguestfs-c-mode ()
56     "C mode with adjusted defaults for use with libguestfs."
57     (interactive)
58     (c-set-style "K&R")
59     (setq c-indent-level 2)
60     (setq c-basic-offset 2))
61   (add-hook 'c-mode-hook
62             '(lambda () (if (string-match "/libguestfs\\>" (buffer-file-name))
63                             (libguestfs-c-mode))))
64
65 Directories
66 ----------------------------------------------------------------------
67
68 appliance/
69         The qemu appliance, build scripts and so on.
70
71 capitests/
72         Automated tests of the C API.
73
74 cat/
75         The 'virt-cat' command and documentation.
76
77 contrib/
78         Outside contributions, experimental parts.
79
80 csharp/
81         Experimental C# bindings.
82
83 daemon/
84         The daemon that runs inside the guest and carries out actions.
85
86 examples/
87         The examples.
88
89 fish/
90         Guestfish (the command-line program / shell)
91
92 fuse/
93         FUSE (userspace filesystem) built on top of libguestfs.
94
95 generator/
96         The crucially important generator, used to automatically
97         generate large amounts of boilerplate C code for things like
98         RPC and bindings.
99
100 haskell/
101         Haskell bindings.
102
103 hivex/ [removed in 1.0.85]
104        This used to contain the hivex library for reading and
105        writing Windows Registry binary hive files.  This is now
106        available as a separate upstream project.
107
108 images/
109         Some guest images to test against.  These are gzipped to save
110         space.  You have to unzip them before use.
111
112         Also contains some files used by the test suite.
113
114 inspector/
115         Virtual machine image inspector (virt-inspector).
116
117 java/
118         Java bindings.
119
120 m4/
121         M4 macros used by autoconf.
122
123 ocaml/
124         OCaml bindings.
125
126 php/
127         PHP bindings.
128
129 po/
130         Translations of simple gettext strings.  For translations of
131         longer documents, see po-docs/.
132
133 po-docs/
134         The build infrastructure and PO files for translations of
135         manpages and POD files.  Eventually this will be combined
136         with the po/ directory, but that is rather complicated.
137
138 perl/
139         Perl bindings.
140
141 python/
142         Python bindings.
143
144 regressions/
145         Regression tests.
146
147 ruby/
148         Ruby bindings.
149
150 tools/
151         Command line tools like virt-df, virt-edit and more.
152
153 src/
154         Source code to the C library.
155
156 test-tool/
157         Interactive qemu/kernel test tool.
158
159 Debugging
160 ----------------------------------------------------------------------
161
162 It's a good idea to use guestfish to try out new commands.
163
164 Debugging the daemon is a problem because it runs inside a minimal
165 qemu environment.  However you can print messages from the daemon, and
166 they will show up if you use 'guestfish -v'.
167
168 Patches
169 ----------------------------------------------------------------------
170
171 Submit patches to the mailing list:
172 http://www.redhat.com/mailman/listinfo/libguestfs
173 and CC to rjones@redhat.com
174
175 I18N
176 ----------------------------------------------------------------------
177
178 We support i18n (gettext anyhow) in the library.
179
180 However many messages come from the daemon, and we don't translate
181 those at the moment.  One reason is that the appliance generally has
182 all locale files removed from it, because they take up a lot of space.
183 So we'd have to readd some of those, as well as copying our PO files
184 into the appliance.
185
186 Debugging messages are never translated, since they are intended for
187 the programmers.
188
189 Extended printf
190 ----------------------------------------------------------------------
191
192 In the daemon code we have created custom printf formatters %Q and %R,
193 which are used to do shell quoting.
194
195 %Q => Simple shell quoted string.  Any spaces or other shell characters
196       are escaped for you.
197
198 %R => Same as %Q except the string is treated as a path which is prefixed
199       by the sysroot.
200
201 eg.
202
203 asprintf (&cmd, "cat %R", path);
204 ==> "cat /sysroot/some\ path\ with\ spaces"
205
206 Note: Do NOT use these when you are passing parameters to the
207 command{,r,v,rv}() functions.  These parameters do NOT need to be
208 quoted because they are not passed via the shell (instead, straight to
209 exec).  You probably want to use the sysroot_path() function however.