Version 1.7.21.
[libguestfs.git] / TODO
1 TODO list for libguestfs
2 ======================================================================
3
4 This list contains random ideas and musings on features we could add
5 to libguestfs in future.
6
7    - RWMJ
8
9 FUSE API
10 --------
11
12 The API needs more test coverage, particularly lesser-used system
13 calls.
14
15 The big unresolved issue is UID/GID mapping between guest filesystem
16 IDs and the host.  It's not easy to automate this because you need
17 extra details about the guest itself in order to get to its
18 UID->username map (eg. /etc/passwd from the guest).
19
20 Haskell bindings
21 ----------------
22
23 Complete the Haskell bindings (see discussion on haskell-cafe).
24
25 PHP bindings
26 ------------
27
28 Add bindtests to PHP bindings.
29
30 Complete bind tests
31 -------------------
32
33 Complete the bind tests - must test the return values and error cases.
34
35 virt-inspector - make libvirt XML
36 ---------------------------------
37
38 It should be possible to generate libvirt XML from virt-inspector
39 data, at least partially.  This would be just another output type so:
40
41  virt-inspector --libvirt guest.img
42
43 Note that recent versions of libvirt/virt-install allow guests to be
44 imported, so this is not so useful any more.
45
46 "Standalone/local mode"
47 -----------------------
48
49 Instead of running guestfsd (the daemon) inside qemu, there should be
50 an option to just run guestfsd directly.
51
52 The architecture in this mode would look like:
53
54      +------------------+
55      | main program     |
56      |------------------|
57      | libguestfs       |
58      +--------^---------+
59           |   | reply
60       cmd |   |
61      +----v-------------+
62      | guestfsd         |
63      +------------------+
64
65 Notes:
66
67 (1) This only makes sense if we are running as root.
68
69 (2) There is no console / kernel messages in this configuration, but
70 we might consider capturing stderr from the daemon.
71
72 (3) guestfs_config and guestfs_add_drive become no-ops.
73
74 Obviously in this configuration, commands are run directly on the
75 local machine's disks.  You could just run the commands themselves
76 directly, but libguestfs provides a convenient API and language
77 bindings.  Also deals with tricky stuff like parsing the output of the
78 LVM commands.  Also we get to leverage other code such as
79 virt-inspector.
80
81 This is mainly useful from live CDs, ie. virt-p2v.
82
83 Should we bother having the daemon at all and just link the guestfsd
84 code directly into libguestfs?
85
86 Ideas for extra commands
87 ------------------------
88
89   General glibc / core programs:
90     chgrp
91     more mk*temp calls
92
93   ext2 properties:
94     chattr
95     lsattr
96     badblocks
97     blkid
98     debugfs
99     dumpe2fs
100     e2image
101     e2undo
102     filefrag
103     findfs
104     logsave
105     mklost+found
106     ext2undelete
107
108   SELinux:
109     chcat
110     restorecon
111     ch???
112
113   Oddball:
114     pivot_root
115     fts(3) / ftw(3)
116
117 Other initrd-* commands
118 -----------------------
119
120 Such as:
121
122 initrd-extract
123 initrd-replace
124
125 Simple editing of configuration files
126 -------------------------------------
127
128 Some easy non-Augeas methods to edit configuration files.
129 I'm thinking:
130
131   replace /etc/file key value
132
133 which would look in /etc/file for any instances of
134
135   key=...
136   key ...
137   key:...
138
139 and replace them with
140
141   key=value
142   key value
143   key:value
144
145 That would solve about 50% of reconfiguration needs, and for the
146 rest you'd use Augeas, 'download'+'upload' or 'edit'.
147
148 RWMJ: I had a go at implementing this, but it's quite error-prone to
149 do this sort of editing inside the C-based daemon code.  It's far
150 better to do it with Augeas, or else to use an external language like
151 Perl.
152
153 Quick Perl scripts
154 ------------------
155
156 Currently we can't do Perl "one-liners".  ie. The current syntax for
157 any short Perl one-liner would be:
158
159   perl -MSys::Guestfs -e '$g = Sys::Guestfs->new(); $g->add_drive ("foo"); $g->launch; $g->mount ("/dev/sda1", "/"); ....'
160
161 You can see we're well beyond a single line just getting to the point
162 of adding drives and mounting.
163
164 First suggestion:
165
166  $h = create ($filename, \"/dev/sda1\" => \"/\");
167
168  $h = create ([$file1, $file2], \"/dev/sda1\" => \"/\");
169
170 To mount read-only, add C<ro =E<gt> 1> like this:
171
172  $h = create ($filename, \"/dev/sda1\" => \"/\", ro => 1);
173
174 which is equivalent to the following sequence of calls:
175
176  $h = Sys::Guestfs->new ();
177  $h->add_drive_ro ($filename);
178  $h->launch ();
179  $h->mount_ro (\"/dev/sda1\", \"/\");
180
181 Command-line form would be:
182
183  perl -MSys::Guestfs=:all -e '$_=create("guest.img", "/dev/sda1" => "/"); $_->cat ("/etc/fstab");'
184
185 That's not brief enough for one-liners, so we could have an extra
186 autogenerated module which creates a Sys::Guestfs handle singleton
187 (the handle is an implicit global variable as in guestfish), eg:
188
189  perl -MSys::Guestfs::One -e 'inspect("guest.img"); cat ("/etc/fstab");'
190
191 How would editing files work?
192
193 ntfsclone
194 ---------
195
196 Useful imaging tool:
197 http://man.linux-ntfs.org/ntfsclone.8.html
198
199 virt-rescue pty
200 ---------------
201
202 See:
203 http://search.cpan.org/~rgiersig/IO-Tty-1.08/Pty.pm
204 http://www.perlmonks.org/index.pl?node_id=582185
205
206 Note that pty requires cooperation inside the C code too (there are
207 two sides to a pty, and one has to be handled after the fork).
208
209 [I tried to implement this in the new C virt-rescue, but it doesn't
210 work.  qemu is implementing its own ptys, and they are broken.  Need
211 to fix qemu.]
212
213 Windows-based daemon/appliance
214 ------------------------------
215
216 See discussion on list:
217 https://www.redhat.com/archives/libguestfs/2009-November/msg00165.html
218
219 qemu locking
220 ------------
221
222 Add -drive file=...,lock=exclusive and -drive file=...,lock=shared
223
224 Change libguestfs and libvirt to do the right thing, so that multiple
225 instances of qemu cannot stomp on each other.
226
227 virt-disk-explore
228 -----------------
229
230 For multi-level disk images such as live CDs:
231 http://rwmj.wordpress.com/2009/07/15/unpack-the-russian-doll-of-a-f11-live-cd/
232
233 It's possible with libguestfs to recursively look for anything that
234 might be a filesystem, mount-{,loop} it and look in those, revealing
235 anything in a disk image.
236
237 However this won't work easily for VM disk images in the disk image.
238 One would have to download those to the host and launch another
239 libguestfs instance.
240
241 [Not sure this is such a good idea.  See also live CD inspection idea below.]
242
243 Map filesystems to disk blocks
244 ------------------------------
245
246 Map files/filesystems/(any other object) to the actual disk
247 blocks they occupy.
248
249 And vice versa.
250
251 Is it even possible?
252
253 See also contribs/visualize-alignment/
254
255 Integration with host intrusion systems
256 ---------------------------------------
257
258 Perfect way to monitor VMs from outside the VM.  Look for file
259 hashes, log events, login/logout etc.
260
261 http://www.ossec.net/
262 http://la-samhna.de/samhain/
263 http://sourceforge.net/projects/aide/
264 http://osiris.shmoo.com/
265 http://sourceforge.net/projects/tripwire/
266
267 Fix 'file'
268 ----------
269
270 https://www.redhat.com/archives/libguestfs/2010-June/msg00053.html
271 https://www.redhat.com/archives/libguestfs/2010-June/msg00079.html
272
273 Freeze/thaw filesystems
274 -----------------------
275
276 Access to these ioctls:
277 http://git.kernel.org/linus/fcccf502540e3d7
278
279 Tips for new users in guestfish
280 -------------------------------
281
282 $ guestfish
283 Tip: You need to 'add disk.img' or 'alloc disk.img nn' to make a new image.
284 Type 'notips' to disable tips permanently.
285 ><fs> add mydisk
286 Tip: You need to type 'run' before you can see into the disk image.
287 ><fs> run
288 Tip: Use 'list-filesystems' to see what filesystems are available.
289 ><fs> list-filesystems
290 /dev/vda1
291 Tip: Use 'mount fs /' to mount a filesystem.
292 ><fs> mount /dev/vda1 /
293 Tip: Use 'll /' to view the filesystem or ...
294 ><fs> ll /
295
296 Could we make guestfish interactive if commands are used without params?
297 ------------------------------------------------------------------------
298
299 ><fs> sparse
300 [[Prints man page]]
301 Image name? disk.img
302 Size of image? 10M
303
304 Common problems
305 ---------------
306
307 How can we solve these common user problems?
308
309 [space for common problems here]
310
311 Better support for encrypted devices
312 ------------------------------------
313
314 Currently LUKS support only works if the device contains volume
315 groups.  If it contains, eg., partitions, you cannot access them.
316 We would like to add:
317
318   - Direct access to the /dev/mapper device (eg. if it contains
319     anything apart from VGs).
320
321 Display image as PS
322 -------------------
323
324 Display the structure of an image file as a PS.
325
326 Greater use of blkid / libblkid
327 -------------------------------
328
329 guestfs_zero should use wipefs.  See wipefs(8).
330
331 There are various useful functions in libblkid for listing partitions,
332 devices etc which we are essentially duplicating in the daemon.  It
333 would make more sense to just use libblkid for this.
334
335 There are some places where we call out to the 'blkid' program.  This
336 might be replaced by direct use of the library (if this is easier).
337
338 Visualization
339 -------------
340
341 Eric Sandeen pointed out the blktrace tool which is a better way of
342 capturing traces than using patched qemu (see
343 contrib/visualize-alignment).  We would still use the same
344 visualization tools in conjunction with blktrace traces.
345
346 guestfish parsing
347 -----------------
348
349 At the moment guestfish uses an ad hoc parser which has many
350 shortcomings.  We should change to using a lex/yacc-based scanner and
351 parser (there are better parsers out there, but yacc is sufficient and
352 very widely available).
353
354 The scanner must deal with the case of parsing a whole command string,
355 eg. for a command that the user types in:
356
357  ><fs> add-drive-opts "/tmp/foo" readonly:true
358
359 and also with parsing single words from the command line:
360
361  guestfish add-drive-opts /tmp/foo readonly:true
362
363 Note the quotes are for scanning and don't indicate types.
364
365 We should also allow variables and expressions as part of this new
366 parsing code, eg:
367
368  set roots inspect-os
369  set product inspect-get-product-name %{roots[0]}
370
371 % is better than $ because of shell escaping and confusion with shell
372 variables.
373
374 live CD inspection
375 ------------------
376
377 guestfish -i livecd.iso
378
379 Could this be done through the core API and existing calls?