todo docs: Discuss shrinking filesystems and specifying sizes in guestfish.
[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 BufferIn
21 --------
22
23 BufferIn should turn into <char *, int> and simple strings in other
24 languages that can handle 8 bit clean strings.
25
26 Limit on transfers would still be 2MB for these types.
27  - then implement write-file properly
28
29 febootstrap / debootstrap inside appliance
30 ------------------------------------------
31
32 This was originally proposed as a way to install new operating systems
33 in the appliance.  However no one has come up with a workable
34 solution.
35
36 Haskell bindings
37 ----------------
38
39 Complete the Haskell bindings (see discussion on haskell-cafe).
40
41 Complete bind tests
42 -------------------
43
44 Complete the bind tests - must test the return values and error cases.
45
46 virt-inspector - make libvirt XML
47 ---------------------------------
48
49 It should be possible to generate libvirt XML from virt-inspector
50 data, at least partially.  This would be just another output type so:
51
52  virt-inspector --libvirt guest.img
53
54 Note that recent versions of libvirt/virt-install allow guests to be
55 imported, so this is not so useful any more.
56
57 "Standalone/local mode"
58 -----------------------
59
60 Instead of running guestfsd (the daemon) inside qemu, there should be
61 an option to just run guestfsd directly.
62
63 The architecture in this mode would look like:
64
65      +------------------+
66      | main program     |
67      |------------------|
68      | libguestfs       |
69      +--------^---------+
70           |   | reply
71       cmd |   |
72      +----v-------------+
73      | guestfsd         |
74      +------------------+
75
76 Notes:
77
78 (1) This only makes sense if we are running as root.
79
80 (2) There is no console / kernel messages in this configuration, but
81 we might consider capturing stderr from the daemon.
82
83 (3) guestfs_config and guestfs_add_drive become no-ops.
84
85 Obviously in this configuration, commands are run directly on the
86 local machine's disks.  You could just run the commands themselves
87 directly, but libguestfs provides a convenient API and language
88 bindings.  Also deals with tricky stuff like parsing the output of the
89 LVM commands.  Also we get to leverage other code such as
90 virt-inspector.
91
92 This is mainly useful from live CDs, ie. virt-p2v.
93
94 Should we bother having the daemon at all and just link the guestfsd
95 code directly into libguestfs?
96
97 Supermin appliance to febootstrap
98 ---------------------------------
99
100 Supermin appliance functionality should be moved into febootstrap.
101
102 Ideas for extra commands
103 ------------------------
104
105   General glibc / core programs:
106     chgrp
107     more mk*temp calls
108
109   ext2 properties:
110     chattr
111     lsattr
112     badblocks
113     blkid
114     debugfs
115     dumpe2fs
116     e2image
117     e2undo
118     filefrag
119     findfs
120     logsave
121     mklost+found
122
123   SELinux:
124     chcat
125     restorecon
126     ch???
127
128   Oddball:
129     pivot_root
130     fts(3) / ftw(3)
131
132 Other initrd-* commands
133 -----------------------
134
135 Such as:
136
137 initrd-extract
138 initrd-replace
139
140 Simple editing of configuration files
141 -------------------------------------
142
143 Some easy non-Augeas methods to edit configuration files.
144 I'm thinking:
145
146   replace /etc/file key value
147
148 which would look in /etc/file for any instances of
149
150   key=...
151   key ...
152   key:...
153
154 and replace them with
155
156   key=value
157   key value
158   key:value
159
160 That would solve about 50% of reconfiguration needs, and for the
161 rest you'd use Augeas, 'download'+'upload' or 'edit'.
162
163 RWMJ: I had a go at implementing this, but it's quite error-prone to
164 do this sort of editing inside the C-based daemon code.  It's far
165 better to do it with Augeas, or else to use an external language like
166 Perl.
167
168 Quick Perl scripts
169 ------------------
170
171 Currently we can't do Perl "one-liners".  ie. The current syntax for
172 any short Perl one-liner would be:
173
174   perl -MSys::Guestfs -e '$g = Sys::Guestfs->new(); $g->add_drive ("foo"); $g->launch; $g->mount ("/dev/sda1", "/"); ....'
175
176 You can see we're well beyond a single line just getting to the point
177 of adding drives and mounting.
178
179 First suggestion:
180
181  $h = create ($filename, \"/dev/sda1\" => \"/\");
182
183  $h = create ([$file1, $file2], \"/dev/sda1\" => \"/\");
184
185 To mount read-only, add C<ro =E<gt> 1> like this:
186
187  $h = create ($filename, \"/dev/sda1\" => \"/\", ro => 1);
188
189 which is equivalent to the following sequence of calls:
190
191  $h = Sys::Guestfs->new ();
192  $h->set_autosync (1);
193  $h->add_drive_ro ($filename);
194  $h->launch ();
195  $h->mount_ro (\"/dev/sda1\", \"/\");
196
197 Command-line form would be:
198
199  perl -MSys::Guestfs=:all -e '$_=create("guest.img", "/dev/sda1" => "/"); $_->cat ("/etc/fstab");'
200
201 That's not brief enough for one-liners, so we could have an extra
202 autogenerated module which creates a Sys::Guestfs handle singleton
203 (the handle is an implicit global variable as in guestfish), eg:
204
205  perl -MSys::Guestfs::One -e 'inspect("guest.img"); cat ("/etc/fstab");'
206
207 How would editing files work?
208
209 ntfsclone
210 ---------
211
212 Useful imaging tool:
213 http://man.linux-ntfs.org/ntfsclone.8.html
214
215 virt-rescue pty
216 ---------------
217
218 See:
219 http://search.cpan.org/~rgiersig/IO-Tty-1.08/Pty.pm
220 http://www.perlmonks.org/index.pl?node_id=582185
221
222 Note that pty requires cooperation inside the C code too (there are
223 two sides to a pty, and one has to be handled after the fork).
224
225 Windows-based daemon/appliance
226 ------------------------------
227
228 See discussion on list:
229 https://www.redhat.com/archives/libguestfs/2009-November/msg00165.html
230
231 qemu locking
232 ------------
233
234 Add -drive file=...,lock=exclusive and -drive file=...,lock=shared
235
236 Change libguestfs and libvirt to do the right thing, so that multiple
237 instances of qemu cannot stomp on each other.
238
239 virt-disk-explore
240 -----------------
241
242 For multi-level disk images such as live CDs:
243 http://rwmj.wordpress.com/2009/07/15/unpack-the-russian-doll-of-a-f11-live-cd/
244
245 It's possible with libguestfs to recursively look for anything that
246 might be a filesystem, mount-{,loop} it and look in those, revealing
247 anything in a disk image.
248
249 However this won't work easily for VM disk images in the disk image.
250 One would have to download those to the host and launch another
251 libguestfs instance.
252
253 List, mount filesystems by UUID and label
254 -----------------------------------------
255
256 [See related:
257 http://www.redhat.com/archives/libguestfs/2009-August/msg00031.html]
258
259 List filesystems by UUID or label.
260
261 Mount filesystems by UUID or label.  (I'm not really sure if we can do
262 this at the moment but we ought to be able to do it, and perhaps make
263 it easier by having a direct command).
264
265 Map filesystems to disk blocks
266 ------------------------------
267
268 Map files/filesystems/(any other object) to the actual disk
269 blocks they occupy.
270
271 And vice versa.
272
273 Is it even possible?
274
275 Integration with host intrusion systems
276 ---------------------------------------
277
278 Perfect way to monitor VMs from outside the VM.  Look for file
279 hashes, log events, login/logout etc.
280
281 http://www.ossec.net/
282 http://la-samhna.de/samhain/
283 http://sourceforge.net/projects/aide/
284 http://osiris.shmoo.com/
285 http://sourceforge.net/projects/tripwire/
286
287 Resizing, shrinking, specifying sizes in guestfish
288 --------------------------------------------------
289
290 Owing to an oversight we don't really supporting shrinking
291 filesystems.  See:
292
293 https://bugzilla.redhat.com/show_bug.cgi?id=585221
294 https://bugzilla.redhat.com/show_bug.cgi?id=585222
295 https://bugzilla.redhat.com/show_bug.cgi?id=585223
296
297 But a related problem is how to specify sizes to guestfish, ie. "100M"
298 or "1G".  Currently the specific alloc and sparse functions contain
299 code to parse these size strings, but that cannot be used anywhere
300 else that would take a byte count.  This is awkward because some
301 commands take units of megabytes (lvresize, sfdiskM) or sectors
302 (part-add), with no unifying theme.