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