New API: Implement pwrite system call (partial fix for RHBZ#592883).
[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 Complete bind tests
33 -------------------
34
35 Complete the bind tests - must test the return values and error cases.
36
37 virt-inspector - make libvirt XML
38 ---------------------------------
39
40 It should be possible to generate libvirt XML from virt-inspector
41 data, at least partially.  This would be just another output type so:
42
43  virt-inspector --libvirt guest.img
44
45 Note that recent versions of libvirt/virt-install allow guests to be
46 imported, so this is not so useful any more.
47
48 "Standalone/local mode"
49 -----------------------
50
51 Instead of running guestfsd (the daemon) inside qemu, there should be
52 an option to just run guestfsd directly.
53
54 The architecture in this mode would look like:
55
56      +------------------+
57      | main program     |
58      |------------------|
59      | libguestfs       |
60      +--------^---------+
61           |   | reply
62       cmd |   |
63      +----v-------------+
64      | guestfsd         |
65      +------------------+
66
67 Notes:
68
69 (1) This only makes sense if we are running as root.
70
71 (2) There is no console / kernel messages in this configuration, but
72 we might consider capturing stderr from the daemon.
73
74 (3) guestfs_config and guestfs_add_drive become no-ops.
75
76 Obviously in this configuration, commands are run directly on the
77 local machine's disks.  You could just run the commands themselves
78 directly, but libguestfs provides a convenient API and language
79 bindings.  Also deals with tricky stuff like parsing the output of the
80 LVM commands.  Also we get to leverage other code such as
81 virt-inspector.
82
83 This is mainly useful from live CDs, ie. virt-p2v.
84
85 Should we bother having the daemon at all and just link the guestfsd
86 code directly into libguestfs?
87
88 Supermin appliance to febootstrap
89 ---------------------------------
90
91 Supermin appliance functionality should be moved into febootstrap.
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
114   SELinux:
115     chcat
116     restorecon
117     ch???
118
119   Oddball:
120     pivot_root
121     fts(3) / ftw(3)
122
123 Other initrd-* commands
124 -----------------------
125
126 Such as:
127
128 initrd-extract
129 initrd-replace
130
131 Simple editing of configuration files
132 -------------------------------------
133
134 Some easy non-Augeas methods to edit configuration files.
135 I'm thinking:
136
137   replace /etc/file key value
138
139 which would look in /etc/file for any instances of
140
141   key=...
142   key ...
143   key:...
144
145 and replace them with
146
147   key=value
148   key value
149   key:value
150
151 That would solve about 50% of reconfiguration needs, and for the
152 rest you'd use Augeas, 'download'+'upload' or 'edit'.
153
154 RWMJ: I had a go at implementing this, but it's quite error-prone to
155 do this sort of editing inside the C-based daemon code.  It's far
156 better to do it with Augeas, or else to use an external language like
157 Perl.
158
159 Quick Perl scripts
160 ------------------
161
162 Currently we can't do Perl "one-liners".  ie. The current syntax for
163 any short Perl one-liner would be:
164
165   perl -MSys::Guestfs -e '$g = Sys::Guestfs->new(); $g->add_drive ("foo"); $g->launch; $g->mount ("/dev/sda1", "/"); ....'
166
167 You can see we're well beyond a single line just getting to the point
168 of adding drives and mounting.
169
170 First suggestion:
171
172  $h = create ($filename, \"/dev/sda1\" => \"/\");
173
174  $h = create ([$file1, $file2], \"/dev/sda1\" => \"/\");
175
176 To mount read-only, add C<ro =E<gt> 1> like this:
177
178  $h = create ($filename, \"/dev/sda1\" => \"/\", ro => 1);
179
180 which is equivalent to the following sequence of calls:
181
182  $h = Sys::Guestfs->new ();
183  $h->set_autosync (1);
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 Resizing, shrinking, specifying sizes in guestfish
279 --------------------------------------------------
280
281 Owing to an oversight we don't really supporting shrinking
282 filesystems.  See:
283
284 https://bugzilla.redhat.com/show_bug.cgi?id=585221
285 https://bugzilla.redhat.com/show_bug.cgi?id=585222
286 https://bugzilla.redhat.com/show_bug.cgi?id=585223
287
288 But a related problem is how to specify sizes to guestfish, ie. "100M"
289 or "1G".  Currently the specific alloc and sparse functions contain
290 code to parse these size strings, but that cannot be used anywhere
291 else that would take a byte count.  This is awkward because some
292 commands take units of megabytes (lvresize, sfdiskM) or sectors
293 (part-add), with no unifying theme.