1 # SOME DESCRIPTIVE TITLE
2 # Copyright (C) YEAR Red Hat Inc.
3 # This file is distributed under the same license as the libguestfs package.
4 # FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
8 "Project-Id-Version: libguestfs\n"
9 "Report-Msgid-Bugs-To: libguestfs@redhat.com\n"
10 "POT-Creation-Date: 2011-05-18 10:02+0200\n"
11 "PO-Revision-Date: 2011-04-01 15:39+0000\n"
12 "Last-Translator: yurchor <yurchor@ukr.net>\n"
13 "Language-Team: Ukrainian <trans-uk@lists.fedoraproject.org>\n"
16 "Content-Type: text/plain; charset=UTF-8\n"
17 "Content-Transfer-Encoding: 8bit\n"
18 "Plural-Forms: nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n"
19 "%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2)\n"
22 #: ../src/guestfs.pod:3 ../fish/guestfish.pod:3
23 #: ../test-tool/libguestfs-test-tool.pod:3 ../fuse/guestmount.pod:3
24 #: ../tools/virt-win-reg.pl:35 ../tools/virt-list-filesystems.pl:30
25 #: ../tools/virt-tar.pl:31 ../tools/virt-make-fs.pl:35
26 #: ../tools/virt-list-partitions.pl:30
31 #: ../src/guestfs.pod:5
32 msgid "guestfs - Library for accessing and modifying virtual machine images"
34 "guestfs — бібліотека для доступу та внесення змін до образів віртуальних "
38 #: ../src/guestfs.pod:7 ../fish/guestfish.pod:7
39 #: ../test-tool/libguestfs-test-tool.pod:7 ../fuse/guestmount.pod:7
40 #: ../tools/virt-win-reg.pl:39 ../tools/virt-list-filesystems.pl:34
41 #: ../tools/virt-tar.pl:35 ../tools/virt-make-fs.pl:39
42 #: ../tools/virt-list-partitions.pl:34
44 msgstr "КОРОТКИЙ ОПИС"
47 #: ../src/guestfs.pod:9
50 " #include <guestfs.h>\n"
53 " #include <guestfs.h>\n"
57 #: ../src/guestfs.pod:11
60 " guestfs_h *g = guestfs_create ();\n"
61 " guestfs_add_drive (g, \"guest.img\");\n"
62 " guestfs_launch (g);\n"
63 " guestfs_mount (g, \"/dev/sda1\", \"/\");\n"
64 " guestfs_touch (g, \"/hello\");\n"
65 " guestfs_umount (g, \"/\");\n"
66 " guestfs_close (g);\n"
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_close (g);\n"
79 #: ../src/guestfs.pod:19
82 " cc prog.c -o prog -lguestfs\n"
84 " cc prog.c -o prog `pkg-config libguestfs --cflags --libs`\n"
87 " cc prog.c -o prog -lguestfs\n"
89 " cc prog.c -o prog `pkg-config libguestfs --cflags --libs`\n"
93 #: ../src/guestfs.pod:23 ../fish/guestfish.pod:30
94 #: ../test-tool/libguestfs-test-tool.pod:11 ../fuse/guestmount.pod:20
95 #: ../tools/virt-win-reg.pl:63 ../tools/virt-list-filesystems.pl:40
96 #: ../tools/virt-tar.pl:77 ../tools/virt-make-fs.pl:47
97 #: ../tools/virt-list-partitions.pl:40
102 #: ../src/guestfs.pod:25
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:33
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:38
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:43
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:48
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:51
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:54
155 "There are also some example programs in the L<guestfs-examples(3)> manual "
160 #: ../src/guestfs.pod:57
165 #: ../src/guestfs.pod:59
167 "This section provides a gentler overview of the libguestfs API. We also try "
168 "to group API calls together, where that may not be obvious from reading "
169 "about the individual calls in the main section of this manual."
173 #: ../src/guestfs.pod:64
178 #: ../src/guestfs.pod:66
180 "Before you can use libguestfs calls, you have to create a handle. Then you "
181 "must add at least one disk image to the handle, followed by launching the "
182 "handle, then performing whatever operations you want, and finally closing "
183 "the handle. By convention we use the single letter C<g> for the name of the "
184 "handle variable, although of course you can use any name you want."
188 #: ../src/guestfs.pod:73
189 msgid "The general structure of all libguestfs-using programs looks like this:"
193 #: ../src/guestfs.pod:76
196 " guestfs_h *g = guestfs_create ();\n"
199 " guestfs_h *g = guestfs_create ();\n"
203 #: ../src/guestfs.pod:78
206 " /* Call guestfs_add_drive additional times if there are\n"
207 " * multiple disk images.\n"
209 " guestfs_add_drive (g, \"guest.img\");\n"
214 #: ../src/guestfs.pod:83
217 " /* Most manipulation calls won't work until you've launched\n"
218 " * the handle 'g'. You have to do this _after_ adding drives\n"
219 " * and _before_ other commands.\n"
221 " guestfs_launch (g);\n"
226 #: ../src/guestfs.pod:89
229 " /* Now you can examine what partitions, LVs etc are available.\n"
231 " char **partitions = guestfs_list_partitions (g);\n"
232 " char **logvols = guestfs_lvs (g);\n"
237 #: ../src/guestfs.pod:94
240 " /* To access a filesystem in the image, you must mount it.\n"
242 " guestfs_mount (g, \"/dev/sda1\", \"/\");\n"
245 " /* Щоб отримати доступ до файлової системи на образі, вам слід його змонтувати.\n"
247 " guestfs_mount (g, \"/dev/sda1\", \"/\");\n"
251 #: ../src/guestfs.pod:98
254 #| " /* Now you can perform filesystem actions on the guest\n"
255 #| " * disk image.\n"
257 #| " guestfs_touch (g, \"/hello\");\n"
260 " /* Now you can perform filesystem actions on the guest\n"
263 " guestfs_touch (g, \"/hello\");\n"
266 " /* Тепер ви можете виконувати дії з файловою системою на\n"
267 " * образі диска операційної системи.\n"
269 " guestfs_touch (g, \"/hello\");\n"
273 #: ../src/guestfs.pod:103
276 " /* This is only needed for libguestfs < 1.5.24. Since then\n"
277 " * it is done automatically when you close the handle. See\n"
278 " * discussion of autosync in this page.\n"
280 " guestfs_sync (g);\n"
285 #: ../src/guestfs.pod:109
288 " /* Close the handle 'g'. */\n"
289 " guestfs_close (g);\n"
294 #: ../src/guestfs.pod:112
296 "The code above doesn't include any error checking. In real code you should "
297 "check return values carefully for errors. In general all functions that "
298 "return integers return C<-1> on error, and all functions that return "
299 "pointers return C<NULL> on error. See section L</ERROR HANDLING> below for "
300 "how to handle errors, and consult the documentation for each function call "
301 "below to see precisely how they return error indications. See L<guestfs-"
302 "examples(3)> for fully worked examples."
306 #: ../src/guestfs.pod:121
311 #: ../src/guestfs.pod:123
313 "The image filename (C<\"guest.img\"> in the example above) could be a disk "
314 "image from a virtual machine, a L<dd(1)> copy of a physical hard disk, an "
315 "actual block device, or simply an empty file of zeroes that you have created "
316 "through L<posix_fallocate(3)>. Libguestfs lets you do useful things to all "
321 #: ../src/guestfs.pod:129
323 "The call you should use in modern code for adding drives is L</"
324 "guestfs_add_drive_opts>. To add a disk image, allowing writes, and "
325 "specifying that the format is raw, do:"
329 #: ../src/guestfs.pod:133
332 " guestfs_add_drive_opts (g, filename,\n"
333 " GUESTFS_ADD_DRIVE_OPTS_FORMAT, \"raw\",\n"
339 #: ../src/guestfs.pod:137
340 msgid "You can add a disk read-only using:"
344 #: ../src/guestfs.pod:139
347 " guestfs_add_drive_opts (g, filename,\n"
348 " GUESTFS_ADD_DRIVE_OPTS_FORMAT, \"raw\",\n"
349 " GUESTFS_ADD_DRIVE_OPTS_READONLY, 1,\n"
355 #: ../src/guestfs.pod:144
357 "or by calling the older function L</guestfs_add_drive_ro>. In either case "
358 "libguestfs won't modify the file."
362 #: ../src/guestfs.pod:147
364 "Be extremely cautious if the disk image is in use, eg. if it is being used "
365 "by a virtual machine. Adding it read-write will almost certainly cause disk "
366 "corruption, but adding it read-only is safe."
370 #: ../src/guestfs.pod:151
372 "You must add at least one disk image, and you may add multiple disk images. "
373 "In the API, the disk images are usually referred to as C</dev/sda> (for the "
374 "first one you added), C</dev/sdb> (for the second one you added), etc."
378 #: ../src/guestfs.pod:156
380 "Once L</guestfs_launch> has been called you cannot add any more images. You "
381 "can call L</guestfs_list_devices> to get a list of the device names, in the "
382 "order that you added them. See also L</BLOCK DEVICE NAMING> below."
386 #: ../src/guestfs.pod:161
391 #: ../src/guestfs.pod:163
393 "Before you can read or write files, create directories and so on in a disk "
394 "image that contains filesystems, you have to mount those filesystems using "
395 "L</guestfs_mount_options> or L</guestfs_mount_ro>. If you already know that "
396 "a disk image contains (for example) one partition with a filesystem on that "
397 "partition, then you can mount it directly:"
401 #: ../src/guestfs.pod:170
404 " guestfs_mount_options (g, \"\", \"/dev/sda1\", \"/\");\n"
409 #: ../src/guestfs.pod:172
411 "where C</dev/sda1> means literally the first partition (C<1>) of the first "
412 "disk image that we added (C</dev/sda>). If the disk contains Linux LVM2 "
413 "logical volumes you could refer to those instead (eg. C</dev/VG/LV>). Note "
414 "that these are libguestfs virtual devices, and are nothing to do with host "
419 #: ../src/guestfs.pod:178
421 "If you are given a disk image and you don't know what it contains then you "
422 "have to find out. Libguestfs can do that too: use L</"
423 "guestfs_list_partitions> and L</guestfs_lvs> to list possible partitions and "
424 "LVs, and either try mounting each to see what is mountable, or else examine "
425 "them with L</guestfs_vfs_type> or L</guestfs_file>. To list just "
426 "filesystems, use L</guestfs_list_filesystems>."
430 #: ../src/guestfs.pod:186
432 "Libguestfs also has a set of APIs for inspection of unknown disk images (see "
433 "L</INSPECTION> below). But you might find it easier to look at higher level "
434 "programs built on top of libguestfs, in particular L<virt-inspector(1)>."
438 #: ../src/guestfs.pod:191
440 "To mount a filesystem read-only, use L</guestfs_mount_ro>. There are "
441 "several other variations of the C<guestfs_mount_*> call."
445 #: ../src/guestfs.pod:194
446 msgid "FILESYSTEM ACCESS AND MODIFICATION"
450 #: ../src/guestfs.pod:196
452 "The majority of the libguestfs API consists of fairly low-level calls for "
453 "accessing and modifying the files, directories, symlinks etc on mounted "
454 "filesystems. There are over a hundred such calls which you can find listed "
455 "in detail below in this man page, and we don't even pretend to cover them "
456 "all in this overview."
460 #: ../src/guestfs.pod:202
462 "Specify filenames as full paths, starting with C<\"/\"> and including the "
467 #: ../src/guestfs.pod:205
469 "For example, if you mounted a filesystem at C<\"/\"> and you want to read "
470 "the file called C<\"etc/passwd\"> then you could do:"
474 #: ../src/guestfs.pod:208
477 " char *data = guestfs_cat (g, \"/etc/passwd\");\n"
482 #: ../src/guestfs.pod:210
484 "This would return C<data> as a newly allocated buffer containing the full "
485 "content of that file (with some conditions: see also L</DOWNLOADING> below), "
486 "or C<NULL> if there was an error."
490 #: ../src/guestfs.pod:214
492 "As another example, to create a top-level directory on that filesystem "
493 "called C<\"var\"> you would do:"
497 #: ../src/guestfs.pod:217
500 " guestfs_mkdir (g, \"/var\");\n"
505 #: ../src/guestfs.pod:219
506 msgid "To create a symlink you could do:"
510 #: ../src/guestfs.pod:221
513 " guestfs_ln_s (g, \"/etc/init.d/portmap\",\n"
514 " \"/etc/rc3.d/S30portmap\");\n"
519 #: ../src/guestfs.pod:224
521 "Libguestfs will reject attempts to use relative paths and there is no "
522 "concept of a current working directory."
526 #: ../src/guestfs.pod:227
528 "Libguestfs can return errors in many situations: for example if the "
529 "filesystem isn't writable, or if a file or directory that you requested "
530 "doesn't exist. If you are using the C API (documented here) you have to "
531 "check for those error conditions after each call. (Other language bindings "
532 "turn these errors into exceptions)."
536 #: ../src/guestfs.pod:233
538 "File writes are affected by the per-handle umask, set by calling L</"
539 "guestfs_umask> and defaulting to 022. See L</UMASK>."
543 #: ../src/guestfs.pod:236
545 msgstr "ПОДІЛ НА РОЗДІЛИ"
548 #: ../src/guestfs.pod:238
550 "Libguestfs contains API calls to read, create and modify partition tables on "
555 #: ../src/guestfs.pod:241
557 "In the common case where you want to create a single partition covering the "
558 "whole disk, you should use the L</guestfs_part_disk> call:"
562 #: ../src/guestfs.pod:245
565 " const char *parttype = \"mbr\";\n"
566 " if (disk_is_larger_than_2TB)\n"
567 " parttype = \"gpt\";\n"
568 " guestfs_part_disk (g, \"/dev/sda\", parttype);\n"
573 #: ../src/guestfs.pod:250
575 "Obviously this effectively wipes anything that was on that disk image before."
579 #: ../src/guestfs.pod:253
584 #: ../src/guestfs.pod:255
586 "Libguestfs provides access to a large part of the LVM2 API, such as L</"
587 "guestfs_lvcreate> and L</guestfs_vgremove>. It won't make much sense unless "
588 "you familiarize yourself with the concepts of physical volumes, volume "
589 "groups and logical volumes."
593 #: ../src/guestfs.pod:260
595 "This author strongly recommends reading the LVM HOWTO, online at L<http://"
596 "tldp.org/HOWTO/LVM-HOWTO/>."
600 #: ../src/guestfs.pod:263
605 #: ../src/guestfs.pod:265
607 "Use L</guestfs_cat> to download small, text only files. This call is "
608 "limited to files which are less than 2 MB and which cannot contain any ASCII "
609 "NUL (C<\\0>) characters. However the API is very simple to use."
613 #: ../src/guestfs.pod:269
615 "L</guestfs_read_file> can be used to read files which contain arbitrary 8 "
616 "bit data, since it returns a (pointer, size) pair. However it is still "
617 "limited to \"small\" files, less than 2 MB."
621 #: ../src/guestfs.pod:273
623 "L</guestfs_download> can be used to download any file, with no limits on "
624 "content or size (even files larger than 4 GB)."
628 #: ../src/guestfs.pod:276
630 "To download multiple files, see L</guestfs_tar_out> and L</guestfs_tgz_out>."
634 #: ../src/guestfs.pod:279
636 msgstr "ВИВАНТАЖЕННЯ"
639 #: ../src/guestfs.pod:281
641 "It's often the case that you want to write a file or files to the disk image."
645 #: ../src/guestfs.pod:284
647 "To write a small file with fixed content, use L</guestfs_write>. To create "
648 "a file of all zeroes, use L</guestfs_truncate_size> (sparse) or L</"
649 "guestfs_fallocate64> (with all disk blocks allocated). There are a variety "
650 "of other functions for creating test files, for example L</guestfs_fill> and "
651 "L</guestfs_fill_pattern>."
655 #: ../src/guestfs.pod:290
657 "To upload a single file, use L</guestfs_upload>. This call has no limits on "
658 "file content or size (even files larger than 4 GB)."
662 #: ../src/guestfs.pod:293
664 "To upload multiple files, see L</guestfs_tar_in> and L</guestfs_tgz_in>."
668 #: ../src/guestfs.pod:295
670 "However the fastest way to upload I<large numbers of arbitrary files> is to "
671 "turn them into a squashfs or CD ISO (see L<mksquashfs(8)> and L<mkisofs(8)"
672 ">), then attach this using L</guestfs_add_drive_ro>. If you add the drive "
673 "in a predictable way (eg. adding it last after all other drives) then you "
674 "can get the device name from L</guestfs_list_devices> and mount it directly "
675 "using L</guestfs_mount_ro>. Note that squashfs images are sometimes non-"
676 "portable between kernel versions, and they don't support labels or UUIDs. "
677 "If you want to pre-build an image or you need to mount it using a label or "
678 "UUID, use an ISO image instead."
682 #: ../src/guestfs.pod:306
687 #: ../src/guestfs.pod:308
689 "There are various different commands for copying between files and devices "
690 "and in and out of the guest filesystem. These are summarised in the table "
695 #: ../src/guestfs.pod:314
696 msgid "B<file> to B<file>"
700 #: ../src/guestfs.pod:316
702 "Use L</guestfs_cp> to copy a single file, or L</guestfs_cp_a> to copy "
703 "directories recursively."
707 #: ../src/guestfs.pod:319
708 msgid "B<file or device> to B<file or device>"
712 #: ../src/guestfs.pod:321
714 "Use L</guestfs_dd> which efficiently uses L<dd(1)> to copy between files and "
715 "devices in the guest."
719 #: ../src/guestfs.pod:324
720 msgid "Example: duplicate the contents of an LV:"
724 #: ../src/guestfs.pod:326
727 " guestfs_dd (g, \"/dev/VG/Original\", \"/dev/VG/Copy\");\n"
732 #: ../src/guestfs.pod:328
734 "The destination (C</dev/VG/Copy>) must be at least as large as the source "
735 "(C</dev/VG/Original>). To copy less than the whole source device, use L</"
736 "guestfs_copy_size>."
740 #: ../src/guestfs.pod:332
741 msgid "B<file on the host> to B<file or device>"
745 #: ../src/guestfs.pod:334
746 msgid "Use L</guestfs_upload>. See L</UPLOADING> above."
750 #: ../src/guestfs.pod:336
751 msgid "B<file or device> to B<file on the host>"
755 #: ../src/guestfs.pod:338
756 msgid "Use L</guestfs_download>. See L</DOWNLOADING> above."
760 #: ../src/guestfs.pod:342
761 msgid "UPLOADING AND DOWNLOADING TO PIPES AND FILE DESCRIPTORS"
765 #: ../src/guestfs.pod:344
767 "Calls like L</guestfs_upload>, L</guestfs_download>, L</guestfs_tar_in>, L</"
768 "guestfs_tar_out> etc appear to only take filenames as arguments, so it "
769 "appears you can only upload and download to files. However many Un*x-like "
770 "hosts let you use the special device files C</dev/stdin>, C</dev/stdout>, C</"
771 "dev/stderr> and C</dev/fd/N> to read and write from stdin, stdout, stderr, "
772 "and arbitrary file descriptor N."
776 #: ../src/guestfs.pod:352
777 msgid "For example, L<virt-cat(1)> writes its output to stdout by doing:"
781 #: ../src/guestfs.pod:355
784 " guestfs_download (g, filename, \"/dev/stdout\");\n"
789 #: ../src/guestfs.pod:357
790 msgid "and you can write tar output to a file descriptor C<fd> by doing:"
794 #: ../src/guestfs.pod:359
798 " snprintf (devfd, sizeof devfd, \"/dev/fd/%d\", fd);\n"
799 " guestfs_tar_out (g, \"/\", devfd);\n"
804 #: ../src/guestfs.pod:363
805 msgid "LISTING FILES"
809 #: ../src/guestfs.pod:365
811 "L</guestfs_ll> is just designed for humans to read (mainly when using the "
812 "L<guestfish(1)>-equivalent command C<ll>)."
816 #: ../src/guestfs.pod:368
818 "L</guestfs_ls> is a quick way to get a list of files in a directory from "
819 "programs, as a flat list of strings."
823 #: ../src/guestfs.pod:371
825 "L</guestfs_readdir> is a programmatic way to get a list of files in a "
826 "directory, plus additional information about each one. It is more "
827 "equivalent to using the L<readdir(3)> call on a local filesystem."
831 #: ../src/guestfs.pod:375
833 "L</guestfs_find> and L</guestfs_find0> can be used to recursively list files."
837 #: ../src/guestfs.pod:378
838 msgid "RUNNING COMMANDS"
842 #: ../src/guestfs.pod:380
844 "Although libguestfs is primarily an API for manipulating files inside guest "
845 "images, we also provide some limited facilities for running commands inside "
850 #: ../src/guestfs.pod:384
851 msgid "There are many limitations to this:"
855 #: ../src/guestfs.pod:388 ../src/guestfs.pod:393 ../src/guestfs.pod:398
856 #: ../src/guestfs.pod:402 ../src/guestfs.pod:407 ../src/guestfs.pod:411
857 #: ../src/guestfs.pod:416 ../src/guestfs.pod:421 ../src/guestfs.pod:1064
858 #: ../src/guestfs.pod:1068 ../src/guestfs.pod:1072 ../src/guestfs.pod:1077
859 #: ../src/guestfs.pod:1085 ../src/guestfs.pod:1104 ../src/guestfs.pod:1112
860 #: ../src/guestfs.pod:1134 ../src/guestfs.pod:1138 ../src/guestfs.pod:1142
861 #: ../src/guestfs.pod:1146 ../src/guestfs.pod:1150 ../src/guestfs.pod:1154
862 #: ../src/guestfs.pod:1643 ../src/guestfs.pod:1648 ../src/guestfs.pod:1652
863 #: ../src/guestfs.pod:1754 ../src/guestfs.pod:1759 ../src/guestfs.pod:1763
864 #: ../src/guestfs.pod:1773 ../src/guestfs.pod:2008 ../src/guestfs.pod:2013
865 #: ../src/guestfs.pod:2019 ../src/guestfs.pod:2027 ../src/guestfs.pod:2381
866 #: ../src/guestfs.pod:2387 ../src/guestfs.pod:2392 ../src/guestfs.pod:2398
867 #: ../src/guestfs.pod:2967 ../src/guestfs.pod:2971 ../src/guestfs.pod:2975
868 #: ../src/guestfs.pod:2979 ../src/guestfs-actions.pod:15
869 #: ../src/guestfs-actions.pod:22 ../src/guestfs-actions.pod:583
870 #: ../src/guestfs-actions.pod:591 ../src/guestfs-actions.pod:598
871 #: ../src/guestfs-actions.pod:605 ../src/guestfs-actions.pod:1603
872 #: ../src/guestfs-actions.pod:1607 ../src/guestfs-actions.pod:1611
873 #: ../src/guestfs-actions.pod:1615 ../src/guestfs-actions.pod:1623
874 #: ../src/guestfs-actions.pod:1627 ../src/guestfs-actions.pod:1631
875 #: ../src/guestfs-actions.pod:1641 ../src/guestfs-actions.pod:1645
876 #: ../src/guestfs-actions.pod:1649 ../src/guestfs-actions.pod:1787
877 #: ../src/guestfs-actions.pod:1791 ../src/guestfs-actions.pod:1796
878 #: ../src/guestfs-actions.pod:1801 ../src/guestfs-actions.pod:1862
879 #: ../src/guestfs-actions.pod:1866 ../src/guestfs-actions.pod:1871
880 #: ../fish/guestfish.pod:445 ../fish/guestfish.pod:449
881 #: ../fish/guestfish.pod:453 ../fish/guestfish.pod:457
882 #: ../fish/guestfish-actions.pod:13 ../fish/guestfish-actions.pod:20
883 #: ../fish/guestfish-actions.pod:385 ../fish/guestfish-actions.pod:393
884 #: ../fish/guestfish-actions.pod:400 ../fish/guestfish-actions.pod:407
885 #: ../fish/guestfish-actions.pod:1074 ../fish/guestfish-actions.pod:1078
886 #: ../fish/guestfish-actions.pod:1082 ../fish/guestfish-actions.pod:1086
887 #: ../fish/guestfish-actions.pod:1094 ../fish/guestfish-actions.pod:1098
888 #: ../fish/guestfish-actions.pod:1102 ../fish/guestfish-actions.pod:1112
889 #: ../fish/guestfish-actions.pod:1116 ../fish/guestfish-actions.pod:1120
890 #: ../fish/guestfish-actions.pod:1210 ../fish/guestfish-actions.pod:1214
891 #: ../fish/guestfish-actions.pod:1219 ../fish/guestfish-actions.pod:1224
892 #: ../fish/guestfish-actions.pod:1266 ../fish/guestfish-actions.pod:1270
893 #: ../fish/guestfish-actions.pod:1275 ../tools/virt-win-reg.pl:195
894 #: ../tools/virt-win-reg.pl:200 ../tools/virt-win-reg.pl:206
895 #: ../tools/virt-win-reg.pl:708 ../tools/virt-win-reg.pl:714
896 #: ../tools/virt-win-reg.pl:720
901 #: ../src/guestfs.pod:390
903 "The kernel version that the command runs under will be different from what "
908 #: ../src/guestfs.pod:395
910 "If the command needs to communicate with daemons, then most likely they "
915 #: ../src/guestfs.pod:400
916 msgid "The command will be running in limited memory."
920 #: ../src/guestfs.pod:404
922 "The network may not be available unless you enable it (see L</"
923 "guestfs_set_network>)."
927 #: ../src/guestfs.pod:409
928 msgid "Only supports Linux guests (not Windows, BSD, etc)."
932 #: ../src/guestfs.pod:413
934 "Architecture limitations (eg. won't work for a PPC guest on an X86 host)."
938 #: ../src/guestfs.pod:418
940 "For SELinux guests, you may need to enable SELinux and load policy first. "
941 "See L</SELINUX> in this manpage."
945 #: ../src/guestfs.pod:423
947 "I<Security:> It is not safe to run commands from untrusted, possibly "
948 "malicious guests. These commands may attempt to exploit your program by "
949 "sending unexpected output. They could also try to exploit the Linux kernel "
950 "or qemu provided by the libguestfs appliance. They could use the network "
951 "provided by the libguestfs appliance to bypass ordinary network partitions "
952 "and firewalls. They could use the elevated privileges or different SELinux "
953 "context of your program to their advantage."
957 #: ../src/guestfs.pod:432
959 "A secure alternative is to use libguestfs to install a \"firstboot\" script "
960 "(a script which runs when the guest next boots normally), and to have this "
961 "script run the commands you want in the normal context of the running guest, "
962 "network security and so on. For information about other security issues, "
967 #: ../src/guestfs.pod:440
969 "The two main API calls to run commands are L</guestfs_command> and L</"
970 "guestfs_sh> (there are also variations)."
974 #: ../src/guestfs.pod:443
976 "The difference is that L</guestfs_sh> runs commands using the shell, so any "
977 "shell globs, redirections, etc will work."
981 #: ../src/guestfs.pod:446
982 msgid "CONFIGURATION FILES"
983 msgstr "ФАЙЛИ НАЛАШТУВАННЯ"
986 #: ../src/guestfs.pod:448
988 "To read and write configuration files in Linux guest filesystems, we "
989 "strongly recommend using Augeas. For example, Augeas understands how to "
990 "read and write, say, a Linux shadow password file or X.org configuration "
991 "file, and so avoids you having to write that code."
995 #: ../src/guestfs.pod:453
997 "The main Augeas calls are bound through the C<guestfs_aug_*> APIs. We don't "
998 "document Augeas itself here because there is excellent documentation on the "
999 "L<http://augeas.net/> website."
1003 #: ../src/guestfs.pod:457
1005 "If you don't want to use Augeas (you fool!) then try calling L</"
1006 "guestfs_read_lines> to get the file as a list of lines which you can iterate "
1011 #: ../src/guestfs.pod:461
1016 #: ../src/guestfs.pod:463
1018 "We support SELinux guests. To ensure that labeling happens correctly in "
1019 "SELinux guests, you need to enable SELinux and load the guest's policy:"
1023 #: ../src/guestfs.pod:469 ../src/guestfs.pod:1257 ../src/guestfs.pod:1395
1024 #: ../src/guestfs.pod:2426
1029 #: ../src/guestfs.pod:471
1030 msgid "Before launching, do:"
1034 #: ../src/guestfs.pod:473
1037 " guestfs_set_selinux (g, 1);\n"
1042 #: ../src/guestfs.pod:475 ../src/guestfs.pod:1261 ../src/guestfs.pod:1399
1043 #: ../src/guestfs.pod:2451
1048 #: ../src/guestfs.pod:477
1050 "After mounting the guest's filesystem(s), load the policy. This is best "
1051 "done by running the L<load_policy(8)> command in the guest itself:"
1055 #: ../src/guestfs.pod:481
1058 " guestfs_sh (g, \"/usr/sbin/load_policy\");\n"
1063 #: ../src/guestfs.pod:483
1065 "(Older versions of C<load_policy> require you to specify the name of the "
1070 #: ../src/guestfs.pod:486 ../src/guestfs.pod:1405
1075 #: ../src/guestfs.pod:488
1077 "Optionally, set the security context for the API. The correct security "
1078 "context to use can only be known by inspecting the guest. As an example:"
1082 #: ../src/guestfs.pod:492
1085 " guestfs_setcon (g, \"unconfined_u:unconfined_r:unconfined_t:s0\");\n"
1090 #: ../src/guestfs.pod:496
1091 msgid "This will work for running commands and editing existing files."
1095 #: ../src/guestfs.pod:498
1097 "When new files are created, you may need to label them explicitly, for "
1098 "example by running the external command C<restorecon pathname>."
1102 #: ../src/guestfs.pod:502
1107 #: ../src/guestfs.pod:504
1109 "Certain calls are affected by the current file mode creation mask (the "
1110 "\"umask\"). In particular ones which create files or directories, such as "
1111 "L</guestfs_touch>, L</guestfs_mknod> or L</guestfs_mkdir>. This affects "
1112 "either the default mode that the file is created with or modifies the mode "
1117 #: ../src/guestfs.pod:510
1119 "The default umask is C<022>, so files are created with modes such as C<0644> "
1120 "and directories with C<0755>."
1124 #: ../src/guestfs.pod:513
1126 "There are two ways to avoid being affected by umask. Either set umask to 0 "
1127 "(call C<guestfs_umask (g, 0)> early after launching). Or call L</"
1128 "guestfs_chmod> after creating each file or directory."
1132 #: ../src/guestfs.pod:517
1133 msgid "For more information about umask, see L<umask(2)>."
1137 #: ../src/guestfs.pod:519 ../fish/guestfish.pod:767
1138 msgid "ENCRYPTED DISKS"
1142 #: ../src/guestfs.pod:521
1144 "Libguestfs allows you to access Linux guests which have been encrypted using "
1145 "whole disk encryption that conforms to the Linux Unified Key Setup (LUKS) "
1146 "standard. This includes nearly all whole disk encryption systems used by "
1147 "modern Linux guests."
1151 #: ../src/guestfs.pod:527
1153 "Use L</guestfs_vfs_type> to identify LUKS-encrypted block devices (it "
1154 "returns the string C<crypto_LUKS>)."
1158 #: ../src/guestfs.pod:530
1160 "Then open these devices by calling L</guestfs_luks_open>. Obviously you "
1161 "will require the passphrase!"
1165 #: ../src/guestfs.pod:533
1167 "Opening a LUKS device creates a new device mapper device called C</dev/"
1168 "mapper/mapname> (where C<mapname> is the string you supply to L</"
1169 "guestfs_luks_open>). Reads and writes to this mapper device are decrypted "
1170 "from and encrypted to the underlying block device respectively."
1174 #: ../src/guestfs.pod:539
1176 "LVM volume groups on the device can be made visible by calling L</"
1177 "guestfs_vgscan> followed by L</guestfs_vg_activate_all>. The logical volume"
1178 "(s) can now be mounted in the usual way."
1182 #: ../src/guestfs.pod:543
1184 "Use the reverse process to close a LUKS device. Unmount any logical volumes "
1185 "on it, deactivate the volume groups by caling C<guestfs_vg_activate (g, 0, "
1186 "[\"/dev/VG\"])>. Then close the mapper device by calling L</"
1187 "guestfs_luks_close> on the C</dev/mapper/mapname> device (I<not> the "
1188 "underlying encrypted block device)."
1192 #: ../src/guestfs.pod:550
1197 #: ../src/guestfs.pod:552
1199 "Libguestfs has APIs for inspecting an unknown disk image to find out if it "
1200 "contains operating systems, an install CD or a live CD. (These APIs used to "
1201 "be in a separate Perl-only library called L<Sys::Guestfs::Lib(3)> but since "
1202 "version 1.5.3 the most frequently used part of this library has been "
1203 "rewritten in C and moved into the core code)."
1207 #: ../src/guestfs.pod:559
1209 "Add all disks belonging to the unknown virtual machine and call L</"
1210 "guestfs_launch> in the usual way."
1214 #: ../src/guestfs.pod:562
1216 "Then call L</guestfs_inspect_os>. This function uses other libguestfs calls "
1217 "and certain heuristics, and returns a list of operating systems that were "
1218 "found. An empty list means none were found. A single element is the root "
1219 "filesystem of the operating system. For dual- or multi-boot guests, "
1220 "multiple roots can be returned, each one corresponding to a separate "
1221 "operating system. (Multi-boot virtual machines are extremely rare in the "
1222 "world of virtualization, but since this scenario can happen, we have built "
1223 "libguestfs to deal with it.)"
1227 #: ../src/guestfs.pod:571
1229 "For each root, you can then call various C<guestfs_inspect_get_*> functions "
1230 "to get additional details about that operating system. For example, call L</"
1231 "guestfs_inspect_get_type> to return the string C<windows> or C<linux> for "
1232 "Windows and Linux-based operating systems respectively."
1236 #: ../src/guestfs.pod:577
1238 "Un*x-like and Linux-based operating systems usually consist of several "
1239 "filesystems which are mounted at boot time (for example, a separate boot "
1240 "partition mounted on C</boot>). The inspection rules are able to detect how "
1241 "filesystems correspond to mount points. Call "
1242 "C<guestfs_inspect_get_mountpoints> to get this mapping. It might return a "
1243 "hash table like this example:"
1247 #: ../src/guestfs.pod:584
1250 " /boot => /dev/sda1\n"
1251 " / => /dev/vg_guest/lv_root\n"
1252 " /usr => /dev/vg_guest/lv_usr\n"
1257 #: ../src/guestfs.pod:588
1259 "The caller can then make calls to L</guestfs_mount_options> to mount the "
1260 "filesystems as suggested."
1264 #: ../src/guestfs.pod:591
1266 "Be careful to mount filesystems in the right order (eg. C</> before C</"
1267 "usr>). Sorting the keys of the hash by length, shortest first, should work."
1271 #: ../src/guestfs.pod:595
1273 "Inspection currently only works for some common operating systems. "
1274 "Contributors are welcome to send patches for other operating systems that we "
1275 "currently cannot detect."
1279 #: ../src/guestfs.pod:599
1281 "Encrypted disks must be opened before inspection. See L</ENCRYPTED DISKS> "
1282 "for more details. The L</guestfs_inspect_os> function just ignores any "
1283 "encrypted devices."
1287 #: ../src/guestfs.pod:603
1289 "A note on the implementation: The call L</guestfs_inspect_os> performs "
1290 "inspection and caches the results in the guest handle. Subsequent calls to "
1291 "C<guestfs_inspect_get_*> return this cached information, but I<do not> re-"
1292 "read the disks. If you change the content of the guest disks, you can redo "
1293 "inspection by calling L</guestfs_inspect_os> again. (L</"
1294 "guestfs_inspect_list_applications> works a little differently from the other "
1295 "calls and does read the disks. See documentation for that function for "
1300 #: ../src/guestfs.pod:612
1301 msgid "INSPECTING INSTALL DISKS"
1305 #: ../src/guestfs.pod:614
1307 "Libguestfs (since 1.9.4) can detect some install disks, install CDs, live "
1312 #: ../src/guestfs.pod:617
1314 "Call L</guestfs_inspect_get_format> to return the format of the operating "
1315 "system, which currently can be C<installed> (a regular operating system) or "
1316 "C<installer> (some sort of install disk)."
1320 #: ../src/guestfs.pod:621
1322 "Further information is available about the operating system that can be "
1323 "installed using the regular inspection APIs like L</"
1324 "guestfs_inspect_get_product_name>, L</guestfs_inspect_get_major_version> etc."
1328 #: ../src/guestfs.pod:626
1330 "Some additional information specific to installer disks is also available "
1331 "from the L</guestfs_inspect_is_live>, L</guestfs_inspect_is_netinst> and L</"
1332 "guestfs_inspect_is_multipart> calls."
1336 #: ../src/guestfs.pod:631
1337 msgid "SPECIAL CONSIDERATIONS FOR WINDOWS GUESTS"
1341 #: ../src/guestfs.pod:633
1343 "Libguestfs can mount NTFS partitions. It does this using the L<http://www."
1344 "ntfs-3g.org/> driver."
1348 #: ../src/guestfs.pod:636
1349 msgid "DRIVE LETTERS AND PATHS"
1353 #: ../src/guestfs.pod:638
1355 "DOS and Windows still use drive letters, and the filesystems are always "
1356 "treated as case insensitive by Windows itself, and therefore you might find "
1357 "a Windows configuration file referring to a path like C<c:\\windows"
1358 "\\system32>. When the filesystem is mounted in libguestfs, that directory "
1359 "might be referred to as C</WINDOWS/System32>."
1363 #: ../src/guestfs.pod:644
1365 "Drive letter mappings can be found using inspection (see L</INSPECTION> and "
1366 "L</guestfs_inspect_get_drive_mappings>)"
1370 #: ../src/guestfs.pod:647
1372 "Dealing with separator characters (backslash vs forward slash) is outside "
1373 "the scope of libguestfs, but usually a simple character replacement will "
1378 #: ../src/guestfs.pod:651
1380 "To resolve the case insensitivity of paths, call L</"
1381 "guestfs_case_sensitive_path>."
1385 #: ../src/guestfs.pod:654
1386 msgid "ACCESSING THE WINDOWS REGISTRY"
1390 #: ../src/guestfs.pod:656
1392 "Libguestfs also provides some help for decoding Windows Registry \"hive\" "
1393 "files, through the library C<hivex> which is part of the libguestfs project "
1394 "although ships as a separate tarball. You have to locate and download the "
1395 "hive file(s) yourself, and then pass them to C<hivex> functions. See also "
1396 "the programs L<hivexml(1)>, L<hivexsh(1)>, L<hivexregedit(1)> and L<virt-win-"
1397 "reg(1)> for more help on this issue."
1401 #: ../src/guestfs.pod:664
1402 msgid "SYMLINKS ON NTFS-3G FILESYSTEMS"
1406 #: ../src/guestfs.pod:666
1408 "Ntfs-3g tries to rewrite \"Junction Points\" and NTFS \"symbolic links\" to "
1409 "provide something which looks like a Linux symlink. The way it tries to do "
1410 "the rewriting is described here:"
1414 #: ../src/guestfs.pod:670
1416 "L<http://www.tuxera.com/community/ntfs-3g-advanced/junction-points-and-"
1419 "L<http://www.tuxera.com/community/ntfs-3g-advanced/junction-points-and-"
1423 #: ../src/guestfs.pod:672
1425 "The essential problem is that ntfs-3g simply does not have enough "
1426 "information to do a correct job. NTFS links can contain drive letters and "
1427 "references to external device GUIDs that ntfs-3g has no way of resolving. "
1428 "It is almost certainly the case that libguestfs callers should ignore what "
1429 "ntfs-3g does (ie. don't use L</guestfs_readlink> on NTFS volumes)."
1433 #: ../src/guestfs.pod:679
1435 "Instead if you encounter a symbolic link on an ntfs-3g filesystem, use L</"
1436 "guestfs_lgetxattr> to read the C<system.ntfs_reparse_data> extended "
1437 "attribute, and read the raw reparse data from that (you can find the format "
1438 "documented in various places around the web)."
1442 #: ../src/guestfs.pod:684
1443 msgid "EXTENDED ATTRIBUTES ON NTFS-3G FILESYSTEMS"
1447 #: ../src/guestfs.pod:686
1449 "There are other useful extended attributes that can be read from ntfs-3g "
1450 "filesystems (using L</guestfs_getxattr>). See:"
1454 #: ../src/guestfs.pod:689
1456 "L<http://www.tuxera.com/community/ntfs-3g-advanced/extended-attributes/>"
1458 "L<http://www.tuxera.com/community/ntfs-3g-advanced/extended-attributes/>"
1461 #: ../src/guestfs.pod:691
1462 msgid "USING LIBGUESTFS WITH OTHER PROGRAMMING LANGUAGES"
1466 #: ../src/guestfs.pod:693
1468 "Although we don't want to discourage you from using the C API, we will "
1469 "mention here that the same API is also available in other languages."
1473 #: ../src/guestfs.pod:696
1475 "The API is broadly identical in all supported languages. This means that "
1476 "the C call C<guestfs_add_drive_ro(g,file)> is C<$g-E<gt>add_drive_ro($file)> "
1477 "in Perl, C<g.add_drive_ro(file)> in Python, and C<g#add_drive_ro file> in "
1478 "OCaml. In other words, a straightforward, predictable isomorphism between "
1483 #: ../src/guestfs.pod:702
1485 "Error messages are automatically transformed into exceptions if the language "
1490 #: ../src/guestfs.pod:705
1492 "We don't try to \"object orientify\" parts of the API in OO languages, "
1493 "although contributors are welcome to write higher level APIs above what we "
1494 "provide in their favourite languages if they wish."
1498 #: ../src/guestfs.pod:711
1503 #: ../src/guestfs.pod:713
1505 "You can use the I<guestfs.h> header file from C++ programs. The C++ API is "
1506 "identical to the C API. C++ classes and exceptions are not used."
1510 #: ../src/guestfs.pod:717
1515 #: ../src/guestfs.pod:719
1517 "The C# bindings are highly experimental. Please read the warnings at the "
1518 "top of C<csharp/Libguestfs.cs>."
1522 #: ../src/guestfs.pod:722
1527 #: ../src/guestfs.pod:724
1529 "This is the only language binding that is working but incomplete. Only "
1530 "calls which return simple integers have been bound in Haskell, and we are "
1531 "looking for help to complete this binding."
1535 #: ../src/guestfs.pod:728
1540 #: ../src/guestfs.pod:730
1542 "Full documentation is contained in the Javadoc which is distributed with "
1547 #: ../src/guestfs.pod:733
1552 #: ../src/guestfs.pod:735
1553 msgid "See L<guestfs-ocaml(3)>."
1554 msgstr "Див. L<guestfs-ocaml(3)>."
1557 #: ../src/guestfs.pod:737
1562 #: ../src/guestfs.pod:739
1563 msgid "See L<guestfs-perl(3)> and L<Sys::Guestfs(3)>."
1564 msgstr "Див. L<guestfs-perl(3)> та L<Sys::Guestfs(3)>."
1567 #: ../src/guestfs.pod:741
1572 #: ../src/guestfs.pod:743
1574 "For documentation see C<README-PHP> supplied with libguestfs sources or in "
1575 "the php-libguestfs package for your distribution."
1579 #: ../src/guestfs.pod:746
1580 msgid "The PHP binding only works correctly on 64 bit machines."
1584 #: ../src/guestfs.pod:748
1589 #: ../src/guestfs.pod:750
1590 msgid "See L<guestfs-python(3)>."
1591 msgstr "Див. L<guestfs-python(3)>."
1594 #: ../src/guestfs.pod:752
1599 #: ../src/guestfs.pod:754
1600 msgid "See L<guestfs-ruby(3)>."
1601 msgstr "Див. L<guestfs-ruby(3)>."
1604 #: ../src/guestfs.pod:756
1605 msgid "B<shell scripts>"
1606 msgstr "B<скрипти оболонки>"
1609 #: ../src/guestfs.pod:758
1610 msgid "See L<guestfish(1)>."
1611 msgstr "Див. L<guestfish(1)>."
1614 #: ../src/guestfs.pod:762
1615 msgid "LIBGUESTFS GOTCHAS"
1619 #: ../src/guestfs.pod:764
1621 "L<http://en.wikipedia.org/wiki/Gotcha_(programming)>: \"A feature of a "
1622 "system [...] that works in the way it is documented but is counterintuitive "
1623 "and almost invites mistakes.\""
1627 #: ../src/guestfs.pod:768
1629 "Since we developed libguestfs and the associated tools, there are several "
1630 "things we would have designed differently, but are now stuck with for "
1631 "backwards compatibility or other reasons. If there is ever a libguestfs 2.0 "
1632 "release, you can expect these to change. Beware of them."
1636 #: ../src/guestfs.pod:776
1637 msgid "Autosync / forgetting to sync."
1641 #: ../src/guestfs.pod:778
1643 "I<Update:> Autosync is enabled by default for all API users starting from "
1644 "libguestfs 1.5.24. This section only applies to older versions."
1648 #: ../src/guestfs.pod:781
1650 "When modifying a filesystem from C or another language, you B<must> unmount "
1651 "all filesystems and call L</guestfs_sync> explicitly before you close the "
1652 "libguestfs handle. You can also call:"
1656 #: ../src/guestfs.pod:785
1659 " guestfs_set_autosync (g, 1);\n"
1664 #: ../src/guestfs.pod:787
1666 "to have the unmount/sync done automatically for you when the handle 'g' is "
1667 "closed. (This feature is called \"autosync\", L</guestfs_set_autosync> q.v.)"
1671 #: ../src/guestfs.pod:791
1673 "If you forget to do this, then it is entirely possible that your changes "
1674 "won't be written out, or will be partially written, or (very rarely) that "
1675 "you'll get disk corruption."
1679 #: ../src/guestfs.pod:795
1681 "Note that in L<guestfish(3)> autosync is the default. So quick and dirty "
1682 "guestfish scripts that forget to sync will work just fine, which can make "
1683 "this very puzzling if you are trying to debug a problem."
1687 #: ../src/guestfs.pod:799
1688 msgid "Mount option C<-o sync> should not be the default."
1692 #: ../src/guestfs.pod:801
1694 "If you use L</guestfs_mount>, then C<-o sync,noatime> are added implicitly. "
1695 "However C<-o sync> does not add any reliability benefit, but does have a "
1696 "very large performance impact."
1700 #: ../src/guestfs.pod:805
1702 "The work around is to use L</guestfs_mount_options> and set the mount "
1703 "options that you actually want to use."
1707 #: ../src/guestfs.pod:808
1708 msgid "Read-only should be the default."
1712 #: ../src/guestfs.pod:810
1714 "In L<guestfish(3)>, I<--ro> should be the default, and you should have to "
1715 "specify I<--rw> if you want to make changes to the image."
1719 #: ../src/guestfs.pod:813
1720 msgid "This would reduce the potential to corrupt live VM images."
1724 #: ../src/guestfs.pod:815
1726 "Note that many filesystems change the disk when you just mount and unmount, "
1727 "even if you didn't perform any writes. You need to use L</"
1728 "guestfs_add_drive_ro> to guarantee that the disk is not changed."
1732 #: ../src/guestfs.pod:819
1733 msgid "guestfish command line is hard to use."
1737 #: ../src/guestfs.pod:821
1739 "C<guestfish disk.img> doesn't do what people expect (open C<disk.img> for "
1740 "examination). It tries to run a guestfish command C<disk.img> which doesn't "
1741 "exist, so it fails. In earlier versions of guestfish the error message was "
1742 "also unintuitive, but we have corrected this since. Like the Bourne shell, "
1743 "we should have used C<guestfish -c command> to run commands."
1747 #: ../src/guestfs.pod:828
1748 msgid "guestfish megabyte modifiers don't work right on all commands"
1752 #: ../src/guestfs.pod:830
1754 "In recent guestfish you can use C<1M> to mean 1 megabyte (and similarly for "
1755 "other modifiers). What guestfish actually does is to multiply the number "
1756 "part by the modifier part and pass the result to the C API. However this "
1757 "doesn't work for a few APIs which aren't expecting bytes, but are already "
1758 "expecting some other unit (eg. megabytes)."
1762 #: ../src/guestfs.pod:837
1763 msgid "The most common is L</guestfs_lvcreate>. The guestfish command:"
1767 #: ../src/guestfs.pod:839
1770 " lvcreate LV VG 100M\n"
1775 #: ../src/guestfs.pod:841
1777 "does not do what you might expect. Instead because L</guestfs_lvcreate> is "
1778 "already expecting megabytes, this tries to create a 100 I<terabyte> (100 "
1779 "megabytes * megabytes) logical volume. The error message you get from this "
1780 "is also a little obscure."
1784 #: ../src/guestfs.pod:846
1786 "This could be fixed in the generator by specially marking parameters and "
1787 "return values which take bytes or other units."
1791 #: ../src/guestfs.pod:849
1792 msgid "Ambiguity between devices and paths"
1796 #: ../src/guestfs.pod:851
1798 "There is a subtle ambiguity in the API between a device name (eg. C</dev/"
1799 "sdb2>) and a similar pathname. A file might just happen to be called "
1800 "C<sdb2> in the directory C</dev> (consider some non-Unix VM image)."
1804 #: ../src/guestfs.pod:856
1806 "In the current API we usually resolve this ambiguity by having two separate "
1807 "calls, for example L</guestfs_checksum> and L</guestfs_checksum_device>. "
1808 "Some API calls are ambiguous and (incorrectly) resolve the problem by "
1809 "detecting if the path supplied begins with C</dev/>."
1813 #: ../src/guestfs.pod:862
1815 "To avoid both the ambiguity and the need to duplicate some calls, we could "
1816 "make paths/devices into structured names. One way to do this would be to "
1817 "use a notation like grub (C<hd(0,0)>), although nobody really likes this "
1818 "aspect of grub. Another way would be to use a structured type, equivalent "
1819 "to this OCaml type:"
1823 #: ../src/guestfs.pod:868
1826 " type path = Path of string | Device of int | Partition of int * int\n"
1831 #: ../src/guestfs.pod:870
1832 msgid "which would allow you to pass arguments like:"
1836 #: ../src/guestfs.pod:872
1839 " Path \"/foo/bar\"\n"
1840 " Device 1 (* /dev/sdb, or perhaps /dev/sda *)\n"
1841 " Partition (1, 2) (* /dev/sdb2 (or is it /dev/sda2 or /dev/sdb3?) *)\n"
1842 " Path \"/dev/sdb2\" (* not a device *)\n"
1847 #: ../src/guestfs.pod:877
1849 "As you can see there are still problems to resolve even with this "
1850 "representation. Also consider how it might work in guestfish."
1854 #: ../src/guestfs.pod:882
1855 msgid "KEYS AND PASSPHRASES"
1859 #: ../src/guestfs.pod:884
1861 "Certain libguestfs calls take a parameter that contains sensitive key "
1862 "material, passed in as a C string."
1866 #: ../src/guestfs.pod:887
1868 "In the future we would hope to change the libguestfs implementation so that "
1869 "keys are L<mlock(2)>-ed into physical RAM, and thus can never end up in "
1870 "swap. However this is I<not> done at the moment, because of the complexity "
1871 "of such an implementation."
1875 #: ../src/guestfs.pod:892
1877 "Therefore you should be aware that any key parameter you pass to libguestfs "
1878 "might end up being written out to the swap partition. If this is a concern, "
1879 "scrub the swap partition or don't use libguestfs on encrypted devices."
1883 #: ../src/guestfs.pod:897
1884 msgid "MULTIPLE HANDLES AND MULTIPLE THREADS"
1888 #: ../src/guestfs.pod:899
1890 "All high-level libguestfs actions are synchronous. If you want to use "
1891 "libguestfs asynchronously then you must create a thread."
1895 #: ../src/guestfs.pod:902
1897 "Only use the handle from a single thread. Either use the handle exclusively "
1898 "from one thread, or provide your own mutex so that two threads cannot issue "
1899 "calls on the same handle at the same time."
1903 #: ../src/guestfs.pod:906
1905 "See the graphical program guestfs-browser for one possible architecture for "
1906 "multithreaded programs using libvirt and libguestfs."
1910 #: ../src/guestfs.pod:909
1915 #: ../src/guestfs.pod:911
1917 "Libguestfs needs a supermin appliance, which it finds by looking along an "
1922 #: ../src/guestfs.pod:914
1924 "By default it looks for these in the directory C<$libdir/guestfs> (eg. C</"
1925 "usr/local/lib/guestfs> or C</usr/lib64/guestfs>)."
1929 #: ../src/guestfs.pod:917
1931 "Use L</guestfs_set_path> or set the environment variable L</LIBGUESTFS_PATH> "
1932 "to change the directories that libguestfs will search in. The value is a "
1933 "colon-separated list of paths. The current directory is I<not> searched "
1934 "unless the path contains an empty element or C<.>. For example "
1935 "C<LIBGUESTFS_PATH=:/usr/lib/guestfs> would search the current directory and "
1936 "then C</usr/lib/guestfs>."
1940 #: ../src/guestfs.pod:924
1941 msgid "QEMU WRAPPERS"
1945 #: ../src/guestfs.pod:926
1947 "If you want to compile your own qemu, run qemu from a non-standard location, "
1948 "or pass extra arguments to qemu, then you can write a shell-script wrapper "
1953 #: ../src/guestfs.pod:930
1955 "There is one important rule to remember: you I<must C<exec qemu>> as the "
1956 "last command in the shell script (so that qemu replaces the shell and "
1957 "becomes the direct child of the libguestfs-using program). If you don't do "
1958 "this, then the qemu process won't be cleaned up correctly."
1962 #: ../src/guestfs.pod:935
1964 "Here is an example of a wrapper, where I have built my own copy of qemu from "
1969 #: ../src/guestfs.pod:938
1973 " qemudir=/home/rjones/d/qemu\n"
1974 " exec $qemudir/x86_64-softmmu/qemu-system-x86_64 -L $qemudir/pc-bios \"$@\"\n"
1979 #: ../src/guestfs.pod:942
1981 "Save this script as C</tmp/qemu.wrapper> (or wherever), C<chmod +x>, and "
1982 "then use it by setting the LIBGUESTFS_QEMU environment variable. For "
1987 #: ../src/guestfs.pod:946
1990 " LIBGUESTFS_QEMU=/tmp/qemu.wrapper guestfish\n"
1995 #: ../src/guestfs.pod:948
1997 "Note that libguestfs also calls qemu with the -help and -version options in "
1998 "order to determine features."
2002 #: ../src/guestfs.pod:951
2003 msgid "ATTACHING TO RUNNING DAEMONS"
2007 #: ../src/guestfs.pod:953
2009 "I<Note (1):> This is B<highly experimental> and has a tendency to eat "
2010 "babies. Use with caution."
2014 #: ../src/guestfs.pod:956
2016 "I<Note (2):> This section explains how to attach to a running daemon from a "
2017 "low level perspective. For most users, simply using virt tools such as "
2018 "L<guestfish(1)> with the I<--live> option will \"just work\"."
2022 #: ../src/guestfs.pod:960
2023 msgid "Using guestfs_set_attach_method"
2027 #: ../src/guestfs.pod:962
2029 "By calling L</guestfs_set_attach_method> you can change how the library "
2030 "connects to the C<guestfsd> daemon in L</guestfs_launch> (read L</"
2031 "ARCHITECTURE> for some background)."
2035 #: ../src/guestfs.pod:966
2037 "The normal attach method is C<appliance>, where a small appliance is created "
2038 "containing the daemon, and then the library connects to this."
2042 #: ../src/guestfs.pod:969
2044 "Setting attach method to C<unix:I<path>> (where I<path> is the path of a "
2045 "Unix domain socket) causes L</guestfs_launch> to connect to an existing "
2046 "daemon over the Unix domain socket."
2050 #: ../src/guestfs.pod:973
2052 "The normal use for this is to connect to a running virtual machine that "
2053 "contains a C<guestfsd> daemon, and send commands so you can read and write "
2054 "files inside the live virtual machine."
2058 #: ../src/guestfs.pod:977
2059 msgid "Using guestfs_add_domain with live flag"
2063 #: ../src/guestfs.pod:979
2065 "L</guestfs_add_domain> provides some help for getting the correct attach "
2066 "method. If you pass the C<live> option to this function, then (if the "
2067 "virtual machine is running) it will examine the libvirt XML looking for a "
2068 "virtio-serial channel to connect to:"
2072 #: ../src/guestfs.pod:985
2079 " <channel type='unix'>\n"
2080 " <source mode='bind' path='/path/to/socket'/>\n"
2081 " <target type='virtio' name='org.libguestfs.channel.0'/>\n"
2090 #: ../src/guestfs.pod:997
2092 "L</guestfs_add_domain> extracts C</path/to/socket> and sets the attach "
2093 "method to C<unix:/path/to/socket>."
2097 #: ../src/guestfs.pod:1000
2099 "Some of the libguestfs tools (including guestfish) support a I<--live> "
2100 "option which is passed through to L</guestfs_add_domain> thus allowing you "
2101 "to attach to and modify live virtual machines."
2105 #: ../src/guestfs.pod:1004
2107 "The virtual machine needs to have been set up beforehand so that it has the "
2108 "virtio-serial channel and so that guestfsd is running inside it."
2112 #: ../src/guestfs.pod:1008
2113 msgid "ABI GUARANTEE"
2117 #: ../src/guestfs.pod:1010
2119 "We guarantee the libguestfs ABI (binary interface), for public, high-level "
2120 "actions as outlined in this section. Although we will deprecate some "
2121 "actions, for example if they get replaced by newer calls, we will keep the "
2122 "old actions forever. This allows you the developer to program in confidence "
2123 "against the libguestfs API."
2127 #: ../src/guestfs.pod:1016
2128 msgid "BLOCK DEVICE NAMING"
2132 #: ../src/guestfs.pod:1018
2134 "In the kernel there is now quite a profusion of schemata for naming block "
2135 "devices (in this context, by I<block device> I mean a physical or virtual "
2136 "hard drive). The original Linux IDE driver used names starting with C</dev/"
2137 "hd*>. SCSI devices have historically used a different naming scheme, C</dev/"
2138 "sd*>. When the Linux kernel I<libata> driver became a popular replacement "
2139 "for the old IDE driver (particularly for SATA devices) those devices also "
2140 "used the C</dev/sd*> scheme. Additionally we now have virtual machines with "
2141 "paravirtualized drivers. This has created several different naming systems, "
2142 "such as C</dev/vd*> for virtio disks and C</dev/xvd*> for Xen PV disks."
2146 #: ../src/guestfs.pod:1030
2148 "As discussed above, libguestfs uses a qemu appliance running an embedded "
2149 "Linux kernel to access block devices. We can run a variety of appliances "
2150 "based on a variety of Linux kernels."
2154 #: ../src/guestfs.pod:1034
2156 "This causes a problem for libguestfs because many API calls use device or "
2157 "partition names. Working scripts and the recipe (example) scripts that we "
2158 "make available over the internet could fail if the naming scheme changes."
2162 #: ../src/guestfs.pod:1039
2164 "Therefore libguestfs defines C</dev/sd*> as the I<standard naming scheme>. "
2165 "Internally C</dev/sd*> names are translated, if necessary, to other names as "
2166 "required. For example, under RHEL 5 which uses the C</dev/hd*> scheme, any "
2167 "device parameter C</dev/sda2> is translated to C</dev/hda2> transparently."
2171 #: ../src/guestfs.pod:1045
2173 "Note that this I<only> applies to parameters. The L</guestfs_list_devices>, "
2174 "L</guestfs_list_partitions> and similar calls return the true names of the "
2175 "devices and partitions as known to the appliance."
2179 #: ../src/guestfs.pod:1050
2180 msgid "ALGORITHM FOR BLOCK DEVICE NAME TRANSLATION"
2184 #: ../src/guestfs.pod:1052
2186 "Usually this translation is transparent. However in some (very rare) cases "
2187 "you may need to know the exact algorithm. Such cases include where you use "
2188 "L</guestfs_config> to add a mixture of virtio and IDE devices to the qemu-"
2189 "based appliance, so have a mixture of C</dev/sd*> and C</dev/vd*> devices."
2193 #: ../src/guestfs.pod:1058
2195 "The algorithm is applied only to I<parameters> which are known to be either "
2196 "device or partition names. Return values from functions such as L</"
2197 "guestfs_list_devices> are never changed."
2201 #: ../src/guestfs.pod:1066
2202 msgid "Is the string a parameter which is a device or partition name?"
2206 #: ../src/guestfs.pod:1070
2207 msgid "Does the string begin with C</dev/sd>?"
2211 #: ../src/guestfs.pod:1074
2213 "Does the named device exist? If so, we use that device. However if I<not> "
2214 "then we continue with this algorithm."
2218 #: ../src/guestfs.pod:1079
2219 msgid "Replace initial C</dev/sd> string with C</dev/hd>."
2223 #: ../src/guestfs.pod:1081
2224 msgid "For example, change C</dev/sda2> to C</dev/hda2>."
2228 #: ../src/guestfs.pod:1083
2229 msgid "If that named device exists, use it. If not, continue."
2233 #: ../src/guestfs.pod:1087
2234 msgid "Replace initial C</dev/sd> string with C</dev/vd>."
2238 #: ../src/guestfs.pod:1089
2239 msgid "If that named device exists, use it. If not, return an error."
2243 #: ../src/guestfs.pod:1093
2244 msgid "PORTABILITY CONCERNS WITH BLOCK DEVICE NAMING"
2248 #: ../src/guestfs.pod:1095
2250 "Although the standard naming scheme and automatic translation is useful for "
2251 "simple programs and guestfish scripts, for larger programs it is best not to "
2252 "rely on this mechanism."
2256 #: ../src/guestfs.pod:1099
2258 "Where possible for maximum future portability programs using libguestfs "
2259 "should use these future-proof techniques:"
2263 #: ../src/guestfs.pod:1106
2265 "Use L</guestfs_list_devices> or L</guestfs_list_partitions> to list actual "
2266 "device names, and then use those names directly."
2270 #: ../src/guestfs.pod:1109
2272 "Since those device names exist by definition, they will never be translated."
2276 #: ../src/guestfs.pod:1114
2278 "Use higher level ways to identify filesystems, such as LVM names, UUIDs and "
2279 "filesystem labels."
2283 #: ../src/guestfs.pod:1119
2288 #: ../src/guestfs.pod:1121
2290 "This section discusses security implications of using libguestfs, "
2291 "particularly with untrusted or malicious guests or disk images."
2295 #: ../src/guestfs.pod:1124
2296 msgid "GENERAL SECURITY CONSIDERATIONS"
2300 #: ../src/guestfs.pod:1126
2302 "Be careful with any files or data that you download from a guest (by "
2303 "\"download\" we mean not just the L</guestfs_download> command but any "
2304 "command that reads files, filenames, directories or anything else from a "
2305 "disk image). An attacker could manipulate the data to fool your program "
2306 "into doing the wrong thing. Consider cases such as:"
2310 #: ../src/guestfs.pod:1136
2311 msgid "the data (file etc) not being present"
2315 #: ../src/guestfs.pod:1140
2316 msgid "being present but empty"
2320 #: ../src/guestfs.pod:1144
2321 msgid "being much larger than normal"
2325 #: ../src/guestfs.pod:1148
2326 msgid "containing arbitrary 8 bit data"
2330 #: ../src/guestfs.pod:1152
2331 msgid "being in an unexpected character encoding"
2335 #: ../src/guestfs.pod:1156
2336 msgid "containing homoglyphs."
2340 #: ../src/guestfs.pod:1160
2341 msgid "SECURITY OF MOUNTING FILESYSTEMS"
2345 #: ../src/guestfs.pod:1162
2347 "When you mount a filesystem under Linux, mistakes in the kernel filesystem "
2348 "(VFS) module can sometimes be escalated into exploits by deliberately "
2349 "creating a malicious, malformed filesystem. These exploits are very severe "
2350 "for two reasons. Firstly there are very many filesystem drivers in the "
2351 "kernel, and many of them are infrequently used and not much developer "
2352 "attention has been paid to the code. Linux userspace helps potential "
2353 "crackers by detecting the filesystem type and automatically choosing the "
2354 "right VFS driver, even if that filesystem type is obscure or unexpected for "
2355 "the administrator. Secondly, a kernel-level exploit is like a local root "
2356 "exploit (worse in some ways), giving immediate and total access to the "
2357 "system right down to the hardware level."
2361 #: ../src/guestfs.pod:1175
2363 "That explains why you should never mount a filesystem from an untrusted "
2364 "guest on your host kernel. How about libguestfs? We run a Linux kernel "
2365 "inside a qemu virtual machine, usually running as a non-root user. The "
2366 "attacker would need to write a filesystem which first exploited the kernel, "
2367 "and then exploited either qemu virtualization (eg. a faulty qemu driver) or "
2368 "the libguestfs protocol, and finally to be as serious as the host kernel "
2369 "exploit it would need to escalate its privileges to root. This multi-step "
2370 "escalation, performed by a static piece of data, is thought to be extremely "
2371 "hard to do, although we never say 'never' about security issues."
2375 #: ../src/guestfs.pod:1186
2377 "In any case callers can reduce the attack surface by forcing the filesystem "
2378 "type when mounting (use L</guestfs_mount_vfs>)."
2382 #: ../src/guestfs.pod:1189
2383 msgid "PROTOCOL SECURITY"
2387 #: ../src/guestfs.pod:1191
2389 "The protocol is designed to be secure, being based on RFC 4506 (XDR) with a "
2390 "defined upper message size. However a program that uses libguestfs must "
2391 "also take care - for example you can write a program that downloads a binary "
2392 "from a disk image and executes it locally, and no amount of protocol "
2393 "security will save you from the consequences."
2397 #: ../src/guestfs.pod:1197
2398 msgid "INSPECTION SECURITY"
2402 #: ../src/guestfs.pod:1199
2404 "Parts of the inspection API (see L</INSPECTION>) return untrusted strings "
2405 "directly from the guest, and these could contain any 8 bit data. Callers "
2406 "should be careful to escape these before printing them to a structured file "
2407 "(for example, use HTML escaping if creating a web page)."
2411 #: ../src/guestfs.pod:1205
2413 "Guest configuration may be altered in unusual ways by the administrator of "
2414 "the virtual machine, and may not reflect reality (particularly for untrusted "
2415 "or actively malicious guests). For example we parse the hostname from "
2416 "configuration files like C</etc/sysconfig/network> that we find in the "
2417 "guest, but the guest administrator can easily manipulate these files to "
2418 "provide the wrong hostname."
2422 #: ../src/guestfs.pod:1213
2424 "The inspection API parses guest configuration using two external libraries: "
2425 "Augeas (Linux configuration) and hivex (Windows Registry). Both are "
2426 "designed to be robust in the face of malicious data, although denial of "
2427 "service attacks are still possible, for example with oversized configuration "
2432 #: ../src/guestfs.pod:1219
2433 msgid "RUNNING UNTRUSTED GUEST COMMANDS"
2437 #: ../src/guestfs.pod:1221
2439 "Be very cautious about running commands from the guest. By running a "
2440 "command in the guest, you are giving CPU time to a binary that you do not "
2441 "control, under the same user account as the library, albeit wrapped in qemu "
2442 "virtualization. More information and alternatives can be found in the "
2443 "section L</RUNNING COMMANDS>."
2447 #: ../src/guestfs.pod:1227
2448 msgid "CVE-2010-3851"
2449 msgstr "CVE-2010-3851"
2452 #: ../src/guestfs.pod:1229
2453 msgid "https://bugzilla.redhat.com/642934"
2454 msgstr "https://bugzilla.redhat.com/642934"
2457 #: ../src/guestfs.pod:1231
2459 "This security bug concerns the automatic disk format detection that qemu "
2460 "does on disk images."
2464 #: ../src/guestfs.pod:1234
2466 "A raw disk image is just the raw bytes, there is no header. Other disk "
2467 "images like qcow2 contain a special header. Qemu deals with this by looking "
2468 "for one of the known headers, and if none is found then assuming the disk "
2469 "image must be raw."
2473 #: ../src/guestfs.pod:1239
2475 "This allows a guest which has been given a raw disk image to write some "
2476 "other header. At next boot (or when the disk image is accessed by "
2477 "libguestfs) qemu would do autodetection and think the disk image format was, "
2478 "say, qcow2 based on the header written by the guest."
2482 #: ../src/guestfs.pod:1244
2484 "This in itself would not be a problem, but qcow2 offers many features, one "
2485 "of which is to allow a disk image to refer to another image (called the "
2486 "\"backing disk\"). It does this by placing the path to the backing disk "
2487 "into the qcow2 header. This path is not validated and could point to any "
2488 "host file (eg. \"/etc/passwd\"). The backing disk is then exposed through "
2489 "\"holes\" in the qcow2 disk image, which of course is completely under the "
2490 "control of the attacker."
2494 #: ../src/guestfs.pod:1252
2496 "In libguestfs this is rather hard to exploit except under two circumstances:"
2500 #: ../src/guestfs.pod:1259
2501 msgid "You have enabled the network or have opened the disk in write mode."
2505 #: ../src/guestfs.pod:1263
2507 "You are also running untrusted code from the guest (see L</RUNNING "
2512 #: ../src/guestfs.pod:1268
2514 "The way to avoid this is to specify the expected disk format when adding "
2515 "disks (the optional C<format> option to L</guestfs_add_drive_opts>). You "
2516 "should always do this if the disk is raw format, and it's a good idea for "
2521 #: ../src/guestfs.pod:1273
2523 "For disks added from libvirt using calls like L</guestfs_add_domain>, the "
2524 "format is fetched from libvirt and passed through."
2528 #: ../src/guestfs.pod:1276
2530 "For libguestfs tools, use the I<--format> command line parameter as "
2535 #: ../src/guestfs.pod:1279
2536 msgid "CONNECTION MANAGEMENT"
2540 #: ../src/guestfs.pod:1281
2545 #: ../src/guestfs.pod:1283
2547 "C<guestfs_h> is the opaque type representing a connection handle. Create a "
2548 "handle by calling L</guestfs_create>. Call L</guestfs_close> to free the "
2549 "handle and release all resources used."
2553 #: ../src/guestfs.pod:1287
2555 "For information on using multiple handles and threads, see the section L</"
2556 "MULTIPLE HANDLES AND MULTIPLE THREADS> above."
2560 #: ../src/guestfs.pod:1290
2561 msgid "guestfs_create"
2565 #: ../src/guestfs.pod:1292
2568 " guestfs_h *guestfs_create (void);\n"
2573 #: ../src/guestfs.pod:1294
2574 msgid "Create a connection handle."
2578 #: ../src/guestfs.pod:1296
2580 "On success this returns a non-NULL pointer to a handle. On error it returns "
2585 #: ../src/guestfs.pod:1299
2587 "You have to \"configure\" the handle after creating it. This includes "
2588 "calling L</guestfs_add_drive_opts> (or one of the equivalent calls) on the "
2589 "handle at least once."
2593 #: ../src/guestfs.pod:1303
2594 msgid "After configuring the handle, you have to call L</guestfs_launch>."
2598 #: ../src/guestfs.pod:1305
2600 "You may also want to configure error handling for the handle. See the L</"
2601 "ERROR HANDLING> section below."
2605 #: ../src/guestfs.pod:1308
2606 msgid "guestfs_close"
2610 #: ../src/guestfs.pod:1310
2613 " void guestfs_close (guestfs_h *g);\n"
2618 #: ../src/guestfs.pod:1312
2619 msgid "This closes the connection handle and frees up all resources used."
2623 #: ../src/guestfs.pod:1314
2625 "If autosync was set on the handle and the handle was launched, then this "
2626 "implicitly calls various functions to unmount filesystems and sync the "
2627 "disk. See L</guestfs_set_autosync> for more details."
2631 #: ../src/guestfs.pod:1318
2632 msgid "If a close callback was set on the handle, then it is called."
2636 #: ../src/guestfs.pod:1320
2637 msgid "ERROR HANDLING"
2638 msgstr "ОБРОБКА ПОМИЛОК"
2641 #: ../src/guestfs.pod:1322
2643 "API functions can return errors. For example, almost all functions that "
2644 "return C<int> will return C<-1> to indicate an error."
2648 #: ../src/guestfs.pod:1325
2650 "Additional information is available for errors: an error message string and "
2651 "optionally an error number (errno) if the thing that failed was a system "
2656 #: ../src/guestfs.pod:1329
2658 "You can get at the additional information about the last error on the handle "
2659 "by calling L</guestfs_last_error>, L</guestfs_last_errno>, and/or by setting "
2660 "up an error handler with L</guestfs_set_error_handler>."
2664 #: ../src/guestfs.pod:1334
2666 "When the handle is created, a default error handler is installed which "
2667 "prints the error message string to C<stderr>. For small short-running "
2668 "command line programs it is sufficient to do:"
2672 #: ../src/guestfs.pod:1338
2675 " if (guestfs_launch (g) == -1)\n"
2676 " exit (EXIT_FAILURE);\n"
2681 #: ../src/guestfs.pod:1341
2683 "since the default error handler will ensure that an error message has been "
2684 "printed to C<stderr> before the program exits."
2688 #: ../src/guestfs.pod:1344
2690 "For other programs the caller will almost certainly want to install an "
2691 "alternate error handler or do error handling in-line like this:"
2695 #: ../src/guestfs.pod:1347
2698 " g = guestfs_create ();\n"
2703 #: ../src/guestfs.pod:1349
2706 " /* This disables the default behaviour of printing errors\n"
2708 " guestfs_set_error_handler (g, NULL, NULL);\n"
2713 #: ../src/guestfs.pod:1353
2716 " if (guestfs_launch (g) == -1) {\n"
2717 " /* Examine the error message and print it etc. */\n"
2718 " char *msg = guestfs_last_error (g);\n"
2719 " int errnum = guestfs_last_errno (g);\n"
2720 " fprintf (stderr, \"%s\\n\", msg);\n"
2727 #: ../src/guestfs.pod:1361
2729 "Out of memory errors are handled differently. The default action is to call "
2730 "L<abort(3)>. If this is undesirable, then you can set a handler using L</"
2731 "guestfs_set_out_of_memory_handler>."
2735 #: ../src/guestfs.pod:1365
2737 "L</guestfs_create> returns C<NULL> if the handle cannot be created, and "
2738 "because there is no handle if this happens there is no way to get additional "
2739 "error information. However L</guestfs_create> is supposed to be a "
2740 "lightweight operation which can only fail because of insufficient memory (it "
2741 "returns NULL in this case)."
2745 #: ../src/guestfs.pod:1371
2746 msgid "guestfs_last_error"
2750 #: ../src/guestfs.pod:1373
2753 " const char *guestfs_last_error (guestfs_h *g);\n"
2758 #: ../src/guestfs.pod:1375
2760 "This returns the last error message that happened on C<g>. If there has not "
2761 "been an error since the handle was created, then this returns C<NULL>."
2765 #: ../src/guestfs.pod:1379
2767 "The lifetime of the returned string is until the next error occurs, or L</"
2768 "guestfs_close> is called."
2772 #: ../src/guestfs.pod:1382
2773 msgid "guestfs_last_errno"
2777 #: ../src/guestfs.pod:1384
2780 " int guestfs_last_errno (guestfs_h *g);\n"
2785 #: ../src/guestfs.pod:1386
2786 msgid "This returns the last error number (errno) that happened on C<g>."
2790 #: ../src/guestfs.pod:1388
2791 msgid "If successful, an errno integer not equal to zero is returned."
2795 #: ../src/guestfs.pod:1390
2797 "If no error, this returns 0. This call can return 0 in three situations:"
2801 #: ../src/guestfs.pod:1397
2802 msgid "There has not been any error on the handle."
2806 #: ../src/guestfs.pod:1401
2808 "There has been an error but the errno was meaningless. This corresponds to "
2809 "the case where the error did not come from a failed system call, but for "
2810 "some other reason."
2814 #: ../src/guestfs.pod:1407
2816 "There was an error from a failed system call, but for some reason the errno "
2817 "was not captured and returned. This usually indicates a bug in libguestfs."
2821 #: ../src/guestfs.pod:1413
2823 "Libguestfs tries to convert the errno from inside the applicance into a "
2824 "corresponding errno for the caller (not entirely trivial: the appliance "
2825 "might be running a completely different operating system from the library "
2826 "and error numbers are not standardized across Un*xen). If this could not be "
2827 "done, then the error is translated to C<EINVAL>. In practice this should "
2828 "only happen in very rare circumstances."
2832 #: ../src/guestfs.pod:1421
2833 msgid "guestfs_set_error_handler"
2837 #: ../src/guestfs.pod:1423
2840 " typedef void (*guestfs_error_handler_cb) (guestfs_h *g,\n"
2842 " const char *msg);\n"
2843 " void guestfs_set_error_handler (guestfs_h *g,\n"
2844 " guestfs_error_handler_cb cb,\n"
2850 #: ../src/guestfs.pod:1430
2852 "The callback C<cb> will be called if there is an error. The parameters "
2853 "passed to the callback are an opaque data pointer and the error message "
2858 #: ../src/guestfs.pod:1434
2860 "C<errno> is not passed to the callback. To get that the callback must call "
2861 "L</guestfs_last_errno>."
2865 #: ../src/guestfs.pod:1437
2867 "Note that the message string C<msg> is freed as soon as the callback "
2868 "function returns, so if you want to stash it somewhere you must make your "
2873 #: ../src/guestfs.pod:1441
2874 msgid "The default handler prints messages on C<stderr>."
2878 #: ../src/guestfs.pod:1443
2879 msgid "If you set C<cb> to C<NULL> then I<no> handler is called."
2883 #: ../src/guestfs.pod:1445
2884 msgid "guestfs_get_error_handler"
2888 #: ../src/guestfs.pod:1447
2891 " guestfs_error_handler_cb guestfs_get_error_handler (guestfs_h *g,\n"
2892 " void **opaque_rtn);\n"
2897 #: ../src/guestfs.pod:1450
2898 msgid "Returns the current error handler callback."
2902 #: ../src/guestfs.pod:1452
2903 msgid "guestfs_set_out_of_memory_handler"
2907 #: ../src/guestfs.pod:1454
2910 " typedef void (*guestfs_abort_cb) (void);\n"
2911 " int guestfs_set_out_of_memory_handler (guestfs_h *g,\n"
2912 " guestfs_abort_cb);\n"
2917 #: ../src/guestfs.pod:1458
2919 "The callback C<cb> will be called if there is an out of memory situation. "
2920 "I<Note this callback must not return>."
2924 #: ../src/guestfs.pod:1461
2925 msgid "The default is to call L<abort(3)>."
2929 #: ../src/guestfs.pod:1463
2931 "You cannot set C<cb> to C<NULL>. You can't ignore out of memory situations."
2935 #: ../src/guestfs.pod:1466
2936 msgid "guestfs_get_out_of_memory_handler"
2940 #: ../src/guestfs.pod:1468
2943 " guestfs_abort_fn guestfs_get_out_of_memory_handler (guestfs_h *g);\n"
2948 #: ../src/guestfs.pod:1470
2949 msgid "This returns the current out of memory handler."
2953 #: ../src/guestfs.pod:1472
2958 #: ../src/guestfs.pod:1474 ../fish/guestfish.pod:1010
2963 #: ../src/guestfs.pod:1476
2968 #: ../src/guestfs.pod:1478
2973 #: ../src/guestfs.pod:1480
2974 msgid "AVAILABILITY"
2978 #: ../src/guestfs.pod:1482
2979 msgid "GROUPS OF FUNCTIONALITY IN THE APPLIANCE"
2983 #: ../src/guestfs.pod:1484
2985 "Using L</guestfs_available> you can test availability of the following "
2986 "groups of functions. This test queries the appliance to see if the "
2987 "appliance you are currently using supports the functionality."
2991 #: ../src/guestfs.pod:1489
2992 msgid "@AVAILABILITY@"
2996 #: ../src/guestfs.pod:1491
2997 msgid "GUESTFISH supported COMMAND"
3001 #: ../src/guestfs.pod:1493
3003 "In L<guestfish(3)> there is a handy interactive command C<supported> which "
3004 "prints out the available groups and whether they are supported by this build "
3005 "of libguestfs. Note however that you have to do C<run> first."
3009 #: ../src/guestfs.pod:1498
3010 msgid "SINGLE CALLS AT COMPILE TIME"
3014 #: ../src/guestfs.pod:1500
3016 "Since version 1.5.8, C<E<lt>guestfs.hE<gt>> defines symbols for each C API "
3017 "function, such as:"
3021 #: ../src/guestfs.pod:1503
3024 " #define LIBGUESTFS_HAVE_DD 1\n"
3029 #: ../src/guestfs.pod:1505
3030 msgid "if L</guestfs_dd> is available."
3034 #: ../src/guestfs.pod:1507
3036 "Before version 1.5.8, if you needed to test whether a single libguestfs "
3037 "function is available at compile time, we recommended using build tools such "
3038 "as autoconf or cmake. For example in autotools you could use:"
3042 #: ../src/guestfs.pod:1512
3045 " AC_CHECK_LIB([guestfs],[guestfs_create])\n"
3046 " AC_CHECK_FUNCS([guestfs_dd])\n"
3051 #: ../src/guestfs.pod:1515
3053 "which would result in C<HAVE_GUESTFS_DD> being either defined or not defined "
3058 #: ../src/guestfs.pod:1518
3059 msgid "SINGLE CALLS AT RUN TIME"
3063 #: ../src/guestfs.pod:1520
3065 "Testing at compile time doesn't guarantee that a function really exists in "
3066 "the library. The reason is that you might be dynamically linked against a "
3067 "previous I<libguestfs.so> (dynamic library) which doesn't have the call. "
3068 "This situation unfortunately results in a segmentation fault, which is a "
3069 "shortcoming of the C dynamic linking system itself."
3073 #: ../src/guestfs.pod:1527
3075 "You can use L<dlopen(3)> to test if a function is available at run time, as "
3076 "in this example program (note that you still need the compile time check as "
3081 #: ../src/guestfs.pod:1531
3084 " #include <stdio.h>\n"
3085 " #include <stdlib.h>\n"
3086 " #include <unistd.h>\n"
3087 " #include <dlfcn.h>\n"
3088 " #include <guestfs.h>\n"
3093 #: ../src/guestfs.pod:1537
3098 " #ifdef LIBGUESTFS_HAVE_DD\n"
3100 " int has_function;\n"
3105 #: ../src/guestfs.pod:1543
3108 " /* Test if the function guestfs_dd is really available. */\n"
3109 " dl = dlopen (NULL, RTLD_LAZY);\n"
3111 " fprintf (stderr, \"dlopen: %s\\n\", dlerror ());\n"
3112 " exit (EXIT_FAILURE);\n"
3114 " has_function = dlsym (dl, \"guestfs_dd\") != NULL;\n"
3120 #: ../src/guestfs.pod:1552
3123 " if (!has_function)\n"
3124 " printf (\"this libguestfs.so does NOT have guestfs_dd function\\n\");\n"
3126 " printf (\"this libguestfs.so has guestfs_dd function\\n\");\n"
3127 " /* Now it's safe to call\n"
3128 " guestfs_dd (g, \"foo\", \"bar\");\n"
3132 " printf (\"guestfs_dd function was not found at compile time\\n\");\n"
3139 #: ../src/guestfs.pod:1565
3141 "You may think the above is an awful lot of hassle, and it is. There are "
3142 "other ways outside of the C linking system to ensure that this kind of "
3143 "incompatibility never arises, such as using package versioning:"
3147 #: ../src/guestfs.pod:1570
3150 " Requires: libguestfs >= 1.0.80\n"
3155 #: ../src/guestfs.pod:1572
3156 msgid "CALLS WITH OPTIONAL ARGUMENTS"
3160 #: ../src/guestfs.pod:1574
3162 "A recent feature of the API is the introduction of calls which take optional "
3163 "arguments. In C these are declared 3 ways. The main way is as a call which "
3164 "takes variable arguments (ie. C<...>), as in this example:"
3168 #: ../src/guestfs.pod:1579
3171 " int guestfs_add_drive_opts (guestfs_h *g, const char *filename, ...);\n"
3176 #: ../src/guestfs.pod:1581
3178 "Call this with a list of optional arguments, terminated by C<-1>. So to "
3179 "call with no optional arguments specified:"
3183 #: ../src/guestfs.pod:1584
3186 " guestfs_add_drive_opts (g, filename, -1);\n"
3191 #: ../src/guestfs.pod:1586
3192 msgid "With a single optional argument:"
3196 #: ../src/guestfs.pod:1588
3199 " guestfs_add_drive_opts (g, filename,\n"
3200 " GUESTFS_ADD_DRIVE_OPTS_FORMAT, \"qcow2\",\n"
3206 #: ../src/guestfs.pod:1592
3211 #: ../src/guestfs.pod:1594
3214 " guestfs_add_drive_opts (g, filename,\n"
3215 " GUESTFS_ADD_DRIVE_OPTS_FORMAT, \"qcow2\",\n"
3216 " GUESTFS_ADD_DRIVE_OPTS_READONLY, 1,\n"
3222 #: ../src/guestfs.pod:1599
3224 "and so forth. Don't forget the terminating C<-1> otherwise Bad Things will "
3229 #: ../src/guestfs.pod:1602
3230 msgid "USING va_list FOR OPTIONAL ARGUMENTS"
3234 #: ../src/guestfs.pod:1604
3236 "The second variant has the same name with the suffix C<_va>, which works the "
3237 "same way but takes a C<va_list>. See the C manual for details. For the "
3238 "example function, this is declared:"
3242 #: ../src/guestfs.pod:1608
3245 " int guestfs_add_drive_opts_va (guestfs_h *g, const char *filename,\n"
3251 #: ../src/guestfs.pod:1611
3252 msgid "CONSTRUCTING OPTIONAL ARGUMENTS"
3256 #: ../src/guestfs.pod:1613
3258 "The third variant is useful where you need to construct these calls. You "
3259 "pass in a structure where you fill in the optional fields. The structure "
3260 "has a bitmask as the first element which you must set to indicate which "
3261 "fields you have filled in. For our example function the structure and call "
3266 #: ../src/guestfs.pod:1619
3269 " struct guestfs_add_drive_opts_argv {\n"
3270 " uint64_t bitmask;\n"
3272 " const char *format;\n"
3275 " int guestfs_add_drive_opts_argv (guestfs_h *g, const char *filename,\n"
3276 " const struct guestfs_add_drive_opts_argv *optargs);\n"
3281 #: ../src/guestfs.pod:1628
3282 msgid "You could call it like this:"
3286 #: ../src/guestfs.pod:1630
3289 " struct guestfs_add_drive_opts_argv optargs = {\n"
3290 " .bitmask = GUESTFS_ADD_DRIVE_OPTS_READONLY_BITMASK |\n"
3291 " GUESTFS_ADD_DRIVE_OPTS_FORMAT_BITMASK,\n"
3293 " .format = \"qcow2\"\n"
3299 #: ../src/guestfs.pod:1637
3302 " guestfs_add_drive_opts_argv (g, filename, &optargs);\n"
3307 #: ../src/guestfs.pod:1639 ../src/guestfs-actions.pod:11
3308 #: ../src/guestfs-actions.pod:1858 ../fish/guestfish-actions.pod:9
3309 #: ../fish/guestfish-actions.pod:1262 ../tools/virt-win-reg.pl:704
3314 #: ../src/guestfs.pod:1645
3315 msgid "The C<_BITMASK> suffix on each option name when specifying the bitmask."
3319 #: ../src/guestfs.pod:1650
3320 msgid "You do not need to fill in all fields of the structure."
3324 #: ../src/guestfs.pod:1654
3326 "There must be a one-to-one correspondence between fields of the structure "
3327 "that are filled in, and bits set in the bitmask."
3331 #: ../src/guestfs.pod:1659
3332 msgid "OPTIONAL ARGUMENTS IN OTHER LANGUAGES"
3336 #: ../src/guestfs.pod:1661
3338 "In other languages, optional arguments are expressed in the way that is "
3339 "natural for that language. We refer you to the language-specific "
3340 "documentation for more details on that."
3344 #: ../src/guestfs.pod:1665
3345 msgid "For guestfish, see L<guestfish(1)/OPTIONAL ARGUMENTS>."
3349 #: ../src/guestfs.pod:1667
3350 msgid "SETTING CALLBACKS TO HANDLE EVENTS"
3354 #: ../src/guestfs.pod:1669
3356 "B<Note:> This section documents the generic event mechanism introduced in "
3357 "libguestfs 1.10, which you should use in new code if possible. The old "
3358 "functions C<guestfs_set_log_message_callback>, "
3359 "C<guestfs_set_subprocess_quit_callback>, "
3360 "C<guestfs_set_launch_done_callback>, C<guestfs_set_close_callback> and "
3361 "C<guestfs_set_progress_callback> are no longer documented in this manual "
3362 "page. Because of the ABI guarantee, the old functions continue to work."
3366 #: ../src/guestfs.pod:1678
3368 "Handles generate events when certain things happen, such as log messages "
3369 "being generated, progress messages during long-running operations, or the "
3370 "handle being closed. The API calls described below let you register a "
3371 "callback to be called when events happen. You can register multiple "
3372 "callbacks (for the same, different or overlapping sets of events), and "
3373 "individually remove callbacks. If callbacks are not removed, then they "
3374 "remain in force until the handle is closed."
3378 #: ../src/guestfs.pod:1686
3380 "In the current implementation, events are only generated synchronously: that "
3381 "means that events (and hence callbacks) can only happen while you are in the "
3382 "middle of making another libguestfs call. The callback is called in the "
3387 #: ../src/guestfs.pod:1691
3389 "Events may contain a payload, usually nothing (void), an array of 64 bit "
3390 "unsigned integers, or a message buffer. Payloads are discussed later on."
3394 #: ../src/guestfs.pod:1695
3395 msgid "CLASSES OF EVENTS"
3399 #: ../src/guestfs.pod:1699
3400 msgid "GUESTFS_EVENT_CLOSE (payload type: void)"
3404 #: ../src/guestfs.pod:1702
3406 "The callback function will be called while the handle is being closed "
3407 "(synchronously from L</guestfs_close>)."
3411 #: ../src/guestfs.pod:1705
3413 "Note that libguestfs installs an L<atexit(3)> handler to try to clean up "
3414 "handles that are open when the program exits. This means that this callback "
3415 "might be called indirectly from L<exit(3)>, which can cause unexpected "
3416 "problems in higher-level languages (eg. if your HLL interpreter has already "
3417 "been cleaned up by the time this is called, and if your callback then jumps "
3418 "into some HLL function)."
3422 #: ../src/guestfs.pod:1712
3424 "If no callback is registered: the handle is closed without any callback "
3429 #: ../src/guestfs.pod:1715
3430 msgid "GUESTFS_EVENT_SUBPROCESS_QUIT (payload type: void)"
3434 #: ../src/guestfs.pod:1718
3436 "The callback function will be called when the child process quits, either "
3437 "asynchronously or if killed by L</guestfs_kill_subprocess>. (This "
3438 "corresponds to a transition from any state to the CONFIG state)."
3442 #: ../src/guestfs.pod:1722 ../src/guestfs.pod:1731
3443 msgid "If no callback is registered: the event is ignored."
3447 #: ../src/guestfs.pod:1724
3448 msgid "GUESTFS_EVENT_LAUNCH_DONE (payload type: void)"
3452 #: ../src/guestfs.pod:1727
3454 "The callback function will be called when the child process becomes ready "
3455 "first time after it has been launched. (This corresponds to a transition "
3456 "from LAUNCHING to the READY state)."
3460 #: ../src/guestfs.pod:1733
3461 msgid "GUESTFS_EVENT_PROGRESS (payload type: array of 4 x uint64_t)"
3465 #: ../src/guestfs.pod:1736
3467 "Some long-running operations can generate progress messages. If this "
3468 "callback is registered, then it will be called each time a progress message "
3469 "is generated (usually two seconds after the operation started, and three "
3470 "times per second thereafter until it completes, although the frequency may "
3471 "change in future versions)."
3475 #: ../src/guestfs.pod:1742
3477 "The callback receives in the payload four unsigned 64 bit numbers which are "
3478 "(in order): C<proc_nr>, C<serial>, C<position>, C<total>."
3482 #: ../src/guestfs.pod:1745
3484 "The units of C<total> are not defined, although for some operations C<total> "
3485 "may relate in some way to the amount of data to be transferred (eg. in bytes "
3486 "or megabytes), and C<position> may be the portion which has been transferred."
3490 #: ../src/guestfs.pod:1750
3491 msgid "The only defined and stable parts of the API are:"
3495 #: ../src/guestfs.pod:1756
3497 "The callback can display to the user some type of progress bar or indicator "
3498 "which shows the ratio of C<position>:C<total>."
3502 #: ../src/guestfs.pod:1761
3503 msgid "0 E<lt>= C<position> E<lt>= C<total>"
3507 #: ../src/guestfs.pod:1765
3509 "If any progress notification is sent during a call, then a final progress "
3510 "notification is always sent when C<position> = C<total> (I<unless> the call "
3511 "fails with an error)."
3515 #: ../src/guestfs.pod:1769
3517 "This is to simplify caller code, so callers can easily set the progress "
3518 "indicator to \"100%\" at the end of the operation, without requiring special "
3519 "code to detect this case."
3523 #: ../src/guestfs.pod:1775
3525 "For some calls we are unable to estimate the progress of the call, but we "
3526 "can still generate progress messages to indicate activity. This is known as "
3527 "\"pulse mode\", and is directly supported by certain progress bar "
3528 "implementations (eg. GtkProgressBar)."
3532 #: ../src/guestfs.pod:1780
3534 "For these calls, zero or more progress messages are generated with "
3535 "C<position = 0> and C<total = 1>, followed by a final message with "
3536 "C<position = total = 1>."
3540 #: ../src/guestfs.pod:1784
3542 "As noted above, if the call fails with an error then the final message may "
3547 #: ../src/guestfs.pod:1789
3549 "The callback also receives the procedure number (C<proc_nr>) and serial "
3550 "number (C<serial>) of the call. These are only useful for debugging "
3551 "protocol issues, and the callback can normally ignore them. The callback "
3552 "may want to print these numbers in error messages or debugging messages."
3556 #: ../src/guestfs.pod:1795
3557 msgid "If no callback is registered: progress messages are discarded."
3561 #: ../src/guestfs.pod:1797
3562 msgid "GUESTFS_EVENT_APPLIANCE (payload type: message buffer)"
3566 #: ../src/guestfs.pod:1800
3568 "The callback function is called whenever a log message is generated by qemu, "
3569 "the appliance kernel, guestfsd (daemon), or utility programs."
3573 #: ../src/guestfs.pod:1803
3575 "If the verbose flag (L</guestfs_set_verbose>) is set before launch (L</"
3576 "guestfs_launch>) then additional debug messages are generated."
3580 #: ../src/guestfs.pod:1806 ../src/guestfs.pod:1820
3582 "If no callback is registered: the messages are discarded unless the verbose "
3583 "flag is set in which case they are sent to stderr. You can override the "
3584 "printing of verbose messages to stderr by setting up a callback."
3588 #: ../src/guestfs.pod:1811
3589 msgid "GUESTFS_EVENT_LIBRARY (payload type: message buffer)"
3593 #: ../src/guestfs.pod:1814
3595 "The callback function is called whenever a log message is generated by the "
3596 "library part of libguestfs."
3600 #: ../src/guestfs.pod:1817
3602 "If the verbose flag (L</guestfs_set_verbose>) is set then additional debug "
3603 "messages are generated."
3607 #: ../src/guestfs.pod:1825
3608 msgid "GUESTFS_EVENT_TRACE (payload type: message buffer)"
3612 #: ../src/guestfs.pod:1828
3614 "The callback function is called whenever a trace message is generated. This "
3615 "only applies if the trace flag (L</guestfs_set_trace>) is set."
3619 #: ../src/guestfs.pod:1831
3621 "If no callback is registered: the messages are sent to stderr. You can "
3622 "override the printing of trace messages to stderr by setting up a callback."
3626 #: ../src/guestfs.pod:1837
3627 msgid "guestfs_set_event_callback"
3631 #: ../src/guestfs.pod:1839
3634 " int guestfs_set_event_callback (guestfs_h *g,\n"
3635 " guestfs_event_callback cb,\n"
3636 " uint64_t event_bitmask,\n"
3643 #: ../src/guestfs.pod:1845
3645 "This function registers a callback (C<cb>) for all event classes in the "
3650 #: ../src/guestfs.pod:1848
3652 "For example, to register for all log message events, you could call this "
3653 "function with the bitmask C<GUESTFS_EVENT_APPLIANCE|GUESTFS_EVENT_LIBRARY>. "
3654 "To register a single callback for all possible classes of events, use "
3655 "C<GUESTFS_EVENT_ALL>."
3659 #: ../src/guestfs.pod:1854
3660 msgid "C<flags> should always be passed as 0."
3664 #: ../src/guestfs.pod:1856
3666 "C<opaque> is an opaque pointer which is passed to the callback. You can use "
3667 "it for any purpose."
3671 #: ../src/guestfs.pod:1859
3673 "The return value is the event handle (an integer) which you can use to "
3674 "delete the callback (see below)."
3678 #: ../src/guestfs.pod:1862
3680 "If there is an error, this function returns C<-1>, and sets the error in the "
3681 "handle in the usual way (see L</guestfs_last_error> etc.)"
3685 #: ../src/guestfs.pod:1865
3687 "Callbacks remain in effect until they are deleted, or until the handle is "
3692 #: ../src/guestfs.pod:1868
3694 "In the case where multiple callbacks are registered for a particular event "
3695 "class, all of the callbacks are called. The order in which multiple "
3696 "callbacks are called is not defined."
3700 #: ../src/guestfs.pod:1872
3701 msgid "guestfs_delete_event_callback"
3705 #: ../src/guestfs.pod:1874
3708 " void guestfs_delete_event_callback (guestfs_h *g, int event_handle);\n"
3713 #: ../src/guestfs.pod:1876
3715 "Delete a callback that was previously registered. C<event_handle> should be "
3716 "the integer that was returned by a previous call to "
3717 "C<guestfs_set_event_callback> on the same handle."
3721 #: ../src/guestfs.pod:1880
3722 msgid "guestfs_event_callback"
3726 #: ../src/guestfs.pod:1882
3729 " typedef void (*guestfs_event_callback) (\n"
3732 " uint64_t event,\n"
3733 " int event_handle,\n"
3735 " const char *buf, size_t buf_len,\n"
3736 " const uint64_t *array, size_t array_len);\n"
3741 #: ../src/guestfs.pod:1891
3743 "This is the type of the event callback function that you have to provide."
3747 #: ../src/guestfs.pod:1894
3749 "The basic parameters are: the handle (C<g>), the opaque user pointer "
3750 "(C<opaque>), the event class (eg. C<GUESTFS_EVENT_PROGRESS>), the event "
3751 "handle, and C<flags> which in the current API you should ignore."
3755 #: ../src/guestfs.pod:1898
3757 "The remaining parameters contain the event payload (if any). Each event may "
3758 "contain a payload, which usually relates to the event class, but for future "
3759 "proofing your code should be written to handle any payload for any event "
3764 #: ../src/guestfs.pod:1903
3766 "C<buf> and C<buf_len> contain a message buffer (if C<buf_len == 0>, then "
3767 "there is no message buffer). Note that this message buffer can contain "
3768 "arbitrary 8 bit data, including NUL bytes."
3772 #: ../src/guestfs.pod:1907
3774 "C<array> and C<array_len> is an array of 64 bit unsigned integers. At the "
3775 "moment this is only used for progress messages."
3779 #: ../src/guestfs.pod:1910
3780 msgid "EXAMPLE: CAPTURING LOG MESSAGES"
3784 #: ../src/guestfs.pod:1912
3786 "One motivation for the generic event API was to allow GUI programs to "
3787 "capture debug and other messages. In libguestfs E<le> 1.8 these were sent "
3788 "unconditionally to C<stderr>."
3792 #: ../src/guestfs.pod:1916
3794 "Events associated with log messages are: C<GUESTFS_EVENT_LIBRARY>, "
3795 "C<GUESTFS_EVENT_APPLIANCE> and C<GUESTFS_EVENT_TRACE>. (Note that error "
3796 "messages are not events; you must capture error messages separately)."
3800 #: ../src/guestfs.pod:1921
3802 "Programs have to set up a callback to capture the classes of events of "
3807 #: ../src/guestfs.pod:1924
3811 " guestfs_set_event_callback\n"
3812 " (g, message_callback,\n"
3813 " GUESTFS_EVENT_LIBRARY|GUESTFS_EVENT_APPLIANCE|\n"
3814 " GUESTFS_EVENT_TRACE,\n"
3815 " 0, NULL) == -1)\n"
3816 " if (eh == -1) {\n"
3817 " // handle error in the usual way\n"
3823 #: ../src/guestfs.pod:1934
3825 "The callback can then direct messages to the appropriate place. In this "
3826 "example, messages are directed to syslog:"
3830 #: ../src/guestfs.pod:1937
3834 " message_callback (\n"
3837 " uint64_t event,\n"
3838 " int event_handle,\n"
3840 " const char *buf, size_t buf_len,\n"
3841 " const uint64_t *array, size_t array_len)\n"
3843 " const int priority = LOG_USER|LOG_INFO;\n"
3844 " if (buf_len > 0)\n"
3845 " syslog (priority, \"event 0x%lx: %s\", event, buf);\n"
3851 #: ../src/guestfs.pod:1952
3852 msgid "PRIVATE DATA AREA"
3856 #: ../src/guestfs.pod:1954
3858 "You can attach named pieces of private data to the libguestfs handle, fetch "
3859 "them by name, and walk over them, for the lifetime of the handle. This is "
3860 "called the private data area and is only available from the C API."
3864 #: ../src/guestfs.pod:1959
3865 msgid "To attach a named piece of data, use the following call:"
3869 #: ../src/guestfs.pod:1961
3872 " void guestfs_set_private (guestfs_h *g, const char *key, void *data);\n"
3877 #: ../src/guestfs.pod:1963
3879 "C<key> is the name to associate with this data, and C<data> is an arbitrary "
3880 "pointer (which can be C<NULL>). Any previous item with the same key is "
3885 #: ../src/guestfs.pod:1967
3887 "You can use any C<key> you want, but your key should I<not> start with an "
3888 "underscore character. Keys beginning with an underscore character are "
3889 "reserved for internal libguestfs purposes (eg. for implementing language "
3890 "bindings). It is recommended that you prefix the key with some unique "
3891 "string to avoid collisions with other users."
3895 #: ../src/guestfs.pod:1973
3896 msgid "To retrieve the pointer, use:"
3900 #: ../src/guestfs.pod:1975
3903 " void *guestfs_get_private (guestfs_h *g, const char *key);\n"
3908 #: ../src/guestfs.pod:1977
3910 "This function returns C<NULL> if either no data is found associated with "
3911 "C<key>, or if the user previously set the C<key>'s C<data> pointer to "
3916 #: ../src/guestfs.pod:1981
3918 "Libguestfs does not try to look at or interpret the C<data> pointer in any "
3919 "way. As far as libguestfs is concerned, it need not be a valid pointer at "
3920 "all. In particular, libguestfs does I<not> try to free the data when the "
3921 "handle is closed. If the data must be freed, then the caller must either "
3922 "free it before calling L</guestfs_close> or must set up a close callback to "
3923 "do it (see L</GUESTFS_EVENT_CLOSE>)."
3927 #: ../src/guestfs.pod:1988
3928 msgid "To walk over all entries, use these two functions:"
3932 #: ../src/guestfs.pod:1990
3935 " void *guestfs_first_private (guestfs_h *g, const char **key_rtn);\n"
3940 #: ../src/guestfs.pod:1992
3943 " void *guestfs_next_private (guestfs_h *g, const char **key_rtn);\n"
3948 #: ../src/guestfs.pod:1994
3950 "C<guestfs_first_private> returns the first key, pointer pair (\"first\" does "
3951 "not have any particular meaning -- keys are not returned in any defined "
3952 "order). A pointer to the key is returned in C<*key_rtn> and the "
3953 "corresponding data pointer is returned from the function. C<NULL> is "
3954 "returned if there are no keys stored in the handle."
3958 #: ../src/guestfs.pod:2000
3960 "C<guestfs_next_private> returns the next key, pointer pair. The return "
3961 "value of this function is also C<NULL> is there are no further entries to "
3966 #: ../src/guestfs.pod:2004
3967 msgid "Notes about walking over entries:"
3971 #: ../src/guestfs.pod:2010
3973 "You must not call C<guestfs_set_private> while walking over the entries."
3977 #: ../src/guestfs.pod:2015
3979 "The handle maintains an internal iterator which is reset when you call "
3980 "C<guestfs_first_private>. This internal iterator is invalidated when you "
3981 "call C<guestfs_set_private>."
3985 #: ../src/guestfs.pod:2021
3986 msgid "If you have set the data pointer associated with a key to C<NULL>, ie:"
3990 #: ../src/guestfs.pod:2023
3993 " guestfs_set_private (g, key, NULL);\n"
3998 #: ../src/guestfs.pod:2025
3999 msgid "then that C<key> is not returned when walking."
4003 #: ../src/guestfs.pod:2029
4005 "C<*key_rtn> is only valid until the next call to C<guestfs_first_private>, "
4006 "C<guestfs_next_private> or C<guestfs_set_private>."
4010 #: ../src/guestfs.pod:2035
4012 "The following example code shows how to print all keys and data pointers "
4013 "that are associated with the handle C<g>:"
4017 #: ../src/guestfs.pod:2038
4020 " const char *key;\n"
4021 " void *data = guestfs_first_private (g, &key);\n"
4022 " while (data != NULL)\n"
4024 " printf (\"key = %s, data = %p\\n\", key, data);\n"
4025 " data = guestfs_next_private (g, &key);\n"
4031 #: ../src/guestfs.pod:2046
4033 "More commonly you are only interested in keys that begin with an application-"
4034 "specific prefix C<foo_>. Modify the loop like so:"
4038 #: ../src/guestfs.pod:2049
4041 " const char *key;\n"
4042 " void *data = guestfs_first_private (g, &key);\n"
4043 " while (data != NULL)\n"
4045 " if (strncmp (key, \"foo_\", strlen (\"foo_\")) == 0)\n"
4046 " printf (\"key = %s, data = %p\\n\", key, data);\n"
4047 " data = guestfs_next_private (g, &key);\n"
4053 #: ../src/guestfs.pod:2058
4055 "If you need to modify keys while walking, then you have to jump back to the "
4056 "beginning of the loop. For example, to delete all keys prefixed with "
4061 #: ../src/guestfs.pod:2062
4064 " const char *key;\n"
4067 " data = guestfs_first_private (g, &key);\n"
4068 " while (data != NULL)\n"
4070 " if (strncmp (key, \"foo_\", strlen (\"foo_\")) == 0)\n"
4072 " guestfs_set_private (g, key, NULL);\n"
4073 " /* note that 'key' pointer is now invalid, and so is\n"
4074 " the internal iterator */\n"
4077 " data = guestfs_next_private (g, &key);\n"
4083 #: ../src/guestfs.pod:2078
4085 "Note that the above loop is guaranteed to terminate because the keys are "
4086 "being deleted, but other manipulations of keys within the loop might not "
4087 "terminate unless you also maintain an indication of which keys have been "
4092 #: ../src/guestfs.pod:2083 ../src/guestfs.pod:2088
4097 #: ../src/guestfs.pod:2085
4099 "<!-- old anchor for the next section --> <a name="
4100 "\"state_machine_and_low_level_event_api\"/>"
4102 "<!-- old anchor for the next section --> <a name="
4103 "\"state_machine_and_low_level_event_api\"/>"
4106 #: ../src/guestfs.pod:2090
4107 msgid "ARCHITECTURE"
4108 msgstr "АРХІТЕКТУРА"
4111 #: ../src/guestfs.pod:2092
4113 "Internally, libguestfs is implemented by running an appliance (a special "
4114 "type of small virtual machine) using L<qemu(1)>. Qemu runs as a child "
4115 "process of the main program."
4119 #: ../src/guestfs.pod:2096
4122 " ___________________\n"
4124 " | main program |\n"
4126 " | | child process / appliance\n"
4127 " | | __________________________\n"
4129 " +-------------------+ RPC | +-----------------+ |\n"
4130 " | libguestfs <--------------------> guestfsd | |\n"
4131 " | | | +-----------------+ |\n"
4132 " \\___________________/ | | Linux kernel | |\n"
4133 " | +--^--------------+ |\n"
4134 " \\_________|________________/\n"
4140 " \\______________/\n"
4145 #: ../src/guestfs.pod:2116
4147 "The library, linked to the main program, creates the child process and hence "
4148 "the appliance in the L</guestfs_launch> function."
4152 #: ../src/guestfs.pod:2119
4154 "Inside the appliance is a Linux kernel and a complete stack of userspace "
4155 "tools (such as LVM and ext2 programs) and a small controlling daemon called "
4156 "L</guestfsd>. The library talks to L</guestfsd> using remote procedure "
4157 "calls (RPC). There is a mostly one-to-one correspondence between libguestfs "
4158 "API calls and RPC calls to the daemon. Lastly the disk image(s) are "
4159 "attached to the qemu process which translates device access by the "
4160 "appliance's Linux kernel into accesses to the image."
4164 #: ../src/guestfs.pod:2128
4166 "A common misunderstanding is that the appliance \"is\" the virtual machine. "
4167 "Although the disk image you are attached to might also be used by some "
4168 "virtual machine, libguestfs doesn't know or care about this. (But you will "
4169 "care if both libguestfs's qemu process and your virtual machine are trying "
4170 "to update the disk image at the same time, since these usually results in "
4171 "massive disk corruption)."
4175 #: ../src/guestfs.pod:2135
4176 msgid "STATE MACHINE"
4177 msgstr "СКІНЧЕННИЙ АВТОМАТ"
4180 #: ../src/guestfs.pod:2137
4181 msgid "libguestfs uses a state machine to model the child process:"
4185 #: ../src/guestfs.pod:2139
4197 " / | \\ \\ guestfs_launch\n"
4198 " / | _\\__V______\n"
4200 " / | | LAUNCHING |\n"
4201 " / | \\___________/\n"
4203 " / | guestfs_launch\n"
4205 " ______ / __|____V\n"
4206 " / \\ ------> / \\\n"
4207 " | BUSY | | READY |\n"
4208 " \\______/ <------ \\________/\n"
4213 #: ../src/guestfs.pod:2161
4215 "The normal transitions are (1) CONFIG (when the handle is created, but there "
4216 "is no child process), (2) LAUNCHING (when the child process is booting up), "
4217 "(3) alternating between READY and BUSY as commands are issued to, and "
4218 "carried out by, the child process."
4222 #: ../src/guestfs.pod:2166
4224 "The guest may be killed by L</guestfs_kill_subprocess>, or may die "
4225 "asynchronously at any time (eg. due to some internal error), and that causes "
4226 "the state to transition back to CONFIG."
4230 #: ../src/guestfs.pod:2170
4232 "Configuration commands for qemu such as L</guestfs_add_drive> can only be "
4233 "issued when in the CONFIG state."
4237 #: ../src/guestfs.pod:2173
4239 "The API offers one call that goes from CONFIG through LAUNCHING to READY. "
4240 "L</guestfs_launch> blocks until the child process is READY to accept "
4241 "commands (or until some failure or timeout). L</guestfs_launch> internally "
4242 "moves the state from CONFIG to LAUNCHING while it is running."
4246 #: ../src/guestfs.pod:2179
4248 "API actions such as L</guestfs_mount> can only be issued when in the READY "
4249 "state. These API calls block waiting for the command to be carried out (ie. "
4250 "the state to transition to BUSY and then back to READY). There are no non-"
4251 "blocking versions, and no way to issue more than one command per handle at "
4256 #: ../src/guestfs.pod:2185
4258 "Finally, the child process sends asynchronous messages back to the main "
4259 "program, such as kernel log messages. You can register a callback to "
4260 "receive these messages."
4264 #: ../src/guestfs.pod:2189
4269 #: ../src/guestfs.pod:2191
4270 msgid "COMMUNICATION PROTOCOL"
4274 #: ../src/guestfs.pod:2193
4276 "Don't rely on using this protocol directly. This section documents how it "
4277 "currently works, but it may change at any time."
4281 #: ../src/guestfs.pod:2196
4283 "The protocol used to talk between the library and the daemon running inside "
4284 "the qemu virtual machine is a simple RPC mechanism built on top of XDR (RFC "
4285 "1014, RFC 1832, RFC 4506)."
4289 #: ../src/guestfs.pod:2200
4291 "The detailed format of structures is in C<src/guestfs_protocol.x> (note: "
4292 "this file is automatically generated)."
4296 #: ../src/guestfs.pod:2203
4298 "There are two broad cases, ordinary functions that don't have any C<FileIn> "
4299 "and C<FileOut> parameters, which are handled with very simple request/reply "
4300 "messages. Then there are functions that have any C<FileIn> or C<FileOut> "
4301 "parameters, which use the same request and reply messages, but they may also "
4302 "be followed by files sent using a chunked encoding."
4306 #: ../src/guestfs.pod:2210
4307 msgid "ORDINARY FUNCTIONS (NO FILEIN/FILEOUT PARAMS)"
4311 #: ../src/guestfs.pod:2212
4312 msgid "For ordinary functions, the request message is:"
4316 #: ../src/guestfs.pod:2214
4319 " total length (header + arguments,\n"
4320 " but not including the length word itself)\n"
4321 " struct guestfs_message_header (encoded as XDR)\n"
4322 " struct guestfs_<foo>_args (encoded as XDR)\n"
4327 #: ../src/guestfs.pod:2219
4329 "The total length field allows the daemon to allocate a fixed size buffer "
4330 "into which it slurps the rest of the message. As a result, the total length "
4331 "is limited to C<GUESTFS_MESSAGE_MAX> bytes (currently 4MB), which means the "
4332 "effective size of any request is limited to somewhere under this size."
4336 #: ../src/guestfs.pod:2225
4338 "Note also that many functions don't take any arguments, in which case the "
4339 "C<guestfs_I<foo>_args> is completely omitted."
4343 #: ../src/guestfs.pod:2228
4345 "The header contains the procedure number (C<guestfs_proc>) which is how the "
4346 "receiver knows what type of args structure to expect, or none at all."
4350 #: ../src/guestfs.pod:2232
4352 "For functions that take optional arguments, the optional arguments are "
4353 "encoded in the C<guestfs_I<foo>_args> structure in the same way as ordinary "
4354 "arguments. A bitmask in the header indicates which optional arguments are "
4355 "meaningful. The bitmask is also checked to see if it contains bits set "
4356 "which the daemon does not know about (eg. if more optional arguments were "
4357 "added in a later version of the library), and this causes the call to be "
4362 #: ../src/guestfs.pod:2240
4363 msgid "The reply message for ordinary functions is:"
4367 #: ../src/guestfs.pod:2242
4370 " total length (header + ret,\n"
4371 " but not including the length word itself)\n"
4372 " struct guestfs_message_header (encoded as XDR)\n"
4373 " struct guestfs_<foo>_ret (encoded as XDR)\n"
4378 #: ../src/guestfs.pod:2247
4380 "As above the C<guestfs_I<foo>_ret> structure may be completely omitted for "
4381 "functions that return no formal return values."
4385 #: ../src/guestfs.pod:2250
4387 "As above the total length of the reply is limited to C<GUESTFS_MESSAGE_MAX>."
4391 #: ../src/guestfs.pod:2253
4393 "In the case of an error, a flag is set in the header, and the reply message "
4394 "is slightly changed:"
4398 #: ../src/guestfs.pod:2256
4401 " total length (header + error,\n"
4402 " but not including the length word itself)\n"
4403 " struct guestfs_message_header (encoded as XDR)\n"
4404 " struct guestfs_message_error (encoded as XDR)\n"
4409 #: ../src/guestfs.pod:2261
4411 "The C<guestfs_message_error> structure contains the error message as a "
4416 #: ../src/guestfs.pod:2264
4417 msgid "FUNCTIONS THAT HAVE FILEIN PARAMETERS"
4421 #: ../src/guestfs.pod:2266
4423 "A C<FileIn> parameter indicates that we transfer a file I<into> the guest. "
4424 "The normal request message is sent (see above). However this is followed by "
4425 "a sequence of file chunks."
4429 #: ../src/guestfs.pod:2270
4432 " total length (header + arguments,\n"
4433 " but not including the length word itself,\n"
4434 " and not including the chunks)\n"
4435 " struct guestfs_message_header (encoded as XDR)\n"
4436 " struct guestfs_<foo>_args (encoded as XDR)\n"
4437 " sequence of chunks for FileIn param #0\n"
4438 " sequence of chunks for FileIn param #1 etc.\n"
4443 #: ../src/guestfs.pod:2278
4444 msgid "The \"sequence of chunks\" is:"
4448 #: ../src/guestfs.pod:2280
4451 " length of chunk (not including length word itself)\n"
4452 " struct guestfs_chunk (encoded as XDR)\n"
4453 " length of chunk\n"
4454 " struct guestfs_chunk (encoded as XDR)\n"
4456 " length of chunk\n"
4457 " struct guestfs_chunk (with data.data_len == 0)\n"
4462 #: ../src/guestfs.pod:2288
4464 "The final chunk has the C<data_len> field set to zero. Additionally a flag "
4465 "is set in the final chunk to indicate either successful completion or early "
4470 #: ../src/guestfs.pod:2292
4472 "At time of writing there are no functions that have more than one FileIn "
4473 "parameter. However this is (theoretically) supported, by sending the "
4474 "sequence of chunks for each FileIn parameter one after another (from left to "
4479 #: ../src/guestfs.pod:2297
4481 "Both the library (sender) I<and> the daemon (receiver) may cancel the "
4482 "transfer. The library does this by sending a chunk with a special flag set "
4483 "to indicate cancellation. When the daemon sees this, it cancels the whole "
4484 "RPC, does I<not> send any reply, and goes back to reading the next request."
4488 #: ../src/guestfs.pod:2303
4490 "The daemon may also cancel. It does this by writing a special word "
4491 "C<GUESTFS_CANCEL_FLAG> to the socket. The library listens for this during "
4492 "the transfer, and if it gets it, it will cancel the transfer (it sends a "
4493 "cancel chunk). The special word is chosen so that even if cancellation "
4494 "happens right at the end of the transfer (after the library has finished "
4495 "writing and has started listening for the reply), the \"spurious\" cancel "
4496 "flag will not be confused with the reply message."
4500 #: ../src/guestfs.pod:2312
4502 "This protocol allows the transfer of arbitrary sized files (no 32 bit "
4503 "limit), and also files where the size is not known in advance (eg. from "
4504 "pipes or sockets). However the chunks are rather small "
4505 "(C<GUESTFS_MAX_CHUNK_SIZE>), so that neither the library nor the daemon need "
4506 "to keep much in memory."
4510 #: ../src/guestfs.pod:2318
4511 msgid "FUNCTIONS THAT HAVE FILEOUT PARAMETERS"
4515 #: ../src/guestfs.pod:2320
4517 "The protocol for FileOut parameters is exactly the same as for FileIn "
4518 "parameters, but with the roles of daemon and library reversed."
4522 #: ../src/guestfs.pod:2323
4525 " total length (header + ret,\n"
4526 " but not including the length word itself,\n"
4527 " and not including the chunks)\n"
4528 " struct guestfs_message_header (encoded as XDR)\n"
4529 " struct guestfs_<foo>_ret (encoded as XDR)\n"
4530 " sequence of chunks for FileOut param #0\n"
4531 " sequence of chunks for FileOut param #1 etc.\n"
4536 #: ../src/guestfs.pod:2331
4537 msgid "INITIAL MESSAGE"
4541 #: ../src/guestfs.pod:2333
4543 "When the daemon launches it sends an initial word (C<GUESTFS_LAUNCH_FLAG>) "
4544 "which indicates that the guest and daemon is alive. This is what L</"
4545 "guestfs_launch> waits for."
4549 #: ../src/guestfs.pod:2337
4550 msgid "PROGRESS NOTIFICATION MESSAGES"
4554 #: ../src/guestfs.pod:2339
4556 "The daemon may send progress notification messages at any time. These are "
4557 "distinguished by the normal length word being replaced by "
4558 "C<GUESTFS_PROGRESS_FLAG>, followed by a fixed size progress message."
4562 #: ../src/guestfs.pod:2343
4564 "The library turns them into progress callbacks (see L</"
4565 "GUESTFS_EVENT_PROGRESS>) if there is a callback registered, or discards them "
4570 #: ../src/guestfs.pod:2347
4572 "The daemon self-limits the frequency of progress messages it sends (see "
4573 "C<daemon/proto.c:notify_progress>). Not all calls generate progress "
4578 #: ../src/guestfs.pod:2351
4579 msgid "LIBGUESTFS VERSION NUMBERS"
4583 #: ../src/guestfs.pod:2353
4585 "Since April 2010, libguestfs has started to make separate development and "
4586 "stable releases, along with corresponding branches in our git repository. "
4587 "These separate releases can be identified by version number:"
4591 #: ../src/guestfs.pod:2358
4594 " even numbers for stable: 1.2.x, 1.4.x, ...\n"
4595 " .-------- odd numbers for development: 1.3.x, 1.5.x, ...\n"
4601 " | `-------- sub-version\n"
4603 " `------ always '1' because we don't change the ABI\n"
4608 #: ../src/guestfs.pod:2369
4609 msgid "Thus \"1.3.5\" is the 5th update to the development branch \"1.3\"."
4613 #: ../src/guestfs.pod:2371
4615 "As time passes we cherry pick fixes from the development branch and backport "
4616 "those into the stable branch, the effect being that the stable branch should "
4617 "get more stable and less buggy over time. So the stable releases are ideal "
4618 "for people who don't need new features but would just like the software to "
4623 #: ../src/guestfs.pod:2377
4624 msgid "Our criteria for backporting changes are:"
4628 #: ../src/guestfs.pod:2383
4630 "Documentation changes which don't affect any code are backported unless the "
4631 "documentation refers to a future feature which is not in stable."
4635 #: ../src/guestfs.pod:2389
4637 "Bug fixes which are not controversial, fix obvious problems, and have been "
4638 "well tested are backported."
4642 #: ../src/guestfs.pod:2394
4644 "Simple rearrangements of code which shouldn't affect how it works get "
4645 "backported. This is so that the code in the two branches doesn't get too "
4646 "far out of step, allowing us to backport future fixes more easily."
4650 #: ../src/guestfs.pod:2400
4652 "We I<don't> backport new features, new APIs, new tools etc, except in one "
4653 "exceptional case: the new feature is required in order to implement an "
4654 "important bug fix."
4658 #: ../src/guestfs.pod:2406
4660 "A new stable branch starts when we think the new features in development are "
4661 "substantial and compelling enough over the current stable branch to warrant "
4662 "it. When that happens we create new stable and development versions 1.N.0 "
4663 "and 1.(N+1).0 [N is even]. The new dot-oh release won't necessarily be so "
4664 "stable at this point, but by backporting fixes from development, that branch "
4665 "will stabilize over time."
4669 #: ../src/guestfs.pod:2414
4670 msgid "EXTENDING LIBGUESTFS"
4674 #: ../src/guestfs.pod:2416
4675 msgid "ADDING A NEW API ACTION"
4679 #: ../src/guestfs.pod:2418
4681 "Large amounts of boilerplate code in libguestfs (RPC, bindings, "
4682 "documentation) are generated, and this makes it easy to extend the "
4687 #: ../src/guestfs.pod:2422
4688 msgid "To add a new API action there are two changes:"
4692 #: ../src/guestfs.pod:2428
4694 "You need to add a description of the call (name, parameters, return type, "
4695 "tests, documentation) to C<generator/generator_actions.ml>."
4699 #: ../src/guestfs.pod:2431
4701 "There are two sorts of API action, depending on whether the call goes "
4702 "through to the daemon in the appliance, or is serviced entirely by the "
4703 "library (see L</ARCHITECTURE> above). L</guestfs_sync> is an example of the "
4704 "former, since the sync is done in the appliance. L</guestfs_set_trace> is "
4705 "an example of the latter, since a trace flag is maintained in the handle and "
4706 "all tracing is done on the library side."
4710 #: ../src/guestfs.pod:2439
4712 "Most new actions are of the first type, and get added to the "
4713 "C<daemon_functions> list. Each function has a unique procedure number used "
4714 "in the RPC protocol which is assigned to that action when we publish "
4715 "libguestfs and cannot be reused. Take the latest procedure number and "
4720 #: ../src/guestfs.pod:2445
4722 "For library-only actions of the second type, add to the "
4723 "C<non_daemon_functions> list. Since these functions are serviced by the "
4724 "library and do not travel over the RPC mechanism to the daemon, these "
4725 "functions do not need a procedure number, and so the procedure number is set "
4730 #: ../src/guestfs.pod:2453
4731 msgid "Implement the action (in C):"
4735 #: ../src/guestfs.pod:2455
4737 "For daemon actions, implement the function C<do_E<lt>nameE<gt>> in the "
4738 "C<daemon/> directory."
4742 #: ../src/guestfs.pod:2458
4744 "For library actions, implement the function C<guestfs__E<lt>nameE<gt>> "
4745 "(note: double underscore) in the C<src/> directory."
4749 #: ../src/guestfs.pod:2461
4750 msgid "In either case, use another function as an example of what to do."
4754 #: ../src/guestfs.pod:2465
4755 msgid "After making these changes, use C<make> to compile."
4759 #: ../src/guestfs.pod:2467
4761 "Note that you don't need to implement the RPC, language bindings, manual "
4762 "pages or anything else. It's all automatically generated from the OCaml "
4767 #: ../src/guestfs.pod:2471
4768 msgid "ADDING TESTS FOR AN API ACTION"
4772 #: ../src/guestfs.pod:2473
4774 "You can supply zero or as many tests as you want per API call. The tests "
4775 "can either be added as part of the API description (C<generator/"
4776 "generator_actions.ml>), or in some rarer cases you may want to drop a script "
4777 "into C<regressions/>. Note that adding a script to C<regressions/> is "
4778 "slower, so if possible use the first method."
4782 #: ../src/guestfs.pod:2479
4784 "The following describes the test environment used when you add an API test "
4785 "in C<generator_actions.ml>."
4789 #: ../src/guestfs.pod:2482
4790 msgid "The test environment has 4 block devices:"
4794 #: ../src/guestfs.pod:2486
4795 msgid "C</dev/sda> 500MB"
4799 #: ../src/guestfs.pod:2488
4800 msgid "General block device for testing."
4804 #: ../src/guestfs.pod:2490
4805 msgid "C</dev/sdb> 50MB"
4809 #: ../src/guestfs.pod:2492
4811 "C</dev/sdb1> is an ext2 filesystem used for testing filesystem write "
4816 #: ../src/guestfs.pod:2495
4817 msgid "C</dev/sdc> 10MB"
4821 #: ../src/guestfs.pod:2497
4822 msgid "Used in a few tests where two block devices are needed."
4826 #: ../src/guestfs.pod:2499
4828 msgstr "C</dev/sdd>"
4831 #: ../src/guestfs.pod:2501
4832 msgid "ISO with fixed content (see C<images/test.iso>)."
4836 #: ../src/guestfs.pod:2505
4838 "To be able to run the tests in a reasonable amount of time, the libguestfs "
4839 "appliance and block devices are reused between tests. So don't try testing "
4840 "L</guestfs_kill_subprocess> :-x"
4844 #: ../src/guestfs.pod:2509
4846 "Each test starts with an initial scenario, selected using one of the "
4847 "C<Init*> expressions, described in C<generator/generator_types.ml>. These "
4848 "initialize the disks mentioned above in a particular way as documented in "
4849 "C<generator_types.ml>. You should not assume anything about the previous "
4850 "contents of other disks that are not initialized."
4854 #: ../src/guestfs.pod:2515
4856 "You can add a prerequisite clause to any individual test. This is a run-"
4857 "time check, which, if it fails, causes the test to be skipped. Useful if "
4858 "testing a command which might not work on all variations of libguestfs "
4859 "builds. A test that has prerequisite of C<Always> means to run "
4864 #: ../src/guestfs.pod:2521
4866 "In addition, packagers can skip individual tests by setting environment "
4867 "variables before running C<make check>."
4871 #: ../src/guestfs.pod:2524
4874 " SKIP_TEST_<CMD>_<NUM>=1\n"
4879 #: ../src/guestfs.pod:2526
4880 msgid "eg: C<SKIP_TEST_COMMAND_3=1> skips test #3 of L</guestfs_command>."
4884 #: ../src/guestfs.pod:2528