1 # SOME DESCRIPTIVE TITLE.
2 # Copyright (C) YEAR Free Software Foundation, Inc.
3 # FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
8 "Project-Id-Version: PACKAGE VERSION\n"
9 "Report-Msgid-Bugs-To: libguestfs@redhat.com\n"
10 "POT-Creation-Date: 2010-11-13 16:19+0000\n"
11 "PO-Revision-Date: 2010-09-02 14:46+0100\n"
12 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
13 "Language-Team: LANGUAGE <LL@li.org>\n"
16 "Content-Type: text/plain; charset=UTF-8\n"
17 "Content-Transfer-Encoding: 8bit\n"
20 #: ../src/guestfs.pod:1 ../fish/guestfish.pod:1
21 #: ../test-tool/libguestfs-test-tool.pod:1 ../fuse/guestmount.pod:1
22 #: ../inspector/virt-inspector.pl:31 ../tools/virt-edit.pl:30
23 #: ../tools/virt-win-reg.pl:33 ../tools/virt-df.pl:32 ../tools/virt-ls.pl:30
24 #: ../tools/virt-resize.pl:38 ../tools/virt-list-filesystems.pl:28
25 #: ../tools/virt-tar.pl:29 ../tools/virt-rescue.pl:29
26 #: ../tools/virt-make-fs.pl:33 ../tools/virt-list-partitions.pl:28
31 #: ../src/guestfs.pod:3 ../fish/guestfish.pod:3
32 #: ../test-tool/libguestfs-test-tool.pod:3 ../fuse/guestmount.pod:3
33 #: ../inspector/virt-inspector.pl:33 ../tools/virt-edit.pl:32
34 #: ../tools/virt-win-reg.pl:35 ../tools/virt-df.pl:34 ../tools/virt-ls.pl:32
35 #: ../tools/virt-resize.pl:40 ../tools/virt-list-filesystems.pl:30
36 #: ../tools/virt-tar.pl:31 ../tools/virt-rescue.pl:31
37 #: ../tools/virt-make-fs.pl:35 ../tools/virt-list-partitions.pl:30
42 #: ../src/guestfs.pod:5
43 msgid "guestfs - Library for accessing and modifying virtual machine images"
47 #: ../src/guestfs.pod:7 ../fish/guestfish.pod:7
48 #: ../test-tool/libguestfs-test-tool.pod:7 ../fuse/guestmount.pod:7
49 #: ../inspector/virt-inspector.pl:37 ../tools/virt-edit.pl:36
50 #: ../tools/virt-win-reg.pl:39 ../tools/virt-df.pl:38 ../tools/virt-ls.pl:36
51 #: ../tools/virt-resize.pl:44 ../tools/virt-list-filesystems.pl:34
52 #: ../tools/virt-tar.pl:35 ../tools/virt-rescue.pl:35
53 #: ../tools/virt-make-fs.pl:39 ../tools/virt-list-partitions.pl:34
58 #: ../src/guestfs.pod:9
61 " #include <guestfs.h>\n"
66 #: ../src/guestfs.pod:11
69 " guestfs_h *g = guestfs_create ();\n"
70 " guestfs_add_drive (g, \"guest.img\");\n"
71 " guestfs_launch (g);\n"
72 " guestfs_mount (g, \"/dev/sda1\", \"/\");\n"
73 " guestfs_touch (g, \"/hello\");\n"
74 " guestfs_umount (g, \"/\");\n"
75 " guestfs_sync (g);\n"
76 " guestfs_close (g);\n"
81 #: ../src/guestfs.pod:20
84 " cc prog.c -o prog -lguestfs\n"
86 " cc prog.c -o prog `pkg-config libguestfs --cflags --libs`\n"
91 #: ../src/guestfs.pod:24 ../fish/guestfish.pod:30
92 #: ../test-tool/libguestfs-test-tool.pod:11 ../fuse/guestmount.pod:20
93 #: ../inspector/virt-inspector.pl:43 ../tools/virt-edit.pl:50
94 #: ../tools/virt-win-reg.pl:63 ../tools/virt-df.pl:46 ../tools/virt-ls.pl:42
95 #: ../tools/virt-resize.pl:50 ../tools/virt-list-filesystems.pl:40
96 #: ../tools/virt-tar.pl:72 ../tools/virt-rescue.pl:51
97 #: ../tools/virt-make-fs.pl:47 ../tools/virt-list-partitions.pl:40
102 #: ../src/guestfs.pod:26
104 "Libguestfs is a library for accessing and modifying guest disk images. "
105 "Amongst the things this is good for: making batch configuration changes to "
106 "guests, getting disk used/free statistics (see also: virt-df), migrating "
107 "between virtualization systems (see also: virt-p2v), performing partial "
108 "backups, performing partial guest clones, cloning guests and changing "
109 "registry/UUID/hostname info, and much else besides."
113 #: ../src/guestfs.pod:34
115 "Libguestfs uses Linux kernel and qemu code, and can access any type of guest "
116 "filesystem that Linux and qemu can, including but not limited to: ext2/3/4, "
117 "btrfs, FAT and NTFS, LVM, many different disk partition schemes, qcow, "
122 #: ../src/guestfs.pod:39
124 "Libguestfs provides ways to enumerate guest storage (eg. partitions, LVs, "
125 "what filesystem is in each LV, etc.). It can also run commands in the "
126 "context of the guest. Also you can access filesystems over FUSE."
130 #: ../src/guestfs.pod:44
132 "Libguestfs is a library that can be linked with C and C++ management "
133 "programs (or management programs written in OCaml, Perl, Python, Ruby, Java, "
134 "PHP, Haskell or C#). You can also use it from shell scripts or the command "
139 #: ../src/guestfs.pod:49
141 "You don't need to be root to use libguestfs, although obviously you do need "
142 "enough permissions to access the disk images."
146 #: ../src/guestfs.pod:52
148 "Libguestfs is a large API because it can do many things. For a gentle "
149 "introduction, please read the L</API OVERVIEW> section next."
153 #: ../src/guestfs.pod:55
158 #: ../src/guestfs.pod:57
160 "This section provides a gentler overview of the libguestfs API. We also try "
161 "to group API calls together, where that may not be obvious from reading "
162 "about the individual calls in the main section of this manual."
166 #: ../src/guestfs.pod:62
171 #: ../src/guestfs.pod:64
173 "Before you can use libguestfs calls, you have to create a handle. Then you "
174 "must add at least one disk image to the handle, followed by launching the "
175 "handle, then performing whatever operations you want, and finally closing "
176 "the handle. By convention we use the single letter C<g> for the name of the "
177 "handle variable, although of course you can use any name you want."
181 #: ../src/guestfs.pod:71
182 msgid "The general structure of all libguestfs-using programs looks like this:"
186 #: ../src/guestfs.pod:74
189 " guestfs_h *g = guestfs_create ();\n"
194 #: ../src/guestfs.pod:76
197 " /* Call guestfs_add_drive additional times if there are\n"
198 " * multiple disk images.\n"
200 " guestfs_add_drive (g, \"guest.img\");\n"
205 #: ../src/guestfs.pod:81
208 " /* Most manipulation calls won't work until you've launched\n"
209 " * the handle 'g'. You have to do this _after_ adding drives\n"
210 " * and _before_ other commands.\n"
212 " guestfs_launch (g);\n"
217 #: ../src/guestfs.pod:87
220 " /* Now you can examine what partitions, LVs etc are available.\n"
222 " char **partitions = guestfs_list_partitions (g);\n"
223 " char **logvols = guestfs_lvs (g);\n"
228 #: ../src/guestfs.pod:92
231 " /* To access a filesystem in the image, you must mount it.\n"
233 " guestfs_mount (g, \"/dev/sda1\", \"/\");\n"
238 #: ../src/guestfs.pod:96
241 " /* Now you can perform filesystem actions on the guest\n"
244 " guestfs_touch (g, \"/hello\");\n"
249 #: ../src/guestfs.pod:101
252 " /* You only need to call guestfs_sync if you have made\n"
253 " * changes to the guest image. (But if you've made changes\n"
254 " * then you *must* sync). See also: guestfs_umount and\n"
255 " * guestfs_umount_all calls.\n"
257 " guestfs_sync (g);\n"
262 #: ../src/guestfs.pod:108
265 " /* Close the handle 'g'. */\n"
266 " guestfs_close (g);\n"
271 #: ../src/guestfs.pod:111
273 "The code above doesn't include any error checking. In real code you should "
274 "check return values carefully for errors. In general all functions that "
275 "return integers return C<-1> on error, and all functions that return "
276 "pointers return C<NULL> on error. See section L</ERROR HANDLING> below for "
277 "how to handle errors, and consult the documentation for each function call "
278 "below to see precisely how they return error indications."
282 #: ../src/guestfs.pod:119
287 #: ../src/guestfs.pod:121
289 "The image filename (C<\"guest.img\"> in the example above) could be a disk "
290 "image from a virtual machine, a L<dd(1)> copy of a physical hard disk, an "
291 "actual block device, or simply an empty file of zeroes that you have created "
292 "through L<posix_fallocate(3)>. Libguestfs lets you do useful things to all "
297 #: ../src/guestfs.pod:127
299 "The call you should use in modern code for adding drives is L</"
300 "guestfs_add_drive_opts>. To add a disk image, allowing writes, and "
301 "specifying that the format is raw, do:"
305 #: ../src/guestfs.pod:131
308 " guestfs_add_drive_opts (g, filename,\n"
309 " GUESTFS_ADD_DRIVE_OPTS_FORMAT, \"raw\",\n"
315 #: ../src/guestfs.pod:135
316 msgid "You can add a disk read-only using:"
320 #: ../src/guestfs.pod:137
323 " guestfs_add_drive_opts (g, filename,\n"
324 " GUESTFS_ADD_DRIVE_OPTS_FORMAT, \"raw\",\n"
325 " GUESTFS_ADD_DRIVE_OPTS_READONLY, 1,\n"
331 #: ../src/guestfs.pod:142
333 "or by calling the older function L</guestfs_add_drive_ro>. In either case "
334 "libguestfs won't modify the file."
338 #: ../src/guestfs.pod:145
340 "Be extremely cautious if the disk image is in use, eg. if it is being used "
341 "by a virtual machine. Adding it read-write will almost certainly cause disk "
342 "corruption, but adding it read-only is safe."
346 #: ../src/guestfs.pod:149
348 "You must add at least one disk image, and you may add multiple disk images. "
349 "In the API, the disk images are usually referred to as C</dev/sda> (for the "
350 "first one you added), C</dev/sdb> (for the second one you added), etc."
354 #: ../src/guestfs.pod:154
356 "Once L</guestfs_launch> has been called you cannot add any more images. You "
357 "can call L</guestfs_list_devices> to get a list of the device names, in the "
358 "order that you added them. See also L</BLOCK DEVICE NAMING> below."
362 #: ../src/guestfs.pod:159
367 #: ../src/guestfs.pod:161
369 "Before you can read or write files, create directories and so on in a disk "
370 "image that contains filesystems, you have to mount those filesystems using "
371 "L</guestfs_mount>. If you already know that a disk image contains (for "
372 "example) one partition with a filesystem on that partition, then you can "
377 #: ../src/guestfs.pod:167
380 " guestfs_mount (g, \"/dev/sda1\", \"/\");\n"
385 #: ../src/guestfs.pod:169
387 "where C</dev/sda1> means literally the first partition (C<1>) of the first "
388 "disk image that we added (C</dev/sda>). If the disk contains Linux LVM2 "
389 "logical volumes you could refer to those instead (eg. C</dev/VG/LV>)."
393 #: ../src/guestfs.pod:173
395 "If you are given a disk image and you don't know what it contains then you "
396 "have to find out. Libguestfs can do that too: use L</"
397 "guestfs_list_partitions> and L</guestfs_lvs> to list possible partitions and "
398 "LVs, and either try mounting each to see what is mountable, or else examine "
399 "them with L</guestfs_vfs_type> or L</guestfs_file>. Libguestfs also has a "
400 "set of APIs for inspection of disk images (see L</INSPECTION> below). But "
401 "you might find it easier to look at higher level programs built on top of "
402 "libguestfs, in particular L<virt-inspector(1)>."
406 #: ../src/guestfs.pod:183
408 "To mount a disk image read-only, use L</guestfs_mount_ro>. There are "
409 "several other variations of the C<guestfs_mount_*> call."
413 #: ../src/guestfs.pod:186
414 msgid "FILESYSTEM ACCESS AND MODIFICATION"
418 #: ../src/guestfs.pod:188
420 "The majority of the libguestfs API consists of fairly low-level calls for "
421 "accessing and modifying the files, directories, symlinks etc on mounted "
422 "filesystems. There are over a hundred such calls which you can find listed "
423 "in detail below in this man page, and we don't even pretend to cover them "
424 "all in this overview."
428 #: ../src/guestfs.pod:194
430 "Specify filenames as full paths, starting with C<\"/\"> and including the "
435 #: ../src/guestfs.pod:197
437 "For example, if you mounted a filesystem at C<\"/\"> and you want to read "
438 "the file called C<\"etc/passwd\"> then you could do:"
442 #: ../src/guestfs.pod:200
445 " char *data = guestfs_cat (g, \"/etc/passwd\");\n"
450 #: ../src/guestfs.pod:202
452 "This would return C<data> as a newly allocated buffer containing the full "
453 "content of that file (with some conditions: see also L</DOWNLOADING> below), "
454 "or C<NULL> if there was an error."
458 #: ../src/guestfs.pod:206
460 "As another example, to create a top-level directory on that filesystem "
461 "called C<\"var\"> you would do:"
465 #: ../src/guestfs.pod:209
468 " guestfs_mkdir (g, \"/var\");\n"
473 #: ../src/guestfs.pod:211
474 msgid "To create a symlink you could do:"
478 #: ../src/guestfs.pod:213
481 " guestfs_ln_s (g, \"/etc/init.d/portmap\",\n"
482 " \"/etc/rc3.d/S30portmap\");\n"
487 #: ../src/guestfs.pod:216
489 "Libguestfs will reject attempts to use relative paths and there is no "
490 "concept of a current working directory."
494 #: ../src/guestfs.pod:219
496 "Libguestfs can return errors in many situations: for example if the "
497 "filesystem isn't writable, or if a file or directory that you requested "
498 "doesn't exist. If you are using the C API (documented here) you have to "
499 "check for those error conditions after each call. (Other language bindings "
500 "turn these errors into exceptions)."
504 #: ../src/guestfs.pod:225
506 "File writes are affected by the per-handle umask, set by calling L</"
507 "guestfs_umask> and defaulting to 022. See L</UMASK>."
511 #: ../src/guestfs.pod:228
516 #: ../src/guestfs.pod:230
518 "Libguestfs contains API calls to read, create and modify partition tables on "
523 #: ../src/guestfs.pod:233
525 "In the common case where you want to create a single partition covering the "
526 "whole disk, you should use the L</guestfs_part_disk> call:"
530 #: ../src/guestfs.pod:237
533 " const char *parttype = \"mbr\";\n"
534 " if (disk_is_larger_than_2TB)\n"
535 " parttype = \"gpt\";\n"
536 " guestfs_part_disk (g, \"/dev/sda\", parttype);\n"
541 #: ../src/guestfs.pod:242
543 "Obviously this effectively wipes anything that was on that disk image before."
547 #: ../src/guestfs.pod:245
552 #: ../src/guestfs.pod:247
554 "Libguestfs provides access to a large part of the LVM2 API, such as L</"
555 "guestfs_lvcreate> and L</guestfs_vgremove>. It won't make much sense unless "
556 "you familiarize yourself with the concepts of physical volumes, volume "
557 "groups and logical volumes."
561 #: ../src/guestfs.pod:252
563 "This author strongly recommends reading the LVM HOWTO, online at L<http://"
564 "tldp.org/HOWTO/LVM-HOWTO/>."
568 #: ../src/guestfs.pod:255
573 #: ../src/guestfs.pod:257
575 "Use L</guestfs_cat> to download small, text only files. This call is "
576 "limited to files which are less than 2 MB and which cannot contain any ASCII "
577 "NUL (C<\\0>) characters. However it has a very simple to use API."
581 #: ../src/guestfs.pod:262
583 "L</guestfs_read_file> can be used to read files which contain arbitrary 8 "
584 "bit data, since it returns a (pointer, size) pair. However it is still "
585 "limited to \"small\" files, less than 2 MB."
589 #: ../src/guestfs.pod:266
591 "L</guestfs_download> can be used to download any file, with no limits on "
592 "content or size (even files larger than 4 GB)."
596 #: ../src/guestfs.pod:269
598 "To download multiple files, see L</guestfs_tar_out> and L</guestfs_tgz_out>."
602 #: ../src/guestfs.pod:272
607 #: ../src/guestfs.pod:274
609 "It's often the case that you want to write a file or files to the disk image."
613 #: ../src/guestfs.pod:277
615 "To write a small file with fixed content, use L</guestfs_write>. To create "
616 "a file of all zeroes, use L</guestfs_truncate_size> (sparse) or L</"
617 "guestfs_fallocate64> (with all disk blocks allocated). There are a variety "
618 "of other functions for creating test files, for example L</guestfs_fill> and "
619 "L</guestfs_fill_pattern>."
623 #: ../src/guestfs.pod:283
625 "To upload a single file, use L</guestfs_upload>. This call has no limits on "
626 "file content or size (even files larger than 4 GB)."
630 #: ../src/guestfs.pod:286
632 "To upload multiple files, see L</guestfs_tar_in> and L</guestfs_tgz_in>."
636 #: ../src/guestfs.pod:288
638 "However the fastest way to upload I<large numbers of arbitrary files> is to "
639 "turn them into a squashfs or CD ISO (see L<mksquashfs(8)> and L<mkisofs(8)"
640 ">), then attach this using L</guestfs_add_drive_ro>. If you add the drive "
641 "in a predictable way (eg. adding it last after all other drives) then you "
642 "can get the device name from L</guestfs_list_devices> and mount it directly "
643 "using L</guestfs_mount_ro>. Note that squashfs images are sometimes non-"
644 "portable between kernel versions, and they don't support labels or UUIDs. "
645 "If you want to pre-build an image or you need to mount it using a label or "
646 "UUID, use an ISO image instead."
650 #: ../src/guestfs.pod:299
655 #: ../src/guestfs.pod:301
657 "There are various different commands for copying between files and devices "
658 "and in and out of the guest filesystem. These are summarised in the table "
663 #: ../src/guestfs.pod:307
664 msgid "B<file> to B<file>"
668 #: ../src/guestfs.pod:309
670 "Use L</guestfs_cp> to copy a single file, or L</guestfs_cp_a> to copy "
671 "directories recursively."
675 #: ../src/guestfs.pod:312
676 msgid "B<file or device> to B<file or device>"
680 #: ../src/guestfs.pod:314
682 "Use L</guestfs_dd> which efficiently uses L<dd(1)> to copy between files and "
683 "devices in the guest."
687 #: ../src/guestfs.pod:317
688 msgid "Example: duplicate the contents of an LV:"
692 #: ../src/guestfs.pod:319
695 " guestfs_dd (g, \"/dev/VG/Original\", \"/dev/VG/Copy\");\n"
700 #: ../src/guestfs.pod:321
702 "The destination (C</dev/VG/Copy>) must be at least as large as the source "
703 "(C</dev/VG/Original>). To copy less than the whole source device, use L</"
704 "guestfs_copy_size>."
708 #: ../src/guestfs.pod:325
709 msgid "B<file on the host> to B<file or device>"
713 #: ../src/guestfs.pod:327
714 msgid "Use L</guestfs_upload>. See L</UPLOADING> above."
718 #: ../src/guestfs.pod:329
719 msgid "B<file or device> to B<file on the host>"
723 #: ../src/guestfs.pod:331
724 msgid "Use L</guestfs_download>. See L</DOWNLOADING> above."
728 #: ../src/guestfs.pod:335
729 msgid "LISTING FILES"
733 #: ../src/guestfs.pod:337
735 "L</guestfs_ll> is just designed for humans to read (mainly when using the "
736 "L<guestfish(1)>-equivalent command C<ll>)."
740 #: ../src/guestfs.pod:340
742 "L</guestfs_ls> is a quick way to get a list of files in a directory from "
743 "programs, as a flat list of strings."
747 #: ../src/guestfs.pod:343
749 "L</guestfs_readdir> is a programmatic way to get a list of files in a "
750 "directory, plus additional information about each one. It is more "
751 "equivalent to using the L<readdir(3)> call on a local filesystem."
755 #: ../src/guestfs.pod:347
757 "L</guestfs_find> and L</guestfs_find0> can be used to recursively list files."
761 #: ../src/guestfs.pod:350
762 msgid "RUNNING COMMANDS"
766 #: ../src/guestfs.pod:352
768 "Although libguestfs is primarily an API for manipulating files inside guest "
769 "images, we also provide some limited facilities for running commands inside "
774 #: ../src/guestfs.pod:356
775 msgid "There are many limitations to this:"
779 #: ../src/guestfs.pod:360 ../src/guestfs.pod:365 ../src/guestfs.pod:370
780 #: ../src/guestfs.pod:374 ../src/guestfs.pod:379 ../src/guestfs.pod:383
781 #: ../src/guestfs.pod:388 ../src/guestfs.pod:393 ../src/guestfs.pod:955
782 #: ../src/guestfs.pod:959 ../src/guestfs.pod:963 ../src/guestfs.pod:968
783 #: ../src/guestfs.pod:976 ../src/guestfs.pod:995 ../src/guestfs.pod:1003
784 #: ../src/guestfs.pod:1025 ../src/guestfs.pod:1029 ../src/guestfs.pod:1033
785 #: ../src/guestfs.pod:1037 ../src/guestfs.pod:1041 ../src/guestfs.pod:1045
786 #: ../src/guestfs.pod:1519 ../src/guestfs.pod:1524 ../src/guestfs.pod:1528
787 #: ../src/guestfs.pod:1638 ../src/guestfs.pod:1643 ../src/guestfs.pod:1647
788 #: ../src/guestfs.pod:1991 ../src/guestfs.pod:1997 ../src/guestfs.pod:2002
789 #: ../src/guestfs.pod:2008 ../src/guestfs.pod:2115 ../src/guestfs.pod:2119
790 #: ../src/guestfs.pod:2123 ../src/guestfs.pod:2127
791 #: ../src/guestfs-actions.pod:15 ../src/guestfs-actions.pod:22
792 #: ../src/guestfs-actions.pod:569 ../src/guestfs-actions.pod:577
793 #: ../src/guestfs-actions.pod:584 ../src/guestfs-actions.pod:591
794 #: ../src/guestfs-actions.pod:1587 ../src/guestfs-actions.pod:1591
795 #: ../src/guestfs-actions.pod:1595 ../src/guestfs-actions.pod:1599
796 #: ../src/guestfs-actions.pod:1607 ../src/guestfs-actions.pod:1611
797 #: ../src/guestfs-actions.pod:1615 ../src/guestfs-actions.pod:1625
798 #: ../src/guestfs-actions.pod:1629 ../src/guestfs-actions.pod:1633
799 #: ../src/guestfs-actions.pod:1771 ../src/guestfs-actions.pod:1775
800 #: ../src/guestfs-actions.pod:1780 ../src/guestfs-actions.pod:1785
801 #: ../src/guestfs-actions.pod:1846 ../src/guestfs-actions.pod:1850
802 #: ../src/guestfs-actions.pod:1855 ../fish/guestfish.pod:376
803 #: ../fish/guestfish.pod:380 ../fish/guestfish.pod:384
804 #: ../fish/guestfish.pod:388 ../fish/guestfish-actions.pod:13
805 #: ../fish/guestfish-actions.pod:20 ../fish/guestfish-actions.pod:375
806 #: ../fish/guestfish-actions.pod:383 ../fish/guestfish-actions.pod:390
807 #: ../fish/guestfish-actions.pod:397 ../fish/guestfish-actions.pod:1067
808 #: ../fish/guestfish-actions.pod:1071 ../fish/guestfish-actions.pod:1075
809 #: ../fish/guestfish-actions.pod:1079 ../fish/guestfish-actions.pod:1087
810 #: ../fish/guestfish-actions.pod:1091 ../fish/guestfish-actions.pod:1095
811 #: ../fish/guestfish-actions.pod:1105 ../fish/guestfish-actions.pod:1109
812 #: ../fish/guestfish-actions.pod:1113 ../fish/guestfish-actions.pod:1203
813 #: ../fish/guestfish-actions.pod:1207 ../fish/guestfish-actions.pod:1212
814 #: ../fish/guestfish-actions.pod:1217 ../fish/guestfish-actions.pod:1259
815 #: ../fish/guestfish-actions.pod:1263 ../fish/guestfish-actions.pod:1268
816 #: ../inspector/virt-inspector.pl:550 ../inspector/virt-inspector.pl:554
817 #: ../tools/virt-df.pl:161 ../tools/virt-df.pl:167 ../tools/virt-resize.pl:348
818 #: ../tools/virt-resize.pl:353 ../tools/virt-resize.pl:363
823 #: ../src/guestfs.pod:362
825 "The kernel version that the command runs under will be different from what "
830 #: ../src/guestfs.pod:367
832 "If the command needs to communicate with daemons, then most likely they "
837 #: ../src/guestfs.pod:372
838 msgid "The command will be running in limited memory."
842 #: ../src/guestfs.pod:376
844 "The network may not be available unless you enable it (see L</"
845 "guestfs_set_network>)."
849 #: ../src/guestfs.pod:381
850 msgid "Only supports Linux guests (not Windows, BSD, etc)."
854 #: ../src/guestfs.pod:385
856 "Architecture limitations (eg. won't work for a PPC guest on an X86 host)."
860 #: ../src/guestfs.pod:390
862 "For SELinux guests, you may need to enable SELinux and load policy first. "
863 "See L</SELINUX> in this manpage."
867 #: ../src/guestfs.pod:395
869 "I<Security:> It is not safe to run commands from untrusted, possibly "
870 "malicious guests. These commands may attempt to exploit your program by "
871 "sending unexpected output. They could also try to exploit the Linux kernel "
872 "or qemu provided by the libguestfs appliance. They could use the network "
873 "provided by the libguestfs appliance to bypass ordinary network partitions "
874 "and firewalls. They could use the elevated privileges or different SELinux "
875 "context of your program to their advantage."
879 #: ../src/guestfs.pod:404
881 "A secure alternative is to use libguestfs to install a \"firstboot\" script "
882 "(a script which runs when the guest next boots normally), and to have this "
883 "script run the commands you want in the normal context of the running guest, "
884 "network security and so on. For information about other security issues, "
889 #: ../src/guestfs.pod:412
891 "The two main API calls to run commands are L</guestfs_command> and L</"
892 "guestfs_sh> (there are also variations)."
896 #: ../src/guestfs.pod:415
898 "The difference is that L</guestfs_sh> runs commands using the shell, so any "
899 "shell globs, redirections, etc will work."
903 #: ../src/guestfs.pod:418
904 msgid "CONFIGURATION FILES"
908 #: ../src/guestfs.pod:420
910 "To read and write configuration files in Linux guest filesystems, we "
911 "strongly recommend using Augeas. For example, Augeas understands how to "
912 "read and write, say, a Linux shadow password file or X.org configuration "
913 "file, and so avoids you having to write that code."
917 #: ../src/guestfs.pod:425
919 "The main Augeas calls are bound through the C<guestfs_aug_*> APIs. We don't "
920 "document Augeas itself here because there is excellent documentation on the "
921 "L<http://augeas.net/> website."
925 #: ../src/guestfs.pod:429
927 "If you don't want to use Augeas (you fool!) then try calling L</"
928 "guestfs_read_lines> to get the file as a list of lines which you can iterate "
933 #: ../src/guestfs.pod:433
938 #: ../src/guestfs.pod:435
940 "We support SELinux guests. To ensure that labeling happens correctly in "
941 "SELinux guests, you need to enable SELinux and load the guest's policy:"
945 #: ../src/guestfs.pod:441 ../src/guestfs.pod:1140 ../src/guestfs.pod:1271
950 #: ../src/guestfs.pod:443
951 msgid "Before launching, do:"
955 #: ../src/guestfs.pod:445
958 " guestfs_set_selinux (g, 1);\n"
963 #: ../src/guestfs.pod:447 ../src/guestfs.pod:1144 ../src/guestfs.pod:1275
968 #: ../src/guestfs.pod:449
970 "After mounting the guest's filesystem(s), load the policy. This is best "
971 "done by running the L<load_policy(8)> command in the guest itself:"
975 #: ../src/guestfs.pod:453
978 " guestfs_sh (g, \"/usr/sbin/load_policy\");\n"
983 #: ../src/guestfs.pod:455
985 "(Older versions of C<load_policy> require you to specify the name of the "
990 #: ../src/guestfs.pod:458 ../src/guestfs.pod:1281
995 #: ../src/guestfs.pod:460
997 "Optionally, set the security context for the API. The correct security "
998 "context to use can only be known by inspecting the guest. As an example:"
1002 #: ../src/guestfs.pod:464
1005 " guestfs_setcon (g, \"unconfined_u:unconfined_r:unconfined_t:s0\");\n"
1010 #: ../src/guestfs.pod:468
1011 msgid "This will work for running commands and editing existing files."
1015 #: ../src/guestfs.pod:470
1017 "When new files are created, you may need to label them explicitly, for "
1018 "example by running the external command C<restorecon pathname>."
1022 #: ../src/guestfs.pod:474
1027 #: ../src/guestfs.pod:476
1029 "Certain calls are affected by the current file mode creation mask (the "
1030 "\"umask\"). In particular ones which create files or directories, such as "
1031 "L</guestfs_touch>, L</guestfs_mknod> or L</guestfs_mkdir>. This affects "
1032 "either the default mode that the file is created with or modifies the mode "
1037 #: ../src/guestfs.pod:482
1039 "The default umask is C<022>, so files are created with modes such as C<0644> "
1040 "and directories with C<0755>."
1044 #: ../src/guestfs.pod:485
1046 "There are two ways to avoid being affected by umask. Either set umask to 0 "
1047 "(call C<guestfs_umask (g, 0)> early after launching). Or call L</"
1048 "guestfs_chmod> after creating each file or directory."
1052 #: ../src/guestfs.pod:489
1053 msgid "For more information about umask, see L<umask(2)>."
1057 #: ../src/guestfs.pod:491 ../fish/guestfish.pod:669
1058 msgid "ENCRYPTED DISKS"
1062 #: ../src/guestfs.pod:493
1064 "Libguestfs allows you to access Linux guests which have been encrypted using "
1065 "whole disk encryption that conforms to the Linux Unified Key Setup (LUKS) "
1066 "standard. This includes nearly all whole disk encryption systems used by "
1067 "modern Linux guests."
1071 #: ../src/guestfs.pod:499
1073 "Use L</guestfs_vfs_type> to identify LUKS-encrypted block devices (it "
1074 "returns the string C<crypto_LUKS>)."
1078 #: ../src/guestfs.pod:502
1080 "Then open these devices by calling L</guestfs_luks_open>. Obviously you "
1081 "will require the passphrase!"
1085 #: ../src/guestfs.pod:505
1087 "Opening a LUKS device creates a new device mapper device called C</dev/"
1088 "mapper/mapname> (where C<mapname> is the string you supply to L</"
1089 "guestfs_luks_open>). Reads and writes to this mapper device are decrypted "
1090 "from and encrypted to the underlying block device respectively."
1094 #: ../src/guestfs.pod:511
1096 "LVM volume groups on the device can be made visible by calling L</"
1097 "guestfs_vgscan> followed by L</guestfs_vg_activate_all>. The logical volume"
1098 "(s) can now be mounted in the usual way."
1102 #: ../src/guestfs.pod:515
1104 "Use the reverse process to close a LUKS device. Unmount any logical volumes "
1105 "on it, deactivate the volume groups by caling C<guestfs_vg_activate (g, 0, "
1106 "[\"/dev/VG\"])>. Then close the mapper device by calling L</"
1107 "guestfs_luks_close> on the C</dev/mapper/mapname> device (I<not> the "
1108 "underlying encrypted block device)."
1112 #: ../src/guestfs.pod:522
1117 #: ../src/guestfs.pod:524
1119 "Libguestfs has APIs for inspecting an unknown disk image to find out if it "
1120 "contains operating systems. (These APIs used to be in a separate Perl-only "
1121 "library called L<Sys::Guestfs::Lib(3)> but since version 1.5.3 the most "
1122 "frequently used part of this library has been rewritten in C and moved into "
1127 #: ../src/guestfs.pod:530
1129 "Add all disks belonging to the unknown virtual machine and call L</"
1130 "guestfs_launch> in the usual way."
1134 #: ../src/guestfs.pod:533
1136 "Then call L</guestfs_inspect_os>. This function uses other libguestfs calls "
1137 "and certain heuristics, and returns a list of operating systems that were "
1138 "found. An empty list means none were found. A single element is the root "
1139 "filesystem of the operating system. For dual- or multi-boot guests, "
1140 "multiple roots can be returned, each one corresponding to a separate "
1141 "operating system. (Multi-boot virtual machines are extremely rare in the "
1142 "world of virtualization, but since this scenario can happen, we have built "
1143 "libguestfs to deal with it.)"
1147 #: ../src/guestfs.pod:542
1149 "For each root, you can then call various C<guestfs_inspect_get_*> functions "
1150 "to get additional details about that operating system. For example, call L</"
1151 "guestfs_inspect_get_type> to return the string C<windows> or C<linux> for "
1152 "Windows and Linux-based operating systems respectively."
1156 #: ../src/guestfs.pod:548
1158 "Un*x-like and Linux-based operating systems usually consist of several "
1159 "filesystems which are mounted at boot time (for example, a separate boot "
1160 "partition mounted on C</boot>). The inspection rules are able to detect how "
1161 "filesystems correspond to mount points. Call "
1162 "C<guestfs_inspect_get_mountpoints> to get this mapping. It might return a "
1163 "hash table like this example:"
1167 #: ../src/guestfs.pod:555
1170 " /boot => /dev/sda1\n"
1171 " / => /dev/vg_guest/lv_root\n"
1172 " /usr => /dev/vg_guest/lv_usr\n"
1177 #: ../src/guestfs.pod:559
1179 "The caller can then make calls to L</guestfs_mount_options> to mount the "
1180 "filesystems as suggested."
1184 #: ../src/guestfs.pod:562
1186 "Be careful to mount filesystems in the right order (eg. C</> before C</"
1187 "usr>). Sorting the keys of the hash by length, shortest first, should work."
1191 #: ../src/guestfs.pod:566
1193 "Inspection currently only works for some common operating systems. "
1194 "Contributors are welcome to send patches for other operating systems that we "
1195 "currently cannot detect."
1199 #: ../src/guestfs.pod:570
1201 "Encrypted disks must be opened before inspection. See L</ENCRYPTED DISKS> "
1202 "for more details. The L</guestfs_inspect_os> function just ignores any "
1203 "encrypted devices."
1207 #: ../src/guestfs.pod:574
1209 "A note on the implementation: The call L</guestfs_inspect_os> performs "
1210 "inspection and caches the results in the guest handle. Subsequent calls to "
1211 "C<guestfs_inspect_get_*> return this cached information, but I<do not> re-"
1212 "read the disks. If you change the content of the guest disks, you can redo "
1213 "inspection by calling L</guestfs_inspect_os> again."
1217 #: ../src/guestfs.pod:581
1218 msgid "SPECIAL CONSIDERATIONS FOR WINDOWS GUESTS"
1222 #: ../src/guestfs.pod:583
1224 "Libguestfs can mount NTFS partitions. It does this using the L<http://www."
1225 "ntfs-3g.org/> driver."
1229 #: ../src/guestfs.pod:586
1231 "DOS and Windows still use drive letters, and the filesystems are always "
1232 "treated as case insensitive by Windows itself, and therefore you might find "
1233 "a Windows configuration file referring to a path like C<c:\\windows"
1234 "\\system32>. When the filesystem is mounted in libguestfs, that directory "
1235 "might be referred to as C</WINDOWS/System32>."
1239 #: ../src/guestfs.pod:592
1241 "Drive letter mappings are outside the scope of libguestfs. You have to use "
1242 "libguestfs to read the appropriate Windows Registry and configuration files, "
1243 "to determine yourself how drives are mapped (see also L<hivex(3)> and L<virt-"
1248 #: ../src/guestfs.pod:597
1250 "Replacing backslash characters with forward slash characters is also outside "
1251 "the scope of libguestfs, but something that you can easily do."
1255 #: ../src/guestfs.pod:600
1257 "Where we can help is in resolving the case insensitivity of paths. For "
1258 "this, call L</guestfs_case_sensitive_path>."
1262 #: ../src/guestfs.pod:603
1264 "Libguestfs also provides some help for decoding Windows Registry \"hive\" "
1265 "files, through the library C<hivex> which is part of the libguestfs project "
1266 "although ships as a separate tarball. You have to locate and download the "
1267 "hive file(s) yourself, and then pass them to C<hivex> functions. See also "
1268 "the programs L<hivexml(1)>, L<hivexsh(1)>, L<hivexregedit(1)> and L<virt-win-"
1269 "reg(1)> for more help on this issue."
1273 #: ../src/guestfs.pod:611
1274 msgid "USING LIBGUESTFS WITH OTHER PROGRAMMING LANGUAGES"
1278 #: ../src/guestfs.pod:613
1280 "Although we don't want to discourage you from using the C API, we will "
1281 "mention here that the same API is also available in other languages."
1285 #: ../src/guestfs.pod:616
1287 "The API is broadly identical in all supported languages. This means that "
1288 "the C call C<guestfs_mount(g,path)> is C<$g-E<gt>mount($path)> in Perl, C<g."
1289 "mount(path)> in Python, and C<Guestfs.mount g path> in OCaml. In other "
1290 "words, a straightforward, predictable isomorphism between each language."
1294 #: ../src/guestfs.pod:622
1296 "Error messages are automatically transformed into exceptions if the language "
1301 #: ../src/guestfs.pod:625
1303 "We don't try to \"object orientify\" parts of the API in OO languages, "
1304 "although contributors are welcome to write higher level APIs above what we "
1305 "provide in their favourite languages if they wish."
1309 #: ../src/guestfs.pod:631
1314 #: ../src/guestfs.pod:633
1316 "You can use the I<guestfs.h> header file from C++ programs. The C++ API is "
1317 "identical to the C API. C++ classes and exceptions are not used."
1321 #: ../src/guestfs.pod:637
1326 #: ../src/guestfs.pod:639
1328 "The C# bindings are highly experimental. Please read the warnings at the "
1329 "top of C<csharp/Libguestfs.cs>."
1333 #: ../src/guestfs.pod:642
1338 #: ../src/guestfs.pod:644
1340 "This is the only language binding that is working but incomplete. Only "
1341 "calls which return simple integers have been bound in Haskell, and we are "
1342 "looking for help to complete this binding."
1346 #: ../src/guestfs.pod:648
1351 #: ../src/guestfs.pod:650
1353 "Full documentation is contained in the Javadoc which is distributed with "
1358 #: ../src/guestfs.pod:653
1363 #: ../src/guestfs.pod:655
1364 msgid "For documentation see the file C<guestfs.mli>."
1368 #: ../src/guestfs.pod:657
1373 #: ../src/guestfs.pod:659
1374 msgid "For documentation see L<Sys::Guestfs(3)>."
1378 #: ../src/guestfs.pod:661
1383 #: ../src/guestfs.pod:663
1385 "For documentation see C<README-PHP> supplied with libguestfs sources or in "
1386 "the php-libguestfs package for your distribution."
1390 #: ../src/guestfs.pod:666
1391 msgid "The PHP binding only works correctly on 64 bit machines."
1395 #: ../src/guestfs.pod:668
1400 #: ../src/guestfs.pod:670
1401 msgid "For documentation do:"
1405 #: ../src/guestfs.pod:672
1409 " >>> import guestfs\n"
1410 " >>> help (guestfs)\n"
1415 #: ../src/guestfs.pod:676
1420 #: ../src/guestfs.pod:678
1422 "Use the Guestfs module. There is no Ruby-specific documentation, but you "
1423 "can find examples written in Ruby in the libguestfs source."
1427 #: ../src/guestfs.pod:681
1428 msgid "B<shell scripts>"
1432 #: ../src/guestfs.pod:683
1433 msgid "For documentation see L<guestfish(1)>."
1437 #: ../src/guestfs.pod:687
1438 msgid "LIBGUESTFS GOTCHAS"
1442 #: ../src/guestfs.pod:689
1444 "L<http://en.wikipedia.org/wiki/Gotcha_(programming)>: \"A feature of a "
1445 "system [...] that works in the way it is documented but is counterintuitive "
1446 "and almost invites mistakes.\""
1450 #: ../src/guestfs.pod:693
1452 "Since we developed libguestfs and the associated tools, there are several "
1453 "things we would have designed differently, but are now stuck with for "
1454 "backwards compatibility or other reasons. If there is ever a libguestfs 2.0 "
1455 "release, you can expect these to change. Beware of them."
1459 #: ../src/guestfs.pod:701
1460 msgid "Autosync / forgetting to sync."
1464 #: ../src/guestfs.pod:703
1466 "When modifying a filesystem from C or another language, you B<must> unmount "
1467 "all filesystems and call L</guestfs_sync> explicitly before you close the "
1468 "libguestfs handle. You can also call:"
1472 #: ../src/guestfs.pod:707
1475 " guestfs_set_autosync (g, 1);\n"
1480 #: ../src/guestfs.pod:709
1482 "to have the unmount/sync done automatically for you when the handle 'g' is "
1483 "closed. (This feature is called \"autosync\", L</guestfs_set_autosync> q.v.)"
1487 #: ../src/guestfs.pod:713
1489 "If you forget to do this, then it is entirely possible that your changes "
1490 "won't be written out, or will be partially written, or (very rarely) that "
1491 "you'll get disk corruption."
1495 #: ../src/guestfs.pod:717
1497 "Note that in L<guestfish(3)> autosync is the default. So quick and dirty "
1498 "guestfish scripts that forget to sync will work just fine, which can make "
1499 "this very puzzling if you are trying to debug a problem."
1503 #: ../src/guestfs.pod:721
1505 "Update: Autosync is enabled by default for all API users starting from "
1506 "libguestfs 1.5.24."
1510 #: ../src/guestfs.pod:724
1511 msgid "Mount option C<-o sync> should not be the default."
1515 #: ../src/guestfs.pod:726
1517 "If you use L</guestfs_mount>, then C<-o sync,noatime> are added implicitly. "
1518 "However C<-o sync> does not add any reliability benefit, but does have a "
1519 "very large performance impact."
1523 #: ../src/guestfs.pod:730
1525 "The work around is to use L</guestfs_mount_options> and set the mount "
1526 "options that you actually want to use."
1530 #: ../src/guestfs.pod:733
1531 msgid "Read-only should be the default."
1535 #: ../src/guestfs.pod:735
1537 "In L<guestfish(3)>, I<--ro> should be the default, and you should have to "
1538 "specify I<--rw> if you want to make changes to the image."
1542 #: ../src/guestfs.pod:738
1543 msgid "This would reduce the potential to corrupt live VM images."
1547 #: ../src/guestfs.pod:740
1549 "Note that many filesystems change the disk when you just mount and unmount, "
1550 "even if you didn't perform any writes. You need to use L</"
1551 "guestfs_add_drive_ro> to guarantee that the disk is not changed."
1555 #: ../src/guestfs.pod:744
1556 msgid "guestfish command line is hard to use."
1560 #: ../src/guestfs.pod:746
1562 "C<guestfish disk.img> doesn't do what people expect (open C<disk.img> for "
1563 "examination). It tries to run a guestfish command C<disk.img> which doesn't "
1564 "exist, so it fails. In earlier versions of guestfish the error message was "
1565 "also unintuitive, but we have corrected this since. Like the Bourne shell, "
1566 "we should have used C<guestfish -c command> to run commands."
1570 #: ../src/guestfs.pod:753
1571 msgid "guestfish megabyte modifiers don't work right on all commands"
1575 #: ../src/guestfs.pod:755
1577 "In recent guestfish you can use C<1M> to mean 1 megabyte (and similarly for "
1578 "other modifiers). What guestfish actually does is to multiply the number "
1579 "part by the modifier part and pass the result to the C API. However this "
1580 "doesn't work for a few APIs which aren't expecting bytes, but are already "
1581 "expecting some other unit (eg. megabytes)."
1585 #: ../src/guestfs.pod:762
1586 msgid "The most common is L</guestfs_lvcreate>. The guestfish command:"
1590 #: ../src/guestfs.pod:764
1593 " lvcreate LV VG 100M\n"
1598 #: ../src/guestfs.pod:766
1600 "does not do what you might expect. Instead because L</guestfs_lvcreate> is "
1601 "already expecting megabytes, this tries to create a 100 I<terabyte> (100 "
1602 "megabytes * megabytes) logical volume. The error message you get from this "
1603 "is also a little obscure."
1607 #: ../src/guestfs.pod:771
1609 "This could be fixed in the generator by specially marking parameters and "
1610 "return values which take bytes or other units."
1614 #: ../src/guestfs.pod:774
1615 msgid "Ambiguity between devices and paths"
1619 #: ../src/guestfs.pod:776
1621 "There is a subtle ambiguity in the API between a device name (eg. C</dev/"
1622 "sdb2>) and a similar pathname. A file might just happen to be called "
1623 "C<sdb2> in the directory C</dev> (consider some non-Unix VM image)."
1627 #: ../src/guestfs.pod:781
1629 "In the current API we usually resolve this ambiguity by having two separate "
1630 "calls, for example L</guestfs_checksum> and L</guestfs_checksum_device>. "
1631 "Some API calls are ambiguous and (incorrectly) resolve the problem by "
1632 "detecting if the path supplied begins with C</dev/>."
1636 #: ../src/guestfs.pod:787
1638 "To avoid both the ambiguity and the need to duplicate some calls, we could "
1639 "make paths/devices into structured names. One way to do this would be to "
1640 "use a notation like grub (C<hd(0,0)>), although nobody really likes this "
1641 "aspect of grub. Another way would be to use a structured type, equivalent "
1642 "to this OCaml type:"
1646 #: ../src/guestfs.pod:793
1649 " type path = Path of string | Device of int | Partition of int * int\n"
1654 #: ../src/guestfs.pod:795
1655 msgid "which would allow you to pass arguments like:"
1659 #: ../src/guestfs.pod:797
1662 " Path \"/foo/bar\"\n"
1663 " Device 1 (* /dev/sdb, or perhaps /dev/sda *)\n"
1664 " Partition (1, 2) (* /dev/sdb2 (or is it /dev/sda2 or /dev/sdb3?) *)\n"
1665 " Path \"/dev/sdb2\" (* not a device *)\n"
1670 #: ../src/guestfs.pod:802
1672 "As you can see there are still problems to resolve even with this "
1673 "representation. Also consider how it might work in guestfish."
1677 #: ../src/guestfs.pod:807
1678 msgid "PROTOCOL LIMITS"
1682 #: ../src/guestfs.pod:809
1684 "Internally libguestfs uses a message-based protocol to pass API calls and "
1685 "their responses to and from a small \"appliance\" (see L</INTERNALS> for "
1686 "plenty more detail about this). The maximum message size used by the "
1687 "protocol is slightly less than 4 MB. For some API calls you may need to be "
1688 "aware of this limit. The API calls which may be affected are individually "
1689 "documented, with a link back to this section of the documentation."
1693 #: ../src/guestfs.pod:817
1695 "A simple call such as L</guestfs_cat> returns its result (the file data) in "
1696 "a simple string. Because this string is at some point internally encoded as "
1697 "a message, the maximum size that it can return is slightly under 4 MB. If "
1698 "the requested file is larger than this then you will get an error."
1702 #: ../src/guestfs.pod:823
1704 "In order to transfer large files into and out of the guest filesystem, you "
1705 "need to use particular calls that support this. The sections L</UPLOADING> "
1706 "and L</DOWNLOADING> document how to do this."
1710 #: ../src/guestfs.pod:827
1712 "You might also consider mounting the disk image using our FUSE filesystem "
1713 "support (L<guestmount(1)>)."
1717 #: ../src/guestfs.pod:830
1718 msgid "KEYS AND PASSPHRASES"
1722 #: ../src/guestfs.pod:832
1724 "Certain libguestfs calls take a parameter that contains sensitive key "
1725 "material, passed in as a C string."
1729 #: ../src/guestfs.pod:835
1731 "In the future we would hope to change the libguestfs implementation so that "
1732 "keys are L<mlock(2)>-ed into physical RAM, and thus can never end up in "
1733 "swap. However this is I<not> done at the moment, because of the complexity "
1734 "of such an implementation."
1738 #: ../src/guestfs.pod:840
1740 "Therefore you should be aware that any key parameter you pass to libguestfs "
1741 "might end up being written out to the swap partition. If this is a concern, "
1742 "scrub the swap partition or don't use libguestfs on encrypted devices."
1746 #: ../src/guestfs.pod:845
1747 msgid "MULTIPLE HANDLES AND MULTIPLE THREADS"
1751 #: ../src/guestfs.pod:847
1753 "All high-level libguestfs actions are synchronous. If you want to use "
1754 "libguestfs asynchronously then you must create a thread."
1758 #: ../src/guestfs.pod:850
1760 "Only use the handle from a single thread. Either use the handle exclusively "
1761 "from one thread, or provide your own mutex so that two threads cannot issue "
1762 "calls on the same handle at the same time."
1766 #: ../src/guestfs.pod:854
1768 "See the graphical program guestfs-browser for one possible architecture for "
1769 "multithreaded programs using libvirt and libguestfs."
1773 #: ../src/guestfs.pod:857
1778 #: ../src/guestfs.pod:859
1780 "Libguestfs needs a kernel and initrd.img, which it finds by looking along an "
1785 #: ../src/guestfs.pod:862
1787 "By default it looks for these in the directory C<$libdir/guestfs> (eg. C</"
1788 "usr/local/lib/guestfs> or C</usr/lib64/guestfs>)."
1792 #: ../src/guestfs.pod:865
1794 "Use L</guestfs_set_path> or set the environment variable L</LIBGUESTFS_PATH> "
1795 "to change the directories that libguestfs will search in. The value is a "
1796 "colon-separated list of paths. The current directory is I<not> searched "
1797 "unless the path contains an empty element or C<.>. For example "
1798 "C<LIBGUESTFS_PATH=:/usr/lib/guestfs> would search the current directory and "
1799 "then C</usr/lib/guestfs>."
1803 #: ../src/guestfs.pod:872
1804 msgid "QEMU WRAPPERS"
1808 #: ../src/guestfs.pod:874
1810 "If you want to compile your own qemu, run qemu from a non-standard location, "
1811 "or pass extra arguments to qemu, then you can write a shell-script wrapper "
1816 #: ../src/guestfs.pod:878
1818 "There is one important rule to remember: you I<must C<exec qemu>> as the "
1819 "last command in the shell script (so that qemu replaces the shell and "
1820 "becomes the direct child of the libguestfs-using program). If you don't do "
1821 "this, then the qemu process won't be cleaned up correctly."
1825 #: ../src/guestfs.pod:883
1827 "Here is an example of a wrapper, where I have built my own copy of qemu from "
1832 #: ../src/guestfs.pod:886
1836 " qemudir=/home/rjones/d/qemu\n"
1837 " exec $qemudir/x86_64-softmmu/qemu-system-x86_64 -L $qemudir/pc-bios \"$@\"\n"
1842 #: ../src/guestfs.pod:890
1844 "Save this script as C</tmp/qemu.wrapper> (or wherever), C<chmod +x>, and "
1845 "then use it by setting the LIBGUESTFS_QEMU environment variable. For "
1850 #: ../src/guestfs.pod:894
1853 " LIBGUESTFS_QEMU=/tmp/qemu.wrapper guestfish\n"
1858 #: ../src/guestfs.pod:896
1860 "Note that libguestfs also calls qemu with the -help and -version options in "
1861 "order to determine features."
1865 #: ../src/guestfs.pod:899
1866 msgid "ABI GUARANTEE"
1870 #: ../src/guestfs.pod:901
1872 "We guarantee the libguestfs ABI (binary interface), for public, high-level "
1873 "actions as outlined in this section. Although we will deprecate some "
1874 "actions, for example if they get replaced by newer calls, we will keep the "
1875 "old actions forever. This allows you the developer to program in confidence "
1876 "against the libguestfs API."
1880 #: ../src/guestfs.pod:907
1881 msgid "BLOCK DEVICE NAMING"
1885 #: ../src/guestfs.pod:909
1887 "In the kernel there is now quite a profusion of schemata for naming block "
1888 "devices (in this context, by I<block device> I mean a physical or virtual "
1889 "hard drive). The original Linux IDE driver used names starting with C</dev/"
1890 "hd*>. SCSI devices have historically used a different naming scheme, C</dev/"
1891 "sd*>. When the Linux kernel I<libata> driver became a popular replacement "
1892 "for the old IDE driver (particularly for SATA devices) those devices also "
1893 "used the C</dev/sd*> scheme. Additionally we now have virtual machines with "
1894 "paravirtualized drivers. This has created several different naming systems, "
1895 "such as C</dev/vd*> for virtio disks and C</dev/xvd*> for Xen PV disks."
1899 #: ../src/guestfs.pod:921
1901 "As discussed above, libguestfs uses a qemu appliance running an embedded "
1902 "Linux kernel to access block devices. We can run a variety of appliances "
1903 "based on a variety of Linux kernels."
1907 #: ../src/guestfs.pod:925
1909 "This causes a problem for libguestfs because many API calls use device or "
1910 "partition names. Working scripts and the recipe (example) scripts that we "
1911 "make available over the internet could fail if the naming scheme changes."
1915 #: ../src/guestfs.pod:930
1917 "Therefore libguestfs defines C</dev/sd*> as the I<standard naming scheme>. "
1918 "Internally C</dev/sd*> names are translated, if necessary, to other names as "
1919 "required. For example, under RHEL 5 which uses the C</dev/hd*> scheme, any "
1920 "device parameter C</dev/sda2> is translated to C</dev/hda2> transparently."
1924 #: ../src/guestfs.pod:936
1926 "Note that this I<only> applies to parameters. The L</guestfs_list_devices>, "
1927 "L</guestfs_list_partitions> and similar calls return the true names of the "
1928 "devices and partitions as known to the appliance."
1932 #: ../src/guestfs.pod:941
1933 msgid "ALGORITHM FOR BLOCK DEVICE NAME TRANSLATION"
1937 #: ../src/guestfs.pod:943
1939 "Usually this translation is transparent. However in some (very rare) cases "
1940 "you may need to know the exact algorithm. Such cases include where you use "
1941 "L</guestfs_config> to add a mixture of virtio and IDE devices to the qemu-"
1942 "based appliance, so have a mixture of C</dev/sd*> and C</dev/vd*> devices."
1946 #: ../src/guestfs.pod:949
1948 "The algorithm is applied only to I<parameters> which are known to be either "
1949 "device or partition names. Return values from functions such as L</"
1950 "guestfs_list_devices> are never changed."
1954 #: ../src/guestfs.pod:957
1955 msgid "Is the string a parameter which is a device or partition name?"
1959 #: ../src/guestfs.pod:961
1960 msgid "Does the string begin with C</dev/sd>?"
1964 #: ../src/guestfs.pod:965
1966 "Does the named device exist? If so, we use that device. However if I<not> "
1967 "then we continue with this algorithm."
1971 #: ../src/guestfs.pod:970
1972 msgid "Replace initial C</dev/sd> string with C</dev/hd>."
1976 #: ../src/guestfs.pod:972
1977 msgid "For example, change C</dev/sda2> to C</dev/hda2>."
1981 #: ../src/guestfs.pod:974
1982 msgid "If that named device exists, use it. If not, continue."
1986 #: ../src/guestfs.pod:978
1987 msgid "Replace initial C</dev/sd> string with C</dev/vd>."
1991 #: ../src/guestfs.pod:980
1992 msgid "If that named device exists, use it. If not, return an error."
1996 #: ../src/guestfs.pod:984
1997 msgid "PORTABILITY CONCERNS WITH BLOCK DEVICE NAMING"
2001 #: ../src/guestfs.pod:986
2003 "Although the standard naming scheme and automatic translation is useful for "
2004 "simple programs and guestfish scripts, for larger programs it is best not to "
2005 "rely on this mechanism."
2009 #: ../src/guestfs.pod:990
2011 "Where possible for maximum future portability programs using libguestfs "
2012 "should use these future-proof techniques:"
2016 #: ../src/guestfs.pod:997
2018 "Use L</guestfs_list_devices> or L</guestfs_list_partitions> to list actual "
2019 "device names, and then use those names directly."
2023 #: ../src/guestfs.pod:1000
2025 "Since those device names exist by definition, they will never be translated."
2029 #: ../src/guestfs.pod:1005
2031 "Use higher level ways to identify filesystems, such as LVM names, UUIDs and "
2032 "filesystem labels."
2036 #: ../src/guestfs.pod:1010
2041 #: ../src/guestfs.pod:1012
2043 "This section discusses security implications of using libguestfs, "
2044 "particularly with untrusted or malicious guests or disk images."
2048 #: ../src/guestfs.pod:1015
2049 msgid "GENERAL SECURITY CONSIDERATIONS"
2053 #: ../src/guestfs.pod:1017
2055 "Be careful with any files or data that you download from a guest (by "
2056 "\"download\" we mean not just the L</guestfs_download> command but any "
2057 "command that reads files, filenames, directories or anything else from a "
2058 "disk image). An attacker could manipulate the data to fool your program "
2059 "into doing the wrong thing. Consider cases such as:"
2063 #: ../src/guestfs.pod:1027
2064 msgid "the data (file etc) not being present"
2068 #: ../src/guestfs.pod:1031
2069 msgid "being present but empty"
2073 #: ../src/guestfs.pod:1035
2074 msgid "being much larger than normal"
2078 #: ../src/guestfs.pod:1039
2079 msgid "containing arbitrary 8 bit data"
2083 #: ../src/guestfs.pod:1043
2084 msgid "being in an unexpected character encoding"
2088 #: ../src/guestfs.pod:1047
2089 msgid "containing homoglyphs."
2093 #: ../src/guestfs.pod:1051
2094 msgid "SECURITY OF MOUNTING FILESYSTEMS"
2098 #: ../src/guestfs.pod:1053
2100 "When you mount a filesystem under Linux, mistakes in the kernel filesystem "
2101 "(VFS) module can sometimes be escalated into exploits by deliberately "
2102 "creating a malicious, malformed filesystem. These exploits are very severe "
2103 "for two reasons. Firstly there are very many filesystem drivers in the "
2104 "kernel, and many of them are infrequently used and not much developer "
2105 "attention has been paid to the code. Linux userspace helps potential "
2106 "crackers by detecting the filesystem type and automatically choosing the "
2107 "right VFS driver, even if that filesystem type is obscure or unexpected for "
2108 "the administrator. Secondly, a kernel-level exploit is like a local root "
2109 "exploit (worse in some ways), giving immediate and total access to the "
2110 "system right down to the hardware level."
2114 #: ../src/guestfs.pod:1066
2116 "That explains why you should never mount a filesystem from an untrusted "
2117 "guest on your host kernel. How about libguestfs? We run a Linux kernel "
2118 "inside a qemu virtual machine, usually running as a non-root user. The "
2119 "attacker would need to write a filesystem which first exploited the kernel, "
2120 "and then exploited either qemu virtualization (eg. a faulty qemu driver) or "
2121 "the libguestfs protocol, and finally to be as serious as the host kernel "
2122 "exploit it would need to escalate its privileges to root. This multi-step "
2123 "escalation, performed by a static piece of data, is thought to be extremely "
2124 "hard to do, although we never say 'never' about security issues."
2128 #: ../src/guestfs.pod:1077
2130 "In any case callers can reduce the attack surface by forcing the filesystem "
2131 "type when mounting (use L</guestfs_mount_vfs>)."
2135 #: ../src/guestfs.pod:1080
2136 msgid "PROTOCOL SECURITY"
2140 #: ../src/guestfs.pod:1082
2142 "The protocol is designed to be secure, being based on RFC 4506 (XDR) with a "
2143 "defined upper message size. However a program that uses libguestfs must "
2144 "also take care - for example you can write a program that downloads a binary "
2145 "from a disk image and executes it locally, and no amount of protocol "
2146 "security will save you from the consequences."
2150 #: ../src/guestfs.pod:1088
2151 msgid "INSPECTION SECURITY"
2155 #: ../src/guestfs.pod:1090
2157 "Parts of the inspection API (see L</INSPECTION>) return untrusted strings "
2158 "directly from the guest, and these could contain any 8 bit data. Callers "
2159 "should be careful to escape these before printing them to a structured file "
2160 "(for example, use HTML escaping if creating a web page)."
2164 #: ../src/guestfs.pod:1096
2166 "The inspection API parses guest configuration using two external libraries: "
2167 "Augeas (Linux configuration) and hivex (Windows Registry). Both are "
2168 "designed to be robust in the face of malicious data, although denial of "
2169 "service attacks are still possible, for example with oversized configuration "
2174 #: ../src/guestfs.pod:1102
2175 msgid "RUNNING UNTRUSTED GUEST COMMANDS"
2179 #: ../src/guestfs.pod:1104
2181 "Be very cautious about running commands from the guest. By running a "
2182 "command in the guest, you are giving CPU time to a binary that you do not "
2183 "control, under the same user account as the library, albeit wrapped in qemu "
2184 "virtualization. More information and alternatives can be found in the "
2185 "section L</RUNNING COMMANDS>."
2189 #: ../src/guestfs.pod:1110
2190 msgid "CVE-2010-3851"
2194 #: ../src/guestfs.pod:1112
2195 msgid "https://bugzilla.redhat.com/642934"
2199 #: ../src/guestfs.pod:1114
2201 "This security bug concerns the automatic disk format detection that qemu "
2202 "does on disk images."
2206 #: ../src/guestfs.pod:1117
2208 "A raw disk image is just the raw bytes, there is no header. Other disk "
2209 "images like qcow2 contain a special header. Qemu deals with this by looking "
2210 "for one of the known headers, and if none is found then assuming the disk "
2211 "image must be raw."
2215 #: ../src/guestfs.pod:1122
2217 "This allows a guest which has been given a raw disk image to write some "
2218 "other header. At next boot (or when the disk image is accessed by "
2219 "libguestfs) qemu would do autodetection and think the disk image format was, "
2220 "say, qcow2 based on the header written by the guest."
2224 #: ../src/guestfs.pod:1127
2226 "This in itself would not be a problem, but qcow2 offers many features, one "
2227 "of which is to allow a disk image to refer to another image (called the "
2228 "\"backing disk\"). It does this by placing the path to the backing disk "
2229 "into the qcow2 header. This path is not validated and could point to any "
2230 "host file (eg. \"/etc/passwd\"). The backing disk is then exposed through "
2231 "\"holes\" in the qcow2 disk image, which of course is completely under the "
2232 "control of the attacker."
2236 #: ../src/guestfs.pod:1135
2238 "In libguestfs this is rather hard to exploit except under two circumstances:"
2242 #: ../src/guestfs.pod:1142
2243 msgid "You have enabled the network or have opened the disk in write mode."
2247 #: ../src/guestfs.pod:1146
2249 "You are also running untrusted code from the guest (see L</RUNNING "
2254 #: ../src/guestfs.pod:1151
2256 "The way to avoid this is to specify the expected disk format when adding "
2257 "disks (the optional C<format> option to L</guestfs_add_drive_opts>). You "
2258 "should always do this if the disk is raw format, and it's a good idea for "
2263 #: ../src/guestfs.pod:1156
2265 "For disks added from libvirt using calls like L</guestfs_add_domain>, the "
2266 "format is fetched from libvirt and passed through."
2270 #: ../src/guestfs.pod:1159
2272 "For libguestfs tools, use the I<--format> command line parameter as "
2277 #: ../src/guestfs.pod:1162
2278 msgid "CONNECTION MANAGEMENT"
2282 #: ../src/guestfs.pod:1164
2287 #: ../src/guestfs.pod:1166
2289 "C<guestfs_h> is the opaque type representing a connection handle. Create a "
2290 "handle by calling L</guestfs_create>. Call L</guestfs_close> to free the "
2291 "handle and release all resources used."
2295 #: ../src/guestfs.pod:1170
2297 "For information on using multiple handles and threads, see the section L</"
2298 "MULTIPLE HANDLES AND MULTIPLE THREADS> below."
2302 #: ../src/guestfs.pod:1173
2303 msgid "guestfs_create"
2307 #: ../src/guestfs.pod:1175
2310 " guestfs_h *guestfs_create (void);\n"
2315 #: ../src/guestfs.pod:1177
2316 msgid "Create a connection handle."
2320 #: ../src/guestfs.pod:1179
2322 "You have to call L</guestfs_add_drive_opts> (or one of the equivalent calls) "
2323 "on the handle at least once."
2327 #: ../src/guestfs.pod:1182
2329 "This function returns a non-NULL pointer to a handle on success or NULL on "
2334 #: ../src/guestfs.pod:1185
2335 msgid "After configuring the handle, you have to call L</guestfs_launch>."
2339 #: ../src/guestfs.pod:1187
2341 "You may also want to configure error handling for the handle. See L</ERROR "
2342 "HANDLING> section below."
2346 #: ../src/guestfs.pod:1190
2347 msgid "guestfs_close"
2351 #: ../src/guestfs.pod:1192
2354 " void guestfs_close (guestfs_h *g);\n"
2359 #: ../src/guestfs.pod:1194
2360 msgid "This closes the connection handle and frees up all resources used."
2364 #: ../src/guestfs.pod:1196
2365 msgid "ERROR HANDLING"
2369 #: ../src/guestfs.pod:1198
2371 "API functions can return errors. For example, almost all functions that "
2372 "return C<int> will return C<-1> to indicate an error."
2376 #: ../src/guestfs.pod:1201
2378 "Additional information is available for errors: an error message string and "
2379 "optionally an error number (errno) if the thing that failed was a system "
2384 #: ../src/guestfs.pod:1205
2386 "You can get at the additional information about the last error on the handle "
2387 "by calling L</guestfs_last_error>, L</guestfs_last_errno>, and/or by setting "
2388 "up an error handler with L</guestfs_set_error_handler>."
2392 #: ../src/guestfs.pod:1210
2394 "When the handle is created, a default error handler is installed which "
2395 "prints the error message string to C<stderr>. For small short-running "
2396 "command line programs it is sufficient to do:"
2400 #: ../src/guestfs.pod:1214
2403 " if (guestfs_launch (g) == -1)\n"
2404 " exit (EXIT_FAILURE);\n"
2409 #: ../src/guestfs.pod:1217
2411 "since the default error handler will ensure that an error message has been "
2412 "printed to C<stderr> before the program exits."
2416 #: ../src/guestfs.pod:1220
2418 "For other programs the caller will almost certainly want to install an "
2419 "alternate error handler or do error handling in-line like this:"
2423 #: ../src/guestfs.pod:1223
2426 " g = guestfs_create ();\n"
2431 #: ../src/guestfs.pod:1225
2434 " /* This disables the default behaviour of printing errors\n"
2436 " guestfs_set_error_handler (g, NULL, NULL);\n"
2441 #: ../src/guestfs.pod:1229
2444 " if (guestfs_launch (g) == -1) {\n"
2445 " /* Examine the error message and print it etc. */\n"
2446 " char *msg = guestfs_last_error (g);\n"
2447 " int errnum = guestfs_last_errno (g);\n"
2448 " fprintf (stderr, \"%s\\n\", msg);\n"
2455 #: ../src/guestfs.pod:1237
2457 "Out of memory errors are handled differently. The default action is to call "
2458 "L<abort(3)>. If this is undesirable, then you can set a handler using L</"
2459 "guestfs_set_out_of_memory_handler>."
2463 #: ../src/guestfs.pod:1241
2465 "L</guestfs_create> returns C<NULL> if the handle cannot be created, and "
2466 "because there is no handle if this happens there is no way to get additional "
2467 "error information. However L</guestfs_create> is supposed to be a "
2468 "lightweight operation which can only fail because of insufficient memory (it "
2469 "returns NULL in this case)."
2473 #: ../src/guestfs.pod:1247
2474 msgid "guestfs_last_error"
2478 #: ../src/guestfs.pod:1249
2481 " const char *guestfs_last_error (guestfs_h *g);\n"
2486 #: ../src/guestfs.pod:1251
2488 "This returns the last error message that happened on C<g>. If there has not "
2489 "been an error since the handle was created, then this returns C<NULL>."
2493 #: ../src/guestfs.pod:1255
2495 "The lifetime of the returned string is until the next error occurs, or L</"
2496 "guestfs_close> is called."
2500 #: ../src/guestfs.pod:1258
2501 msgid "guestfs_last_errno"
2505 #: ../src/guestfs.pod:1260
2508 " int guestfs_last_errno (guestfs_h *g);\n"
2513 #: ../src/guestfs.pod:1262
2514 msgid "This returns the last error number (errno) that happened on C<g>."
2518 #: ../src/guestfs.pod:1264
2519 msgid "If successful, an errno integer not equal to zero is returned."
2523 #: ../src/guestfs.pod:1266
2525 "If no error, this returns 0. This call can return 0 in three situations:"
2529 #: ../src/guestfs.pod:1273
2530 msgid "There has not been any error on the handle."
2534 #: ../src/guestfs.pod:1277
2536 "There has been an error but the errno was meaningless. This corresponds to "
2537 "the case where the error did not come from a failed system call, but for "
2538 "some other reason."
2542 #: ../src/guestfs.pod:1283
2544 "There was an error from a failed system call, but for some reason the errno "
2545 "was not captured and returned. This usually indicates a bug in libguestfs."
2549 #: ../src/guestfs.pod:1289
2551 "Libguestfs tries to convert the errno from inside the applicance into a "
2552 "corresponding errno for the caller (not entirely trivial: the appliance "
2553 "might be running a completely different operating system from the library "
2554 "and error numbers are not standardized across Un*xen). If this could not be "
2555 "done, then the error is translated to C<EINVAL>. In practice this should "
2556 "only happen in very rare circumstances."
2560 #: ../src/guestfs.pod:1297
2561 msgid "guestfs_set_error_handler"
2565 #: ../src/guestfs.pod:1299
2568 " typedef void (*guestfs_error_handler_cb) (guestfs_h *g,\n"
2570 " const char *msg);\n"
2571 " void guestfs_set_error_handler (guestfs_h *g,\n"
2572 " guestfs_error_handler_cb cb,\n"
2578 #: ../src/guestfs.pod:1306
2580 "The callback C<cb> will be called if there is an error. The parameters "
2581 "passed to the callback are an opaque data pointer and the error message "
2586 #: ../src/guestfs.pod:1310
2588 "C<errno> is not passed to the callback. To get that the callback must call "
2589 "L</guestfs_last_errno>."
2593 #: ../src/guestfs.pod:1313
2595 "Note that the message string C<msg> is freed as soon as the callback "
2596 "function returns, so if you want to stash it somewhere you must make your "
2601 #: ../src/guestfs.pod:1317
2602 msgid "The default handler prints messages on C<stderr>."
2606 #: ../src/guestfs.pod:1319
2607 msgid "If you set C<cb> to C<NULL> then I<no> handler is called."
2611 #: ../src/guestfs.pod:1321
2612 msgid "guestfs_get_error_handler"
2616 #: ../src/guestfs.pod:1323
2619 " guestfs_error_handler_cb guestfs_get_error_handler (guestfs_h *g,\n"
2620 " void **opaque_rtn);\n"
2625 #: ../src/guestfs.pod:1326
2626 msgid "Returns the current error handler callback."
2630 #: ../src/guestfs.pod:1328
2631 msgid "guestfs_set_out_of_memory_handler"
2635 #: ../src/guestfs.pod:1330
2638 " typedef void (*guestfs_abort_cb) (void);\n"
2639 " int guestfs_set_out_of_memory_handler (guestfs_h *g,\n"
2640 " guestfs_abort_cb);\n"
2645 #: ../src/guestfs.pod:1334
2647 "The callback C<cb> will be called if there is an out of memory situation. "
2648 "I<Note this callback must not return>."
2652 #: ../src/guestfs.pod:1337
2653 msgid "The default is to call L<abort(3)>."
2657 #: ../src/guestfs.pod:1339
2659 "You cannot set C<cb> to C<NULL>. You can't ignore out of memory situations."
2663 #: ../src/guestfs.pod:1342
2664 msgid "guestfs_get_out_of_memory_handler"
2668 #: ../src/guestfs.pod:1344
2671 " guestfs_abort_fn guestfs_get_out_of_memory_handler (guestfs_h *g);\n"
2676 #: ../src/guestfs.pod:1346
2677 msgid "This returns the current out of memory handler."
2681 #: ../src/guestfs.pod:1348
2686 #: ../src/guestfs.pod:1350 ../fish/guestfish.pod:907
2691 #: ../src/guestfs.pod:1352
2696 #: ../src/guestfs.pod:1354
2701 #: ../src/guestfs.pod:1356
2702 msgid "AVAILABILITY"
2706 #: ../src/guestfs.pod:1358
2707 msgid "GROUPS OF FUNCTIONALITY IN THE APPLIANCE"
2711 #: ../src/guestfs.pod:1360
2713 "Using L</guestfs_available> you can test availability of the following "
2714 "groups of functions. This test queries the appliance to see if the "
2715 "appliance you are currently using supports the functionality."
2719 #: ../src/guestfs.pod:1365
2720 msgid "@AVAILABILITY@"
2724 #: ../src/guestfs.pod:1367
2725 msgid "GUESTFISH supported COMMAND"
2729 #: ../src/guestfs.pod:1369
2731 "In L<guestfish(3)> there is a handy interactive command C<supported> which "
2732 "prints out the available groups and whether they are supported by this build "
2733 "of libguestfs. Note however that you have to do C<run> first."
2737 #: ../src/guestfs.pod:1374
2738 msgid "SINGLE CALLS AT COMPILE TIME"
2742 #: ../src/guestfs.pod:1376
2744 "Since version 1.5.8, C<E<lt>guestfs.hE<gt>> defines symbols for each C API "
2745 "function, such as:"
2749 #: ../src/guestfs.pod:1379
2752 " #define LIBGUESTFS_HAVE_DD 1\n"
2757 #: ../src/guestfs.pod:1381
2758 msgid "if L</guestfs_dd> is available."
2762 #: ../src/guestfs.pod:1383
2764 "Before version 1.5.8, if you needed to test whether a single libguestfs "
2765 "function is available at compile time, we recommended using build tools such "
2766 "as autoconf or cmake. For example in autotools you could use:"
2770 #: ../src/guestfs.pod:1388
2773 " AC_CHECK_LIB([guestfs],[guestfs_create])\n"
2774 " AC_CHECK_FUNCS([guestfs_dd])\n"
2779 #: ../src/guestfs.pod:1391
2781 "which would result in C<HAVE_GUESTFS_DD> being either defined or not defined "
2786 #: ../src/guestfs.pod:1394
2787 msgid "SINGLE CALLS AT RUN TIME"
2791 #: ../src/guestfs.pod:1396
2793 "Testing at compile time doesn't guarantee that a function really exists in "
2794 "the library. The reason is that you might be dynamically linked against a "
2795 "previous I<libguestfs.so> (dynamic library) which doesn't have the call. "
2796 "This situation unfortunately results in a segmentation fault, which is a "
2797 "shortcoming of the C dynamic linking system itself."
2801 #: ../src/guestfs.pod:1403
2803 "You can use L<dlopen(3)> to test if a function is available at run time, as "
2804 "in this example program (note that you still need the compile time check as "
2809 #: ../src/guestfs.pod:1407
2812 " #include <stdio.h>\n"
2813 " #include <stdlib.h>\n"
2814 " #include <unistd.h>\n"
2815 " #include <dlfcn.h>\n"
2816 " #include <guestfs.h>\n"
2821 #: ../src/guestfs.pod:1413
2826 " #ifdef LIBGUESTFS_HAVE_DD\n"
2828 " int has_function;\n"
2833 #: ../src/guestfs.pod:1419
2836 " /* Test if the function guestfs_dd is really available. */\n"
2837 " dl = dlopen (NULL, RTLD_LAZY);\n"
2839 " fprintf (stderr, \"dlopen: %s\\n\", dlerror ());\n"
2840 " exit (EXIT_FAILURE);\n"
2842 " has_function = dlsym (dl, \"guestfs_dd\") != NULL;\n"
2848 #: ../src/guestfs.pod:1428
2851 " if (!has_function)\n"
2852 " printf (\"this libguestfs.so does NOT have guestfs_dd function\\n\");\n"
2854 " printf (\"this libguestfs.so has guestfs_dd function\\n\");\n"
2855 " /* Now it's safe to call\n"
2856 " guestfs_dd (g, \"foo\", \"bar\");\n"
2860 " printf (\"guestfs_dd function was not found at compile time\\n\");\n"
2867 #: ../src/guestfs.pod:1441
2869 "You may think the above is an awful lot of hassle, and it is. There are "
2870 "other ways outside of the C linking system to ensure that this kind of "
2871 "incompatibility never arises, such as using package versioning:"
2875 #: ../src/guestfs.pod:1446
2878 " Requires: libguestfs >= 1.0.80\n"
2883 #: ../src/guestfs.pod:1448
2884 msgid "CALLS WITH OPTIONAL ARGUMENTS"
2888 #: ../src/guestfs.pod:1450
2890 "A recent feature of the API is the introduction of calls which take optional "
2891 "arguments. In C these are declared 3 ways. The main way is as a call which "
2892 "takes variable arguments (ie. C<...>), as in this example:"
2896 #: ../src/guestfs.pod:1455
2899 " int guestfs_add_drive_opts (guestfs_h *g, const char *filename, ...);\n"
2904 #: ../src/guestfs.pod:1457
2906 "Call this with a list of optional arguments, terminated by C<-1>. So to "
2907 "call with no optional arguments specified:"
2911 #: ../src/guestfs.pod:1460
2914 " guestfs_add_drive_opts (g, filename, -1);\n"
2919 #: ../src/guestfs.pod:1462
2920 msgid "With a single optional argument:"
2924 #: ../src/guestfs.pod:1464
2927 " guestfs_add_drive_opts (g, filename,\n"
2928 " GUESTFS_ADD_DRIVE_OPTS_FORMAT, \"qcow2\",\n"
2934 #: ../src/guestfs.pod:1468
2939 #: ../src/guestfs.pod:1470
2942 " guestfs_add_drive_opts (g, filename,\n"
2943 " GUESTFS_ADD_DRIVE_OPTS_FORMAT, \"qcow2\",\n"
2944 " GUESTFS_ADD_DRIVE_OPTS_READONLY, 1,\n"
2950 #: ../src/guestfs.pod:1475
2952 "and so forth. Don't forget the terminating C<-1> otherwise Bad Things will "
2957 #: ../src/guestfs.pod:1478
2958 msgid "USING va_list FOR OPTIONAL ARGUMENTS"
2962 #: ../src/guestfs.pod:1480
2964 "The second variant has the same name with the suffix C<_va>, which works the "
2965 "same way but takes a C<va_list>. See the C manual for details. For the "
2966 "example function, this is declared:"
2970 #: ../src/guestfs.pod:1484
2973 " int guestfs_add_drive_opts_va (guestfs_h *g, const char *filename,\n"
2979 #: ../src/guestfs.pod:1487
2980 msgid "CONSTRUCTING OPTIONAL ARGUMENTS"
2984 #: ../src/guestfs.pod:1489
2986 "The third variant is useful where you need to construct these calls. You "
2987 "pass in a structure where you fill in the optional fields. The structure "
2988 "has a bitmask as the first element which you must set to indicate which "
2989 "fields you have filled in. For our example function the structure and call "
2994 #: ../src/guestfs.pod:1495
2997 " struct guestfs_add_drive_opts_argv {\n"
2998 " uint64_t bitmask;\n"
3000 " const char *format;\n"
3003 " int guestfs_add_drive_opts_argv (guestfs_h *g, const char *filename,\n"
3004 " const struct guestfs_add_drive_opts_argv *optargs);\n"
3009 #: ../src/guestfs.pod:1504
3010 msgid "You could call it like this:"
3014 #: ../src/guestfs.pod:1506
3017 " struct guestfs_add_drive_opts_argv optargs = {\n"
3018 " .bitmask = GUESTFS_ADD_DRIVE_OPTS_READONLY_BITMASK |\n"
3019 " GUESTFS_ADD_DRIVE_OPTS_FORMAT_BITMASK,\n"
3021 " .format = \"qcow2\"\n"
3027 #: ../src/guestfs.pod:1513
3030 " guestfs_add_drive_opts_argv (g, filename, &optargs);\n"
3035 #: ../src/guestfs.pod:1515 ../src/guestfs-actions.pod:11
3036 #: ../src/guestfs-actions.pod:1842 ../fish/guestfish-actions.pod:9
3037 #: ../fish/guestfish-actions.pod:1255
3042 #: ../src/guestfs.pod:1521
3043 msgid "The C<_BITMASK> suffix on each option name when specifying the bitmask."
3047 #: ../src/guestfs.pod:1526
3048 msgid "You do not need to fill in all fields of the structure."
3052 #: ../src/guestfs.pod:1530
3054 "There must be a one-to-one correspondence between fields of the structure "
3055 "that are filled in, and bits set in the bitmask."
3059 #: ../src/guestfs.pod:1535
3060 msgid "OPTIONAL ARGUMENTS IN OTHER LANGUAGES"
3064 #: ../src/guestfs.pod:1537
3066 "In other languages, optional arguments are expressed in the way that is "
3067 "natural for that language. We refer you to the language-specific "
3068 "documentation for more details on that."
3072 #: ../src/guestfs.pod:1541
3073 msgid "For guestfish, see L<guestfish(1)/OPTIONAL ARGUMENTS>."
3077 #: ../src/guestfs.pod:1543
3078 msgid "SETTING CALLBACKS TO HANDLE EVENTS"
3082 #: ../src/guestfs.pod:1545
3084 "The child process generates events in some situations. Current events "
3085 "include: receiving a log message, the child process exits."
3089 #: ../src/guestfs.pod:1548
3091 "Use the C<guestfs_set_*_callback> functions to set a callback for different "
3096 #: ../src/guestfs.pod:1551
3098 "Only I<one callback of each type> can be registered for each handle. "
3099 "Calling C<guestfs_set_*_callback> again overwrites the previous callback of "
3100 "that type. Cancel all callbacks of this type by calling this function with "
3101 "C<cb> set to C<NULL>."
3105 #: ../src/guestfs.pod:1556
3106 msgid "guestfs_set_log_message_callback"
3110 #: ../src/guestfs.pod:1558
3113 " typedef void (*guestfs_log_message_cb) (guestfs_h *g, void *opaque,\n"
3114 " char *buf, int len);\n"
3115 " void guestfs_set_log_message_callback (guestfs_h *g,\n"
3116 " guestfs_log_message_cb cb,\n"
3122 #: ../src/guestfs.pod:1564
3124 "The callback function C<cb> will be called whenever qemu or the guest writes "
3125 "anything to the console."
3129 #: ../src/guestfs.pod:1567
3130 msgid "Use this function to capture kernel messages and similar."
3134 #: ../src/guestfs.pod:1569
3136 "Normally there is no log message handler, and log messages are just "
3141 #: ../src/guestfs.pod:1572
3142 msgid "guestfs_set_subprocess_quit_callback"
3146 #: ../src/guestfs.pod:1574
3149 " typedef void (*guestfs_subprocess_quit_cb) (guestfs_h *g, void *opaque);\n"
3150 " void guestfs_set_subprocess_quit_callback (guestfs_h *g,\n"
3151 " guestfs_subprocess_quit_cb cb,\n"
3157 #: ../src/guestfs.pod:1579
3159 "The callback function C<cb> will be called when the child process quits, "
3160 "either asynchronously or if killed by L</guestfs_kill_subprocess>. (This "
3161 "corresponds to a transition from any state to the CONFIG state)."
3165 #: ../src/guestfs.pod:1584
3166 msgid "guestfs_set_launch_done_callback"
3170 #: ../src/guestfs.pod:1586
3173 " typedef void (*guestfs_launch_done_cb) (guestfs_h *g, void *opaque);\n"
3174 " void guestfs_set_launch_done_callback (guestfs_h *g,\n"
3175 " guestfs_launch_done_cb cb,\n"
3181 #: ../src/guestfs.pod:1591
3183 "The callback function C<cb> will be called when the child process becomes "
3184 "ready first time after it has been launched. (This corresponds to a "
3185 "transition from LAUNCHING to the READY state)."
3189 #: ../src/guestfs.pod:1595
3190 msgid "guestfs_set_close_callback"
3194 #: ../src/guestfs.pod:1597
3197 " typedef void (*guestfs_close_cb) (guestfs_h *g, void *opaque);\n"
3198 " void guestfs_set_close_callback (guestfs_h *g,\n"
3199 " guestfs_close_cb cb,\n"
3205 #: ../src/guestfs.pod:1602
3207 "The callback function C<cb> will be called while the handle is being closed "
3208 "(synchronously from L</guestfs_close>)."
3212 #: ../src/guestfs.pod:1605
3214 "Note that libguestfs installs an L<atexit(3)> handler to try to clean up "
3215 "handles that are open when the program exits. This means that this callback "
3216 "might be called indirectly from L<exit(3)>, which can cause unexpected "
3217 "problems in higher-level languages (eg. if your HLL interpreter has already "
3218 "been cleaned up by the time this is called, and if your callback then jumps "
3219 "into some HLL function)."
3223 #: ../src/guestfs.pod:1613
3224 msgid "guestfs_set_progress_callback"
3228 #: ../src/guestfs.pod:1615
3231 " typedef void (*guestfs_progress_cb) (guestfs_h *g, void *opaque,\n"
3232 " int proc_nr, int serial,\n"
3233 " uint64_t position, uint64_t total);\n"
3234 " void guestfs_set_progress_callback (guestfs_h *g,\n"
3235 " guestfs_progress_cb cb,\n"
3241 #: ../src/guestfs.pod:1622
3243 "Some long-running operations can generate progress messages. If this "
3244 "callback is registered, then it will be called each time a progress message "
3245 "is generated (usually two seconds after the operation started, and three "
3246 "times per second thereafter until it completes, although the frequency may "
3247 "change in future versions)."
3251 #: ../src/guestfs.pod:1628
3253 "The callback receives two numbers: C<position> and C<total>. The units of "
3254 "C<total> are not defined, although for some operations C<total> may relate "
3255 "in some way to the amount of data to be transferred (eg. in bytes or "
3256 "megabytes), and C<position> may be the portion which has been transferred."
3260 #: ../src/guestfs.pod:1634
3261 msgid "The only defined and stable parts of the API are:"
3265 #: ../src/guestfs.pod:1640
3267 "The callback can display to the user some type of progress bar or indicator "
3268 "which shows the ratio of C<position>:C<total>."
3272 #: ../src/guestfs.pod:1645
3273 msgid "0 E<lt>= C<position> E<lt>= C<total>"
3277 #: ../src/guestfs.pod:1649
3279 "If any progress notification is sent during a call, then a final progress "
3280 "notification is always sent when C<position> = C<total>."
3284 #: ../src/guestfs.pod:1652
3286 "This is to simplify caller code, so callers can easily set the progress "
3287 "indicator to \"100%\" at the end of the operation, without requiring special "
3288 "code to detect this case."
3292 #: ../src/guestfs.pod:1658
3294 "The callback also receives the procedure number and serial number of the "
3295 "call. These are only useful for debugging protocol issues, and the callback "
3296 "can normally ignore them. The callback may want to print these numbers in "
3297 "error messages or debugging messages."
3301 #: ../src/guestfs.pod:1663
3302 msgid "PRIVATE DATA AREA"
3306 #: ../src/guestfs.pod:1665
3308 "You can attach named pieces of private data to the libguestfs handle, and "
3309 "fetch them by name for the lifetime of the handle. This is called the "
3310 "private data area and is only available from the C API."
3314 #: ../src/guestfs.pod:1669
3315 msgid "To attach a named piece of data, use the following call:"
3319 #: ../src/guestfs.pod:1671
3322 " void guestfs_set_private (guestfs_h *g, const char *key, void *data);\n"
3327 #: ../src/guestfs.pod:1673
3329 "C<key> is the name to associate with this data, and C<data> is an arbitrary "
3330 "pointer (which can be C<NULL>). Any previous item with the same name is "
3335 #: ../src/guestfs.pod:1677
3337 "You can use any C<key> you want, but names beginning with an underscore "
3338 "character are reserved for internal libguestfs purposes (for implementing "
3339 "language bindings). It is recommended to prefix the name with some unique "
3340 "string to avoid collisions with other users."
3344 #: ../src/guestfs.pod:1682
3345 msgid "To retrieve the pointer, use:"
3349 #: ../src/guestfs.pod:1684
3352 " void *guestfs_get_private (guestfs_h *g, const char *key);\n"
3357 #: ../src/guestfs.pod:1686
3359 "This function returns C<NULL> if either no data is found associated with "
3360 "C<key>, or if the user previously set the C<key>'s C<data> pointer to "
3365 #: ../src/guestfs.pod:1690
3367 "Libguestfs does not try to look at or interpret the C<data> pointer in any "
3368 "way. As far as libguestfs is concerned, it need not be a valid pointer at "
3369 "all. In particular, libguestfs does I<not> try to free the data when the "
3370 "handle is closed. If the data must be freed, then the caller must either "
3371 "free it before calling L</guestfs_close> or must set up a close callback to "
3372 "do it (see L</guestfs_set_close_callback>, and note that only one callback "
3373 "can be registered for a handle)."
3377 #: ../src/guestfs.pod:1698
3379 "The private data area is implemented using a hash table, and should be "
3380 "reasonably efficient for moderate numbers of keys."
3384 #: ../src/guestfs.pod:1701 ../src/guestfs.pod:1706
3389 #: ../src/guestfs.pod:1703
3391 "<!-- old anchor for the next section --> <a name="
3392 "\"state_machine_and_low_level_event_api\"/>"
3396 #: ../src/guestfs.pod:1708
3397 msgid "ARCHITECTURE"
3401 #: ../src/guestfs.pod:1710
3403 "Internally, libguestfs is implemented by running an appliance (a special "
3404 "type of small virtual machine) using L<qemu(1)>. Qemu runs as a child "
3405 "process of the main program."
3409 #: ../src/guestfs.pod:1714
3412 " ___________________\n"
3414 " | main program |\n"
3416 " | | child process / appliance\n"
3417 " | | __________________________\n"
3419 " +-------------------+ RPC | +-----------------+ |\n"
3420 " | libguestfs <--------------------> guestfsd | |\n"
3421 " | | | +-----------------+ |\n"
3422 " \\___________________/ | | Linux kernel | |\n"
3423 " | +--^--------------+ |\n"
3424 " \\_________|________________/\n"
3430 " \\______________/\n"
3435 #: ../src/guestfs.pod:1734
3437 "The library, linked to the main program, creates the child process and hence "
3438 "the appliance in the L</guestfs_launch> function."
3442 #: ../src/guestfs.pod:1737
3444 "Inside the appliance is a Linux kernel and a complete stack of userspace "
3445 "tools (such as LVM and ext2 programs) and a small controlling daemon called "
3446 "L</guestfsd>. The library talks to L</guestfsd> using remote procedure "
3447 "calls (RPC). There is a mostly one-to-one correspondence between libguestfs "
3448 "API calls and RPC calls to the daemon. Lastly the disk image(s) are "
3449 "attached to the qemu process which translates device access by the "
3450 "appliance's Linux kernel into accesses to the image."
3454 #: ../src/guestfs.pod:1746
3456 "A common misunderstanding is that the appliance \"is\" the virtual machine. "
3457 "Although the disk image you are attached to might also be used by some "
3458 "virtual machine, libguestfs doesn't know or care about this. (But you will "
3459 "care if both libguestfs's qemu process and your virtual machine are trying "
3460 "to update the disk image at the same time, since these usually results in "
3461 "massive disk corruption)."
3465 #: ../src/guestfs.pod:1753
3466 msgid "STATE MACHINE"
3470 #: ../src/guestfs.pod:1755
3471 msgid "libguestfs uses a state machine to model the child process:"
3475 #: ../src/guestfs.pod:1757
3487 " / | \\ \\ guestfs_launch\n"
3488 " / | _\\__V______\n"
3490 " / | | LAUNCHING |\n"
3491 " / | \\___________/\n"
3493 " / | guestfs_launch\n"
3495 " ______ / __|____V\n"
3496 " / \\ ------> / \\\n"
3497 " | BUSY | | READY |\n"
3498 " \\______/ <------ \\________/\n"
3503 #: ../src/guestfs.pod:1779
3505 "The normal transitions are (1) CONFIG (when the handle is created, but there "
3506 "is no child process), (2) LAUNCHING (when the child process is booting up), "
3507 "(3) alternating between READY and BUSY as commands are issued to, and "
3508 "carried out by, the child process."
3512 #: ../src/guestfs.pod:1784
3514 "The guest may be killed by L</guestfs_kill_subprocess>, or may die "
3515 "asynchronously at any time (eg. due to some internal error), and that causes "
3516 "the state to transition back to CONFIG."
3520 #: ../src/guestfs.pod:1788
3522 "Configuration commands for qemu such as L</guestfs_add_drive> can only be "
3523 "issued when in the CONFIG state."
3527 #: ../src/guestfs.pod:1791
3529 "The API offers one call that goes from CONFIG through LAUNCHING to READY. "
3530 "L</guestfs_launch> blocks until the child process is READY to accept "
3531 "commands (or until some failure or timeout). L</guestfs_launch> internally "
3532 "moves the state from CONFIG to LAUNCHING while it is running."
3536 #: ../src/guestfs.pod:1797
3538 "API actions such as L</guestfs_mount> can only be issued when in the READY "
3539 "state. These API calls block waiting for the command to be carried out (ie. "
3540 "the state to transition to BUSY and then back to READY). There are no non-"
3541 "blocking versions, and no way to issue more than one command per handle at "
3546 #: ../src/guestfs.pod:1803
3548 "Finally, the child process sends asynchronous messages back to the main "
3549 "program, such as kernel log messages. You can register a callback to "
3550 "receive these messages."
3554 #: ../src/guestfs.pod:1807
3559 #: ../src/guestfs.pod:1809
3560 msgid "COMMUNICATION PROTOCOL"
3564 #: ../src/guestfs.pod:1811
3566 "Don't rely on using this protocol directly. This section documents how it "
3567 "currently works, but it may change at any time."
3571 #: ../src/guestfs.pod:1814
3573 "The protocol used to talk between the library and the daemon running inside "
3574 "the qemu virtual machine is a simple RPC mechanism built on top of XDR (RFC "
3575 "1014, RFC 1832, RFC 4506)."
3579 #: ../src/guestfs.pod:1818
3581 "The detailed format of structures is in C<src/guestfs_protocol.x> (note: "
3582 "this file is automatically generated)."
3586 #: ../src/guestfs.pod:1821
3588 "There are two broad cases, ordinary functions that don't have any C<FileIn> "
3589 "and C<FileOut> parameters, which are handled with very simple request/reply "
3590 "messages. Then there are functions that have any C<FileIn> or C<FileOut> "
3591 "parameters, which use the same request and reply messages, but they may also "
3592 "be followed by files sent using a chunked encoding."
3596 #: ../src/guestfs.pod:1828
3597 msgid "ORDINARY FUNCTIONS (NO FILEIN/FILEOUT PARAMS)"
3601 #: ../src/guestfs.pod:1830
3602 msgid "For ordinary functions, the request message is:"
3606 #: ../src/guestfs.pod:1832
3609 " total length (header + arguments,\n"
3610 " but not including the length word itself)\n"
3611 " struct guestfs_message_header (encoded as XDR)\n"
3612 " struct guestfs_<foo>_args (encoded as XDR)\n"
3617 #: ../src/guestfs.pod:1837
3619 "The total length field allows the daemon to allocate a fixed size buffer "
3620 "into which it slurps the rest of the message. As a result, the total length "
3621 "is limited to C<GUESTFS_MESSAGE_MAX> bytes (currently 4MB), which means the "
3622 "effective size of any request is limited to somewhere under this size."
3626 #: ../src/guestfs.pod:1843
3628 "Note also that many functions don't take any arguments, in which case the "
3629 "C<guestfs_I<foo>_args> is completely omitted."
3633 #: ../src/guestfs.pod:1846
3635 "The header contains the procedure number (C<guestfs_proc>) which is how the "
3636 "receiver knows what type of args structure to expect, or none at all."
3640 #: ../src/guestfs.pod:1850
3641 msgid "The reply message for ordinary functions is:"
3645 #: ../src/guestfs.pod:1852
3648 " total length (header + ret,\n"
3649 " but not including the length word itself)\n"
3650 " struct guestfs_message_header (encoded as XDR)\n"
3651 " struct guestfs_<foo>_ret (encoded as XDR)\n"
3656 #: ../src/guestfs.pod:1857
3658 "As above the C<guestfs_I<foo>_ret> structure may be completely omitted for "
3659 "functions that return no formal return values."
3663 #: ../src/guestfs.pod:1860
3665 "As above the total length of the reply is limited to C<GUESTFS_MESSAGE_MAX>."
3669 #: ../src/guestfs.pod:1863
3671 "In the case of an error, a flag is set in the header, and the reply message "
3672 "is slightly changed:"
3676 #: ../src/guestfs.pod:1866
3679 " total length (header + error,\n"
3680 " but not including the length word itself)\n"
3681 " struct guestfs_message_header (encoded as XDR)\n"
3682 " struct guestfs_message_error (encoded as XDR)\n"
3687 #: ../src/guestfs.pod:1871
3689 "The C<guestfs_message_error> structure contains the error message as a "
3694 #: ../src/guestfs.pod:1874
3695 msgid "FUNCTIONS THAT HAVE FILEIN PARAMETERS"
3699 #: ../src/guestfs.pod:1876
3701 "A C<FileIn> parameter indicates that we transfer a file I<into> the guest. "
3702 "The normal request message is sent (see above). However this is followed by "
3703 "a sequence of file chunks."
3707 #: ../src/guestfs.pod:1880
3710 " total length (header + arguments,\n"
3711 " but not including the length word itself,\n"
3712 " and not including the chunks)\n"
3713 " struct guestfs_message_header (encoded as XDR)\n"
3714 " struct guestfs_<foo>_args (encoded as XDR)\n"
3715 " sequence of chunks for FileIn param #0\n"
3716 " sequence of chunks for FileIn param #1 etc.\n"
3721 #: ../src/guestfs.pod:1888
3722 msgid "The \"sequence of chunks\" is:"
3726 #: ../src/guestfs.pod:1890
3729 " length of chunk (not including length word itself)\n"
3730 " struct guestfs_chunk (encoded as XDR)\n"
3731 " length of chunk\n"
3732 " struct guestfs_chunk (encoded as XDR)\n"
3734 " length of chunk\n"
3735 " struct guestfs_chunk (with data.data_len == 0)\n"
3740 #: ../src/guestfs.pod:1898
3742 "The final chunk has the C<data_len> field set to zero. Additionally a flag "
3743 "is set in the final chunk to indicate either successful completion or early "
3748 #: ../src/guestfs.pod:1902
3750 "At time of writing there are no functions that have more than one FileIn "
3751 "parameter. However this is (theoretically) supported, by sending the "
3752 "sequence of chunks for each FileIn parameter one after another (from left to "
3757 #: ../src/guestfs.pod:1907
3759 "Both the library (sender) I<and> the daemon (receiver) may cancel the "
3760 "transfer. The library does this by sending a chunk with a special flag set "
3761 "to indicate cancellation. When the daemon sees this, it cancels the whole "
3762 "RPC, does I<not> send any reply, and goes back to reading the next request."
3766 #: ../src/guestfs.pod:1913
3768 "The daemon may also cancel. It does this by writing a special word "
3769 "C<GUESTFS_CANCEL_FLAG> to the socket. The library listens for this during "
3770 "the transfer, and if it gets it, it will cancel the transfer (it sends a "
3771 "cancel chunk). The special word is chosen so that even if cancellation "
3772 "happens right at the end of the transfer (after the library has finished "
3773 "writing and has started listening for the reply), the \"spurious\" cancel "
3774 "flag will not be confused with the reply message."
3778 #: ../src/guestfs.pod:1922
3780 "This protocol allows the transfer of arbitrary sized files (no 32 bit "
3781 "limit), and also files where the size is not known in advance (eg. from "
3782 "pipes or sockets). However the chunks are rather small "
3783 "(C<GUESTFS_MAX_CHUNK_SIZE>), so that neither the library nor the daemon need "
3784 "to keep much in memory."
3788 #: ../src/guestfs.pod:1928
3789 msgid "FUNCTIONS THAT HAVE FILEOUT PARAMETERS"
3793 #: ../src/guestfs.pod:1930
3795 "The protocol for FileOut parameters is exactly the same as for FileIn "
3796 "parameters, but with the roles of daemon and library reversed."
3800 #: ../src/guestfs.pod:1933
3803 " total length (header + ret,\n"
3804 " but not including the length word itself,\n"
3805 " and not including the chunks)\n"
3806 " struct guestfs_message_header (encoded as XDR)\n"
3807 " struct guestfs_<foo>_ret (encoded as XDR)\n"
3808 " sequence of chunks for FileOut param #0\n"
3809 " sequence of chunks for FileOut param #1 etc.\n"
3814 #: ../src/guestfs.pod:1941
3815 msgid "INITIAL MESSAGE"
3819 #: ../src/guestfs.pod:1943
3821 "When the daemon launches it sends an initial word (C<GUESTFS_LAUNCH_FLAG>) "
3822 "which indicates that the guest and daemon is alive. This is what L</"
3823 "guestfs_launch> waits for."
3827 #: ../src/guestfs.pod:1947
3828 msgid "PROGRESS NOTIFICATION MESSAGES"
3832 #: ../src/guestfs.pod:1949
3834 "The daemon may send progress notification messages at any time. These are "
3835 "distinguished by the normal length word being replaced by "
3836 "C<GUESTFS_PROGRESS_FLAG>, followed by a fixed size progress message."
3840 #: ../src/guestfs.pod:1953
3842 "The library turns them into progress callbacks (see "
3843 "C<guestfs_set_progress_callback>) if there is a callback registered, or "
3844 "discards them if not."
3848 #: ../src/guestfs.pod:1957
3850 "The daemon self-limits the frequency of progress messages it sends (see "
3851 "C<daemon/proto.c:notify_progress>). Not all calls generate progress "
3856 #: ../src/guestfs.pod:1961
3857 msgid "LIBGUESTFS VERSION NUMBERS"
3861 #: ../src/guestfs.pod:1963
3863 "Since April 2010, libguestfs has started to make separate development and "
3864 "stable releases, along with corresponding branches in our git repository. "
3865 "These separate releases can be identified by version number:"
3869 #: ../src/guestfs.pod:1968
3872 " even numbers for stable: 1.2.x, 1.4.x, ...\n"
3873 " .-------- odd numbers for development: 1.3.x, 1.5.x, ...\n"
3879 " | `-------- sub-version\n"
3881 " `------ always '1' because we don't change the ABI\n"
3886 #: ../src/guestfs.pod:1979
3887 msgid "Thus \"1.3.5\" is the 5th update to the development branch \"1.3\"."
3891 #: ../src/guestfs.pod:1981
3893 "As time passes we cherry pick fixes from the development branch and backport "
3894 "those into the stable branch, the effect being that the stable branch should "
3895 "get more stable and less buggy over time. So the stable releases are ideal "
3896 "for people who don't need new features but would just like the software to "
3901 #: ../src/guestfs.pod:1987
3902 msgid "Our criteria for backporting changes are:"
3906 #: ../src/guestfs.pod:1993
3908 "Documentation changes which don't affect any code are backported unless the "
3909 "documentation refers to a future feature which is not in stable."
3913 #: ../src/guestfs.pod:1999
3915 "Bug fixes which are not controversial, fix obvious problems, and have been "
3916 "well tested are backported."
3920 #: ../src/guestfs.pod:2004
3922 "Simple rearrangements of code which shouldn't affect how it works get "
3923 "backported. This is so that the code in the two branches doesn't get too "
3924 "far out of step, allowing us to backport future fixes more easily."
3928 #: ../src/guestfs.pod:2010
3930 "We I<don't> backport new features, new APIs, new tools etc, except in one "
3931 "exceptional case: the new feature is required in order to implement an "
3932 "important bug fix."
3936 #: ../src/guestfs.pod:2016
3938 "A new stable branch starts when we think the new features in development are "
3939 "substantial and compelling enough over the current stable branch to warrant "
3940 "it. When that happens we create new stable and development versions 1.N.0 "
3941 "and 1.(N+1).0 [N is even]. The new dot-oh release won't necessarily be so "
3942 "stable at this point, but by backporting fixes from development, that branch "
3943 "will stabilize over time."
3947 #: ../src/guestfs.pod:2024 ../fish/guestfish.pod:914
3948 #: ../test-tool/libguestfs-test-tool.pod:104 ../tools/virt-edit.pl:330
3949 #: ../tools/virt-rescue.pl:255
3950 msgid "ENVIRONMENT VARIABLES"
3954 #: ../src/guestfs.pod:2028 ../fish/guestfish.pod:940
3955 msgid "LIBGUESTFS_APPEND"
3959 #: ../src/guestfs.pod:2030 ../fish/guestfish.pod:942
3960 msgid "Pass additional options to the guest kernel."
3964 #: ../src/guestfs.pod:2032 ../fish/guestfish.pod:944
3965 msgid "LIBGUESTFS_DEBUG"
3969 #: ../src/guestfs.pod:2034
3971 "Set C<LIBGUESTFS_DEBUG=1> to enable verbose messages. This has the same "
3972 "effect as calling C<guestfs_set_verbose (g, 1)>."
3976 #: ../src/guestfs.pod:2037 ../fish/guestfish.pod:949
3977 msgid "LIBGUESTFS_MEMSIZE"
3981 #: ../src/guestfs.pod:2039 ../fish/guestfish.pod:951
3983 "Set the memory allocated to the qemu process, in megabytes. For example:"
3987 #: ../src/guestfs.pod:2042 ../fish/guestfish.pod:954
3990 " LIBGUESTFS_MEMSIZE=700\n"
3995 #: ../src/guestfs.pod:2044 ../fish/guestfish.pod:956
3996 msgid "LIBGUESTFS_PATH"
4000 #: ../src/guestfs.pod:2046
4002 "Set the path that libguestfs uses to search for kernel and initrd.img. See "
4003 "the discussion of paths in section PATH above."
4007 #: ../src/guestfs.pod:2049 ../fish/guestfish.pod:961
4008 msgid "LIBGUESTFS_QEMU"
4012 #: ../src/guestfs.pod:2051 ../fish/guestfish.pod:963
4014 "Set the default qemu binary that libguestfs uses. If not set, then the qemu "
4015 "which was found at compile time by the configure script is used."
4019 #: ../src/guestfs.pod:2055
4020 msgid "See also L</QEMU WRAPPERS> above."
4024 #: ../src/guestfs.pod:2057 ../fish/guestfish.pod:967
4025 msgid "LIBGUESTFS_TRACE"
4029 #: ../src/guestfs.pod:2059
4031 "Set C<LIBGUESTFS_TRACE=1> to enable command traces. This has the same "
4032 "effect as calling C<guestfs_set_trace (g, 1)>."
4036 #: ../src/guestfs.pod:2062 ../fish/guestfish.pod:976
4041 #: ../src/guestfs.pod:2064 ../fish/guestfish.pod:978
4042 msgid "Location of temporary directory, defaults to C</tmp>."
4046 #: ../src/guestfs.pod:2066 ../fish/guestfish.pod:980
4048 "If libguestfs was compiled to use the supermin appliance then the real "
4049 "appliance is cached in this directory, shared between all handles belonging "
4050 "to the same EUID. You can use C<$TMPDIR> to configure another directory to "
4051 "use in case C</tmp> is not large enough."
4055 #: ../src/guestfs.pod:2074 ../fish/guestfish.pod:1038
4056 #: ../test-tool/libguestfs-test-tool.pod:109 ../fuse/guestmount.pod:233
4057 #: ../inspector/virt-inspector.pl:536 ../tools/virt-edit.pl:350
4058 #: ../tools/virt-win-reg.pl:484 ../tools/virt-df.pl:640
4059 #: ../tools/virt-ls.pl:232 ../tools/virt-resize.pl:1486
4060 #: ../tools/virt-list-filesystems.pl:186 ../tools/virt-tar.pl:281
4061 #: ../tools/virt-rescue.pl:267 ../tools/virt-make-fs.pl:534
4062 #: ../tools/virt-list-partitions.pl:254
4067 #: ../src/guestfs.pod:2076
4069 "L<guestfish(1)>, L<guestmount(1)>, L<virt-cat(1)>, L<virt-df(1)>, L<virt-edit"