1 # SOME DESCRIPTIVE TITLE
2 # Copyright (C) YEAR Red Hat Inc.
3 # This file is distributed under the same license as the libguestfs package.
4 # FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
9 "Project-Id-Version: libguestfs 1.7.17\n"
10 "Report-Msgid-Bugs-To: libguestfs@redhat.com\n"
11 "POT-Creation-Date: 2010-11-30 15:00+0000\n"
12 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
13 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
14 "Language-Team: LANGUAGE <LL@li.org>\n"
16 "Content-Type: text/plain; charset=utf-8\n"
17 "Content-Transfer-Encoding: ENCODING"
20 #: ../src/guestfs.pod:1 ../fish/guestfish.pod:1 ../test-tool/libguestfs-test-tool.pod:1 ../fuse/guestmount.pod:1 ../tools/virt-edit.pl:30 ../tools/virt-win-reg.pl:33 ../tools/virt-resize.pl:38 ../tools/virt-list-filesystems.pl:28 ../tools/virt-tar.pl:29 ../tools/virt-make-fs.pl:33 ../tools/virt-list-partitions.pl:28
25 #: ../src/guestfs.pod:3 ../fish/guestfish.pod:3 ../test-tool/libguestfs-test-tool.pod:3 ../fuse/guestmount.pod:3 ../tools/virt-edit.pl:32 ../tools/virt-win-reg.pl:35 ../tools/virt-resize.pl:40 ../tools/virt-list-filesystems.pl:30 ../tools/virt-tar.pl:31 ../tools/virt-make-fs.pl:35 ../tools/virt-list-partitions.pl:30
30 #: ../src/guestfs.pod:5
31 msgid "guestfs - Library for accessing and modifying virtual machine images"
35 #: ../src/guestfs.pod:7 ../fish/guestfish.pod:7 ../test-tool/libguestfs-test-tool.pod:7 ../fuse/guestmount.pod:7 ../tools/virt-edit.pl:36 ../tools/virt-win-reg.pl:39 ../tools/virt-resize.pl:44 ../tools/virt-list-filesystems.pl:34 ../tools/virt-tar.pl:35 ../tools/virt-make-fs.pl:39 ../tools/virt-list-partitions.pl:34
40 #: ../src/guestfs.pod:9
43 " #include <guestfs.h>\n"
48 #: ../src/guestfs.pod:11
51 " guestfs_h *g = guestfs_create ();\n"
52 " guestfs_add_drive (g, \"guest.img\");\n"
53 " guestfs_launch (g);\n"
54 " guestfs_mount (g, \"/dev/sda1\", \"/\");\n"
55 " guestfs_touch (g, \"/hello\");\n"
56 " guestfs_umount (g, \"/\");\n"
57 " guestfs_sync (g);\n"
58 " guestfs_close (g);\n"
63 #: ../src/guestfs.pod:20
66 " cc prog.c -o prog -lguestfs\n"
68 " cc prog.c -o prog `pkg-config libguestfs --cflags --libs`\n"
73 #: ../src/guestfs.pod:24 ../fish/guestfish.pod:30 ../test-tool/libguestfs-test-tool.pod:11 ../fuse/guestmount.pod:20 ../tools/virt-edit.pl:50 ../tools/virt-win-reg.pl:63 ../tools/virt-resize.pl:50 ../tools/virt-list-filesystems.pl:40 ../tools/virt-tar.pl:72 ../tools/virt-make-fs.pl:47 ../tools/virt-list-partitions.pl:40
78 #: ../src/guestfs.pod:26
80 "Libguestfs is a library for accessing and modifying guest disk images. "
81 "Amongst the things this is good for: making batch configuration changes to "
82 "guests, getting disk used/free statistics (see also: virt-df), migrating "
83 "between virtualization systems (see also: virt-p2v), performing partial "
84 "backups, performing partial guest clones, cloning guests and changing "
85 "registry/UUID/hostname info, and much else besides."
89 #: ../src/guestfs.pod:34
91 "Libguestfs uses Linux kernel and qemu code, and can access any type of guest "
92 "filesystem that Linux and qemu can, including but not limited to: ext2/3/4, "
93 "btrfs, FAT and NTFS, LVM, many different disk partition schemes, qcow, "
98 #: ../src/guestfs.pod:39
100 "Libguestfs provides ways to enumerate guest storage (eg. partitions, LVs, "
101 "what filesystem is in each LV, etc.). It can also run commands in the "
102 "context of the guest. Also you can access filesystems over FUSE."
106 #: ../src/guestfs.pod:44
108 "Libguestfs is a library that can be linked with C and C++ management "
109 "programs (or management programs written in OCaml, Perl, Python, Ruby, Java, "
110 "PHP, Haskell or C#). You can also use it from shell scripts or the command "
115 #: ../src/guestfs.pod:49
117 "You don't need to be root to use libguestfs, although obviously you do need "
118 "enough permissions to access the disk images."
122 #: ../src/guestfs.pod:52
124 "Libguestfs is a large API because it can do many things. For a gentle "
125 "introduction, please read the L</API OVERVIEW> section next."
129 #: ../src/guestfs.pod:55
131 "There are also some example programs in the L<guestfs-examples(3)> manual "
136 #: ../src/guestfs.pod:58
141 #: ../src/guestfs.pod:60
143 "This section provides a gentler overview of the libguestfs API. We also try "
144 "to group API calls together, where that may not be obvious from reading "
145 "about the individual calls in the main section of this manual."
149 #: ../src/guestfs.pod:65
154 #: ../src/guestfs.pod:67
156 "Before you can use libguestfs calls, you have to create a handle. Then you "
157 "must add at least one disk image to the handle, followed by launching the "
158 "handle, then performing whatever operations you want, and finally closing "
159 "the handle. By convention we use the single letter C<g> for the name of the "
160 "handle variable, although of course you can use any name you want."
164 #: ../src/guestfs.pod:74
165 msgid "The general structure of all libguestfs-using programs looks like this:"
169 #: ../src/guestfs.pod:77
172 " guestfs_h *g = guestfs_create ();\n"
177 #: ../src/guestfs.pod:79
180 " /* Call guestfs_add_drive additional times if there are\n"
181 " * multiple disk images.\n"
183 " guestfs_add_drive (g, \"guest.img\");\n"
188 #: ../src/guestfs.pod:84
191 " /* Most manipulation calls won't work until you've launched\n"
192 " * the handle 'g'. You have to do this _after_ adding drives\n"
193 " * and _before_ other commands.\n"
195 " guestfs_launch (g);\n"
200 #: ../src/guestfs.pod:90
203 " /* Now you can examine what partitions, LVs etc are available.\n"
205 " char **partitions = guestfs_list_partitions (g);\n"
206 " char **logvols = guestfs_lvs (g);\n"
211 #: ../src/guestfs.pod:95
214 " /* To access a filesystem in the image, you must mount it.\n"
216 " guestfs_mount (g, \"/dev/sda1\", \"/\");\n"
221 #: ../src/guestfs.pod:99
224 " /* Now you can perform filesystem actions on the guest\n"
227 " guestfs_touch (g, \"/hello\");\n"
232 #: ../src/guestfs.pod:104
235 " /* You only need to call guestfs_sync if you have made\n"
236 " * changes to the guest image. (But if you've made changes\n"
237 " * then you *must* sync). See also: guestfs_umount and\n"
238 " * guestfs_umount_all calls.\n"
240 " guestfs_sync (g);\n"
245 #: ../src/guestfs.pod:111
248 " /* Close the handle 'g'. */\n"
249 " guestfs_close (g);\n"
254 #: ../src/guestfs.pod:114
256 "The code above doesn't include any error checking. In real code you should "
257 "check return values carefully for errors. In general all functions that "
258 "return integers return C<-1> on error, and all functions that return "
259 "pointers return C<NULL> on error. See section L</ERROR HANDLING> below for "
260 "how to handle errors, and consult the documentation for each function call "
261 "below to see precisely how they return error indications."
265 #: ../src/guestfs.pod:122
270 #: ../src/guestfs.pod:124
272 "The image filename (C<\"guest.img\"> in the example above) could be a disk "
273 "image from a virtual machine, a L<dd(1)> copy of a physical hard disk, an "
274 "actual block device, or simply an empty file of zeroes that you have created "
275 "through L<posix_fallocate(3)>. Libguestfs lets you do useful things to all "
280 #: ../src/guestfs.pod:130
282 "The call you should use in modern code for adding drives is "
283 "L</guestfs_add_drive_opts>. To add a disk image, allowing writes, and "
284 "specifying that the format is raw, do:"
288 #: ../src/guestfs.pod:134
291 " guestfs_add_drive_opts (g, filename,\n"
292 " GUESTFS_ADD_DRIVE_OPTS_FORMAT, \"raw\",\n"
298 #: ../src/guestfs.pod:138
299 msgid "You can add a disk read-only using:"
303 #: ../src/guestfs.pod:140
306 " guestfs_add_drive_opts (g, filename,\n"
307 " GUESTFS_ADD_DRIVE_OPTS_FORMAT, \"raw\",\n"
308 " GUESTFS_ADD_DRIVE_OPTS_READONLY, 1,\n"
314 #: ../src/guestfs.pod:145
316 "or by calling the older function L</guestfs_add_drive_ro>. In either case "
317 "libguestfs won't modify the file."
321 #: ../src/guestfs.pod:148
323 "Be extremely cautious if the disk image is in use, eg. if it is being used "
324 "by a virtual machine. Adding it read-write will almost certainly cause disk "
325 "corruption, but adding it read-only is safe."
329 #: ../src/guestfs.pod:152
331 "You must add at least one disk image, and you may add multiple disk images. "
332 "In the API, the disk images are usually referred to as C</dev/sda> (for the "
333 "first one you added), C</dev/sdb> (for the second one you added), etc."
337 #: ../src/guestfs.pod:157
339 "Once L</guestfs_launch> has been called you cannot add any more images. You "
340 "can call L</guestfs_list_devices> to get a list of the device names, in the "
341 "order that you added them. See also L</BLOCK DEVICE NAMING> below."
345 #: ../src/guestfs.pod:162
350 #: ../src/guestfs.pod:164
352 "Before you can read or write files, create directories and so on in a disk "
353 "image that contains filesystems, you have to mount those filesystems using "
354 "L</guestfs_mount>. If you already know that a disk image contains (for "
355 "example) one partition with a filesystem on that partition, then you can "
360 #: ../src/guestfs.pod:170
363 " guestfs_mount (g, \"/dev/sda1\", \"/\");\n"
368 #: ../src/guestfs.pod:172
370 "where C</dev/sda1> means literally the first partition (C<1>) of the first "
371 "disk image that we added (C</dev/sda>). If the disk contains Linux LVM2 "
372 "logical volumes you could refer to those instead (eg. C</dev/VG/LV>)."
376 #: ../src/guestfs.pod:176
378 "If you are given a disk image and you don't know what it contains then you "
379 "have to find out. Libguestfs can do that too: use "
380 "L</guestfs_list_partitions> and L</guestfs_lvs> to list possible partitions "
381 "and LVs, and either try mounting each to see what is mountable, or else "
382 "examine them with L</guestfs_vfs_type> or L</guestfs_file>. Libguestfs also "
383 "has a set of APIs for inspection of disk images (see L</INSPECTION> below). "
384 "But you might find it easier to look at higher level programs built on top "
385 "of libguestfs, in particular L<virt-inspector(1)>."
389 #: ../src/guestfs.pod:186
391 "To mount a disk image read-only, use L</guestfs_mount_ro>. There are "
392 "several other variations of the C<guestfs_mount_*> call."
396 #: ../src/guestfs.pod:189
397 msgid "FILESYSTEM ACCESS AND MODIFICATION"
401 #: ../src/guestfs.pod:191
403 "The majority of the libguestfs API consists of fairly low-level calls for "
404 "accessing and modifying the files, directories, symlinks etc on mounted "
405 "filesystems. There are over a hundred such calls which you can find listed "
406 "in detail below in this man page, and we don't even pretend to cover them "
407 "all in this overview."
411 #: ../src/guestfs.pod:197
413 "Specify filenames as full paths, starting with C<\"/\"> and including the "
418 #: ../src/guestfs.pod:200
420 "For example, if you mounted a filesystem at C<\"/\"> and you want to read "
421 "the file called C<\"etc/passwd\"> then you could do:"
425 #: ../src/guestfs.pod:203
428 " char *data = guestfs_cat (g, \"/etc/passwd\");\n"
433 #: ../src/guestfs.pod:205
435 "This would return C<data> as a newly allocated buffer containing the full "
436 "content of that file (with some conditions: see also L</DOWNLOADING> below), "
437 "or C<NULL> if there was an error."
441 #: ../src/guestfs.pod:209
443 "As another example, to create a top-level directory on that filesystem "
444 "called C<\"var\"> you would do:"
448 #: ../src/guestfs.pod:212
451 " guestfs_mkdir (g, \"/var\");\n"
456 #: ../src/guestfs.pod:214
457 msgid "To create a symlink you could do:"
461 #: ../src/guestfs.pod:216
464 " guestfs_ln_s (g, \"/etc/init.d/portmap\",\n"
465 " \"/etc/rc3.d/S30portmap\");\n"
470 #: ../src/guestfs.pod:219
472 "Libguestfs will reject attempts to use relative paths and there is no "
473 "concept of a current working directory."
477 #: ../src/guestfs.pod:222
479 "Libguestfs can return errors in many situations: for example if the "
480 "filesystem isn't writable, or if a file or directory that you requested "
481 "doesn't exist. If you are using the C API (documented here) you have to "
482 "check for those error conditions after each call. (Other language bindings "
483 "turn these errors into exceptions)."
487 #: ../src/guestfs.pod:228
489 "File writes are affected by the per-handle umask, set by calling "
490 "L</guestfs_umask> and defaulting to 022. See L</UMASK>."
494 #: ../src/guestfs.pod:231
499 #: ../src/guestfs.pod:233
501 "Libguestfs contains API calls to read, create and modify partition tables on "
506 #: ../src/guestfs.pod:236
508 "In the common case where you want to create a single partition covering the "
509 "whole disk, you should use the L</guestfs_part_disk> call:"
513 #: ../src/guestfs.pod:240
516 " const char *parttype = \"mbr\";\n"
517 " if (disk_is_larger_than_2TB)\n"
518 " parttype = \"gpt\";\n"
519 " guestfs_part_disk (g, \"/dev/sda\", parttype);\n"
524 #: ../src/guestfs.pod:245
526 "Obviously this effectively wipes anything that was on that disk image "
531 #: ../src/guestfs.pod:248
536 #: ../src/guestfs.pod:250
538 "Libguestfs provides access to a large part of the LVM2 API, such as "
539 "L</guestfs_lvcreate> and L</guestfs_vgremove>. It won't make much sense "
540 "unless you familiarize yourself with the concepts of physical volumes, "
541 "volume groups and logical volumes."
545 #: ../src/guestfs.pod:255
547 "This author strongly recommends reading the LVM HOWTO, online at "
548 "L<http://tldp.org/HOWTO/LVM-HOWTO/>."
552 #: ../src/guestfs.pod:258
557 #: ../src/guestfs.pod:260
559 "Use L</guestfs_cat> to download small, text only files. This call is "
560 "limited to files which are less than 2 MB and which cannot contain any ASCII "
561 "NUL (C<\\0>) characters. However it has a very simple to use API."
565 #: ../src/guestfs.pod:265
567 "L</guestfs_read_file> can be used to read files which contain arbitrary 8 "
568 "bit data, since it returns a (pointer, size) pair. However it is still "
569 "limited to \"small\" files, less than 2 MB."
573 #: ../src/guestfs.pod:269
575 "L</guestfs_download> can be used to download any file, with no limits on "
576 "content or size (even files larger than 4 GB)."
580 #: ../src/guestfs.pod:272
581 msgid "To download multiple files, see L</guestfs_tar_out> and L</guestfs_tgz_out>."
585 #: ../src/guestfs.pod:275
590 #: ../src/guestfs.pod:277
592 "It's often the case that you want to write a file or files to the disk "
597 #: ../src/guestfs.pod:280
599 "To write a small file with fixed content, use L</guestfs_write>. To create "
600 "a file of all zeroes, use L</guestfs_truncate_size> (sparse) or "
601 "L</guestfs_fallocate64> (with all disk blocks allocated). There are a "
602 "variety of other functions for creating test files, for example "
603 "L</guestfs_fill> and L</guestfs_fill_pattern>."
607 #: ../src/guestfs.pod:286
609 "To upload a single file, use L</guestfs_upload>. This call has no limits on "
610 "file content or size (even files larger than 4 GB)."
614 #: ../src/guestfs.pod:289
615 msgid "To upload multiple files, see L</guestfs_tar_in> and L</guestfs_tgz_in>."
619 #: ../src/guestfs.pod:291
621 "However the fastest way to upload I<large numbers of arbitrary files> is to "
622 "turn them into a squashfs or CD ISO (see L<mksquashfs(8)> and "
623 "L<mkisofs(8)>), then attach this using L</guestfs_add_drive_ro>. If you add "
624 "the drive in a predictable way (eg. adding it last after all other drives) "
625 "then you can get the device name from L</guestfs_list_devices> and mount it "
626 "directly using L</guestfs_mount_ro>. Note that squashfs images are "
627 "sometimes non-portable between kernel versions, and they don't support "
628 "labels or UUIDs. If you want to pre-build an image or you need to mount it "
629 "using a label or UUID, use an ISO image instead."
633 #: ../src/guestfs.pod:302
638 #: ../src/guestfs.pod:304
640 "There are various different commands for copying between files and devices "
641 "and in and out of the guest filesystem. These are summarised in the table "
646 #: ../src/guestfs.pod:310
647 msgid "B<file> to B<file>"
651 #: ../src/guestfs.pod:312
653 "Use L</guestfs_cp> to copy a single file, or L</guestfs_cp_a> to copy "
654 "directories recursively."
658 #: ../src/guestfs.pod:315
659 msgid "B<file or device> to B<file or device>"
663 #: ../src/guestfs.pod:317
665 "Use L</guestfs_dd> which efficiently uses L<dd(1)> to copy between files and "
666 "devices in the guest."
670 #: ../src/guestfs.pod:320
671 msgid "Example: duplicate the contents of an LV:"
675 #: ../src/guestfs.pod:322
678 " guestfs_dd (g, \"/dev/VG/Original\", \"/dev/VG/Copy\");\n"
683 #: ../src/guestfs.pod:324
685 "The destination (C</dev/VG/Copy>) must be at least as large as the source "
686 "(C</dev/VG/Original>). To copy less than the whole source device, use "
687 "L</guestfs_copy_size>."
691 #: ../src/guestfs.pod:328
692 msgid "B<file on the host> to B<file or device>"
696 #: ../src/guestfs.pod:330
697 msgid "Use L</guestfs_upload>. See L</UPLOADING> above."
701 #: ../src/guestfs.pod:332
702 msgid "B<file or device> to B<file on the host>"
706 #: ../src/guestfs.pod:334
707 msgid "Use L</guestfs_download>. See L</DOWNLOADING> above."
711 #: ../src/guestfs.pod:338
712 msgid "LISTING FILES"
716 #: ../src/guestfs.pod:340
718 "L</guestfs_ll> is just designed for humans to read (mainly when using the "
719 "L<guestfish(1)>-equivalent command C<ll>)."
723 #: ../src/guestfs.pod:343
725 "L</guestfs_ls> is a quick way to get a list of files in a directory from "
726 "programs, as a flat list of strings."
730 #: ../src/guestfs.pod:346
732 "L</guestfs_readdir> is a programmatic way to get a list of files in a "
733 "directory, plus additional information about each one. It is more "
734 "equivalent to using the L<readdir(3)> call on a local filesystem."
738 #: ../src/guestfs.pod:350
740 "L</guestfs_find> and L</guestfs_find0> can be used to recursively list "
745 #: ../src/guestfs.pod:353
746 msgid "RUNNING COMMANDS"
750 #: ../src/guestfs.pod:355
752 "Although libguestfs is primarily an API for manipulating files inside guest "
753 "images, we also provide some limited facilities for running commands inside "
758 #: ../src/guestfs.pod:359
759 msgid "There are many limitations to this:"
763 #: ../src/guestfs.pod:363 ../src/guestfs.pod:368 ../src/guestfs.pod:373 ../src/guestfs.pod:377 ../src/guestfs.pod:382 ../src/guestfs.pod:386 ../src/guestfs.pod:391 ../src/guestfs.pod:396 ../src/guestfs.pod:955 ../src/guestfs.pod:959 ../src/guestfs.pod:963 ../src/guestfs.pod:968 ../src/guestfs.pod:976 ../src/guestfs.pod:995 ../src/guestfs.pod:1003 ../src/guestfs.pod:1025 ../src/guestfs.pod:1029 ../src/guestfs.pod:1033 ../src/guestfs.pod:1037 ../src/guestfs.pod:1041 ../src/guestfs.pod:1045 ../src/guestfs.pod:1527 ../src/guestfs.pod:1532 ../src/guestfs.pod:1536 ../src/guestfs.pod:1646 ../src/guestfs.pod:1651 ../src/guestfs.pod:1655 ../src/guestfs.pod:1999 ../src/guestfs.pod:2005 ../src/guestfs.pod:2010 ../src/guestfs.pod:2016 ../src/guestfs.pod:2128 ../src/guestfs.pod:2132 ../src/guestfs.pod:2136 ../src/guestfs.pod:2140 ../src/guestfs-actions.pod:15 ../src/guestfs-actions.pod:22 ../src/guestfs-actions.pod:571 ../src/guestfs-actions.pod:579 ../src/guestfs-actions.pod:586 ../src/guestfs-actions.pod:593 ../src/guestfs-actions.pod:1589 ../src/guestfs-actions.pod:1593 ../src/guestfs-actions.pod:1597 ../src/guestfs-actions.pod:1601 ../src/guestfs-actions.pod:1609 ../src/guestfs-actions.pod:1613 ../src/guestfs-actions.pod:1617 ../src/guestfs-actions.pod:1627 ../src/guestfs-actions.pod:1631 ../src/guestfs-actions.pod:1635 ../src/guestfs-actions.pod:1773 ../src/guestfs-actions.pod:1777 ../src/guestfs-actions.pod:1782 ../src/guestfs-actions.pod:1787 ../src/guestfs-actions.pod:1848 ../src/guestfs-actions.pod:1852 ../src/guestfs-actions.pod:1857 ../fish/guestfish.pod:377 ../fish/guestfish.pod:381 ../fish/guestfish.pod:385 ../fish/guestfish.pod:389 ../fish/guestfish-actions.pod:13 ../fish/guestfish-actions.pod:20 ../fish/guestfish-actions.pod:375 ../fish/guestfish-actions.pod:383 ../fish/guestfish-actions.pod:390 ../fish/guestfish-actions.pod:397 ../fish/guestfish-actions.pod:1067 ../fish/guestfish-actions.pod:1071 ../fish/guestfish-actions.pod:1075 ../fish/guestfish-actions.pod:1079 ../fish/guestfish-actions.pod:1087 ../fish/guestfish-actions.pod:1091 ../fish/guestfish-actions.pod:1095 ../fish/guestfish-actions.pod:1105 ../fish/guestfish-actions.pod:1109 ../fish/guestfish-actions.pod:1113 ../fish/guestfish-actions.pod:1203 ../fish/guestfish-actions.pod:1207 ../fish/guestfish-actions.pod:1212 ../fish/guestfish-actions.pod:1217 ../fish/guestfish-actions.pod:1259 ../fish/guestfish-actions.pod:1263 ../fish/guestfish-actions.pod:1268 ../tools/virt-resize.pl:345 ../tools/virt-resize.pl:350 ../tools/virt-resize.pl:360
768 #: ../src/guestfs.pod:365
770 "The kernel version that the command runs under will be different from what "
775 #: ../src/guestfs.pod:370
777 "If the command needs to communicate with daemons, then most likely they "
782 #: ../src/guestfs.pod:375
783 msgid "The command will be running in limited memory."
787 #: ../src/guestfs.pod:379
789 "The network may not be available unless you enable it (see "
790 "L</guestfs_set_network>)."
794 #: ../src/guestfs.pod:384
795 msgid "Only supports Linux guests (not Windows, BSD, etc)."
799 #: ../src/guestfs.pod:388
800 msgid "Architecture limitations (eg. won't work for a PPC guest on an X86 host)."
804 #: ../src/guestfs.pod:393
806 "For SELinux guests, you may need to enable SELinux and load policy first. "
807 "See L</SELINUX> in this manpage."
811 #: ../src/guestfs.pod:398
813 "I<Security:> It is not safe to run commands from untrusted, possibly "
814 "malicious guests. These commands may attempt to exploit your program by "
815 "sending unexpected output. They could also try to exploit the Linux kernel "
816 "or qemu provided by the libguestfs appliance. They could use the network "
817 "provided by the libguestfs appliance to bypass ordinary network partitions "
818 "and firewalls. They could use the elevated privileges or different SELinux "
819 "context of your program to their advantage."
823 #: ../src/guestfs.pod:407
825 "A secure alternative is to use libguestfs to install a \"firstboot\" script "
826 "(a script which runs when the guest next boots normally), and to have this "
827 "script run the commands you want in the normal context of the running guest, "
828 "network security and so on. For information about other security issues, "
833 #: ../src/guestfs.pod:415
835 "The two main API calls to run commands are L</guestfs_command> and "
836 "L</guestfs_sh> (there are also variations)."
840 #: ../src/guestfs.pod:418
842 "The difference is that L</guestfs_sh> runs commands using the shell, so any "
843 "shell globs, redirections, etc will work."
847 #: ../src/guestfs.pod:421
848 msgid "CONFIGURATION FILES"
852 #: ../src/guestfs.pod:423
854 "To read and write configuration files in Linux guest filesystems, we "
855 "strongly recommend using Augeas. For example, Augeas understands how to "
856 "read and write, say, a Linux shadow password file or X.org configuration "
857 "file, and so avoids you having to write that code."
861 #: ../src/guestfs.pod:428
863 "The main Augeas calls are bound through the C<guestfs_aug_*> APIs. We don't "
864 "document Augeas itself here because there is excellent documentation on the "
865 "L<http://augeas.net/> website."
869 #: ../src/guestfs.pod:432
871 "If you don't want to use Augeas (you fool!) then try calling "
872 "L</guestfs_read_lines> to get the file as a list of lines which you can "
877 #: ../src/guestfs.pod:436
882 #: ../src/guestfs.pod:438
884 "We support SELinux guests. To ensure that labeling happens correctly in "
885 "SELinux guests, you need to enable SELinux and load the guest's policy:"
889 #: ../src/guestfs.pod:444 ../src/guestfs.pod:1148 ../src/guestfs.pod:1279
894 #: ../src/guestfs.pod:446
895 msgid "Before launching, do:"
899 #: ../src/guestfs.pod:448
902 " guestfs_set_selinux (g, 1);\n"
907 #: ../src/guestfs.pod:450 ../src/guestfs.pod:1152 ../src/guestfs.pod:1283
912 #: ../src/guestfs.pod:452
914 "After mounting the guest's filesystem(s), load the policy. This is best "
915 "done by running the L<load_policy(8)> command in the guest itself:"
919 #: ../src/guestfs.pod:456
922 " guestfs_sh (g, \"/usr/sbin/load_policy\");\n"
927 #: ../src/guestfs.pod:458
929 "(Older versions of C<load_policy> require you to specify the name of the "
934 #: ../src/guestfs.pod:461 ../src/guestfs.pod:1289
939 #: ../src/guestfs.pod:463
941 "Optionally, set the security context for the API. The correct security "
942 "context to use can only be known by inspecting the guest. As an example:"
946 #: ../src/guestfs.pod:467
949 " guestfs_setcon (g, \"unconfined_u:unconfined_r:unconfined_t:s0\");\n"
954 #: ../src/guestfs.pod:471
955 msgid "This will work for running commands and editing existing files."
959 #: ../src/guestfs.pod:473
961 "When new files are created, you may need to label them explicitly, for "
962 "example by running the external command C<restorecon pathname>."
966 #: ../src/guestfs.pod:477
971 #: ../src/guestfs.pod:479
973 "Certain calls are affected by the current file mode creation mask (the "
974 "\"umask\"). In particular ones which create files or directories, such as "
975 "L</guestfs_touch>, L</guestfs_mknod> or L</guestfs_mkdir>. This affects "
976 "either the default mode that the file is created with or modifies the mode "
981 #: ../src/guestfs.pod:485
983 "The default umask is C<022>, so files are created with modes such as C<0644> "
984 "and directories with C<0755>."
988 #: ../src/guestfs.pod:488
990 "There are two ways to avoid being affected by umask. Either set umask to 0 "
991 "(call C<guestfs_umask (g, 0)> early after launching). Or call "
992 "L</guestfs_chmod> after creating each file or directory."
996 #: ../src/guestfs.pod:492
997 msgid "For more information about umask, see L<umask(2)>."
1001 #: ../src/guestfs.pod:494 ../fish/guestfish.pod:670
1002 msgid "ENCRYPTED DISKS"
1006 #: ../src/guestfs.pod:496
1008 "Libguestfs allows you to access Linux guests which have been encrypted using "
1009 "whole disk encryption that conforms to the Linux Unified Key Setup (LUKS) "
1010 "standard. This includes nearly all whole disk encryption systems used by "
1011 "modern Linux guests."
1015 #: ../src/guestfs.pod:502
1017 "Use L</guestfs_vfs_type> to identify LUKS-encrypted block devices (it "
1018 "returns the string C<crypto_LUKS>)."
1022 #: ../src/guestfs.pod:505
1024 "Then open these devices by calling L</guestfs_luks_open>. Obviously you "
1025 "will require the passphrase!"
1029 #: ../src/guestfs.pod:508
1031 "Opening a LUKS device creates a new device mapper device called "
1032 "C</dev/mapper/mapname> (where C<mapname> is the string you supply to "
1033 "L</guestfs_luks_open>). Reads and writes to this mapper device are "
1034 "decrypted from and encrypted to the underlying block device respectively."
1038 #: ../src/guestfs.pod:514
1040 "LVM volume groups on the device can be made visible by calling "
1041 "L</guestfs_vgscan> followed by L</guestfs_vg_activate_all>. The logical "
1042 "volume(s) can now be mounted in the usual way."
1046 #: ../src/guestfs.pod:518
1048 "Use the reverse process to close a LUKS device. Unmount any logical volumes "
1049 "on it, deactivate the volume groups by caling C<guestfs_vg_activate (g, 0, "
1050 "[\"/dev/VG\"])>. Then close the mapper device by calling "
1051 "L</guestfs_luks_close> on the C</dev/mapper/mapname> device (I<not> the "
1052 "underlying encrypted block device)."
1056 #: ../src/guestfs.pod:525
1061 #: ../src/guestfs.pod:527
1063 "Libguestfs has APIs for inspecting an unknown disk image to find out if it "
1064 "contains operating systems. (These APIs used to be in a separate Perl-only "
1065 "library called L<Sys::Guestfs::Lib(3)> but since version 1.5.3 the most "
1066 "frequently used part of this library has been rewritten in C and moved into "
1071 #: ../src/guestfs.pod:533
1073 "Add all disks belonging to the unknown virtual machine and call "
1074 "L</guestfs_launch> in the usual way."
1078 #: ../src/guestfs.pod:536
1080 "Then call L</guestfs_inspect_os>. This function uses other libguestfs calls "
1081 "and certain heuristics, and returns a list of operating systems that were "
1082 "found. An empty list means none were found. A single element is the root "
1083 "filesystem of the operating system. For dual- or multi-boot guests, "
1084 "multiple roots can be returned, each one corresponding to a separate "
1085 "operating system. (Multi-boot virtual machines are extremely rare in the "
1086 "world of virtualization, but since this scenario can happen, we have built "
1087 "libguestfs to deal with it.)"
1091 #: ../src/guestfs.pod:545
1093 "For each root, you can then call various C<guestfs_inspect_get_*> functions "
1094 "to get additional details about that operating system. For example, call "
1095 "L</guestfs_inspect_get_type> to return the string C<windows> or C<linux> for "
1096 "Windows and Linux-based operating systems respectively."
1100 #: ../src/guestfs.pod:551
1102 "Un*x-like and Linux-based operating systems usually consist of several "
1103 "filesystems which are mounted at boot time (for example, a separate boot "
1104 "partition mounted on C</boot>). The inspection rules are able to detect how "
1105 "filesystems correspond to mount points. Call "
1106 "C<guestfs_inspect_get_mountpoints> to get this mapping. It might return a "
1107 "hash table like this example:"
1111 #: ../src/guestfs.pod:558
1114 " /boot => /dev/sda1\n"
1115 " / => /dev/vg_guest/lv_root\n"
1116 " /usr => /dev/vg_guest/lv_usr\n"
1121 #: ../src/guestfs.pod:562
1123 "The caller can then make calls to L</guestfs_mount_options> to mount the "
1124 "filesystems as suggested."
1128 #: ../src/guestfs.pod:565
1130 "Be careful to mount filesystems in the right order (eg. C</> before "
1131 "C</usr>). Sorting the keys of the hash by length, shortest first, should "
1136 #: ../src/guestfs.pod:569
1138 "Inspection currently only works for some common operating systems. "
1139 "Contributors are welcome to send patches for other operating systems that we "
1140 "currently cannot detect."
1144 #: ../src/guestfs.pod:573
1146 "Encrypted disks must be opened before inspection. See L</ENCRYPTED DISKS> "
1147 "for more details. The L</guestfs_inspect_os> function just ignores any "
1148 "encrypted devices."
1152 #: ../src/guestfs.pod:577
1154 "A note on the implementation: The call L</guestfs_inspect_os> performs "
1155 "inspection and caches the results in the guest handle. Subsequent calls to "
1156 "C<guestfs_inspect_get_*> return this cached information, but I<do not> "
1157 "re-read the disks. If you change the content of the guest disks, you can "
1158 "redo inspection by calling L</guestfs_inspect_os> again. "
1159 "(L</guestfs_inspect_list_applications> works a little differently from the "
1160 "other calls and does read the disks. See documentation for that function "
1165 #: ../src/guestfs.pod:586
1166 msgid "SPECIAL CONSIDERATIONS FOR WINDOWS GUESTS"
1170 #: ../src/guestfs.pod:588
1172 "Libguestfs can mount NTFS partitions. It does this using the "
1173 "L<http://www.ntfs-3g.org/> driver."
1177 #: ../src/guestfs.pod:591
1179 "DOS and Windows still use drive letters, and the filesystems are always "
1180 "treated as case insensitive by Windows itself, and therefore you might find "
1181 "a Windows configuration file referring to a path like "
1182 "C<c:\\windows\\system32>. When the filesystem is mounted in libguestfs, "
1183 "that directory might be referred to as C</WINDOWS/System32>."
1187 #: ../src/guestfs.pod:597
1189 "Drive letter mappings are outside the scope of libguestfs. You have to use "
1190 "libguestfs to read the appropriate Windows Registry and configuration files, "
1191 "to determine yourself how drives are mapped (see also L<hivex(3)> and "
1192 "L<virt-inspector(1)>)."
1196 #: ../src/guestfs.pod:602
1198 "Replacing backslash characters with forward slash characters is also outside "
1199 "the scope of libguestfs, but something that you can easily do."
1203 #: ../src/guestfs.pod:605
1205 "Where we can help is in resolving the case insensitivity of paths. For "
1206 "this, call L</guestfs_case_sensitive_path>."
1210 #: ../src/guestfs.pod:608
1212 "Libguestfs also provides some help for decoding Windows Registry \"hive\" "
1213 "files, through the library C<hivex> which is part of the libguestfs project "
1214 "although ships as a separate tarball. You have to locate and download the "
1215 "hive file(s) yourself, and then pass them to C<hivex> functions. See also "
1216 "the programs L<hivexml(1)>, L<hivexsh(1)>, L<hivexregedit(1)> and "
1217 "L<virt-win-reg(1)> for more help on this issue."
1221 #: ../src/guestfs.pod:616
1222 msgid "USING LIBGUESTFS WITH OTHER PROGRAMMING LANGUAGES"
1226 #: ../src/guestfs.pod:618
1228 "Although we don't want to discourage you from using the C API, we will "
1229 "mention here that the same API is also available in other languages."
1233 #: ../src/guestfs.pod:621
1235 "The API is broadly identical in all supported languages. This means that "
1236 "the C call C<guestfs_mount(g,path)> is C<$g-E<gt>mount($path)> in Perl, "
1237 "C<g.mount(path)> in Python, and C<Guestfs.mount g path> in OCaml. In other "
1238 "words, a straightforward, predictable isomorphism between each language."
1242 #: ../src/guestfs.pod:627
1244 "Error messages are automatically transformed into exceptions if the language "
1249 #: ../src/guestfs.pod:630
1251 "We don't try to \"object orientify\" parts of the API in OO languages, "
1252 "although contributors are welcome to write higher level APIs above what we "
1253 "provide in their favourite languages if they wish."
1257 #: ../src/guestfs.pod:636
1262 #: ../src/guestfs.pod:638
1264 "You can use the I<guestfs.h> header file from C++ programs. The C++ API is "
1265 "identical to the C API. C++ classes and exceptions are not used."
1269 #: ../src/guestfs.pod:642
1274 #: ../src/guestfs.pod:644
1276 "The C# bindings are highly experimental. Please read the warnings at the "
1277 "top of C<csharp/Libguestfs.cs>."
1281 #: ../src/guestfs.pod:647
1286 #: ../src/guestfs.pod:649
1288 "This is the only language binding that is working but incomplete. Only "
1289 "calls which return simple integers have been bound in Haskell, and we are "
1290 "looking for help to complete this binding."
1294 #: ../src/guestfs.pod:653
1299 #: ../src/guestfs.pod:655
1301 "Full documentation is contained in the Javadoc which is distributed with "
1306 #: ../src/guestfs.pod:658
1311 #: ../src/guestfs.pod:660
1312 msgid "For documentation see L<guestfs-ocaml(3)>."
1316 #: ../src/guestfs.pod:662
1321 #: ../src/guestfs.pod:664
1322 msgid "For documentation see L<Sys::Guestfs(3)>."
1326 #: ../src/guestfs.pod:666
1331 #: ../src/guestfs.pod:668
1333 "For documentation see C<README-PHP> supplied with libguestfs sources or in "
1334 "the php-libguestfs package for your distribution."
1338 #: ../src/guestfs.pod:671
1339 msgid "The PHP binding only works correctly on 64 bit machines."
1343 #: ../src/guestfs.pod:673
1348 #: ../src/guestfs.pod:675
1349 msgid "For documentation see L<guestfs-python(3)>."
1353 #: ../src/guestfs.pod:677
1358 #: ../src/guestfs.pod:679
1359 msgid "For documentation see L<guestfs-ruby(3)>."
1363 #: ../src/guestfs.pod:681
1364 msgid "B<shell scripts>"
1368 #: ../src/guestfs.pod:683
1369 msgid "For documentation see L<guestfish(1)>."
1373 #: ../src/guestfs.pod:687
1374 msgid "LIBGUESTFS GOTCHAS"
1378 #: ../src/guestfs.pod:689
1380 "L<http://en.wikipedia.org/wiki/Gotcha_(programming)>: \"A feature of a "
1381 "system [...] that works in the way it is documented but is counterintuitive "
1382 "and almost invites mistakes.\""
1386 #: ../src/guestfs.pod:693
1388 "Since we developed libguestfs and the associated tools, there are several "
1389 "things we would have designed differently, but are now stuck with for "
1390 "backwards compatibility or other reasons. If there is ever a libguestfs 2.0 "
1391 "release, you can expect these to change. Beware of them."
1395 #: ../src/guestfs.pod:701
1396 msgid "Autosync / forgetting to sync."
1400 #: ../src/guestfs.pod:703
1402 "When modifying a filesystem from C or another language, you B<must> unmount "
1403 "all filesystems and call L</guestfs_sync> explicitly before you close the "
1404 "libguestfs handle. You can also call:"
1408 #: ../src/guestfs.pod:707
1411 " guestfs_set_autosync (g, 1);\n"
1416 #: ../src/guestfs.pod:709
1418 "to have the unmount/sync done automatically for you when the handle 'g' is "
1419 "closed. (This feature is called \"autosync\", L</guestfs_set_autosync> "
1424 #: ../src/guestfs.pod:713
1426 "If you forget to do this, then it is entirely possible that your changes "
1427 "won't be written out, or will be partially written, or (very rarely) that "
1428 "you'll get disk corruption."
1432 #: ../src/guestfs.pod:717
1434 "Note that in L<guestfish(3)> autosync is the default. So quick and dirty "
1435 "guestfish scripts that forget to sync will work just fine, which can make "
1436 "this very puzzling if you are trying to debug a problem."
1440 #: ../src/guestfs.pod:721
1442 "Update: Autosync is enabled by default for all API users starting from "
1443 "libguestfs 1.5.24."
1447 #: ../src/guestfs.pod:724
1448 msgid "Mount option C<-o sync> should not be the default."
1452 #: ../src/guestfs.pod:726
1454 "If you use L</guestfs_mount>, then C<-o sync,noatime> are added implicitly. "
1455 "However C<-o sync> does not add any reliability benefit, but does have a "
1456 "very large performance impact."
1460 #: ../src/guestfs.pod:730
1462 "The work around is to use L</guestfs_mount_options> and set the mount "
1463 "options that you actually want to use."
1467 #: ../src/guestfs.pod:733
1468 msgid "Read-only should be the default."
1472 #: ../src/guestfs.pod:735
1474 "In L<guestfish(3)>, I<--ro> should be the default, and you should have to "
1475 "specify I<--rw> if you want to make changes to the image."
1479 #: ../src/guestfs.pod:738
1480 msgid "This would reduce the potential to corrupt live VM images."
1484 #: ../src/guestfs.pod:740
1486 "Note that many filesystems change the disk when you just mount and unmount, "
1487 "even if you didn't perform any writes. You need to use "
1488 "L</guestfs_add_drive_ro> to guarantee that the disk is not changed."
1492 #: ../src/guestfs.pod:744
1493 msgid "guestfish command line is hard to use."
1497 #: ../src/guestfs.pod:746
1499 "C<guestfish disk.img> doesn't do what people expect (open C<disk.img> for "
1500 "examination). It tries to run a guestfish command C<disk.img> which doesn't "
1501 "exist, so it fails. In earlier versions of guestfish the error message was "
1502 "also unintuitive, but we have corrected this since. Like the Bourne shell, "
1503 "we should have used C<guestfish -c command> to run commands."
1507 #: ../src/guestfs.pod:753
1508 msgid "guestfish megabyte modifiers don't work right on all commands"
1512 #: ../src/guestfs.pod:755
1514 "In recent guestfish you can use C<1M> to mean 1 megabyte (and similarly for "
1515 "other modifiers). What guestfish actually does is to multiply the number "
1516 "part by the modifier part and pass the result to the C API. However this "
1517 "doesn't work for a few APIs which aren't expecting bytes, but are already "
1518 "expecting some other unit (eg. megabytes)."
1522 #: ../src/guestfs.pod:762
1523 msgid "The most common is L</guestfs_lvcreate>. The guestfish command:"
1527 #: ../src/guestfs.pod:764
1530 " lvcreate LV VG 100M\n"
1535 #: ../src/guestfs.pod:766
1537 "does not do what you might expect. Instead because L</guestfs_lvcreate> is "
1538 "already expecting megabytes, this tries to create a 100 I<terabyte> (100 "
1539 "megabytes * megabytes) logical volume. The error message you get from this "
1540 "is also a little obscure."
1544 #: ../src/guestfs.pod:771
1546 "This could be fixed in the generator by specially marking parameters and "
1547 "return values which take bytes or other units."
1551 #: ../src/guestfs.pod:774
1552 msgid "Ambiguity between devices and paths"
1556 #: ../src/guestfs.pod:776
1558 "There is a subtle ambiguity in the API between a device name "
1559 "(eg. C</dev/sdb2>) and a similar pathname. A file might just happen to be "
1560 "called C<sdb2> in the directory C</dev> (consider some non-Unix VM image)."
1564 #: ../src/guestfs.pod:781
1566 "In the current API we usually resolve this ambiguity by having two separate "
1567 "calls, for example L</guestfs_checksum> and L</guestfs_checksum_device>. "
1568 "Some API calls are ambiguous and (incorrectly) resolve the problem by "
1569 "detecting if the path supplied begins with C</dev/>."
1573 #: ../src/guestfs.pod:787
1575 "To avoid both the ambiguity and the need to duplicate some calls, we could "
1576 "make paths/devices into structured names. One way to do this would be to "
1577 "use a notation like grub (C<hd(0,0)>), although nobody really likes this "
1578 "aspect of grub. Another way would be to use a structured type, equivalent "
1579 "to this OCaml type:"
1583 #: ../src/guestfs.pod:793
1586 " type path = Path of string | Device of int | Partition of int * int\n"
1591 #: ../src/guestfs.pod:795
1592 msgid "which would allow you to pass arguments like:"
1596 #: ../src/guestfs.pod:797
1599 " Path \"/foo/bar\"\n"
1600 " Device 1 (* /dev/sdb, or perhaps /dev/sda *)\n"
1601 " Partition (1, 2) (* /dev/sdb2 (or is it /dev/sda2 or /dev/sdb3?) *)\n"
1602 " Path \"/dev/sdb2\" (* not a device *)\n"
1607 #: ../src/guestfs.pod:802
1609 "As you can see there are still problems to resolve even with this "
1610 "representation. Also consider how it might work in guestfish."
1614 #: ../src/guestfs.pod:807
1615 msgid "PROTOCOL LIMITS"
1619 #: ../src/guestfs.pod:809
1621 "Internally libguestfs uses a message-based protocol to pass API calls and "
1622 "their responses to and from a small \"appliance\" (see L</INTERNALS> for "
1623 "plenty more detail about this). The maximum message size used by the "
1624 "protocol is slightly less than 4 MB. For some API calls you may need to be "
1625 "aware of this limit. The API calls which may be affected are individually "
1626 "documented, with a link back to this section of the documentation."
1630 #: ../src/guestfs.pod:817
1632 "A simple call such as L</guestfs_cat> returns its result (the file data) in "
1633 "a simple string. Because this string is at some point internally encoded as "
1634 "a message, the maximum size that it can return is slightly under 4 MB. If "
1635 "the requested file is larger than this then you will get an error."
1639 #: ../src/guestfs.pod:823
1641 "In order to transfer large files into and out of the guest filesystem, you "
1642 "need to use particular calls that support this. The sections L</UPLOADING> "
1643 "and L</DOWNLOADING> document how to do this."
1647 #: ../src/guestfs.pod:827
1649 "You might also consider mounting the disk image using our FUSE filesystem "
1650 "support (L<guestmount(1)>)."
1654 #: ../src/guestfs.pod:830
1655 msgid "KEYS AND PASSPHRASES"
1659 #: ../src/guestfs.pod:832
1661 "Certain libguestfs calls take a parameter that contains sensitive key "
1662 "material, passed in as a C string."
1666 #: ../src/guestfs.pod:835
1668 "In the future we would hope to change the libguestfs implementation so that "
1669 "keys are L<mlock(2)>-ed into physical RAM, and thus can never end up in "
1670 "swap. However this is I<not> done at the moment, because of the complexity "
1671 "of such an implementation."
1675 #: ../src/guestfs.pod:840
1677 "Therefore you should be aware that any key parameter you pass to libguestfs "
1678 "might end up being written out to the swap partition. If this is a concern, "
1679 "scrub the swap partition or don't use libguestfs on encrypted devices."
1683 #: ../src/guestfs.pod:845
1684 msgid "MULTIPLE HANDLES AND MULTIPLE THREADS"
1688 #: ../src/guestfs.pod:847
1690 "All high-level libguestfs actions are synchronous. If you want to use "
1691 "libguestfs asynchronously then you must create a thread."
1695 #: ../src/guestfs.pod:850
1697 "Only use the handle from a single thread. Either use the handle exclusively "
1698 "from one thread, or provide your own mutex so that two threads cannot issue "
1699 "calls on the same handle at the same time."
1703 #: ../src/guestfs.pod:854
1705 "See the graphical program guestfs-browser for one possible architecture for "
1706 "multithreaded programs using libvirt and libguestfs."
1710 #: ../src/guestfs.pod:857
1715 #: ../src/guestfs.pod:859
1717 "Libguestfs needs a kernel and initrd.img, which it finds by looking along an "
1722 #: ../src/guestfs.pod:862
1724 "By default it looks for these in the directory C<$libdir/guestfs> "
1725 "(eg. C</usr/local/lib/guestfs> or C</usr/lib64/guestfs>)."
1729 #: ../src/guestfs.pod:865
1731 "Use L</guestfs_set_path> or set the environment variable L</LIBGUESTFS_PATH> "
1732 "to change the directories that libguestfs will search in. The value is a "
1733 "colon-separated list of paths. The current directory is I<not> searched "
1734 "unless the path contains an empty element or C<.>. For example "
1735 "C<LIBGUESTFS_PATH=:/usr/lib/guestfs> would search the current directory and "
1736 "then C</usr/lib/guestfs>."
1740 #: ../src/guestfs.pod:872
1741 msgid "QEMU WRAPPERS"
1745 #: ../src/guestfs.pod:874
1747 "If you want to compile your own qemu, run qemu from a non-standard location, "
1748 "or pass extra arguments to qemu, then you can write a shell-script wrapper "
1753 #: ../src/guestfs.pod:878
1755 "There is one important rule to remember: you I<must C<exec qemu>> as the "
1756 "last command in the shell script (so that qemu replaces the shell and "
1757 "becomes the direct child of the libguestfs-using program). If you don't do "
1758 "this, then the qemu process won't be cleaned up correctly."
1762 #: ../src/guestfs.pod:883
1764 "Here is an example of a wrapper, where I have built my own copy of qemu from "
1769 #: ../src/guestfs.pod:886
1773 " qemudir=/home/rjones/d/qemu\n"
1774 " exec $qemudir/x86_64-softmmu/qemu-system-x86_64 -L $qemudir/pc-bios "
1780 #: ../src/guestfs.pod:890
1782 "Save this script as C</tmp/qemu.wrapper> (or wherever), C<chmod +x>, and "
1783 "then use it by setting the LIBGUESTFS_QEMU environment variable. For "
1788 #: ../src/guestfs.pod:894
1791 " LIBGUESTFS_QEMU=/tmp/qemu.wrapper guestfish\n"
1796 #: ../src/guestfs.pod:896
1798 "Note that libguestfs also calls qemu with the -help and -version options in "
1799 "order to determine features."
1803 #: ../src/guestfs.pod:899
1804 msgid "ABI GUARANTEE"
1808 #: ../src/guestfs.pod:901
1810 "We guarantee the libguestfs ABI (binary interface), for public, high-level "
1811 "actions as outlined in this section. Although we will deprecate some "
1812 "actions, for example if they get replaced by newer calls, we will keep the "
1813 "old actions forever. This allows you the developer to program in confidence "
1814 "against the libguestfs API."
1818 #: ../src/guestfs.pod:907
1819 msgid "BLOCK DEVICE NAMING"
1823 #: ../src/guestfs.pod:909
1825 "In the kernel there is now quite a profusion of schemata for naming block "
1826 "devices (in this context, by I<block device> I mean a physical or virtual "
1827 "hard drive). The original Linux IDE driver used names starting with "
1828 "C</dev/hd*>. SCSI devices have historically used a different naming scheme, "
1829 "C</dev/sd*>. When the Linux kernel I<libata> driver became a popular "
1830 "replacement for the old IDE driver (particularly for SATA devices) those "
1831 "devices also used the C</dev/sd*> scheme. Additionally we now have virtual "
1832 "machines with paravirtualized drivers. This has created several different "
1833 "naming systems, such as C</dev/vd*> for virtio disks and C</dev/xvd*> for "
1838 #: ../src/guestfs.pod:921
1840 "As discussed above, libguestfs uses a qemu appliance running an embedded "
1841 "Linux kernel to access block devices. We can run a variety of appliances "
1842 "based on a variety of Linux kernels."
1846 #: ../src/guestfs.pod:925
1848 "This causes a problem for libguestfs because many API calls use device or "
1849 "partition names. Working scripts and the recipe (example) scripts that we "
1850 "make available over the internet could fail if the naming scheme changes."
1854 #: ../src/guestfs.pod:930
1856 "Therefore libguestfs defines C</dev/sd*> as the I<standard naming scheme>. "
1857 "Internally C</dev/sd*> names are translated, if necessary, to other names as "
1858 "required. For example, under RHEL 5 which uses the C</dev/hd*> scheme, any "
1859 "device parameter C</dev/sda2> is translated to C</dev/hda2> transparently."
1863 #: ../src/guestfs.pod:936
1865 "Note that this I<only> applies to parameters. The L</guestfs_list_devices>, "
1866 "L</guestfs_list_partitions> and similar calls return the true names of the "
1867 "devices and partitions as known to the appliance."
1871 #: ../src/guestfs.pod:941
1872 msgid "ALGORITHM FOR BLOCK DEVICE NAME TRANSLATION"
1876 #: ../src/guestfs.pod:943
1878 "Usually this translation is transparent. However in some (very rare) cases "
1879 "you may need to know the exact algorithm. Such cases include where you use "
1880 "L</guestfs_config> to add a mixture of virtio and IDE devices to the "
1881 "qemu-based appliance, so have a mixture of C</dev/sd*> and C</dev/vd*> "
1886 #: ../src/guestfs.pod:949
1888 "The algorithm is applied only to I<parameters> which are known to be either "
1889 "device or partition names. Return values from functions such as "
1890 "L</guestfs_list_devices> are never changed."
1894 #: ../src/guestfs.pod:957
1895 msgid "Is the string a parameter which is a device or partition name?"
1899 #: ../src/guestfs.pod:961
1900 msgid "Does the string begin with C</dev/sd>?"
1904 #: ../src/guestfs.pod:965
1906 "Does the named device exist? If so, we use that device. However if I<not> "
1907 "then we continue with this algorithm."
1911 #: ../src/guestfs.pod:970
1912 msgid "Replace initial C</dev/sd> string with C</dev/hd>."
1916 #: ../src/guestfs.pod:972
1917 msgid "For example, change C</dev/sda2> to C</dev/hda2>."
1921 #: ../src/guestfs.pod:974
1922 msgid "If that named device exists, use it. If not, continue."
1926 #: ../src/guestfs.pod:978
1927 msgid "Replace initial C</dev/sd> string with C</dev/vd>."
1931 #: ../src/guestfs.pod:980
1932 msgid "If that named device exists, use it. If not, return an error."
1936 #: ../src/guestfs.pod:984
1937 msgid "PORTABILITY CONCERNS WITH BLOCK DEVICE NAMING"
1941 #: ../src/guestfs.pod:986
1943 "Although the standard naming scheme and automatic translation is useful for "
1944 "simple programs and guestfish scripts, for larger programs it is best not to "
1945 "rely on this mechanism."
1949 #: ../src/guestfs.pod:990
1951 "Where possible for maximum future portability programs using libguestfs "
1952 "should use these future-proof techniques:"
1956 #: ../src/guestfs.pod:997
1958 "Use L</guestfs_list_devices> or L</guestfs_list_partitions> to list actual "
1959 "device names, and then use those names directly."
1963 #: ../src/guestfs.pod:1000
1964 msgid "Since those device names exist by definition, they will never be translated."
1968 #: ../src/guestfs.pod:1005
1970 "Use higher level ways to identify filesystems, such as LVM names, UUIDs and "
1971 "filesystem labels."
1975 #: ../src/guestfs.pod:1010
1980 #: ../src/guestfs.pod:1012
1982 "This section discusses security implications of using libguestfs, "
1983 "particularly with untrusted or malicious guests or disk images."
1987 #: ../src/guestfs.pod:1015
1988 msgid "GENERAL SECURITY CONSIDERATIONS"
1992 #: ../src/guestfs.pod:1017
1994 "Be careful with any files or data that you download from a guest (by "
1995 "\"download\" we mean not just the L</guestfs_download> command but any "
1996 "command that reads files, filenames, directories or anything else from a "
1997 "disk image). An attacker could manipulate the data to fool your program "
1998 "into doing the wrong thing. Consider cases such as:"
2002 #: ../src/guestfs.pod:1027
2003 msgid "the data (file etc) not being present"
2007 #: ../src/guestfs.pod:1031
2008 msgid "being present but empty"
2012 #: ../src/guestfs.pod:1035
2013 msgid "being much larger than normal"
2017 #: ../src/guestfs.pod:1039
2018 msgid "containing arbitrary 8 bit data"
2022 #: ../src/guestfs.pod:1043
2023 msgid "being in an unexpected character encoding"
2027 #: ../src/guestfs.pod:1047
2028 msgid "containing homoglyphs."
2032 #: ../src/guestfs.pod:1051
2033 msgid "SECURITY OF MOUNTING FILESYSTEMS"
2037 #: ../src/guestfs.pod:1053
2039 "When you mount a filesystem under Linux, mistakes in the kernel filesystem "
2040 "(VFS) module can sometimes be escalated into exploits by deliberately "
2041 "creating a malicious, malformed filesystem. These exploits are very severe "
2042 "for two reasons. Firstly there are very many filesystem drivers in the "
2043 "kernel, and many of them are infrequently used and not much developer "
2044 "attention has been paid to the code. Linux userspace helps potential "
2045 "crackers by detecting the filesystem type and automatically choosing the "
2046 "right VFS driver, even if that filesystem type is obscure or unexpected for "
2047 "the administrator. Secondly, a kernel-level exploit is like a local root "
2048 "exploit (worse in some ways), giving immediate and total access to the "
2049 "system right down to the hardware level."
2053 #: ../src/guestfs.pod:1066
2055 "That explains why you should never mount a filesystem from an untrusted "
2056 "guest on your host kernel. How about libguestfs? We run a Linux kernel "
2057 "inside a qemu virtual machine, usually running as a non-root user. The "
2058 "attacker would need to write a filesystem which first exploited the kernel, "
2059 "and then exploited either qemu virtualization (eg. a faulty qemu driver) or "
2060 "the libguestfs protocol, and finally to be as serious as the host kernel "
2061 "exploit it would need to escalate its privileges to root. This multi-step "
2062 "escalation, performed by a static piece of data, is thought to be extremely "
2063 "hard to do, although we never say 'never' about security issues."
2067 #: ../src/guestfs.pod:1077
2069 "In any case callers can reduce the attack surface by forcing the filesystem "
2070 "type when mounting (use L</guestfs_mount_vfs>)."
2074 #: ../src/guestfs.pod:1080
2075 msgid "PROTOCOL SECURITY"
2079 #: ../src/guestfs.pod:1082
2081 "The protocol is designed to be secure, being based on RFC 4506 (XDR) with a "
2082 "defined upper message size. However a program that uses libguestfs must "
2083 "also take care - for example you can write a program that downloads a binary "
2084 "from a disk image and executes it locally, and no amount of protocol "
2085 "security will save you from the consequences."
2089 #: ../src/guestfs.pod:1088
2090 msgid "INSPECTION SECURITY"
2094 #: ../src/guestfs.pod:1090
2096 "Parts of the inspection API (see L</INSPECTION>) return untrusted strings "
2097 "directly from the guest, and these could contain any 8 bit data. Callers "
2098 "should be careful to escape these before printing them to a structured file "
2099 "(for example, use HTML escaping if creating a web page)."
2103 #: ../src/guestfs.pod:1096
2105 "Guest configuration may be altered in unusual ways by the administrator of "
2106 "the virtual machine, and may not reflect reality (particularly for untrusted "
2107 "or actively malicious guests). For example we parse the hostname from "
2108 "configuration files like C</etc/sysconfig/network> that we find in the "
2109 "guest, but the guest administrator can easily manipulate these files to "
2110 "provide the wrong hostname."
2114 #: ../src/guestfs.pod:1104
2116 "The inspection API parses guest configuration using two external libraries: "
2117 "Augeas (Linux configuration) and hivex (Windows Registry). Both are "
2118 "designed to be robust in the face of malicious data, although denial of "
2119 "service attacks are still possible, for example with oversized configuration "
2124 #: ../src/guestfs.pod:1110
2125 msgid "RUNNING UNTRUSTED GUEST COMMANDS"
2129 #: ../src/guestfs.pod:1112
2131 "Be very cautious about running commands from the guest. By running a "
2132 "command in the guest, you are giving CPU time to a binary that you do not "
2133 "control, under the same user account as the library, albeit wrapped in qemu "
2134 "virtualization. More information and alternatives can be found in the "
2135 "section L</RUNNING COMMANDS>."
2139 #: ../src/guestfs.pod:1118
2140 msgid "CVE-2010-3851"
2144 #: ../src/guestfs.pod:1120
2145 msgid "https://bugzilla.redhat.com/642934"
2149 #: ../src/guestfs.pod:1122
2151 "This security bug concerns the automatic disk format detection that qemu "
2152 "does on disk images."
2156 #: ../src/guestfs.pod:1125
2158 "A raw disk image is just the raw bytes, there is no header. Other disk "
2159 "images like qcow2 contain a special header. Qemu deals with this by looking "
2160 "for one of the known headers, and if none is found then assuming the disk "
2161 "image must be raw."
2165 #: ../src/guestfs.pod:1130
2167 "This allows a guest which has been given a raw disk image to write some "
2168 "other header. At next boot (or when the disk image is accessed by "
2169 "libguestfs) qemu would do autodetection and think the disk image format was, "
2170 "say, qcow2 based on the header written by the guest."
2174 #: ../src/guestfs.pod:1135
2176 "This in itself would not be a problem, but qcow2 offers many features, one "
2177 "of which is to allow a disk image to refer to another image (called the "
2178 "\"backing disk\"). It does this by placing the path to the backing disk "
2179 "into the qcow2 header. This path is not validated and could point to any "
2180 "host file (eg. \"/etc/passwd\"). The backing disk is then exposed through "
2181 "\"holes\" in the qcow2 disk image, which of course is completely under the "
2182 "control of the attacker."
2186 #: ../src/guestfs.pod:1143
2187 msgid "In libguestfs this is rather hard to exploit except under two circumstances:"
2191 #: ../src/guestfs.pod:1150
2192 msgid "You have enabled the network or have opened the disk in write mode."
2196 #: ../src/guestfs.pod:1154
2198 "You are also running untrusted code from the guest (see L</RUNNING "
2203 #: ../src/guestfs.pod:1159
2205 "The way to avoid this is to specify the expected disk format when adding "
2206 "disks (the optional C<format> option to L</guestfs_add_drive_opts>). You "
2207 "should always do this if the disk is raw format, and it's a good idea for "
2212 #: ../src/guestfs.pod:1164
2214 "For disks added from libvirt using calls like L</guestfs_add_domain>, the "
2215 "format is fetched from libvirt and passed through."
2219 #: ../src/guestfs.pod:1167
2221 "For libguestfs tools, use the I<--format> command line parameter as "
2226 #: ../src/guestfs.pod:1170
2227 msgid "CONNECTION MANAGEMENT"
2231 #: ../src/guestfs.pod:1172
2236 #: ../src/guestfs.pod:1174
2238 "C<guestfs_h> is the opaque type representing a connection handle. Create a "
2239 "handle by calling L</guestfs_create>. Call L</guestfs_close> to free the "
2240 "handle and release all resources used."
2244 #: ../src/guestfs.pod:1178
2246 "For information on using multiple handles and threads, see the section "
2247 "L</MULTIPLE HANDLES AND MULTIPLE THREADS> below."
2251 #: ../src/guestfs.pod:1181
2252 msgid "guestfs_create"
2256 #: ../src/guestfs.pod:1183
2259 " guestfs_h *guestfs_create (void);\n"
2264 #: ../src/guestfs.pod:1185
2265 msgid "Create a connection handle."
2269 #: ../src/guestfs.pod:1187
2271 "You have to call L</guestfs_add_drive_opts> (or one of the equivalent calls) "
2272 "on the handle at least once."
2276 #: ../src/guestfs.pod:1190
2278 "This function returns a non-NULL pointer to a handle on success or NULL on "
2283 #: ../src/guestfs.pod:1193
2284 msgid "After configuring the handle, you have to call L</guestfs_launch>."
2288 #: ../src/guestfs.pod:1195
2290 "You may also want to configure error handling for the handle. See L</ERROR "
2291 "HANDLING> section below."
2295 #: ../src/guestfs.pod:1198
2296 msgid "guestfs_close"
2300 #: ../src/guestfs.pod:1200
2303 " void guestfs_close (guestfs_h *g);\n"
2308 #: ../src/guestfs.pod:1202
2309 msgid "This closes the connection handle and frees up all resources used."
2313 #: ../src/guestfs.pod:1204
2314 msgid "ERROR HANDLING"
2318 #: ../src/guestfs.pod:1206
2320 "API functions can return errors. For example, almost all functions that "
2321 "return C<int> will return C<-1> to indicate an error."
2325 #: ../src/guestfs.pod:1209
2327 "Additional information is available for errors: an error message string and "
2328 "optionally an error number (errno) if the thing that failed was a system "
2333 #: ../src/guestfs.pod:1213
2335 "You can get at the additional information about the last error on the handle "
2336 "by calling L</guestfs_last_error>, L</guestfs_last_errno>, and/or by setting "
2337 "up an error handler with L</guestfs_set_error_handler>."
2341 #: ../src/guestfs.pod:1218
2343 "When the handle is created, a default error handler is installed which "
2344 "prints the error message string to C<stderr>. For small short-running "
2345 "command line programs it is sufficient to do:"
2349 #: ../src/guestfs.pod:1222
2352 " if (guestfs_launch (g) == -1)\n"
2353 " exit (EXIT_FAILURE);\n"
2358 #: ../src/guestfs.pod:1225
2360 "since the default error handler will ensure that an error message has been "
2361 "printed to C<stderr> before the program exits."
2365 #: ../src/guestfs.pod:1228
2367 "For other programs the caller will almost certainly want to install an "
2368 "alternate error handler or do error handling in-line like this:"
2372 #: ../src/guestfs.pod:1231
2375 " g = guestfs_create ();\n"
2380 #: ../src/guestfs.pod:1233
2383 " /* This disables the default behaviour of printing errors\n"
2385 " guestfs_set_error_handler (g, NULL, NULL);\n"
2390 #: ../src/guestfs.pod:1237
2393 " if (guestfs_launch (g) == -1) {\n"
2394 " /* Examine the error message and print it etc. */\n"
2395 " char *msg = guestfs_last_error (g);\n"
2396 " int errnum = guestfs_last_errno (g);\n"
2397 " fprintf (stderr, \"%s\\n\", msg);\n"
2404 #: ../src/guestfs.pod:1245
2406 "Out of memory errors are handled differently. The default action is to call "
2407 "L<abort(3)>. If this is undesirable, then you can set a handler using "
2408 "L</guestfs_set_out_of_memory_handler>."
2412 #: ../src/guestfs.pod:1249
2414 "L</guestfs_create> returns C<NULL> if the handle cannot be created, and "
2415 "because there is no handle if this happens there is no way to get additional "
2416 "error information. However L</guestfs_create> is supposed to be a "
2417 "lightweight operation which can only fail because of insufficient memory (it "
2418 "returns NULL in this case)."
2422 #: ../src/guestfs.pod:1255
2423 msgid "guestfs_last_error"
2427 #: ../src/guestfs.pod:1257
2430 " const char *guestfs_last_error (guestfs_h *g);\n"
2435 #: ../src/guestfs.pod:1259
2437 "This returns the last error message that happened on C<g>. If there has not "
2438 "been an error since the handle was created, then this returns C<NULL>."
2442 #: ../src/guestfs.pod:1263
2444 "The lifetime of the returned string is until the next error occurs, or "
2445 "L</guestfs_close> is called."
2449 #: ../src/guestfs.pod:1266
2450 msgid "guestfs_last_errno"
2454 #: ../src/guestfs.pod:1268
2457 " int guestfs_last_errno (guestfs_h *g);\n"
2462 #: ../src/guestfs.pod:1270
2463 msgid "This returns the last error number (errno) that happened on C<g>."
2467 #: ../src/guestfs.pod:1272
2468 msgid "If successful, an errno integer not equal to zero is returned."
2472 #: ../src/guestfs.pod:1274
2473 msgid "If no error, this returns 0. This call can return 0 in three situations:"
2477 #: ../src/guestfs.pod:1281
2478 msgid "There has not been any error on the handle."
2482 #: ../src/guestfs.pod:1285
2484 "There has been an error but the errno was meaningless. This corresponds to "
2485 "the case where the error did not come from a failed system call, but for "
2486 "some other reason."
2490 #: ../src/guestfs.pod:1291
2492 "There was an error from a failed system call, but for some reason the errno "
2493 "was not captured and returned. This usually indicates a bug in libguestfs."
2497 #: ../src/guestfs.pod:1297
2499 "Libguestfs tries to convert the errno from inside the applicance into a "
2500 "corresponding errno for the caller (not entirely trivial: the appliance "
2501 "might be running a completely different operating system from the library "
2502 "and error numbers are not standardized across Un*xen). If this could not be "
2503 "done, then the error is translated to C<EINVAL>. In practice this should "
2504 "only happen in very rare circumstances."
2508 #: ../src/guestfs.pod:1305
2509 msgid "guestfs_set_error_handler"
2513 #: ../src/guestfs.pod:1307
2516 " typedef void (*guestfs_error_handler_cb) (guestfs_h *g,\n"
2518 " const char *msg);\n"
2519 " void guestfs_set_error_handler (guestfs_h *g,\n"
2520 " guestfs_error_handler_cb cb,\n"
2526 #: ../src/guestfs.pod:1314
2528 "The callback C<cb> will be called if there is an error. The parameters "
2529 "passed to the callback are an opaque data pointer and the error message "
2534 #: ../src/guestfs.pod:1318
2536 "C<errno> is not passed to the callback. To get that the callback must call "
2537 "L</guestfs_last_errno>."
2541 #: ../src/guestfs.pod:1321
2543 "Note that the message string C<msg> is freed as soon as the callback "
2544 "function returns, so if you want to stash it somewhere you must make your "
2549 #: ../src/guestfs.pod:1325
2550 msgid "The default handler prints messages on C<stderr>."
2554 #: ../src/guestfs.pod:1327
2555 msgid "If you set C<cb> to C<NULL> then I<no> handler is called."
2559 #: ../src/guestfs.pod:1329
2560 msgid "guestfs_get_error_handler"
2564 #: ../src/guestfs.pod:1331
2567 " guestfs_error_handler_cb guestfs_get_error_handler (guestfs_h *g,\n"
2568 " void **opaque_rtn);\n"
2573 #: ../src/guestfs.pod:1334
2574 msgid "Returns the current error handler callback."
2578 #: ../src/guestfs.pod:1336
2579 msgid "guestfs_set_out_of_memory_handler"
2583 #: ../src/guestfs.pod:1338
2586 " typedef void (*guestfs_abort_cb) (void);\n"
2587 " int guestfs_set_out_of_memory_handler (guestfs_h *g,\n"
2588 " guestfs_abort_cb);\n"
2593 #: ../src/guestfs.pod:1342
2595 "The callback C<cb> will be called if there is an out of memory situation. "
2596 "I<Note this callback must not return>."
2600 #: ../src/guestfs.pod:1345
2601 msgid "The default is to call L<abort(3)>."
2605 #: ../src/guestfs.pod:1347
2606 msgid "You cannot set C<cb> to C<NULL>. You can't ignore out of memory situations."
2610 #: ../src/guestfs.pod:1350
2611 msgid "guestfs_get_out_of_memory_handler"
2615 #: ../src/guestfs.pod:1352
2618 " guestfs_abort_fn guestfs_get_out_of_memory_handler (guestfs_h *g);\n"
2623 #: ../src/guestfs.pod:1354
2624 msgid "This returns the current out of memory handler."
2628 #: ../src/guestfs.pod:1356
2633 #: ../src/guestfs.pod:1358 ../fish/guestfish.pod:908
2638 #: ../src/guestfs.pod:1360
2643 #: ../src/guestfs.pod:1362
2648 #: ../src/guestfs.pod:1364
2649 msgid "AVAILABILITY"
2653 #: ../src/guestfs.pod:1366
2654 msgid "GROUPS OF FUNCTIONALITY IN THE APPLIANCE"
2658 #: ../src/guestfs.pod:1368
2660 "Using L</guestfs_available> you can test availability of the following "
2661 "groups of functions. This test queries the appliance to see if the "
2662 "appliance you are currently using supports the functionality."
2666 #: ../src/guestfs.pod:1373
2667 msgid "@AVAILABILITY@"
2671 #: ../src/guestfs.pod:1375
2672 msgid "GUESTFISH supported COMMAND"
2676 #: ../src/guestfs.pod:1377
2678 "In L<guestfish(3)> there is a handy interactive command C<supported> which "
2679 "prints out the available groups and whether they are supported by this build "
2680 "of libguestfs. Note however that you have to do C<run> first."
2684 #: ../src/guestfs.pod:1382
2685 msgid "SINGLE CALLS AT COMPILE TIME"
2689 #: ../src/guestfs.pod:1384
2691 "Since version 1.5.8, C<E<lt>guestfs.hE<gt>> defines symbols for each C API "
2692 "function, such as:"
2696 #: ../src/guestfs.pod:1387
2699 " #define LIBGUESTFS_HAVE_DD 1\n"
2704 #: ../src/guestfs.pod:1389
2705 msgid "if L</guestfs_dd> is available."
2709 #: ../src/guestfs.pod:1391
2711 "Before version 1.5.8, if you needed to test whether a single libguestfs "
2712 "function is available at compile time, we recommended using build tools such "
2713 "as autoconf or cmake. For example in autotools you could use:"
2717 #: ../src/guestfs.pod:1396
2720 " AC_CHECK_LIB([guestfs],[guestfs_create])\n"
2721 " AC_CHECK_FUNCS([guestfs_dd])\n"
2726 #: ../src/guestfs.pod:1399
2728 "which would result in C<HAVE_GUESTFS_DD> being either defined or not defined "
2733 #: ../src/guestfs.pod:1402
2734 msgid "SINGLE CALLS AT RUN TIME"
2738 #: ../src/guestfs.pod:1404
2740 "Testing at compile time doesn't guarantee that a function really exists in "
2741 "the library. The reason is that you might be dynamically linked against a "
2742 "previous I<libguestfs.so> (dynamic library) which doesn't have the call. "
2743 "This situation unfortunately results in a segmentation fault, which is a "
2744 "shortcoming of the C dynamic linking system itself."
2748 #: ../src/guestfs.pod:1411
2750 "You can use L<dlopen(3)> to test if a function is available at run time, as "
2751 "in this example program (note that you still need the compile time check as "
2756 #: ../src/guestfs.pod:1415
2759 " #include <stdio.h>\n"
2760 " #include <stdlib.h>\n"
2761 " #include <unistd.h>\n"
2762 " #include <dlfcn.h>\n"
2763 " #include <guestfs.h>\n"
2768 #: ../src/guestfs.pod:1421
2773 " #ifdef LIBGUESTFS_HAVE_DD\n"
2775 " int has_function;\n"
2780 #: ../src/guestfs.pod:1427
2783 " /* Test if the function guestfs_dd is really available. */\n"
2784 " dl = dlopen (NULL, RTLD_LAZY);\n"
2786 " fprintf (stderr, \"dlopen: %s\\n\", dlerror ());\n"
2787 " exit (EXIT_FAILURE);\n"
2789 " has_function = dlsym (dl, \"guestfs_dd\") != NULL;\n"
2795 #: ../src/guestfs.pod:1436
2798 " if (!has_function)\n"
2799 " printf (\"this libguestfs.so does NOT have guestfs_dd function\\n\");\n"
2801 " printf (\"this libguestfs.so has guestfs_dd function\\n\");\n"
2802 " /* Now it's safe to call\n"
2803 " guestfs_dd (g, \"foo\", \"bar\");\n"
2807 " printf (\"guestfs_dd function was not found at compile time\\n\");\n"
2814 #: ../src/guestfs.pod:1449
2816 "You may think the above is an awful lot of hassle, and it is. There are "
2817 "other ways outside of the C linking system to ensure that this kind of "
2818 "incompatibility never arises, such as using package versioning:"
2822 #: ../src/guestfs.pod:1454
2825 " Requires: libguestfs >= 1.0.80\n"
2830 #: ../src/guestfs.pod:1456
2831 msgid "CALLS WITH OPTIONAL ARGUMENTS"
2835 #: ../src/guestfs.pod:1458
2837 "A recent feature of the API is the introduction of calls which take optional "
2838 "arguments. In C these are declared 3 ways. The main way is as a call which "
2839 "takes variable arguments (ie. C<...>), as in this example:"
2843 #: ../src/guestfs.pod:1463
2846 " int guestfs_add_drive_opts (guestfs_h *g, const char *filename, ...);\n"
2851 #: ../src/guestfs.pod:1465
2853 "Call this with a list of optional arguments, terminated by C<-1>. So to "
2854 "call with no optional arguments specified:"
2858 #: ../src/guestfs.pod:1468
2861 " guestfs_add_drive_opts (g, filename, -1);\n"
2866 #: ../src/guestfs.pod:1470
2867 msgid "With a single optional argument:"
2871 #: ../src/guestfs.pod:1472
2874 " guestfs_add_drive_opts (g, filename,\n"
2875 " GUESTFS_ADD_DRIVE_OPTS_FORMAT, \"qcow2\",\n"
2881 #: ../src/guestfs.pod:1476
2886 #: ../src/guestfs.pod:1478
2889 " guestfs_add_drive_opts (g, filename,\n"
2890 " GUESTFS_ADD_DRIVE_OPTS_FORMAT, \"qcow2\",\n"
2891 " GUESTFS_ADD_DRIVE_OPTS_READONLY, 1,\n"
2897 #: ../src/guestfs.pod:1483
2899 "and so forth. Don't forget the terminating C<-1> otherwise Bad Things will "
2904 #: ../src/guestfs.pod:1486
2905 msgid "USING va_list FOR OPTIONAL ARGUMENTS"
2909 #: ../src/guestfs.pod:1488
2911 "The second variant has the same name with the suffix C<_va>, which works the "
2912 "same way but takes a C<va_list>. See the C manual for details. For the "
2913 "example function, this is declared:"
2917 #: ../src/guestfs.pod:1492
2920 " int guestfs_add_drive_opts_va (guestfs_h *g, const char *filename,\n"
2926 #: ../src/guestfs.pod:1495
2927 msgid "CONSTRUCTING OPTIONAL ARGUMENTS"
2931 #: ../src/guestfs.pod:1497
2933 "The third variant is useful where you need to construct these calls. You "
2934 "pass in a structure where you fill in the optional fields. The structure "
2935 "has a bitmask as the first element which you must set to indicate which "
2936 "fields you have filled in. For our example function the structure and call "
2941 #: ../src/guestfs.pod:1503
2944 " struct guestfs_add_drive_opts_argv {\n"
2945 " uint64_t bitmask;\n"
2947 " const char *format;\n"
2950 " int guestfs_add_drive_opts_argv (guestfs_h *g, const char *filename,\n"
2951 " const struct guestfs_add_drive_opts_argv *optargs);\n"
2956 #: ../src/guestfs.pod:1512
2957 msgid "You could call it like this:"
2961 #: ../src/guestfs.pod:1514
2964 " struct guestfs_add_drive_opts_argv optargs = {\n"
2965 " .bitmask = GUESTFS_ADD_DRIVE_OPTS_READONLY_BITMASK |\n"
2966 " GUESTFS_ADD_DRIVE_OPTS_FORMAT_BITMASK,\n"
2968 " .format = \"qcow2\"\n"
2974 #: ../src/guestfs.pod:1521
2977 " guestfs_add_drive_opts_argv (g, filename, &optargs);\n"
2982 #: ../src/guestfs.pod:1523 ../src/guestfs-actions.pod:11 ../src/guestfs-actions.pod:1844 ../fish/guestfish-actions.pod:9 ../fish/guestfish-actions.pod:1255
2987 #: ../src/guestfs.pod:1529
2988 msgid "The C<_BITMASK> suffix on each option name when specifying the bitmask."
2992 #: ../src/guestfs.pod:1534
2993 msgid "You do not need to fill in all fields of the structure."
2997 #: ../src/guestfs.pod:1538
2999 "There must be a one-to-one correspondence between fields of the structure "
3000 "that are filled in, and bits set in the bitmask."
3004 #: ../src/guestfs.pod:1543
3005 msgid "OPTIONAL ARGUMENTS IN OTHER LANGUAGES"
3009 #: ../src/guestfs.pod:1545
3011 "In other languages, optional arguments are expressed in the way that is "
3012 "natural for that language. We refer you to the language-specific "
3013 "documentation for more details on that."
3017 #: ../src/guestfs.pod:1549
3018 msgid "For guestfish, see L<guestfish(1)/OPTIONAL ARGUMENTS>."
3022 #: ../src/guestfs.pod:1551
3023 msgid "SETTING CALLBACKS TO HANDLE EVENTS"
3027 #: ../src/guestfs.pod:1553
3029 "The child process generates events in some situations. Current events "
3030 "include: receiving a log message, the child process exits."
3034 #: ../src/guestfs.pod:1556
3036 "Use the C<guestfs_set_*_callback> functions to set a callback for different "
3041 #: ../src/guestfs.pod:1559
3043 "Only I<one callback of each type> can be registered for each handle. "
3044 "Calling C<guestfs_set_*_callback> again overwrites the previous callback of "
3045 "that type. Cancel all callbacks of this type by calling this function with "
3046 "C<cb> set to C<NULL>."
3050 #: ../src/guestfs.pod:1564
3051 msgid "guestfs_set_log_message_callback"
3055 #: ../src/guestfs.pod:1566
3058 " typedef void (*guestfs_log_message_cb) (guestfs_h *g, void *opaque,\n"
3059 " char *buf, int len);\n"
3060 " void guestfs_set_log_message_callback (guestfs_h *g,\n"
3061 " guestfs_log_message_cb cb,\n"
3067 #: ../src/guestfs.pod:1572
3069 "The callback function C<cb> will be called whenever qemu or the guest writes "
3070 "anything to the console."
3074 #: ../src/guestfs.pod:1575
3075 msgid "Use this function to capture kernel messages and similar."
3079 #: ../src/guestfs.pod:1577
3081 "Normally there is no log message handler, and log messages are just "
3086 #: ../src/guestfs.pod:1580
3087 msgid "guestfs_set_subprocess_quit_callback"
3091 #: ../src/guestfs.pod:1582
3094 " typedef void (*guestfs_subprocess_quit_cb) (guestfs_h *g, void *opaque);\n"
3095 " void guestfs_set_subprocess_quit_callback (guestfs_h *g,\n"
3096 " guestfs_subprocess_quit_cb cb,\n"
3102 #: ../src/guestfs.pod:1587
3104 "The callback function C<cb> will be called when the child process quits, "
3105 "either asynchronously or if killed by L</guestfs_kill_subprocess>. (This "
3106 "corresponds to a transition from any state to the CONFIG state)."
3110 #: ../src/guestfs.pod:1592
3111 msgid "guestfs_set_launch_done_callback"
3115 #: ../src/guestfs.pod:1594
3118 " typedef void (*guestfs_launch_done_cb) (guestfs_h *g, void *opaque);\n"
3119 " void guestfs_set_launch_done_callback (guestfs_h *g,\n"
3120 " guestfs_launch_done_cb cb,\n"
3126 #: ../src/guestfs.pod:1599
3128 "The callback function C<cb> will be called when the child process becomes "
3129 "ready first time after it has been launched. (This corresponds to a "
3130 "transition from LAUNCHING to the READY state)."
3134 #: ../src/guestfs.pod:1603
3135 msgid "guestfs_set_close_callback"
3139 #: ../src/guestfs.pod:1605
3142 " typedef void (*guestfs_close_cb) (guestfs_h *g, void *opaque);\n"
3143 " void guestfs_set_close_callback (guestfs_h *g,\n"
3144 " guestfs_close_cb cb,\n"
3150 #: ../src/guestfs.pod:1610
3152 "The callback function C<cb> will be called while the handle is being closed "
3153 "(synchronously from L</guestfs_close>)."
3157 #: ../src/guestfs.pod:1613
3159 "Note that libguestfs installs an L<atexit(3)> handler to try to clean up "
3160 "handles that are open when the program exits. This means that this callback "
3161 "might be called indirectly from L<exit(3)>, which can cause unexpected "
3162 "problems in higher-level languages (eg. if your HLL interpreter has already "
3163 "been cleaned up by the time this is called, and if your callback then jumps "
3164 "into some HLL function)."
3168 #: ../src/guestfs.pod:1621
3169 msgid "guestfs_set_progress_callback"
3173 #: ../src/guestfs.pod:1623
3176 " typedef void (*guestfs_progress_cb) (guestfs_h *g, void *opaque,\n"
3177 " int proc_nr, int serial,\n"
3178 " uint64_t position, uint64_t total);\n"
3179 " void guestfs_set_progress_callback (guestfs_h *g,\n"
3180 " guestfs_progress_cb cb,\n"
3186 #: ../src/guestfs.pod:1630
3188 "Some long-running operations can generate progress messages. If this "
3189 "callback is registered, then it will be called each time a progress message "
3190 "is generated (usually two seconds after the operation started, and three "
3191 "times per second thereafter until it completes, although the frequency may "
3192 "change in future versions)."
3196 #: ../src/guestfs.pod:1636
3198 "The callback receives two numbers: C<position> and C<total>. The units of "
3199 "C<total> are not defined, although for some operations C<total> may relate "
3200 "in some way to the amount of data to be transferred (eg. in bytes or "
3201 "megabytes), and C<position> may be the portion which has been transferred."
3205 #: ../src/guestfs.pod:1642
3206 msgid "The only defined and stable parts of the API are:"
3210 #: ../src/guestfs.pod:1648
3212 "The callback can display to the user some type of progress bar or indicator "
3213 "which shows the ratio of C<position>:C<total>."
3217 #: ../src/guestfs.pod:1653
3218 msgid "0 E<lt>= C<position> E<lt>= C<total>"
3222 #: ../src/guestfs.pod:1657
3224 "If any progress notification is sent during a call, then a final progress "
3225 "notification is always sent when C<position> = C<total>."
3229 #: ../src/guestfs.pod:1660
3231 "This is to simplify caller code, so callers can easily set the progress "
3232 "indicator to \"100%\" at the end of the operation, without requiring special "
3233 "code to detect this case."
3237 #: ../src/guestfs.pod:1666
3239 "The callback also receives the procedure number and serial number of the "
3240 "call. These are only useful for debugging protocol issues, and the callback "
3241 "can normally ignore them. The callback may want to print these numbers in "
3242 "error messages or debugging messages."
3246 #: ../src/guestfs.pod:1671
3247 msgid "PRIVATE DATA AREA"
3251 #: ../src/guestfs.pod:1673
3253 "You can attach named pieces of private data to the libguestfs handle, and "
3254 "fetch them by name for the lifetime of the handle. This is called the "
3255 "private data area and is only available from the C API."
3259 #: ../src/guestfs.pod:1677
3260 msgid "To attach a named piece of data, use the following call:"
3264 #: ../src/guestfs.pod:1679
3267 " void guestfs_set_private (guestfs_h *g, const char *key, void *data);\n"
3272 #: ../src/guestfs.pod:1681
3274 "C<key> is the name to associate with this data, and C<data> is an arbitrary "
3275 "pointer (which can be C<NULL>). Any previous item with the same name is "
3280 #: ../src/guestfs.pod:1685
3282 "You can use any C<key> you want, but names beginning with an underscore "
3283 "character are reserved for internal libguestfs purposes (for implementing "
3284 "language bindings). It is recommended to prefix the name with some unique "
3285 "string to avoid collisions with other users."
3289 #: ../src/guestfs.pod:1690
3290 msgid "To retrieve the pointer, use:"
3294 #: ../src/guestfs.pod:1692
3297 " void *guestfs_get_private (guestfs_h *g, const char *key);\n"
3302 #: ../src/guestfs.pod:1694
3304 "This function returns C<NULL> if either no data is found associated with "
3305 "C<key>, or if the user previously set the C<key>'s C<data> pointer to "
3310 #: ../src/guestfs.pod:1698
3312 "Libguestfs does not try to look at or interpret the C<data> pointer in any "
3313 "way. As far as libguestfs is concerned, it need not be a valid pointer at "
3314 "all. In particular, libguestfs does I<not> try to free the data when the "
3315 "handle is closed. If the data must be freed, then the caller must either "
3316 "free it before calling L</guestfs_close> or must set up a close callback to "
3317 "do it (see L</guestfs_set_close_callback>, and note that only one callback "
3318 "can be registered for a handle)."
3322 #: ../src/guestfs.pod:1706
3324 "The private data area is implemented using a hash table, and should be "
3325 "reasonably efficient for moderate numbers of keys."
3329 #: ../src/guestfs.pod:1709 ../src/guestfs.pod:1714
3334 #: ../src/guestfs.pod:1711
3336 "<!-- old anchor for the next section --> <a "
3337 "name=\"state_machine_and_low_level_event_api\"/>"
3341 #: ../src/guestfs.pod:1716
3342 msgid "ARCHITECTURE"
3346 #: ../src/guestfs.pod:1718
3348 "Internally, libguestfs is implemented by running an appliance (a special "
3349 "type of small virtual machine) using L<qemu(1)>. Qemu runs as a child "
3350 "process of the main program."
3354 #: ../src/guestfs.pod:1722
3357 " ___________________\n"
3359 " | main program |\n"
3361 " | | child process / appliance\n"
3362 " | | __________________________\n"
3364 " +-------------------+ RPC | +-----------------+ |\n"
3365 " | libguestfs <--------------------> guestfsd | |\n"
3366 " | | | +-----------------+ |\n"
3367 " \\___________________/ | | Linux kernel | |\n"
3368 " | +--^--------------+ |\n"
3369 " \\_________|________________/\n"
3375 " \\______________/\n"
3380 #: ../src/guestfs.pod:1742
3382 "The library, linked to the main program, creates the child process and hence "
3383 "the appliance in the L</guestfs_launch> function."
3387 #: ../src/guestfs.pod:1745
3389 "Inside the appliance is a Linux kernel and a complete stack of userspace "
3390 "tools (such as LVM and ext2 programs) and a small controlling daemon called "
3391 "L</guestfsd>. The library talks to L</guestfsd> using remote procedure "
3392 "calls (RPC). There is a mostly one-to-one correspondence between libguestfs "
3393 "API calls and RPC calls to the daemon. Lastly the disk image(s) are "
3394 "attached to the qemu process which translates device access by the "
3395 "appliance's Linux kernel into accesses to the image."
3399 #: ../src/guestfs.pod:1754
3401 "A common misunderstanding is that the appliance \"is\" the virtual machine. "
3402 "Although the disk image you are attached to might also be used by some "
3403 "virtual machine, libguestfs doesn't know or care about this. (But you will "
3404 "care if both libguestfs's qemu process and your virtual machine are trying "
3405 "to update the disk image at the same time, since these usually results in "
3406 "massive disk corruption)."
3410 #: ../src/guestfs.pod:1761
3411 msgid "STATE MACHINE"
3415 #: ../src/guestfs.pod:1763
3416 msgid "libguestfs uses a state machine to model the child process:"
3420 #: ../src/guestfs.pod:1765
3432 " / | \\ \\ guestfs_launch\n"
3433 " / | _\\__V______\n"
3435 " / | | LAUNCHING |\n"
3436 " / | \\___________/\n"
3438 " / | guestfs_launch\n"
3440 " ______ / __|____V\n"
3441 " / \\ ------> / \\\n"
3442 " | BUSY | | READY |\n"
3443 " \\______/ <------ \\________/\n"
3448 #: ../src/guestfs.pod:1787
3450 "The normal transitions are (1) CONFIG (when the handle is created, but there "
3451 "is no child process), (2) LAUNCHING (when the child process is booting up), "
3452 "(3) alternating between READY and BUSY as commands are issued to, and "
3453 "carried out by, the child process."
3457 #: ../src/guestfs.pod:1792
3459 "The guest may be killed by L</guestfs_kill_subprocess>, or may die "
3460 "asynchronously at any time (eg. due to some internal error), and that causes "
3461 "the state to transition back to CONFIG."
3465 #: ../src/guestfs.pod:1796
3467 "Configuration commands for qemu such as L</guestfs_add_drive> can only be "
3468 "issued when in the CONFIG state."
3472 #: ../src/guestfs.pod:1799
3474 "The API offers one call that goes from CONFIG through LAUNCHING to READY. "
3475 "L</guestfs_launch> blocks until the child process is READY to accept "
3476 "commands (or until some failure or timeout). L</guestfs_launch> internally "
3477 "moves the state from CONFIG to LAUNCHING while it is running."
3481 #: ../src/guestfs.pod:1805
3483 "API actions such as L</guestfs_mount> can only be issued when in the READY "
3484 "state. These API calls block waiting for the command to be carried out "
3485 "(ie. the state to transition to BUSY and then back to READY). There are no "
3486 "non-blocking versions, and no way to issue more than one command per handle "
3491 #: ../src/guestfs.pod:1811
3493 "Finally, the child process sends asynchronous messages back to the main "
3494 "program, such as kernel log messages. You can register a callback to "
3495 "receive these messages."
3499 #: ../src/guestfs.pod:1815
3504 #: ../src/guestfs.pod:1817
3505 msgid "COMMUNICATION PROTOCOL"
3509 #: ../src/guestfs.pod:1819
3511 "Don't rely on using this protocol directly. This section documents how it "
3512 "currently works, but it may change at any time."
3516 #: ../src/guestfs.pod:1822
3518 "The protocol used to talk between the library and the daemon running inside "
3519 "the qemu virtual machine is a simple RPC mechanism built on top of XDR (RFC "
3520 "1014, RFC 1832, RFC 4506)."
3524 #: ../src/guestfs.pod:1826
3526 "The detailed format of structures is in C<src/guestfs_protocol.x> (note: "
3527 "this file is automatically generated)."
3531 #: ../src/guestfs.pod:1829
3533 "There are two broad cases, ordinary functions that don't have any C<FileIn> "
3534 "and C<FileOut> parameters, which are handled with very simple request/reply "
3535 "messages. Then there are functions that have any C<FileIn> or C<FileOut> "
3536 "parameters, which use the same request and reply messages, but they may also "
3537 "be followed by files sent using a chunked encoding."
3541 #: ../src/guestfs.pod:1836
3542 msgid "ORDINARY FUNCTIONS (NO FILEIN/FILEOUT PARAMS)"
3546 #: ../src/guestfs.pod:1838
3547 msgid "For ordinary functions, the request message is:"
3551 #: ../src/guestfs.pod:1840
3554 " total length (header + arguments,\n"
3555 " but not including the length word itself)\n"
3556 " struct guestfs_message_header (encoded as XDR)\n"
3557 " struct guestfs_<foo>_args (encoded as XDR)\n"
3562 #: ../src/guestfs.pod:1845
3564 "The total length field allows the daemon to allocate a fixed size buffer "
3565 "into which it slurps the rest of the message. As a result, the total length "
3566 "is limited to C<GUESTFS_MESSAGE_MAX> bytes (currently 4MB), which means the "
3567 "effective size of any request is limited to somewhere under this size."
3571 #: ../src/guestfs.pod:1851
3573 "Note also that many functions don't take any arguments, in which case the "
3574 "C<guestfs_I<foo>_args> is completely omitted."
3578 #: ../src/guestfs.pod:1854
3580 "The header contains the procedure number (C<guestfs_proc>) which is how the "
3581 "receiver knows what type of args structure to expect, or none at all."
3585 #: ../src/guestfs.pod:1858
3586 msgid "The reply message for ordinary functions is:"
3590 #: ../src/guestfs.pod:1860
3593 " total length (header + ret,\n"
3594 " but not including the length word itself)\n"
3595 " struct guestfs_message_header (encoded as XDR)\n"
3596 " struct guestfs_<foo>_ret (encoded as XDR)\n"
3601 #: ../src/guestfs.pod:1865
3603 "As above the C<guestfs_I<foo>_ret> structure may be completely omitted for "
3604 "functions that return no formal return values."
3608 #: ../src/guestfs.pod:1868
3609 msgid "As above the total length of the reply is limited to C<GUESTFS_MESSAGE_MAX>."
3613 #: ../src/guestfs.pod:1871
3615 "In the case of an error, a flag is set in the header, and the reply message "
3616 "is slightly changed:"
3620 #: ../src/guestfs.pod:1874
3623 " total length (header + error,\n"
3624 " but not including the length word itself)\n"
3625 " struct guestfs_message_header (encoded as XDR)\n"
3626 " struct guestfs_message_error (encoded as XDR)\n"
3631 #: ../src/guestfs.pod:1879
3633 "The C<guestfs_message_error> structure contains the error message as a "
3638 #: ../src/guestfs.pod:1882
3639 msgid "FUNCTIONS THAT HAVE FILEIN PARAMETERS"
3643 #: ../src/guestfs.pod:1884
3645 "A C<FileIn> parameter indicates that we transfer a file I<into> the guest. "
3646 "The normal request message is sent (see above). However this is followed by "
3647 "a sequence of file chunks."
3651 #: ../src/guestfs.pod:1888
3654 " total length (header + arguments,\n"
3655 " but not including the length word itself,\n"
3656 " and not including the chunks)\n"
3657 " struct guestfs_message_header (encoded as XDR)\n"
3658 " struct guestfs_<foo>_args (encoded as XDR)\n"
3659 " sequence of chunks for FileIn param #0\n"
3660 " sequence of chunks for FileIn param #1 etc.\n"
3665 #: ../src/guestfs.pod:1896
3666 msgid "The \"sequence of chunks\" is:"
3670 #: ../src/guestfs.pod:1898
3673 " length of chunk (not including length word itself)\n"
3674 " struct guestfs_chunk (encoded as XDR)\n"
3675 " length of chunk\n"
3676 " struct guestfs_chunk (encoded as XDR)\n"
3678 " length of chunk\n"
3679 " struct guestfs_chunk (with data.data_len == 0)\n"
3684 #: ../src/guestfs.pod:1906
3686 "The final chunk has the C<data_len> field set to zero. Additionally a flag "
3687 "is set in the final chunk to indicate either successful completion or early "
3692 #: ../src/guestfs.pod:1910
3694 "At time of writing there are no functions that have more than one FileIn "
3695 "parameter. However this is (theoretically) supported, by sending the "
3696 "sequence of chunks for each FileIn parameter one after another (from left to "
3701 #: ../src/guestfs.pod:1915
3703 "Both the library (sender) I<and> the daemon (receiver) may cancel the "
3704 "transfer. The library does this by sending a chunk with a special flag set "
3705 "to indicate cancellation. When the daemon sees this, it cancels the whole "
3706 "RPC, does I<not> send any reply, and goes back to reading the next request."
3710 #: ../src/guestfs.pod:1921
3712 "The daemon may also cancel. It does this by writing a special word "
3713 "C<GUESTFS_CANCEL_FLAG> to the socket. The library listens for this during "
3714 "the transfer, and if it gets it, it will cancel the transfer (it sends a "
3715 "cancel chunk). The special word is chosen so that even if cancellation "
3716 "happens right at the end of the transfer (after the library has finished "
3717 "writing and has started listening for the reply), the \"spurious\" cancel "
3718 "flag will not be confused with the reply message."
3722 #: ../src/guestfs.pod:1930
3724 "This protocol allows the transfer of arbitrary sized files (no 32 bit "
3725 "limit), and also files where the size is not known in advance (eg. from "
3726 "pipes or sockets). However the chunks are rather small "
3727 "(C<GUESTFS_MAX_CHUNK_SIZE>), so that neither the library nor the daemon need "
3728 "to keep much in memory."
3732 #: ../src/guestfs.pod:1936
3733 msgid "FUNCTIONS THAT HAVE FILEOUT PARAMETERS"
3737 #: ../src/guestfs.pod:1938
3739 "The protocol for FileOut parameters is exactly the same as for FileIn "
3740 "parameters, but with the roles of daemon and library reversed."
3744 #: ../src/guestfs.pod:1941
3747 " total length (header + ret,\n"
3748 " but not including the length word itself,\n"
3749 " and not including the chunks)\n"
3750 " struct guestfs_message_header (encoded as XDR)\n"
3751 " struct guestfs_<foo>_ret (encoded as XDR)\n"
3752 " sequence of chunks for FileOut param #0\n"
3753 " sequence of chunks for FileOut param #1 etc.\n"
3758 #: ../src/guestfs.pod:1949
3759 msgid "INITIAL MESSAGE"
3763 #: ../src/guestfs.pod:1951
3765 "When the daemon launches it sends an initial word (C<GUESTFS_LAUNCH_FLAG>) "
3766 "which indicates that the guest and daemon is alive. This is what "
3767 "L</guestfs_launch> waits for."
3771 #: ../src/guestfs.pod:1955
3772 msgid "PROGRESS NOTIFICATION MESSAGES"
3776 #: ../src/guestfs.pod:1957
3778 "The daemon may send progress notification messages at any time. These are "
3779 "distinguished by the normal length word being replaced by "
3780 "C<GUESTFS_PROGRESS_FLAG>, followed by a fixed size progress message."
3784 #: ../src/guestfs.pod:1961
3786 "The library turns them into progress callbacks (see "
3787 "C<guestfs_set_progress_callback>) if there is a callback registered, or "
3788 "discards them if not."
3792 #: ../src/guestfs.pod:1965
3794 "The daemon self-limits the frequency of progress messages it sends (see "
3795 "C<daemon/proto.c:notify_progress>). Not all calls generate progress "
3800 #: ../src/guestfs.pod:1969
3801 msgid "LIBGUESTFS VERSION NUMBERS"
3805 #: ../src/guestfs.pod:1971
3807 "Since April 2010, libguestfs has started to make separate development and "
3808 "stable releases, along with corresponding branches in our git repository. "
3809 "These separate releases can be identified by version number:"
3813 #: ../src/guestfs.pod:1976
3816 " even numbers for stable: 1.2.x, 1.4.x, ...\n"
3817 " .-------- odd numbers for development: 1.3.x, 1.5.x, ...\n"
3823 " | `-------- sub-version\n"
3825 " `------ always '1' because we don't change the ABI\n"
3830 #: ../src/guestfs.pod:1987
3831 msgid "Thus \"1.3.5\" is the 5th update to the development branch \"1.3\"."
3835 #: ../src/guestfs.pod:1989
3837 "As time passes we cherry pick fixes from the development branch and backport "
3838 "those into the stable branch, the effect being that the stable branch should "
3839 "get more stable and less buggy over time. So the stable releases are ideal "
3840 "for people who don't need new features but would just like the software to "
3845 #: ../src/guestfs.pod:1995
3846 msgid "Our criteria for backporting changes are:"
3850 #: ../src/guestfs.pod:2001
3852 "Documentation changes which don't affect any code are backported unless the "
3853 "documentation refers to a future feature which is not in stable."
3857 #: ../src/guestfs.pod:2007
3859 "Bug fixes which are not controversial, fix obvious problems, and have been "
3860 "well tested are backported."
3864 #: ../src/guestfs.pod:2012
3866 "Simple rearrangements of code which shouldn't affect how it works get "
3867 "backported. This is so that the code in the two branches doesn't get too "
3868 "far out of step, allowing us to backport future fixes more easily."
3872 #: ../src/guestfs.pod:2018
3874 "We I<don't> backport new features, new APIs, new tools etc, except in one "
3875 "exceptional case: the new feature is required in order to implement an "
3876 "important bug fix."
3880 #: ../src/guestfs.pod:2024
3882 "A new stable branch starts when we think the new features in development are "
3883 "substantial and compelling enough over the current stable branch to warrant "
3884 "it. When that happens we create new stable and development versions 1.N.0 "
3885 "and 1.(N+1).0 [N is even]. The new dot-oh release won't necessarily be so "
3886 "stable at this point, but by backporting fixes from development, that branch "
3887 "will stabilize over time."
3891 #: ../src/guestfs.pod:2032 ../fish/guestfish.pod:915 ../test-tool/libguestfs-test-tool.pod:104 ../tools/virt-edit.pl:330
3892 msgid "ENVIRONMENT VARIABLES"
3896 #: ../src/guestfs.pod:2036 ../fish/guestfish.pod:941
3897 msgid "LIBGUESTFS_APPEND"
3901 #: ../src/guestfs.pod:2038 ../fish/guestfish.pod:943
3902 msgid "Pass additional options to the guest kernel."
3906 #: ../src/guestfs.pod:2040 ../fish/guestfish.pod:945
3907 msgid "LIBGUESTFS_DEBUG"
3911 #: ../src/guestfs.pod:2042
3913 "Set C<LIBGUESTFS_DEBUG=1> to enable verbose messages. This has the same "
3914 "effect as calling C<guestfs_set_verbose (g, 1)>."
3918 #: ../src/guestfs.pod:2045 ../fish/guestfish.pod:950
3919 msgid "LIBGUESTFS_MEMSIZE"
3923 #: ../src/guestfs.pod:2047 ../fish/guestfish.pod:952
3924 msgid "Set the memory allocated to the qemu process, in megabytes. For example:"
3928 #: ../src/guestfs.pod:2050 ../fish/guestfish.pod:955
3931 " LIBGUESTFS_MEMSIZE=700\n"
3936 #: ../src/guestfs.pod:2052 ../fish/guestfish.pod:957
3937 msgid "LIBGUESTFS_PATH"
3941 #: ../src/guestfs.pod:2054
3943 "Set the path that libguestfs uses to search for kernel and initrd.img. See "
3944 "the discussion of paths in section PATH above."
3948 #: ../src/guestfs.pod:2057 ../fish/guestfish.pod:962
3949 msgid "LIBGUESTFS_QEMU"
3953 #: ../src/guestfs.pod:2059 ../fish/guestfish.pod:964
3955 "Set the default qemu binary that libguestfs uses. If not set, then the qemu "
3956 "which was found at compile time by the configure script is used."
3960 #: ../src/guestfs.pod:2063
3961 msgid "See also L</QEMU WRAPPERS> above."
3965 #: ../src/guestfs.pod:2065 ../fish/guestfish.pod:968
3966 msgid "LIBGUESTFS_TRACE"
3970 #: ../src/guestfs.pod:2067
3972 "Set C<LIBGUESTFS_TRACE=1> to enable command traces. This has the same "
3973 "effect as calling C<guestfs_set_trace (g, 1)>."
3977 #: ../src/guestfs.pod:2070 ../fish/guestfish.pod:977
3982 #: ../src/guestfs.pod:2072 ../fish/guestfish.pod:979
3983 msgid "Location of temporary directory, defaults to C</tmp>."
3987 #: ../src/guestfs.pod:2074 ../fish/guestfish.pod:981
3989 "If libguestfs was compiled to use the supermin appliance then the real "
3990 "appliance is cached in this directory, shared between all handles belonging "
3991 "to the same EUID. You can use C<$TMPDIR> to configure another directory to "
3992 "use in case C</tmp> is not large enough."
3996 #: ../src/guestfs.pod:2082 ../fish/guestfish.pod:1039 ../test-tool/libguestfs-test-tool.pod:109 ../fuse/guestmount.pod:233 ../tools/virt-edit.pl:350 ../tools/virt-win-reg.pl:484 ../tools/virt-resize.pl:1483 ../tools/virt-list-filesystems.pl:189 ../tools/virt-tar.pl:281 ../tools/virt-make-fs.pl:534 ../tools/virt-list-partitions.pl:257
4001 #: ../src/guestfs.pod:2084
4003 "L<guestfs-examples(3)>, L<guestfs-ocaml(3)>, L<guestfs-python(3)>, "
4004 "L<guestfs-ruby(3)>, L<guestfish(1)>, L<guestmount(1)>, L<virt-cat(1)>, "
4005 "L<virt-df(1)>, L<virt-edit(1)>, L<virt-filesystems(1)>, "
4006 "L<virt-inspector(1)>, L<virt-list-filesystems(1)>, "
4007 "L<virt-list-partitions(1)>, L<virt-ls(1)>, L<virt-make-fs(1)>, "
4008 "L<virt-rescue(1)>, L<virt-tar(1)>, L<virt-win-reg(1)>, L<qemu(1)>, "
4009 "L<febootstrap(1)>, L<hivex(3)>, L<http://libguestfs.org/>."
4013 #: ../src/guestfs.pod:2107
4015 "Tools with a similar purpose: L<fdisk(8)>, L<parted(8)>, L<kpartx(8)>, "
4016 "L<lvm(8)>, L<disktype(1)>."
4020 #: ../src/guestfs.pod:2114 ../tools/virt-win-reg.pl:499 ../tools/virt-make-fs.pl:548
4025 #: ../src/guestfs.pod:2116
4026 msgid "To get a list of bugs against libguestfs use this link:"
4030 #: ../src/guestfs.pod:2118
4031 msgid "L<https://bugzilla.redhat.com/buglist.cgi?component=libguestfs&product=Virtualization+Tools>"
4035 #: ../src/guestfs.pod:2120
4036 msgid "To report a new bug against libguestfs use this link:"
4040 #: ../src/guestfs.pod:2122
4041 msgid "L<https://bugzilla.redhat.com/enter_bug.cgi?component=libguestfs&product=Virtualization+Tools>"
4045 #: ../src/guestfs.pod:2124
4046 msgid "When reporting a bug, please check:"
4050 #: ../src/guestfs.pod:2130
4051 msgid "That the bug hasn't been reported already."
4055 #: ../src/guestfs.pod:2134
4056 msgid "That you are testing a recent version."
4060 #: ../src/guestfs.pod:2138
4061 msgid "Describe the bug accurately, and give a way to reproduce it."
4065 #: ../src/guestfs.pod:2142
4067 "Run libguestfs-test-tool and paste the B<complete, unedited> output into the "
4072 #: ../src/guestfs.pod:2147 ../fish/guestfish.pod:1058 ../test-tool/libguestfs-test-tool.pod:115 ../fuse/guestmount.pod:244
4077 #: ../src/guestfs.pod:2149 ../fish/guestfish.pod:1060 ../test-tool/libguestfs-test-tool.pod:117 ../fuse/guestmount.pod:246
4078 msgid "Richard W.M. Jones (C<rjones at redhat dot com>)"
4082 #: ../src/guestfs.pod:2151 ../fish/guestfish.pod:1062 ../test-tool/libguestfs-test-tool.pod:119 ../fuse/guestmount.pod:248 ../tools/virt-edit.pl:366 ../tools/virt-win-reg.pl:514 ../tools/virt-resize.pl:1508 ../tools/virt-list-filesystems.pl:206 ../tools/virt-tar.pl:296 ../tools/virt-make-fs.pl:563 ../tools/virt-list-partitions.pl:273
4087 #: ../src/guestfs.pod:2153 ../fish/guestfish.pod:1064 ../fuse/guestmount.pod:250
4088 msgid "Copyright (C) 2009-2010 Red Hat Inc. L<http://libguestfs.org/>"
4092 #: ../src/guestfs.pod:2156
4094 "This library is free software; you can redistribute it and/or modify it "
4095 "under the terms of the GNU Lesser General Public License as published by the "
4096 "Free Software Foundation; either version 2 of the License, or (at your "
4097 "option) any later version."
4101 #: ../src/guestfs.pod:2161
4103 "This library is distributed in the hope that it will be useful, but WITHOUT "
4104 "ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or "
4105 "FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License "
4110 #: ../src/guestfs.pod:2166
4112 "You should have received a copy of the GNU Lesser General Public License "
4113 "along with this library; if not, write to the Free Software Foundation, "
4114 "Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA"
4118 #: ../src/guestfs-actions.pod:1
4119 msgid "guestfs_add_cdrom"
4123 #: ../src/guestfs-actions.pod:3
4127 " guestfs_add_cdrom (guestfs_h *g,\n"
4128 " const char *filename);\n"
4133 #: ../src/guestfs-actions.pod:7 ../fish/guestfish-actions.pod:5
4134 msgid "This function adds a virtual CD-ROM disk image to the guest."
4138 #: ../src/guestfs-actions.pod:9 ../fish/guestfish-actions.pod:7
4139 msgid "This is equivalent to the qemu parameter C<-cdrom filename>."
4143 #: ../src/guestfs-actions.pod:17
4145 "This call checks for the existence of C<filename>. This stops you from "
4146 "specifying other types of drive which are supported by qemu such as C<nbd:> "
4147 "and C<http:> URLs. To specify those, use the general C<guestfs_config> call "
4152 #: ../src/guestfs-actions.pod:24
4154 "If you just want to add an ISO file (often you use this as an efficient way "
4155 "to transfer large files into the guest), then you should probably use "
4156 "C<guestfs_add_drive_ro> instead."
4160 #: ../src/guestfs-actions.pod:30 ../src/guestfs-actions.pod:128 ../src/guestfs-actions.pod:189 ../src/guestfs-actions.pod:226 ../src/guestfs-actions.pod:240 ../src/guestfs-actions.pod:261 ../src/guestfs-actions.pod:281 ../src/guestfs-actions.pod:295 ../src/guestfs-actions.pod:410 ../src/guestfs-actions.pod:430 ../src/guestfs-actions.pod:444 ../src/guestfs-actions.pod:489 ../src/guestfs-actions.pod:517 ../src/guestfs-actions.pod:535 ../src/guestfs-actions.pod:602 ../src/guestfs-actions.pod:635 ../src/guestfs-actions.pod:649 ../src/guestfs-actions.pod:664 ../src/guestfs-actions.pod:763 ../src/guestfs-actions.pod:781 ../src/guestfs-actions.pod:795 ../src/guestfs-actions.pod:809 ../src/guestfs-actions.pod:970 ../src/guestfs-actions.pod:990 ../src/guestfs-actions.pod:1008 ../src/guestfs-actions.pod:1092 ../src/guestfs-actions.pod:1110 ../src/guestfs-actions.pod:1129 ../src/guestfs-actions.pod:1143 ../src/guestfs-actions.pod:1163 ../src/guestfs-actions.pod:1233 ../src/guestfs-actions.pod:1264 ../src/guestfs-actions.pod:1289 ../src/guestfs-actions.pod:1326 ../src/guestfs-actions.pod:1432 ../src/guestfs-actions.pod:1466 ../src/guestfs-actions.pod:1684 ../src/guestfs-actions.pod:1706 ../src/guestfs-actions.pod:1793 ../src/guestfs-actions.pod:2215 ../src/guestfs-actions.pod:2359 ../src/guestfs-actions.pod:2420 ../src/guestfs-actions.pod:2455 ../src/guestfs-actions.pod:3194 ../src/guestfs-actions.pod:3209 ../src/guestfs-actions.pod:3229 ../src/guestfs-actions.pod:3354 ../src/guestfs-actions.pod:3368 ../src/guestfs-actions.pod:3381 ../src/guestfs-actions.pod:3395 ../src/guestfs-actions.pod:3410 ../src/guestfs-actions.pod:3446 ../src/guestfs-actions.pod:3518 ../src/guestfs-actions.pod:3538 ../src/guestfs-actions.pod:3555 ../src/guestfs-actions.pod:3578 ../src/guestfs-actions.pod:3601 ../src/guestfs-actions.pod:3633 ../src/guestfs-actions.pod:3652 ../src/guestfs-actions.pod:3671 ../src/guestfs-actions.pod:3706 ../src/guestfs-actions.pod:3718 ../src/guestfs-actions.pod:3754 ../src/guestfs-actions.pod:3770 ../src/guestfs-actions.pod:3783 ../src/guestfs-actions.pod:3798 ../src/guestfs-actions.pod:3815 ../src/guestfs-actions.pod:3908 ../src/guestfs-actions.pod:3928 ../src/guestfs-actions.pod:3941 ../src/guestfs-actions.pod:3992 ../src/guestfs-actions.pod:4010 ../src/guestfs-actions.pod:4028 ../src/guestfs-actions.pod:4044 ../src/guestfs-actions.pod:4058 ../src/guestfs-actions.pod:4072 ../src/guestfs-actions.pod:4089 ../src/guestfs-actions.pod:4104 ../src/guestfs-actions.pod:4124 ../src/guestfs-actions.pod:4173 ../src/guestfs-actions.pod:4204 ../src/guestfs-actions.pod:4223 ../src/guestfs-actions.pod:4242 ../src/guestfs-actions.pod:4254 ../src/guestfs-actions.pod:4271 ../src/guestfs-actions.pod:4284 ../src/guestfs-actions.pod:4299 ../src/guestfs-actions.pod:4314 ../src/guestfs-actions.pod:4349 ../src/guestfs-actions.pod:4364 ../src/guestfs-actions.pod:4384 ../src/guestfs-actions.pod:4398 ../src/guestfs-actions.pod:4415 ../src/guestfs-actions.pod:4464 ../src/guestfs-actions.pod:4501 ../src/guestfs-actions.pod:4515 ../src/guestfs-actions.pod:4543 ../src/guestfs-actions.pod:4560 ../src/guestfs-actions.pod:4578 ../src/guestfs-actions.pod:4712 ../src/guestfs-actions.pod:4769 ../src/guestfs-actions.pod:4791 ../src/guestfs-actions.pod:4809 ../src/guestfs-actions.pod:4841 ../src/guestfs-actions.pod:4907 ../src/guestfs-actions.pod:4924 ../src/guestfs-actions.pod:4937 ../src/guestfs-actions.pod:4951 ../src/guestfs-actions.pod:5240 ../src/guestfs-actions.pod:5259 ../src/guestfs-actions.pod:5273 ../src/guestfs-actions.pod:5285 ../src/guestfs-actions.pod:5299 ../src/guestfs-actions.pod:5311 ../src/guestfs-actions.pod:5325 ../src/guestfs-actions.pod:5341 ../src/guestfs-actions.pod:5362 ../src/guestfs-actions.pod:5381 ../src/guestfs-actions.pod:5400 ../src/guestfs-actions.pod:5418 ../src/guestfs-actions.pod:5441 ../src/guestfs-actions.pod:5459 ../src/guestfs-actions.pod:5478 ../src/guestfs-actions.pod:5499 ../src/guestfs-actions.pod:5518 ../src/guestfs-actions.pod:5535 ../src/guestfs-actions.pod:5563 ../src/guestfs-actions.pod:5587 ../src/guestfs-actions.pod:5606 ../src/guestfs-actions.pod:5630 ../src/guestfs-actions.pod:5645 ../src/guestfs-actions.pod:5660 ../src/guestfs-actions.pod:5679 ../src/guestfs-actions.pod:5716 ../src/guestfs-actions.pod:5739 ../src/guestfs-actions.pod:5765 ../src/guestfs-actions.pod:5873 ../src/guestfs-actions.pod:5994 ../src/guestfs-actions.pod:6006 ../src/guestfs-actions.pod:6019 ../src/guestfs-actions.pod:6032 ../src/guestfs-actions.pod:6054 ../src/guestfs-actions.pod:6067 ../src/guestfs-actions.pod:6080 ../src/guestfs-actions.pod:6093 ../src/guestfs-actions.pod:6108 ../src/guestfs-actions.pod:6167 ../src/guestfs-actions.pod:6184 ../src/guestfs-actions.pod:6200 ../src/guestfs-actions.pod:6216 ../src/guestfs-actions.pod:6233 ../src/guestfs-actions.pod:6246 ../src/guestfs-actions.pod:6266 ../src/guestfs-actions.pod:6302 ../src/guestfs-actions.pod:6316 ../src/guestfs-actions.pod:6357 ../src/guestfs-actions.pod:6370 ../src/guestfs-actions.pod:6388 ../src/guestfs-actions.pod:6417 ../src/guestfs-actions.pod:6448 ../src/guestfs-actions.pod:6567 ../src/guestfs-actions.pod:6585 ../src/guestfs-actions.pod:6599 ../src/guestfs-actions.pod:6654 ../src/guestfs-actions.pod:6667 ../src/guestfs-actions.pod:6712 ../src/guestfs-actions.pod:6745 ../src/guestfs-actions.pod:6799 ../src/guestfs-actions.pod:6825 ../src/guestfs-actions.pod:6891 ../src/guestfs-actions.pod:6910 ../src/guestfs-actions.pod:6939
4161 msgid "This function returns 0 on success or -1 on error."
4165 #: ../src/guestfs-actions.pod:32 ../src/guestfs-actions.pod:242 ../src/guestfs-actions.pod:263 ../fish/guestfish-actions.pod:28 ../fish/guestfish-actions.pod:153 ../fish/guestfish-actions.pod:167
4167 "This function is deprecated. In new code, use the C<add_drive_opts> call "
4172 #: ../src/guestfs-actions.pod:35 ../src/guestfs-actions.pod:245 ../src/guestfs-actions.pod:266 ../src/guestfs-actions.pod:1437 ../src/guestfs-actions.pod:1923 ../src/guestfs-actions.pod:1944 ../src/guestfs-actions.pod:6833 ../src/guestfs-actions.pod:7002 ../fish/guestfish-actions.pod:31 ../fish/guestfish-actions.pod:156 ../fish/guestfish-actions.pod:170 ../fish/guestfish-actions.pod:951 ../fish/guestfish-actions.pod:1308 ../fish/guestfish-actions.pod:1322 ../fish/guestfish-actions.pod:4549 ../fish/guestfish-actions.pod:4646
4174 "Deprecated functions will not be removed from the API, but the fact that "
4175 "they are deprecated indicates that there are problems with correct use of "
4180 #: ../src/guestfs-actions.pod:39 ../src/guestfs-actions.pod:130 ../src/guestfs-actions.pod:1094 ../src/guestfs-actions.pod:1895 ../src/guestfs-actions.pod:1993 ../src/guestfs-actions.pod:2096 ../src/guestfs-actions.pod:3196 ../src/guestfs-actions.pod:3211 ../src/guestfs-actions.pod:4351 ../src/guestfs-actions.pod:5420 ../src/guestfs-actions.pod:5537 ../src/guestfs-actions.pod:5647 ../src/guestfs-actions.pod:6110 ../src/guestfs-actions.pod:6235 ../src/guestfs-actions.pod:6747
4181 msgid "(Added in 0.3)"
4185 #: ../src/guestfs-actions.pod:41
4186 msgid "guestfs_add_domain"
4190 #: ../src/guestfs-actions.pod:43
4194 " guestfs_add_domain (guestfs_h *g,\n"
4195 " const char *dom,\n"
4201 #: ../src/guestfs-actions.pod:48 ../src/guestfs-actions.pod:139
4203 "You may supply a list of optional arguments to this call. Use zero or more "
4204 "of the following pairs of parameters, and terminate the list with C<-1> on "
4205 "its own. See L</CALLS WITH OPTIONAL ARGUMENTS>."
4209 #: ../src/guestfs-actions.pod:53
4212 " GUESTFS_ADD_DOMAIN_LIBVIRTURI, const char *libvirturi,\n"
4213 " GUESTFS_ADD_DOMAIN_READONLY, int readonly,\n"
4214 " GUESTFS_ADD_DOMAIN_IFACE, const char *iface,\n"
4219 #: ../src/guestfs-actions.pod:57
4221 "This function adds the disk(s) attached to the named libvirt domain C<dom>. "
4222 "It works by connecting to libvirt, requesting the domain and domain XML from "
4223 "libvirt, parsing it for disks, and calling C<guestfs_add_drive_opts> on each "
4228 #: ../src/guestfs-actions.pod:62 ../fish/guestfish-actions.pod:46
4230 "The number of disks added is returned. This operation is atomic: if an "
4231 "error is returned, then no disks are added."
4235 #: ../src/guestfs-actions.pod:65 ../fish/guestfish-actions.pod:49
4237 "This function does some minimal checks to make sure the libvirt domain is "
4238 "not running (unless C<readonly> is true). In a future version we will try "
4239 "to acquire the libvirt lock on each disk."
4243 #: ../src/guestfs-actions.pod:69 ../fish/guestfish-actions.pod:53
4245 "Disks must be accessible locally. This often means that adding disks from a "
4246 "remote libvirt connection (see L<http://libvirt.org/remote.html>) will fail "
4247 "unless those disks are accessible via the same device path locally too."
4251 #: ../src/guestfs-actions.pod:74
4253 "The optional C<libvirturi> parameter sets the libvirt URI (see "
4254 "L<http://libvirt.org/uri.html>). If this is not set then we connect to the "
4255 "default libvirt URI (or one set through an environment variable, see the "
4256 "libvirt documentation for full details). If you are using the C API "
4257 "directly then it is more flexible to create the libvirt connection object "
4258 "yourself, get the domain object, and call C<guestfs_add_libvirt_dom>."
4262 #: ../src/guestfs-actions.pod:82
4264 "The other optional parameters are passed directly through to "
4265 "C<guestfs_add_drive_opts>."
4269 #: ../src/guestfs-actions.pod:85 ../src/guestfs-actions.pod:338 ../src/guestfs-actions.pod:503 ../src/guestfs-actions.pod:681 ../src/guestfs-actions.pod:712 ../src/guestfs-actions.pod:730 ../src/guestfs-actions.pod:749 ../src/guestfs-actions.pod:1309 ../src/guestfs-actions.pod:1663 ../src/guestfs-actions.pod:1866 ../src/guestfs-actions.pod:1965 ../src/guestfs-actions.pod:2005 ../src/guestfs-actions.pod:2060 ../src/guestfs-actions.pod:2083 ../src/guestfs-actions.pod:2346 ../src/guestfs-actions.pod:2634 ../src/guestfs-actions.pod:2655 ../src/guestfs-actions.pod:4487 ../src/guestfs-actions.pod:4615 ../src/guestfs-actions.pod:5021 ../src/guestfs-actions.pod:5047 ../src/guestfs-actions.pod:6343 ../src/guestfs-actions.pod:6758 ../src/guestfs-actions.pod:6771 ../src/guestfs-actions.pod:6784
4270 msgid "On error this function returns -1."
4274 #: ../src/guestfs-actions.pod:87
4275 msgid "(Added in 1.7.4)"
4279 #: ../src/guestfs-actions.pod:89
4280 msgid "guestfs_add_domain_va"
4284 #: ../src/guestfs-actions.pod:91
4288 " guestfs_add_domain_va (guestfs_h *g,\n"
4289 " const char *dom,\n"
4295 #: ../src/guestfs-actions.pod:96
4296 msgid "This is the \"va_list variant\" of L</guestfs_add_domain>."
4300 #: ../src/guestfs-actions.pod:98 ../src/guestfs-actions.pod:109 ../src/guestfs-actions.pod:202 ../src/guestfs-actions.pod:213
4301 msgid "See L</CALLS WITH OPTIONAL ARGUMENTS>."
4305 #: ../src/guestfs-actions.pod:100
4306 msgid "guestfs_add_domain_argv"
4310 #: ../src/guestfs-actions.pod:102
4314 " guestfs_add_domain_argv (guestfs_h *g,\n"
4315 " const char *dom,\n"
4316 " const struct guestfs_add_domain_argv *optargs);\n"
4321 #: ../src/guestfs-actions.pod:107
4322 msgid "This is the \"argv variant\" of L</guestfs_add_domain>."
4326 #: ../src/guestfs-actions.pod:111
4327 msgid "guestfs_add_drive"
4331 #: ../src/guestfs-actions.pod:113
4335 " guestfs_add_drive (guestfs_h *g,\n"
4336 " const char *filename);\n"
4341 #: ../src/guestfs-actions.pod:117
4343 "This function is the equivalent of calling C<guestfs_add_drive_opts> with no "
4344 "optional parameters, so the disk is added writable, with the format being "
4345 "detected automatically."
4349 #: ../src/guestfs-actions.pod:121
4351 "Automatic detection of the format opens you up to a potential security hole "
4352 "when dealing with untrusted raw-format images. See CVE-2010-3851 and "
4353 "RHBZ#642934. Specifying the format closes this security hole. Therefore "
4354 "you should think about replacing calls to this function with calls to "
4355 "C<guestfs_add_drive_opts>, and specifying the format."
4359 #: ../src/guestfs-actions.pod:132
4360 msgid "guestfs_add_drive_opts"
4364 #: ../src/guestfs-actions.pod:134
4368 " guestfs_add_drive_opts (guestfs_h *g,\n"
4369 " const char *filename,\n"
4375 #: ../src/guestfs-actions.pod:144
4378 " GUESTFS_ADD_DRIVE_OPTS_READONLY, int readonly,\n"
4379 " GUESTFS_ADD_DRIVE_OPTS_FORMAT, const char *format,\n"
4380 " GUESTFS_ADD_DRIVE_OPTS_IFACE, const char *iface,\n"
4385 #: ../src/guestfs-actions.pod:148 ../fish/guestfish-actions.pod:92
4387 "This function adds a virtual machine disk image C<filename> to libguestfs. "
4388 "The first time you call this function, the disk appears as C</dev/sda>, the "
4389 "second time as C</dev/sdb>, and so on."
4393 #: ../src/guestfs-actions.pod:153 ../fish/guestfish-actions.pod:97
4395 "You don't necessarily need to be root when using libguestfs. However you "
4396 "obviously do need sufficient permissions to access the filename for whatever "
4397 "operations you want to perform (ie. read access if you just want to read the "
4398 "image or write access if you want to modify the image)."
4402 #: ../src/guestfs-actions.pod:159 ../fish/guestfish-actions.pod:103
4403 msgid "This call checks that C<filename> exists."
4407 #: ../src/guestfs-actions.pod:161 ../fish/guestfish-actions.pod:105
4408 msgid "The optional arguments are:"
4412 #: ../src/guestfs-actions.pod:165 ../fish/guestfish-actions.pod:109
4417 #: ../src/guestfs-actions.pod:167 ../fish/guestfish-actions.pod:111
4419 "If true then the image is treated as read-only. Writes are still allowed, "
4420 "but they are stored in a temporary snapshot overlay which is discarded at "
4421 "the end. The disk that you add is not modified."
4425 #: ../src/guestfs-actions.pod:171 ../fish/guestfish-actions.pod:115
4430 #: ../src/guestfs-actions.pod:173
4432 "This forces the image format. If you omit this (or use C<guestfs_add_drive> "
4433 "or C<guestfs_add_drive_ro>) then the format is automatically detected. "
4434 "Possible formats include C<raw> and C<qcow2>."
4438 #: ../src/guestfs-actions.pod:177 ../fish/guestfish-actions.pod:121
4440 "Automatic detection of the format opens you up to a potential security hole "
4441 "when dealing with untrusted raw-format images. See CVE-2010-3851 and "
4442 "RHBZ#642934. Specifying the format closes this security hole."
4446 #: ../src/guestfs-actions.pod:182 ../fish/guestfish-actions.pod:126
4451 #: ../src/guestfs-actions.pod:184
4453 "This rarely-used option lets you emulate the behaviour of the deprecated "
4454 "C<guestfs_add_drive_with_if> call (q.v.)"
4458 #: ../src/guestfs-actions.pod:191
4459 msgid "(Added in 1.5.23)"
4463 #: ../src/guestfs-actions.pod:193
4464 msgid "guestfs_add_drive_opts_va"
4468 #: ../src/guestfs-actions.pod:195
4472 " guestfs_add_drive_opts_va (guestfs_h *g,\n"
4473 " const char *filename,\n"
4479 #: ../src/guestfs-actions.pod:200
4480 msgid "This is the \"va_list variant\" of L</guestfs_add_drive_opts>."
4484 #: ../src/guestfs-actions.pod:204
4485 msgid "guestfs_add_drive_opts_argv"
4489 #: ../src/guestfs-actions.pod:206
4493 " guestfs_add_drive_opts_argv (guestfs_h *g,\n"
4494 " const char *filename,\n"
4495 " const struct guestfs_add_drive_opts_argv "
4501 #: ../src/guestfs-actions.pod:211
4502 msgid "This is the \"argv variant\" of L</guestfs_add_drive_opts>."
4506 #: ../src/guestfs-actions.pod:215
4507 msgid "guestfs_add_drive_ro"
4511 #: ../src/guestfs-actions.pod:217
4515 " guestfs_add_drive_ro (guestfs_h *g,\n"
4516 " const char *filename);\n"
4521 #: ../src/guestfs-actions.pod:221
4523 "This function is the equivalent of calling C<guestfs_add_drive_opts> with "
4524 "the optional parameter C<GUESTFS_ADD_DRIVE_OPTS_READONLY> set to 1, so the "
4525 "disk is added read-only, with the format being detected automatically."
4529 #: ../src/guestfs-actions.pod:228
4530 msgid "(Added in 1.0.38)"
4534 #: ../src/guestfs-actions.pod:230
4535 msgid "guestfs_add_drive_ro_with_if"
4539 #: ../src/guestfs-actions.pod:232