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-09 15:21+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:1606
872 #: ../src/guestfs-actions.pod:1610 ../src/guestfs-actions.pod:1614
873 #: ../src/guestfs-actions.pod:1618 ../src/guestfs-actions.pod:1626
874 #: ../src/guestfs-actions.pod:1630 ../src/guestfs-actions.pod:1634
875 #: ../src/guestfs-actions.pod:1644 ../src/guestfs-actions.pod:1648
876 #: ../src/guestfs-actions.pod:1652 ../src/guestfs-actions.pod:1790
877 #: ../src/guestfs-actions.pod:1794 ../src/guestfs-actions.pod:1799
878 #: ../src/guestfs-actions.pod:1804 ../src/guestfs-actions.pod:1865
879 #: ../src/guestfs-actions.pod:1869 ../src/guestfs-actions.pod:1874
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:1077 ../fish/guestfish-actions.pod:1081
886 #: ../fish/guestfish-actions.pod:1085 ../fish/guestfish-actions.pod:1089
887 #: ../fish/guestfish-actions.pod:1097 ../fish/guestfish-actions.pod:1101
888 #: ../fish/guestfish-actions.pod:1105 ../fish/guestfish-actions.pod:1115
889 #: ../fish/guestfish-actions.pod:1119 ../fish/guestfish-actions.pod:1123
890 #: ../fish/guestfish-actions.pod:1213 ../fish/guestfish-actions.pod:1217
891 #: ../fish/guestfish-actions.pod:1222 ../fish/guestfish-actions.pod:1227
892 #: ../fish/guestfish-actions.pod:1269 ../fish/guestfish-actions.pod:1273
893 #: ../fish/guestfish-actions.pod:1278 ../tools/virt-win-reg.pl:536
894 #: ../tools/virt-win-reg.pl:542 ../tools/virt-win-reg.pl:548
899 #: ../src/guestfs.pod:390
901 "The kernel version that the command runs under will be different from what "
906 #: ../src/guestfs.pod:395
908 "If the command needs to communicate with daemons, then most likely they "
913 #: ../src/guestfs.pod:400
914 msgid "The command will be running in limited memory."
918 #: ../src/guestfs.pod:404
920 "The network may not be available unless you enable it (see L</"
921 "guestfs_set_network>)."
925 #: ../src/guestfs.pod:409
926 msgid "Only supports Linux guests (not Windows, BSD, etc)."
930 #: ../src/guestfs.pod:413
932 "Architecture limitations (eg. won't work for a PPC guest on an X86 host)."
936 #: ../src/guestfs.pod:418
938 "For SELinux guests, you may need to enable SELinux and load policy first. "
939 "See L</SELINUX> in this manpage."
943 #: ../src/guestfs.pod:423
945 "I<Security:> It is not safe to run commands from untrusted, possibly "
946 "malicious guests. These commands may attempt to exploit your program by "
947 "sending unexpected output. They could also try to exploit the Linux kernel "
948 "or qemu provided by the libguestfs appliance. They could use the network "
949 "provided by the libguestfs appliance to bypass ordinary network partitions "
950 "and firewalls. They could use the elevated privileges or different SELinux "
951 "context of your program to their advantage."
955 #: ../src/guestfs.pod:432
957 "A secure alternative is to use libguestfs to install a \"firstboot\" script "
958 "(a script which runs when the guest next boots normally), and to have this "
959 "script run the commands you want in the normal context of the running guest, "
960 "network security and so on. For information about other security issues, "
965 #: ../src/guestfs.pod:440
967 "The two main API calls to run commands are L</guestfs_command> and L</"
968 "guestfs_sh> (there are also variations)."
972 #: ../src/guestfs.pod:443
974 "The difference is that L</guestfs_sh> runs commands using the shell, so any "
975 "shell globs, redirections, etc will work."
979 #: ../src/guestfs.pod:446
980 msgid "CONFIGURATION FILES"
981 msgstr "ФАЙЛИ НАЛАШТУВАННЯ"
984 #: ../src/guestfs.pod:448
986 "To read and write configuration files in Linux guest filesystems, we "
987 "strongly recommend using Augeas. For example, Augeas understands how to "
988 "read and write, say, a Linux shadow password file or X.org configuration "
989 "file, and so avoids you having to write that code."
993 #: ../src/guestfs.pod:453
995 "The main Augeas calls are bound through the C<guestfs_aug_*> APIs. We don't "
996 "document Augeas itself here because there is excellent documentation on the "
997 "L<http://augeas.net/> website."
1001 #: ../src/guestfs.pod:457
1003 "If you don't want to use Augeas (you fool!) then try calling L</"
1004 "guestfs_read_lines> to get the file as a list of lines which you can iterate "
1009 #: ../src/guestfs.pod:461
1014 #: ../src/guestfs.pod:463
1016 "We support SELinux guests. To ensure that labeling happens correctly in "
1017 "SELinux guests, you need to enable SELinux and load the guest's policy:"
1021 #: ../src/guestfs.pod:469 ../src/guestfs.pod:1257 ../src/guestfs.pod:1395
1022 #: ../src/guestfs.pod:2426
1027 #: ../src/guestfs.pod:471
1028 msgid "Before launching, do:"
1032 #: ../src/guestfs.pod:473
1035 " guestfs_set_selinux (g, 1);\n"
1040 #: ../src/guestfs.pod:475 ../src/guestfs.pod:1261 ../src/guestfs.pod:1399
1041 #: ../src/guestfs.pod:2451
1046 #: ../src/guestfs.pod:477
1048 "After mounting the guest's filesystem(s), load the policy. This is best "
1049 "done by running the L<load_policy(8)> command in the guest itself:"
1053 #: ../src/guestfs.pod:481
1056 " guestfs_sh (g, \"/usr/sbin/load_policy\");\n"
1061 #: ../src/guestfs.pod:483
1063 "(Older versions of C<load_policy> require you to specify the name of the "
1068 #: ../src/guestfs.pod:486 ../src/guestfs.pod:1405
1073 #: ../src/guestfs.pod:488
1075 "Optionally, set the security context for the API. The correct security "
1076 "context to use can only be known by inspecting the guest. As an example:"
1080 #: ../src/guestfs.pod:492
1083 " guestfs_setcon (g, \"unconfined_u:unconfined_r:unconfined_t:s0\");\n"
1088 #: ../src/guestfs.pod:496
1089 msgid "This will work for running commands and editing existing files."
1093 #: ../src/guestfs.pod:498
1095 "When new files are created, you may need to label them explicitly, for "
1096 "example by running the external command C<restorecon pathname>."
1100 #: ../src/guestfs.pod:502
1105 #: ../src/guestfs.pod:504
1107 "Certain calls are affected by the current file mode creation mask (the "
1108 "\"umask\"). In particular ones which create files or directories, such as "
1109 "L</guestfs_touch>, L</guestfs_mknod> or L</guestfs_mkdir>. This affects "
1110 "either the default mode that the file is created with or modifies the mode "
1115 #: ../src/guestfs.pod:510
1117 "The default umask is C<022>, so files are created with modes such as C<0644> "
1118 "and directories with C<0755>."
1122 #: ../src/guestfs.pod:513
1124 "There are two ways to avoid being affected by umask. Either set umask to 0 "
1125 "(call C<guestfs_umask (g, 0)> early after launching). Or call L</"
1126 "guestfs_chmod> after creating each file or directory."
1130 #: ../src/guestfs.pod:517
1131 msgid "For more information about umask, see L<umask(2)>."
1135 #: ../src/guestfs.pod:519 ../fish/guestfish.pod:767
1136 msgid "ENCRYPTED DISKS"
1140 #: ../src/guestfs.pod:521
1142 "Libguestfs allows you to access Linux guests which have been encrypted using "
1143 "whole disk encryption that conforms to the Linux Unified Key Setup (LUKS) "
1144 "standard. This includes nearly all whole disk encryption systems used by "
1145 "modern Linux guests."
1149 #: ../src/guestfs.pod:527
1151 "Use L</guestfs_vfs_type> to identify LUKS-encrypted block devices (it "
1152 "returns the string C<crypto_LUKS>)."
1156 #: ../src/guestfs.pod:530
1158 "Then open these devices by calling L</guestfs_luks_open>. Obviously you "
1159 "will require the passphrase!"
1163 #: ../src/guestfs.pod:533
1165 "Opening a LUKS device creates a new device mapper device called C</dev/"
1166 "mapper/mapname> (where C<mapname> is the string you supply to L</"
1167 "guestfs_luks_open>). Reads and writes to this mapper device are decrypted "
1168 "from and encrypted to the underlying block device respectively."
1172 #: ../src/guestfs.pod:539
1174 "LVM volume groups on the device can be made visible by calling L</"
1175 "guestfs_vgscan> followed by L</guestfs_vg_activate_all>. The logical volume"
1176 "(s) can now be mounted in the usual way."
1180 #: ../src/guestfs.pod:543
1182 "Use the reverse process to close a LUKS device. Unmount any logical volumes "
1183 "on it, deactivate the volume groups by caling C<guestfs_vg_activate (g, 0, "
1184 "[\"/dev/VG\"])>. Then close the mapper device by calling L</"
1185 "guestfs_luks_close> on the C</dev/mapper/mapname> device (I<not> the "
1186 "underlying encrypted block device)."
1190 #: ../src/guestfs.pod:550
1195 #: ../src/guestfs.pod:552
1197 "Libguestfs has APIs for inspecting an unknown disk image to find out if it "
1198 "contains operating systems, an install CD or a live CD. (These APIs used to "
1199 "be in a separate Perl-only library called L<Sys::Guestfs::Lib(3)> but since "
1200 "version 1.5.3 the most frequently used part of this library has been "
1201 "rewritten in C and moved into the core code)."
1205 #: ../src/guestfs.pod:559
1207 "Add all disks belonging to the unknown virtual machine and call L</"
1208 "guestfs_launch> in the usual way."
1212 #: ../src/guestfs.pod:562
1214 "Then call L</guestfs_inspect_os>. This function uses other libguestfs calls "
1215 "and certain heuristics, and returns a list of operating systems that were "
1216 "found. An empty list means none were found. A single element is the root "
1217 "filesystem of the operating system. For dual- or multi-boot guests, "
1218 "multiple roots can be returned, each one corresponding to a separate "
1219 "operating system. (Multi-boot virtual machines are extremely rare in the "
1220 "world of virtualization, but since this scenario can happen, we have built "
1221 "libguestfs to deal with it.)"
1225 #: ../src/guestfs.pod:571
1227 "For each root, you can then call various C<guestfs_inspect_get_*> functions "
1228 "to get additional details about that operating system. For example, call L</"
1229 "guestfs_inspect_get_type> to return the string C<windows> or C<linux> for "
1230 "Windows and Linux-based operating systems respectively."
1234 #: ../src/guestfs.pod:577
1236 "Un*x-like and Linux-based operating systems usually consist of several "
1237 "filesystems which are mounted at boot time (for example, a separate boot "
1238 "partition mounted on C</boot>). The inspection rules are able to detect how "
1239 "filesystems correspond to mount points. Call "
1240 "C<guestfs_inspect_get_mountpoints> to get this mapping. It might return a "
1241 "hash table like this example:"
1245 #: ../src/guestfs.pod:584
1248 " /boot => /dev/sda1\n"
1249 " / => /dev/vg_guest/lv_root\n"
1250 " /usr => /dev/vg_guest/lv_usr\n"
1255 #: ../src/guestfs.pod:588
1257 "The caller can then make calls to L</guestfs_mount_options> to mount the "
1258 "filesystems as suggested."
1262 #: ../src/guestfs.pod:591
1264 "Be careful to mount filesystems in the right order (eg. C</> before C</"
1265 "usr>). Sorting the keys of the hash by length, shortest first, should work."
1269 #: ../src/guestfs.pod:595
1271 "Inspection currently only works for some common operating systems. "
1272 "Contributors are welcome to send patches for other operating systems that we "
1273 "currently cannot detect."
1277 #: ../src/guestfs.pod:599
1279 "Encrypted disks must be opened before inspection. See L</ENCRYPTED DISKS> "
1280 "for more details. The L</guestfs_inspect_os> function just ignores any "
1281 "encrypted devices."
1285 #: ../src/guestfs.pod:603
1287 "A note on the implementation: The call L</guestfs_inspect_os> performs "
1288 "inspection and caches the results in the guest handle. Subsequent calls to "
1289 "C<guestfs_inspect_get_*> return this cached information, but I<do not> re-"
1290 "read the disks. If you change the content of the guest disks, you can redo "
1291 "inspection by calling L</guestfs_inspect_os> again. (L</"
1292 "guestfs_inspect_list_applications> works a little differently from the other "
1293 "calls and does read the disks. See documentation for that function for "
1298 #: ../src/guestfs.pod:612
1299 msgid "INSPECTING INSTALL DISKS"
1303 #: ../src/guestfs.pod:614
1305 "Libguestfs (since 1.9.4) can detect some install disks, install CDs, live "
1310 #: ../src/guestfs.pod:617
1312 "Call L</guestfs_inspect_get_format> to return the format of the operating "
1313 "system, which currently can be C<installed> (a regular operating system) or "
1314 "C<installer> (some sort of install disk)."
1318 #: ../src/guestfs.pod:621
1320 "Further information is available about the operating system that can be "
1321 "installed using the regular inspection APIs like L</"
1322 "guestfs_inspect_get_product_name>, L</guestfs_inspect_get_major_version> etc."
1326 #: ../src/guestfs.pod:626
1328 "Some additional information specific to installer disks is also available "
1329 "from the L</guestfs_inspect_is_live>, L</guestfs_inspect_is_netinst> and L</"
1330 "guestfs_inspect_is_multipart> calls."
1334 #: ../src/guestfs.pod:631
1335 msgid "SPECIAL CONSIDERATIONS FOR WINDOWS GUESTS"
1339 #: ../src/guestfs.pod:633
1341 "Libguestfs can mount NTFS partitions. It does this using the L<http://www."
1342 "ntfs-3g.org/> driver."
1346 #: ../src/guestfs.pod:636
1347 msgid "DRIVE LETTERS AND PATHS"
1351 #: ../src/guestfs.pod:638
1353 "DOS and Windows still use drive letters, and the filesystems are always "
1354 "treated as case insensitive by Windows itself, and therefore you might find "
1355 "a Windows configuration file referring to a path like C<c:\\windows"
1356 "\\system32>. When the filesystem is mounted in libguestfs, that directory "
1357 "might be referred to as C</WINDOWS/System32>."
1361 #: ../src/guestfs.pod:644
1363 "Drive letter mappings can be found using inspection (see L</INSPECTION> and "
1364 "L</guestfs_inspect_get_drive_mappings>)"
1368 #: ../src/guestfs.pod:647
1370 "Dealing with separator characters (backslash vs forward slash) is outside "
1371 "the scope of libguestfs, but usually a simple character replacement will "
1376 #: ../src/guestfs.pod:651
1378 "To resolve the case insensitivity of paths, call L</"
1379 "guestfs_case_sensitive_path>."
1383 #: ../src/guestfs.pod:654
1384 msgid "ACCESSING THE WINDOWS REGISTRY"
1388 #: ../src/guestfs.pod:656
1390 "Libguestfs also provides some help for decoding Windows Registry \"hive\" "
1391 "files, through the library C<hivex> which is part of the libguestfs project "
1392 "although ships as a separate tarball. You have to locate and download the "
1393 "hive file(s) yourself, and then pass them to C<hivex> functions. See also "
1394 "the programs L<hivexml(1)>, L<hivexsh(1)>, L<hivexregedit(1)> and L<virt-win-"
1395 "reg(1)> for more help on this issue."
1399 #: ../src/guestfs.pod:664
1400 msgid "SYMLINKS ON NTFS-3G FILESYSTEMS"
1404 #: ../src/guestfs.pod:666
1406 "Ntfs-3g tries to rewrite \"Junction Points\" and NTFS \"symbolic links\" to "
1407 "provide something which looks like a Linux symlink. The way it tries to do "
1408 "the rewriting is described here:"
1412 #: ../src/guestfs.pod:670
1414 "L<http://www.tuxera.com/community/ntfs-3g-advanced/junction-points-and-"
1417 "L<http://www.tuxera.com/community/ntfs-3g-advanced/junction-points-and-"
1421 #: ../src/guestfs.pod:672
1423 "The essential problem is that ntfs-3g simply does not have enough "
1424 "information to do a correct job. NTFS links can contain drive letters and "
1425 "references to external device GUIDs that ntfs-3g has no way of resolving. "
1426 "It is almost certainly the case that libguestfs callers should ignore what "
1427 "ntfs-3g does (ie. don't use L</guestfs_readlink> on NTFS volumes)."
1431 #: ../src/guestfs.pod:679
1433 "Instead if you encounter a symbolic link on an ntfs-3g filesystem, use L</"
1434 "guestfs_lgetxattr> to read the C<system.ntfs_reparse_data> extended "
1435 "attribute, and read the raw reparse data from that (you can find the format "
1436 "documented in various places around the web)."
1440 #: ../src/guestfs.pod:684
1441 msgid "EXTENDED ATTRIBUTES ON NTFS-3G FILESYSTEMS"
1445 #: ../src/guestfs.pod:686
1447 "There are other useful extended attributes that can be read from ntfs-3g "
1448 "filesystems (using L</guestfs_getxattr>). See:"
1452 #: ../src/guestfs.pod:689
1454 "L<http://www.tuxera.com/community/ntfs-3g-advanced/extended-attributes/>"
1456 "L<http://www.tuxera.com/community/ntfs-3g-advanced/extended-attributes/>"
1459 #: ../src/guestfs.pod:691
1460 msgid "USING LIBGUESTFS WITH OTHER PROGRAMMING LANGUAGES"
1464 #: ../src/guestfs.pod:693
1466 "Although we don't want to discourage you from using the C API, we will "
1467 "mention here that the same API is also available in other languages."
1471 #: ../src/guestfs.pod:696
1473 "The API is broadly identical in all supported languages. This means that "
1474 "the C call C<guestfs_add_drive_ro(g,file)> is C<$g-E<gt>add_drive_ro($file)> "
1475 "in Perl, C<g.add_drive_ro(file)> in Python, and C<g#add_drive_ro file> in "
1476 "OCaml. In other words, a straightforward, predictable isomorphism between "
1481 #: ../src/guestfs.pod:702
1483 "Error messages are automatically transformed into exceptions if the language "
1488 #: ../src/guestfs.pod:705
1490 "We don't try to \"object orientify\" parts of the API in OO languages, "
1491 "although contributors are welcome to write higher level APIs above what we "
1492 "provide in their favourite languages if they wish."
1496 #: ../src/guestfs.pod:711
1501 #: ../src/guestfs.pod:713
1503 "You can use the I<guestfs.h> header file from C++ programs. The C++ API is "
1504 "identical to the C API. C++ classes and exceptions are not used."
1508 #: ../src/guestfs.pod:717
1513 #: ../src/guestfs.pod:719
1515 "The C# bindings are highly experimental. Please read the warnings at the "
1516 "top of C<csharp/Libguestfs.cs>."
1520 #: ../src/guestfs.pod:722
1525 #: ../src/guestfs.pod:724
1527 "This is the only language binding that is working but incomplete. Only "
1528 "calls which return simple integers have been bound in Haskell, and we are "
1529 "looking for help to complete this binding."
1533 #: ../src/guestfs.pod:728
1538 #: ../src/guestfs.pod:730
1540 "Full documentation is contained in the Javadoc which is distributed with "
1545 #: ../src/guestfs.pod:733
1550 #: ../src/guestfs.pod:735
1551 msgid "See L<guestfs-ocaml(3)>."
1552 msgstr "Див. L<guestfs-ocaml(3)>."
1555 #: ../src/guestfs.pod:737
1560 #: ../src/guestfs.pod:739
1561 msgid "See L<guestfs-perl(3)> and L<Sys::Guestfs(3)>."
1562 msgstr "Див. L<guestfs-perl(3)> та L<Sys::Guestfs(3)>."
1565 #: ../src/guestfs.pod:741
1570 #: ../src/guestfs.pod:743
1572 "For documentation see C<README-PHP> supplied with libguestfs sources or in "
1573 "the php-libguestfs package for your distribution."
1577 #: ../src/guestfs.pod:746
1578 msgid "The PHP binding only works correctly on 64 bit machines."
1582 #: ../src/guestfs.pod:748
1587 #: ../src/guestfs.pod:750
1588 msgid "See L<guestfs-python(3)>."
1589 msgstr "Див. L<guestfs-python(3)>."
1592 #: ../src/guestfs.pod:752
1597 #: ../src/guestfs.pod:754
1598 msgid "See L<guestfs-ruby(3)>."
1599 msgstr "Див. L<guestfs-ruby(3)>."
1602 #: ../src/guestfs.pod:756
1603 msgid "B<shell scripts>"
1604 msgstr "B<скрипти оболонки>"
1607 #: ../src/guestfs.pod:758
1608 msgid "See L<guestfish(1)>."
1609 msgstr "Див. L<guestfish(1)>."
1612 #: ../src/guestfs.pod:762
1613 msgid "LIBGUESTFS GOTCHAS"
1617 #: ../src/guestfs.pod:764
1619 "L<http://en.wikipedia.org/wiki/Gotcha_(programming)>: \"A feature of a "
1620 "system [...] that works in the way it is documented but is counterintuitive "
1621 "and almost invites mistakes.\""
1625 #: ../src/guestfs.pod:768
1627 "Since we developed libguestfs and the associated tools, there are several "
1628 "things we would have designed differently, but are now stuck with for "
1629 "backwards compatibility or other reasons. If there is ever a libguestfs 2.0 "
1630 "release, you can expect these to change. Beware of them."
1634 #: ../src/guestfs.pod:776
1635 msgid "Autosync / forgetting to sync."
1639 #: ../src/guestfs.pod:778
1641 "I<Update:> Autosync is enabled by default for all API users starting from "
1642 "libguestfs 1.5.24. This section only applies to older versions."
1646 #: ../src/guestfs.pod:781
1648 "When modifying a filesystem from C or another language, you B<must> unmount "
1649 "all filesystems and call L</guestfs_sync> explicitly before you close the "
1650 "libguestfs handle. You can also call:"
1654 #: ../src/guestfs.pod:785
1657 " guestfs_set_autosync (g, 1);\n"
1662 #: ../src/guestfs.pod:787
1664 "to have the unmount/sync done automatically for you when the handle 'g' is "
1665 "closed. (This feature is called \"autosync\", L</guestfs_set_autosync> q.v.)"
1669 #: ../src/guestfs.pod:791
1671 "If you forget to do this, then it is entirely possible that your changes "
1672 "won't be written out, or will be partially written, or (very rarely) that "
1673 "you'll get disk corruption."
1677 #: ../src/guestfs.pod:795
1679 "Note that in L<guestfish(3)> autosync is the default. So quick and dirty "
1680 "guestfish scripts that forget to sync will work just fine, which can make "
1681 "this very puzzling if you are trying to debug a problem."
1685 #: ../src/guestfs.pod:799
1686 msgid "Mount option C<-o sync> should not be the default."
1690 #: ../src/guestfs.pod:801
1692 "If you use L</guestfs_mount>, then C<-o sync,noatime> are added implicitly. "
1693 "However C<-o sync> does not add any reliability benefit, but does have a "
1694 "very large performance impact."
1698 #: ../src/guestfs.pod:805
1700 "The work around is to use L</guestfs_mount_options> and set the mount "
1701 "options that you actually want to use."
1705 #: ../src/guestfs.pod:808
1706 msgid "Read-only should be the default."
1710 #: ../src/guestfs.pod:810
1712 "In L<guestfish(3)>, I<--ro> should be the default, and you should have to "
1713 "specify I<--rw> if you want to make changes to the image."
1717 #: ../src/guestfs.pod:813
1718 msgid "This would reduce the potential to corrupt live VM images."
1722 #: ../src/guestfs.pod:815
1724 "Note that many filesystems change the disk when you just mount and unmount, "
1725 "even if you didn't perform any writes. You need to use L</"
1726 "guestfs_add_drive_ro> to guarantee that the disk is not changed."
1730 #: ../src/guestfs.pod:819
1731 msgid "guestfish command line is hard to use."
1735 #: ../src/guestfs.pod:821
1737 "C<guestfish disk.img> doesn't do what people expect (open C<disk.img> for "
1738 "examination). It tries to run a guestfish command C<disk.img> which doesn't "
1739 "exist, so it fails. In earlier versions of guestfish the error message was "
1740 "also unintuitive, but we have corrected this since. Like the Bourne shell, "
1741 "we should have used C<guestfish -c command> to run commands."
1745 #: ../src/guestfs.pod:828
1746 msgid "guestfish megabyte modifiers don't work right on all commands"
1750 #: ../src/guestfs.pod:830
1752 "In recent guestfish you can use C<1M> to mean 1 megabyte (and similarly for "
1753 "other modifiers). What guestfish actually does is to multiply the number "
1754 "part by the modifier part and pass the result to the C API. However this "
1755 "doesn't work for a few APIs which aren't expecting bytes, but are already "
1756 "expecting some other unit (eg. megabytes)."
1760 #: ../src/guestfs.pod:837
1761 msgid "The most common is L</guestfs_lvcreate>. The guestfish command:"
1765 #: ../src/guestfs.pod:839
1768 " lvcreate LV VG 100M\n"
1773 #: ../src/guestfs.pod:841
1775 "does not do what you might expect. Instead because L</guestfs_lvcreate> is "
1776 "already expecting megabytes, this tries to create a 100 I<terabyte> (100 "
1777 "megabytes * megabytes) logical volume. The error message you get from this "
1778 "is also a little obscure."
1782 #: ../src/guestfs.pod:846
1784 "This could be fixed in the generator by specially marking parameters and "
1785 "return values which take bytes or other units."
1789 #: ../src/guestfs.pod:849
1790 msgid "Ambiguity between devices and paths"
1794 #: ../src/guestfs.pod:851
1796 "There is a subtle ambiguity in the API between a device name (eg. C</dev/"
1797 "sdb2>) and a similar pathname. A file might just happen to be called "
1798 "C<sdb2> in the directory C</dev> (consider some non-Unix VM image)."
1802 #: ../src/guestfs.pod:856
1804 "In the current API we usually resolve this ambiguity by having two separate "
1805 "calls, for example L</guestfs_checksum> and L</guestfs_checksum_device>. "
1806 "Some API calls are ambiguous and (incorrectly) resolve the problem by "
1807 "detecting if the path supplied begins with C</dev/>."
1811 #: ../src/guestfs.pod:862
1813 "To avoid both the ambiguity and the need to duplicate some calls, we could "
1814 "make paths/devices into structured names. One way to do this would be to "
1815 "use a notation like grub (C<hd(0,0)>), although nobody really likes this "
1816 "aspect of grub. Another way would be to use a structured type, equivalent "
1817 "to this OCaml type:"
1821 #: ../src/guestfs.pod:868
1824 " type path = Path of string | Device of int | Partition of int * int\n"
1829 #: ../src/guestfs.pod:870
1830 msgid "which would allow you to pass arguments like:"
1834 #: ../src/guestfs.pod:872
1837 " Path \"/foo/bar\"\n"
1838 " Device 1 (* /dev/sdb, or perhaps /dev/sda *)\n"
1839 " Partition (1, 2) (* /dev/sdb2 (or is it /dev/sda2 or /dev/sdb3?) *)\n"
1840 " Path \"/dev/sdb2\" (* not a device *)\n"
1845 #: ../src/guestfs.pod:877
1847 "As you can see there are still problems to resolve even with this "
1848 "representation. Also consider how it might work in guestfish."
1852 #: ../src/guestfs.pod:882
1853 msgid "KEYS AND PASSPHRASES"
1857 #: ../src/guestfs.pod:884
1859 "Certain libguestfs calls take a parameter that contains sensitive key "
1860 "material, passed in as a C string."
1864 #: ../src/guestfs.pod:887
1866 "In the future we would hope to change the libguestfs implementation so that "
1867 "keys are L<mlock(2)>-ed into physical RAM, and thus can never end up in "
1868 "swap. However this is I<not> done at the moment, because of the complexity "
1869 "of such an implementation."
1873 #: ../src/guestfs.pod:892
1875 "Therefore you should be aware that any key parameter you pass to libguestfs "
1876 "might end up being written out to the swap partition. If this is a concern, "
1877 "scrub the swap partition or don't use libguestfs on encrypted devices."
1881 #: ../src/guestfs.pod:897
1882 msgid "MULTIPLE HANDLES AND MULTIPLE THREADS"
1886 #: ../src/guestfs.pod:899
1888 "All high-level libguestfs actions are synchronous. If you want to use "
1889 "libguestfs asynchronously then you must create a thread."
1893 #: ../src/guestfs.pod:902
1895 "Only use the handle from a single thread. Either use the handle exclusively "
1896 "from one thread, or provide your own mutex so that two threads cannot issue "
1897 "calls on the same handle at the same time."
1901 #: ../src/guestfs.pod:906
1903 "See the graphical program guestfs-browser for one possible architecture for "
1904 "multithreaded programs using libvirt and libguestfs."
1908 #: ../src/guestfs.pod:909
1913 #: ../src/guestfs.pod:911
1915 "Libguestfs needs a supermin appliance, which it finds by looking along an "
1920 #: ../src/guestfs.pod:914
1922 "By default it looks for these in the directory C<$libdir/guestfs> (eg. C</"
1923 "usr/local/lib/guestfs> or C</usr/lib64/guestfs>)."
1927 #: ../src/guestfs.pod:917
1929 "Use L</guestfs_set_path> or set the environment variable L</LIBGUESTFS_PATH> "
1930 "to change the directories that libguestfs will search in. The value is a "
1931 "colon-separated list of paths. The current directory is I<not> searched "
1932 "unless the path contains an empty element or C<.>. For example "
1933 "C<LIBGUESTFS_PATH=:/usr/lib/guestfs> would search the current directory and "
1934 "then C</usr/lib/guestfs>."
1938 #: ../src/guestfs.pod:924
1939 msgid "QEMU WRAPPERS"
1943 #: ../src/guestfs.pod:926
1945 "If you want to compile your own qemu, run qemu from a non-standard location, "
1946 "or pass extra arguments to qemu, then you can write a shell-script wrapper "
1951 #: ../src/guestfs.pod:930
1953 "There is one important rule to remember: you I<must C<exec qemu>> as the "
1954 "last command in the shell script (so that qemu replaces the shell and "
1955 "becomes the direct child of the libguestfs-using program). If you don't do "
1956 "this, then the qemu process won't be cleaned up correctly."
1960 #: ../src/guestfs.pod:935
1962 "Here is an example of a wrapper, where I have built my own copy of qemu from "
1967 #: ../src/guestfs.pod:938
1971 " qemudir=/home/rjones/d/qemu\n"
1972 " exec $qemudir/x86_64-softmmu/qemu-system-x86_64 -L $qemudir/pc-bios \"$@\"\n"
1977 #: ../src/guestfs.pod:942
1979 "Save this script as C</tmp/qemu.wrapper> (or wherever), C<chmod +x>, and "
1980 "then use it by setting the LIBGUESTFS_QEMU environment variable. For "
1985 #: ../src/guestfs.pod:946
1988 " LIBGUESTFS_QEMU=/tmp/qemu.wrapper guestfish\n"
1993 #: ../src/guestfs.pod:948
1995 "Note that libguestfs also calls qemu with the -help and -version options in "
1996 "order to determine features."
2000 #: ../src/guestfs.pod:951
2001 msgid "ATTACHING TO RUNNING DAEMONS"
2005 #: ../src/guestfs.pod:953
2007 "I<Note (1):> This is B<highly experimental> and has a tendency to eat "
2008 "babies. Use with caution."
2012 #: ../src/guestfs.pod:956
2014 "I<Note (2):> This section explains how to attach to a running daemon from a "
2015 "low level perspective. For most users, simply using virt tools such as "
2016 "L<guestfish(1)> with the I<--live> option will \"just work\"."
2020 #: ../src/guestfs.pod:960
2021 msgid "Using guestfs_set_attach_method"
2025 #: ../src/guestfs.pod:962
2027 "By calling L</guestfs_set_attach_method> you can change how the library "
2028 "connects to the C<guestfsd> daemon in L</guestfs_launch> (read L</"
2029 "ARCHITECTURE> for some background)."
2033 #: ../src/guestfs.pod:966
2035 "The normal attach method is C<appliance>, where a small appliance is created "
2036 "containing the daemon, and then the library connects to this."
2040 #: ../src/guestfs.pod:969
2042 "Setting attach method to C<unix:I<path>> (where I<path> is the path of a "
2043 "Unix domain socket) causes L</guestfs_launch> to connect to an existing "
2044 "daemon over the Unix domain socket."
2048 #: ../src/guestfs.pod:973
2050 "The normal use for this is to connect to a running virtual machine that "
2051 "contains a C<guestfsd> daemon, and send commands so you can read and write "
2052 "files inside the live virtual machine."
2056 #: ../src/guestfs.pod:977
2057 msgid "Using guestfs_add_domain with live flag"
2061 #: ../src/guestfs.pod:979
2063 "L</guestfs_add_domain> provides some help for getting the correct attach "
2064 "method. If you pass the C<live> option to this function, then (if the "
2065 "virtual machine is running) it will examine the libvirt XML looking for a "
2066 "virtio-serial channel to connect to:"
2070 #: ../src/guestfs.pod:985
2077 " <channel type='unix'>\n"
2078 " <source mode='bind' path='/path/to/socket'/>\n"
2079 " <target type='virtio' name='org.libguestfs.channel.0'/>\n"
2088 #: ../src/guestfs.pod:997
2090 "L</guestfs_add_domain> extracts C</path/to/socket> and sets the attach "
2091 "method to C<unix:/path/to/socket>."
2095 #: ../src/guestfs.pod:1000
2097 "Some of the libguestfs tools (including guestfish) support a I<--live> "
2098 "option which is passed through to L</guestfs_add_domain> thus allowing you "
2099 "to attach to and modify live virtual machines."
2103 #: ../src/guestfs.pod:1004
2105 "The virtual machine needs to have been set up beforehand so that it has the "
2106 "virtio-serial channel and so that guestfsd is running inside it."
2110 #: ../src/guestfs.pod:1008
2111 msgid "ABI GUARANTEE"
2115 #: ../src/guestfs.pod:1010
2117 "We guarantee the libguestfs ABI (binary interface), for public, high-level "
2118 "actions as outlined in this section. Although we will deprecate some "
2119 "actions, for example if they get replaced by newer calls, we will keep the "
2120 "old actions forever. This allows you the developer to program in confidence "
2121 "against the libguestfs API."
2125 #: ../src/guestfs.pod:1016
2126 msgid "BLOCK DEVICE NAMING"
2130 #: ../src/guestfs.pod:1018
2132 "In the kernel there is now quite a profusion of schemata for naming block "
2133 "devices (in this context, by I<block device> I mean a physical or virtual "
2134 "hard drive). The original Linux IDE driver used names starting with C</dev/"
2135 "hd*>. SCSI devices have historically used a different naming scheme, C</dev/"
2136 "sd*>. When the Linux kernel I<libata> driver became a popular replacement "
2137 "for the old IDE driver (particularly for SATA devices) those devices also "
2138 "used the C</dev/sd*> scheme. Additionally we now have virtual machines with "
2139 "paravirtualized drivers. This has created several different naming systems, "
2140 "such as C</dev/vd*> for virtio disks and C</dev/xvd*> for Xen PV disks."
2144 #: ../src/guestfs.pod:1030
2146 "As discussed above, libguestfs uses a qemu appliance running an embedded "
2147 "Linux kernel to access block devices. We can run a variety of appliances "
2148 "based on a variety of Linux kernels."
2152 #: ../src/guestfs.pod:1034
2154 "This causes a problem for libguestfs because many API calls use device or "
2155 "partition names. Working scripts and the recipe (example) scripts that we "
2156 "make available over the internet could fail if the naming scheme changes."
2160 #: ../src/guestfs.pod:1039
2162 "Therefore libguestfs defines C</dev/sd*> as the I<standard naming scheme>. "
2163 "Internally C</dev/sd*> names are translated, if necessary, to other names as "
2164 "required. For example, under RHEL 5 which uses the C</dev/hd*> scheme, any "
2165 "device parameter C</dev/sda2> is translated to C</dev/hda2> transparently."
2169 #: ../src/guestfs.pod:1045
2171 "Note that this I<only> applies to parameters. The L</guestfs_list_devices>, "
2172 "L</guestfs_list_partitions> and similar calls return the true names of the "
2173 "devices and partitions as known to the appliance."
2177 #: ../src/guestfs.pod:1050
2178 msgid "ALGORITHM FOR BLOCK DEVICE NAME TRANSLATION"
2182 #: ../src/guestfs.pod:1052
2184 "Usually this translation is transparent. However in some (very rare) cases "
2185 "you may need to know the exact algorithm. Such cases include where you use "
2186 "L</guestfs_config> to add a mixture of virtio and IDE devices to the qemu-"
2187 "based appliance, so have a mixture of C</dev/sd*> and C</dev/vd*> devices."
2191 #: ../src/guestfs.pod:1058
2193 "The algorithm is applied only to I<parameters> which are known to be either "
2194 "device or partition names. Return values from functions such as L</"
2195 "guestfs_list_devices> are never changed."
2199 #: ../src/guestfs.pod:1066
2200 msgid "Is the string a parameter which is a device or partition name?"
2204 #: ../src/guestfs.pod:1070
2205 msgid "Does the string begin with C</dev/sd>?"
2209 #: ../src/guestfs.pod:1074
2211 "Does the named device exist? If so, we use that device. However if I<not> "
2212 "then we continue with this algorithm."
2216 #: ../src/guestfs.pod:1079
2217 msgid "Replace initial C</dev/sd> string with C</dev/hd>."
2221 #: ../src/guestfs.pod:1081
2222 msgid "For example, change C</dev/sda2> to C</dev/hda2>."
2226 #: ../src/guestfs.pod:1083
2227 msgid "If that named device exists, use it. If not, continue."
2231 #: ../src/guestfs.pod:1087
2232 msgid "Replace initial C</dev/sd> string with C</dev/vd>."
2236 #: ../src/guestfs.pod:1089
2237 msgid "If that named device exists, use it. If not, return an error."
2241 #: ../src/guestfs.pod:1093
2242 msgid "PORTABILITY CONCERNS WITH BLOCK DEVICE NAMING"
2246 #: ../src/guestfs.pod:1095
2248 "Although the standard naming scheme and automatic translation is useful for "
2249 "simple programs and guestfish scripts, for larger programs it is best not to "
2250 "rely on this mechanism."
2254 #: ../src/guestfs.pod:1099
2256 "Where possible for maximum future portability programs using libguestfs "
2257 "should use these future-proof techniques:"
2261 #: ../src/guestfs.pod:1106
2263 "Use L</guestfs_list_devices> or L</guestfs_list_partitions> to list actual "
2264 "device names, and then use those names directly."
2268 #: ../src/guestfs.pod:1109
2270 "Since those device names exist by definition, they will never be translated."
2274 #: ../src/guestfs.pod:1114
2276 "Use higher level ways to identify filesystems, such as LVM names, UUIDs and "
2277 "filesystem labels."
2281 #: ../src/guestfs.pod:1119
2286 #: ../src/guestfs.pod:1121
2288 "This section discusses security implications of using libguestfs, "
2289 "particularly with untrusted or malicious guests or disk images."
2293 #: ../src/guestfs.pod:1124
2294 msgid "GENERAL SECURITY CONSIDERATIONS"
2298 #: ../src/guestfs.pod:1126
2300 "Be careful with any files or data that you download from a guest (by "
2301 "\"download\" we mean not just the L</guestfs_download> command but any "
2302 "command that reads files, filenames, directories or anything else from a "
2303 "disk image). An attacker could manipulate the data to fool your program "
2304 "into doing the wrong thing. Consider cases such as:"
2308 #: ../src/guestfs.pod:1136
2309 msgid "the data (file etc) not being present"
2313 #: ../src/guestfs.pod:1140
2314 msgid "being present but empty"
2318 #: ../src/guestfs.pod:1144
2319 msgid "being much larger than normal"
2323 #: ../src/guestfs.pod:1148
2324 msgid "containing arbitrary 8 bit data"
2328 #: ../src/guestfs.pod:1152
2329 msgid "being in an unexpected character encoding"
2333 #: ../src/guestfs.pod:1156
2334 msgid "containing homoglyphs."
2338 #: ../src/guestfs.pod:1160
2339 msgid "SECURITY OF MOUNTING FILESYSTEMS"
2343 #: ../src/guestfs.pod:1162
2345 "When you mount a filesystem under Linux, mistakes in the kernel filesystem "
2346 "(VFS) module can sometimes be escalated into exploits by deliberately "
2347 "creating a malicious, malformed filesystem. These exploits are very severe "
2348 "for two reasons. Firstly there are very many filesystem drivers in the "
2349 "kernel, and many of them are infrequently used and not much developer "
2350 "attention has been paid to the code. Linux userspace helps potential "
2351 "crackers by detecting the filesystem type and automatically choosing the "
2352 "right VFS driver, even if that filesystem type is obscure or unexpected for "
2353 "the administrator. Secondly, a kernel-level exploit is like a local root "
2354 "exploit (worse in some ways), giving immediate and total access to the "
2355 "system right down to the hardware level."
2359 #: ../src/guestfs.pod:1175
2361 "That explains why you should never mount a filesystem from an untrusted "
2362 "guest on your host kernel. How about libguestfs? We run a Linux kernel "
2363 "inside a qemu virtual machine, usually running as a non-root user. The "
2364 "attacker would need to write a filesystem which first exploited the kernel, "
2365 "and then exploited either qemu virtualization (eg. a faulty qemu driver) or "
2366 "the libguestfs protocol, and finally to be as serious as the host kernel "
2367 "exploit it would need to escalate its privileges to root. This multi-step "
2368 "escalation, performed by a static piece of data, is thought to be extremely "
2369 "hard to do, although we never say 'never' about security issues."
2373 #: ../src/guestfs.pod:1186
2375 "In any case callers can reduce the attack surface by forcing the filesystem "
2376 "type when mounting (use L</guestfs_mount_vfs>)."
2380 #: ../src/guestfs.pod:1189
2381 msgid "PROTOCOL SECURITY"
2385 #: ../src/guestfs.pod:1191
2387 "The protocol is designed to be secure, being based on RFC 4506 (XDR) with a "
2388 "defined upper message size. However a program that uses libguestfs must "
2389 "also take care - for example you can write a program that downloads a binary "
2390 "from a disk image and executes it locally, and no amount of protocol "
2391 "security will save you from the consequences."
2395 #: ../src/guestfs.pod:1197
2396 msgid "INSPECTION SECURITY"
2400 #: ../src/guestfs.pod:1199
2402 "Parts of the inspection API (see L</INSPECTION>) return untrusted strings "
2403 "directly from the guest, and these could contain any 8 bit data. Callers "
2404 "should be careful to escape these before printing them to a structured file "
2405 "(for example, use HTML escaping if creating a web page)."
2409 #: ../src/guestfs.pod:1205
2411 "Guest configuration may be altered in unusual ways by the administrator of "
2412 "the virtual machine, and may not reflect reality (particularly for untrusted "
2413 "or actively malicious guests). For example we parse the hostname from "
2414 "configuration files like C</etc/sysconfig/network> that we find in the "
2415 "guest, but the guest administrator can easily manipulate these files to "
2416 "provide the wrong hostname."
2420 #: ../src/guestfs.pod:1213
2422 "The inspection API parses guest configuration using two external libraries: "
2423 "Augeas (Linux configuration) and hivex (Windows Registry). Both are "
2424 "designed to be robust in the face of malicious data, although denial of "
2425 "service attacks are still possible, for example with oversized configuration "
2430 #: ../src/guestfs.pod:1219
2431 msgid "RUNNING UNTRUSTED GUEST COMMANDS"
2435 #: ../src/guestfs.pod:1221
2437 "Be very cautious about running commands from the guest. By running a "
2438 "command in the guest, you are giving CPU time to a binary that you do not "
2439 "control, under the same user account as the library, albeit wrapped in qemu "
2440 "virtualization. More information and alternatives can be found in the "
2441 "section L</RUNNING COMMANDS>."
2445 #: ../src/guestfs.pod:1227
2446 msgid "CVE-2010-3851"
2447 msgstr "CVE-2010-3851"
2450 #: ../src/guestfs.pod:1229
2451 msgid "https://bugzilla.redhat.com/642934"
2452 msgstr "https://bugzilla.redhat.com/642934"
2455 #: ../src/guestfs.pod:1231
2457 "This security bug concerns the automatic disk format detection that qemu "
2458 "does on disk images."
2462 #: ../src/guestfs.pod:1234
2464 "A raw disk image is just the raw bytes, there is no header. Other disk "
2465 "images like qcow2 contain a special header. Qemu deals with this by looking "
2466 "for one of the known headers, and if none is found then assuming the disk "
2467 "image must be raw."
2471 #: ../src/guestfs.pod:1239
2473 "This allows a guest which has been given a raw disk image to write some "
2474 "other header. At next boot (or when the disk image is accessed by "
2475 "libguestfs) qemu would do autodetection and think the disk image format was, "
2476 "say, qcow2 based on the header written by the guest."
2480 #: ../src/guestfs.pod:1244
2482 "This in itself would not be a problem, but qcow2 offers many features, one "
2483 "of which is to allow a disk image to refer to another image (called the "
2484 "\"backing disk\"). It does this by placing the path to the backing disk "
2485 "into the qcow2 header. This path is not validated and could point to any "
2486 "host file (eg. \"/etc/passwd\"). The backing disk is then exposed through "
2487 "\"holes\" in the qcow2 disk image, which of course is completely under the "
2488 "control of the attacker."
2492 #: ../src/guestfs.pod:1252
2494 "In libguestfs this is rather hard to exploit except under two circumstances:"
2498 #: ../src/guestfs.pod:1259
2499 msgid "You have enabled the network or have opened the disk in write mode."
2503 #: ../src/guestfs.pod:1263
2505 "You are also running untrusted code from the guest (see L</RUNNING "
2510 #: ../src/guestfs.pod:1268
2512 "The way to avoid this is to specify the expected disk format when adding "
2513 "disks (the optional C<format> option to L</guestfs_add_drive_opts>). You "
2514 "should always do this if the disk is raw format, and it's a good idea for "
2519 #: ../src/guestfs.pod:1273
2521 "For disks added from libvirt using calls like L</guestfs_add_domain>, the "
2522 "format is fetched from libvirt and passed through."
2526 #: ../src/guestfs.pod:1276
2528 "For libguestfs tools, use the I<--format> command line parameter as "
2533 #: ../src/guestfs.pod:1279
2534 msgid "CONNECTION MANAGEMENT"
2538 #: ../src/guestfs.pod:1281
2543 #: ../src/guestfs.pod:1283
2545 "C<guestfs_h> is the opaque type representing a connection handle. Create a "
2546 "handle by calling L</guestfs_create>. Call L</guestfs_close> to free the "
2547 "handle and release all resources used."
2551 #: ../src/guestfs.pod:1287
2553 "For information on using multiple handles and threads, see the section L</"
2554 "MULTIPLE HANDLES AND MULTIPLE THREADS> above."
2558 #: ../src/guestfs.pod:1290
2559 msgid "guestfs_create"
2563 #: ../src/guestfs.pod:1292
2566 " guestfs_h *guestfs_create (void);\n"
2571 #: ../src/guestfs.pod:1294
2572 msgid "Create a connection handle."
2576 #: ../src/guestfs.pod:1296
2578 "On success this returns a non-NULL pointer to a handle. On error it returns "
2583 #: ../src/guestfs.pod:1299
2585 "You have to \"configure\" the handle after creating it. This includes "
2586 "calling L</guestfs_add_drive_opts> (or one of the equivalent calls) on the "
2587 "handle at least once."
2591 #: ../src/guestfs.pod:1303
2592 msgid "After configuring the handle, you have to call L</guestfs_launch>."
2596 #: ../src/guestfs.pod:1305
2598 "You may also want to configure error handling for the handle. See the L</"
2599 "ERROR HANDLING> section below."
2603 #: ../src/guestfs.pod:1308
2604 msgid "guestfs_close"
2608 #: ../src/guestfs.pod:1310
2611 " void guestfs_close (guestfs_h *g);\n"
2616 #: ../src/guestfs.pod:1312
2617 msgid "This closes the connection handle and frees up all resources used."
2621 #: ../src/guestfs.pod:1314
2623 "If autosync was set on the handle and the handle was launched, then this "
2624 "implicitly calls various functions to unmount filesystems and sync the "
2625 "disk. See L</guestfs_set_autosync> for more details."
2629 #: ../src/guestfs.pod:1318
2630 msgid "If a close callback was set on the handle, then it is called."
2634 #: ../src/guestfs.pod:1320
2635 msgid "ERROR HANDLING"
2636 msgstr "ОБРОБКА ПОМИЛОК"
2639 #: ../src/guestfs.pod:1322
2641 "API functions can return errors. For example, almost all functions that "
2642 "return C<int> will return C<-1> to indicate an error."
2646 #: ../src/guestfs.pod:1325
2648 "Additional information is available for errors: an error message string and "
2649 "optionally an error number (errno) if the thing that failed was a system "
2654 #: ../src/guestfs.pod:1329
2656 "You can get at the additional information about the last error on the handle "
2657 "by calling L</guestfs_last_error>, L</guestfs_last_errno>, and/or by setting "
2658 "up an error handler with L</guestfs_set_error_handler>."
2662 #: ../src/guestfs.pod:1334
2664 "When the handle is created, a default error handler is installed which "
2665 "prints the error message string to C<stderr>. For small short-running "
2666 "command line programs it is sufficient to do:"
2670 #: ../src/guestfs.pod:1338
2673 " if (guestfs_launch (g) == -1)\n"
2674 " exit (EXIT_FAILURE);\n"
2679 #: ../src/guestfs.pod:1341
2681 "since the default error handler will ensure that an error message has been "
2682 "printed to C<stderr> before the program exits."
2686 #: ../src/guestfs.pod:1344
2688 "For other programs the caller will almost certainly want to install an "
2689 "alternate error handler or do error handling in-line like this:"
2693 #: ../src/guestfs.pod:1347
2696 " g = guestfs_create ();\n"
2701 #: ../src/guestfs.pod:1349
2704 " /* This disables the default behaviour of printing errors\n"
2706 " guestfs_set_error_handler (g, NULL, NULL);\n"
2711 #: ../src/guestfs.pod:1353
2714 " if (guestfs_launch (g) == -1) {\n"
2715 " /* Examine the error message and print it etc. */\n"
2716 " char *msg = guestfs_last_error (g);\n"
2717 " int errnum = guestfs_last_errno (g);\n"
2718 " fprintf (stderr, \"%s\\n\", msg);\n"
2725 #: ../src/guestfs.pod:1361
2727 "Out of memory errors are handled differently. The default action is to call "
2728 "L<abort(3)>. If this is undesirable, then you can set a handler using L</"
2729 "guestfs_set_out_of_memory_handler>."
2733 #: ../src/guestfs.pod:1365
2735 "L</guestfs_create> returns C<NULL> if the handle cannot be created, and "
2736 "because there is no handle if this happens there is no way to get additional "
2737 "error information. However L</guestfs_create> is supposed to be a "
2738 "lightweight operation which can only fail because of insufficient memory (it "
2739 "returns NULL in this case)."
2743 #: ../src/guestfs.pod:1371
2744 msgid "guestfs_last_error"
2748 #: ../src/guestfs.pod:1373
2751 " const char *guestfs_last_error (guestfs_h *g);\n"
2756 #: ../src/guestfs.pod:1375
2758 "This returns the last error message that happened on C<g>. If there has not "
2759 "been an error since the handle was created, then this returns C<NULL>."
2763 #: ../src/guestfs.pod:1379
2765 "The lifetime of the returned string is until the next error occurs, or L</"
2766 "guestfs_close> is called."
2770 #: ../src/guestfs.pod:1382
2771 msgid "guestfs_last_errno"
2775 #: ../src/guestfs.pod:1384
2778 " int guestfs_last_errno (guestfs_h *g);\n"
2783 #: ../src/guestfs.pod:1386
2784 msgid "This returns the last error number (errno) that happened on C<g>."
2788 #: ../src/guestfs.pod:1388
2789 msgid "If successful, an errno integer not equal to zero is returned."
2793 #: ../src/guestfs.pod:1390
2795 "If no error, this returns 0. This call can return 0 in three situations:"
2799 #: ../src/guestfs.pod:1397
2800 msgid "There has not been any error on the handle."
2804 #: ../src/guestfs.pod:1401
2806 "There has been an error but the errno was meaningless. This corresponds to "
2807 "the case where the error did not come from a failed system call, but for "
2808 "some other reason."
2812 #: ../src/guestfs.pod:1407
2814 "There was an error from a failed system call, but for some reason the errno "
2815 "was not captured and returned. This usually indicates a bug in libguestfs."
2819 #: ../src/guestfs.pod:1413
2821 "Libguestfs tries to convert the errno from inside the applicance into a "
2822 "corresponding errno for the caller (not entirely trivial: the appliance "
2823 "might be running a completely different operating system from the library "
2824 "and error numbers are not standardized across Un*xen). If this could not be "
2825 "done, then the error is translated to C<EINVAL>. In practice this should "
2826 "only happen in very rare circumstances."
2830 #: ../src/guestfs.pod:1421
2831 msgid "guestfs_set_error_handler"
2835 #: ../src/guestfs.pod:1423
2838 " typedef void (*guestfs_error_handler_cb) (guestfs_h *g,\n"
2840 " const char *msg);\n"
2841 " void guestfs_set_error_handler (guestfs_h *g,\n"
2842 " guestfs_error_handler_cb cb,\n"
2848 #: ../src/guestfs.pod:1430
2850 "The callback C<cb> will be called if there is an error. The parameters "
2851 "passed to the callback are an opaque data pointer and the error message "
2856 #: ../src/guestfs.pod:1434
2858 "C<errno> is not passed to the callback. To get that the callback must call "
2859 "L</guestfs_last_errno>."
2863 #: ../src/guestfs.pod:1437
2865 "Note that the message string C<msg> is freed as soon as the callback "
2866 "function returns, so if you want to stash it somewhere you must make your "
2871 #: ../src/guestfs.pod:1441
2872 msgid "The default handler prints messages on C<stderr>."
2876 #: ../src/guestfs.pod:1443
2877 msgid "If you set C<cb> to C<NULL> then I<no> handler is called."
2881 #: ../src/guestfs.pod:1445
2882 msgid "guestfs_get_error_handler"
2886 #: ../src/guestfs.pod:1447
2889 " guestfs_error_handler_cb guestfs_get_error_handler (guestfs_h *g,\n"
2890 " void **opaque_rtn);\n"
2895 #: ../src/guestfs.pod:1450
2896 msgid "Returns the current error handler callback."
2900 #: ../src/guestfs.pod:1452
2901 msgid "guestfs_set_out_of_memory_handler"
2905 #: ../src/guestfs.pod:1454
2908 " typedef void (*guestfs_abort_cb) (void);\n"
2909 " int guestfs_set_out_of_memory_handler (guestfs_h *g,\n"
2910 " guestfs_abort_cb);\n"
2915 #: ../src/guestfs.pod:1458
2917 "The callback C<cb> will be called if there is an out of memory situation. "
2918 "I<Note this callback must not return>."
2922 #: ../src/guestfs.pod:1461
2923 msgid "The default is to call L<abort(3)>."
2927 #: ../src/guestfs.pod:1463
2929 "You cannot set C<cb> to C<NULL>. You can't ignore out of memory situations."
2933 #: ../src/guestfs.pod:1466
2934 msgid "guestfs_get_out_of_memory_handler"
2938 #: ../src/guestfs.pod:1468
2941 " guestfs_abort_fn guestfs_get_out_of_memory_handler (guestfs_h *g);\n"
2946 #: ../src/guestfs.pod:1470
2947 msgid "This returns the current out of memory handler."
2951 #: ../src/guestfs.pod:1472
2956 #: ../src/guestfs.pod:1474 ../fish/guestfish.pod:1010
2961 #: ../src/guestfs.pod:1476
2966 #: ../src/guestfs.pod:1478
2971 #: ../src/guestfs.pod:1480
2972 msgid "AVAILABILITY"
2976 #: ../src/guestfs.pod:1482
2977 msgid "GROUPS OF FUNCTIONALITY IN THE APPLIANCE"
2981 #: ../src/guestfs.pod:1484
2983 "Using L</guestfs_available> you can test availability of the following "
2984 "groups of functions. This test queries the appliance to see if the "
2985 "appliance you are currently using supports the functionality."
2989 #: ../src/guestfs.pod:1489
2990 msgid "@AVAILABILITY@"
2994 #: ../src/guestfs.pod:1491
2995 msgid "GUESTFISH supported COMMAND"
2999 #: ../src/guestfs.pod:1493
3001 "In L<guestfish(3)> there is a handy interactive command C<supported> which "
3002 "prints out the available groups and whether they are supported by this build "
3003 "of libguestfs. Note however that you have to do C<run> first."
3007 #: ../src/guestfs.pod:1498
3008 msgid "SINGLE CALLS AT COMPILE TIME"
3012 #: ../src/guestfs.pod:1500
3014 "Since version 1.5.8, C<E<lt>guestfs.hE<gt>> defines symbols for each C API "
3015 "function, such as:"
3019 #: ../src/guestfs.pod:1503
3022 " #define LIBGUESTFS_HAVE_DD 1\n"
3027 #: ../src/guestfs.pod:1505
3028 msgid "if L</guestfs_dd> is available."
3032 #: ../src/guestfs.pod:1507
3034 "Before version 1.5.8, if you needed to test whether a single libguestfs "
3035 "function is available at compile time, we recommended using build tools such "
3036 "as autoconf or cmake. For example in autotools you could use:"
3040 #: ../src/guestfs.pod:1512
3043 " AC_CHECK_LIB([guestfs],[guestfs_create])\n"
3044 " AC_CHECK_FUNCS([guestfs_dd])\n"
3049 #: ../src/guestfs.pod:1515
3051 "which would result in C<HAVE_GUESTFS_DD> being either defined or not defined "
3056 #: ../src/guestfs.pod:1518
3057 msgid "SINGLE CALLS AT RUN TIME"
3061 #: ../src/guestfs.pod:1520
3063 "Testing at compile time doesn't guarantee that a function really exists in "
3064 "the library. The reason is that you might be dynamically linked against a "
3065 "previous I<libguestfs.so> (dynamic library) which doesn't have the call. "
3066 "This situation unfortunately results in a segmentation fault, which is a "
3067 "shortcoming of the C dynamic linking system itself."
3071 #: ../src/guestfs.pod:1527
3073 "You can use L<dlopen(3)> to test if a function is available at run time, as "
3074 "in this example program (note that you still need the compile time check as "
3079 #: ../src/guestfs.pod:1531
3082 " #include <stdio.h>\n"
3083 " #include <stdlib.h>\n"
3084 " #include <unistd.h>\n"
3085 " #include <dlfcn.h>\n"
3086 " #include <guestfs.h>\n"
3091 #: ../src/guestfs.pod:1537
3096 " #ifdef LIBGUESTFS_HAVE_DD\n"
3098 " int has_function;\n"
3103 #: ../src/guestfs.pod:1543
3106 " /* Test if the function guestfs_dd is really available. */\n"
3107 " dl = dlopen (NULL, RTLD_LAZY);\n"
3109 " fprintf (stderr, \"dlopen: %s\\n\", dlerror ());\n"
3110 " exit (EXIT_FAILURE);\n"
3112 " has_function = dlsym (dl, \"guestfs_dd\") != NULL;\n"
3118 #: ../src/guestfs.pod:1552
3121 " if (!has_function)\n"
3122 " printf (\"this libguestfs.so does NOT have guestfs_dd function\\n\");\n"
3124 " printf (\"this libguestfs.so has guestfs_dd function\\n\");\n"
3125 " /* Now it's safe to call\n"
3126 " guestfs_dd (g, \"foo\", \"bar\");\n"
3130 " printf (\"guestfs_dd function was not found at compile time\\n\");\n"
3137 #: ../src/guestfs.pod:1565
3139 "You may think the above is an awful lot of hassle, and it is. There are "
3140 "other ways outside of the C linking system to ensure that this kind of "
3141 "incompatibility never arises, such as using package versioning:"
3145 #: ../src/guestfs.pod:1570
3148 " Requires: libguestfs >= 1.0.80\n"
3153 #: ../src/guestfs.pod:1572
3154 msgid "CALLS WITH OPTIONAL ARGUMENTS"
3158 #: ../src/guestfs.pod:1574
3160 "A recent feature of the API is the introduction of calls which take optional "
3161 "arguments. In C these are declared 3 ways. The main way is as a call which "
3162 "takes variable arguments (ie. C<...>), as in this example:"
3166 #: ../src/guestfs.pod:1579
3169 " int guestfs_add_drive_opts (guestfs_h *g, const char *filename, ...);\n"
3174 #: ../src/guestfs.pod:1581
3176 "Call this with a list of optional arguments, terminated by C<-1>. So to "
3177 "call with no optional arguments specified:"
3181 #: ../src/guestfs.pod:1584
3184 " guestfs_add_drive_opts (g, filename, -1);\n"
3189 #: ../src/guestfs.pod:1586
3190 msgid "With a single optional argument:"
3194 #: ../src/guestfs.pod:1588
3197 " guestfs_add_drive_opts (g, filename,\n"
3198 " GUESTFS_ADD_DRIVE_OPTS_FORMAT, \"qcow2\",\n"
3204 #: ../src/guestfs.pod:1592
3209 #: ../src/guestfs.pod:1594
3212 " guestfs_add_drive_opts (g, filename,\n"
3213 " GUESTFS_ADD_DRIVE_OPTS_FORMAT, \"qcow2\",\n"
3214 " GUESTFS_ADD_DRIVE_OPTS_READONLY, 1,\n"
3220 #: ../src/guestfs.pod:1599
3222 "and so forth. Don't forget the terminating C<-1> otherwise Bad Things will "
3227 #: ../src/guestfs.pod:1602
3228 msgid "USING va_list FOR OPTIONAL ARGUMENTS"
3232 #: ../src/guestfs.pod:1604
3234 "The second variant has the same name with the suffix C<_va>, which works the "
3235 "same way but takes a C<va_list>. See the C manual for details. For the "
3236 "example function, this is declared:"
3240 #: ../src/guestfs.pod:1608
3243 " int guestfs_add_drive_opts_va (guestfs_h *g, const char *filename,\n"
3249 #: ../src/guestfs.pod:1611
3250 msgid "CONSTRUCTING OPTIONAL ARGUMENTS"
3254 #: ../src/guestfs.pod:1613
3256 "The third variant is useful where you need to construct these calls. You "
3257 "pass in a structure where you fill in the optional fields. The structure "
3258 "has a bitmask as the first element which you must set to indicate which "
3259 "fields you have filled in. For our example function the structure and call "
3264 #: ../src/guestfs.pod:1619
3267 " struct guestfs_add_drive_opts_argv {\n"
3268 " uint64_t bitmask;\n"
3270 " const char *format;\n"
3273 " int guestfs_add_drive_opts_argv (guestfs_h *g, const char *filename,\n"
3274 " const struct guestfs_add_drive_opts_argv *optargs);\n"
3279 #: ../src/guestfs.pod:1628
3280 msgid "You could call it like this:"
3284 #: ../src/guestfs.pod:1630
3287 " struct guestfs_add_drive_opts_argv optargs = {\n"
3288 " .bitmask = GUESTFS_ADD_DRIVE_OPTS_READONLY_BITMASK |\n"
3289 " GUESTFS_ADD_DRIVE_OPTS_FORMAT_BITMASK,\n"
3291 " .format = \"qcow2\"\n"
3297 #: ../src/guestfs.pod:1637
3300 " guestfs_add_drive_opts_argv (g, filename, &optargs);\n"
3305 #: ../src/guestfs.pod:1639 ../src/guestfs-actions.pod:11
3306 #: ../src/guestfs-actions.pod:1861 ../fish/guestfish-actions.pod:9
3307 #: ../fish/guestfish-actions.pod:1265 ../tools/virt-win-reg.pl:532
3312 #: ../src/guestfs.pod:1645
3313 msgid "The C<_BITMASK> suffix on each option name when specifying the bitmask."
3317 #: ../src/guestfs.pod:1650
3318 msgid "You do not need to fill in all fields of the structure."
3322 #: ../src/guestfs.pod:1654
3324 "There must be a one-to-one correspondence between fields of the structure "
3325 "that are filled in, and bits set in the bitmask."
3329 #: ../src/guestfs.pod:1659
3330 msgid "OPTIONAL ARGUMENTS IN OTHER LANGUAGES"
3334 #: ../src/guestfs.pod:1661
3336 "In other languages, optional arguments are expressed in the way that is "
3337 "natural for that language. We refer you to the language-specific "
3338 "documentation for more details on that."
3342 #: ../src/guestfs.pod:1665
3343 msgid "For guestfish, see L<guestfish(1)/OPTIONAL ARGUMENTS>."
3347 #: ../src/guestfs.pod:1667
3348 msgid "SETTING CALLBACKS TO HANDLE EVENTS"
3352 #: ../src/guestfs.pod:1669
3354 "B<Note:> This section documents the generic event mechanism introduced in "
3355 "libguestfs 1.10, which you should use in new code if possible. The old "
3356 "functions C<guestfs_set_log_message_callback>, "
3357 "C<guestfs_set_subprocess_quit_callback>, "
3358 "C<guestfs_set_launch_done_callback>, C<guestfs_set_close_callback> and "
3359 "C<guestfs_set_progress_callback> are no longer documented in this manual "
3360 "page. Because of the ABI guarantee, the old functions continue to work."
3364 #: ../src/guestfs.pod:1678
3366 "Handles generate events when certain things happen, such as log messages "
3367 "being generated, progress messages during long-running operations, or the "
3368 "handle being closed. The API calls described below let you register a "
3369 "callback to be called when events happen. You can register multiple "
3370 "callbacks (for the same, different or overlapping sets of events), and "
3371 "individually remove callbacks. If callbacks are not removed, then they "
3372 "remain in force until the handle is closed."
3376 #: ../src/guestfs.pod:1686
3378 "In the current implementation, events are only generated synchronously: that "
3379 "means that events (and hence callbacks) can only happen while you are in the "
3380 "middle of making another libguestfs call. The callback is called in the "
3385 #: ../src/guestfs.pod:1691
3387 "Events may contain a payload, usually nothing (void), an array of 64 bit "
3388 "unsigned integers, or a message buffer. Payloads are discussed later on."
3392 #: ../src/guestfs.pod:1695
3393 msgid "CLASSES OF EVENTS"
3397 #: ../src/guestfs.pod:1699
3398 msgid "GUESTFS_EVENT_CLOSE (payload type: void)"
3402 #: ../src/guestfs.pod:1702
3404 "The callback function will be called while the handle is being closed "
3405 "(synchronously from L</guestfs_close>)."
3409 #: ../src/guestfs.pod:1705
3411 "Note that libguestfs installs an L<atexit(3)> handler to try to clean up "
3412 "handles that are open when the program exits. This means that this callback "
3413 "might be called indirectly from L<exit(3)>, which can cause unexpected "
3414 "problems in higher-level languages (eg. if your HLL interpreter has already "
3415 "been cleaned up by the time this is called, and if your callback then jumps "
3416 "into some HLL function)."
3420 #: ../src/guestfs.pod:1712
3422 "If no callback is registered: the handle is closed without any callback "
3427 #: ../src/guestfs.pod:1715
3428 msgid "GUESTFS_EVENT_SUBPROCESS_QUIT (payload type: void)"
3432 #: ../src/guestfs.pod:1718
3434 "The callback function will be called when the child process quits, either "
3435 "asynchronously or if killed by L</guestfs_kill_subprocess>. (This "
3436 "corresponds to a transition from any state to the CONFIG state)."
3440 #: ../src/guestfs.pod:1722 ../src/guestfs.pod:1731
3441 msgid "If no callback is registered: the event is ignored."
3445 #: ../src/guestfs.pod:1724
3446 msgid "GUESTFS_EVENT_LAUNCH_DONE (payload type: void)"
3450 #: ../src/guestfs.pod:1727
3452 "The callback function will be called when the child process becomes ready "
3453 "first time after it has been launched. (This corresponds to a transition "
3454 "from LAUNCHING to the READY state)."
3458 #: ../src/guestfs.pod:1733
3459 msgid "GUESTFS_EVENT_PROGRESS (payload type: array of 4 x uint64_t)"
3463 #: ../src/guestfs.pod:1736
3465 "Some long-running operations can generate progress messages. If this "
3466 "callback is registered, then it will be called each time a progress message "
3467 "is generated (usually two seconds after the operation started, and three "
3468 "times per second thereafter until it completes, although the frequency may "
3469 "change in future versions)."
3473 #: ../src/guestfs.pod:1742
3475 "The callback receives in the payload four unsigned 64 bit numbers which are "
3476 "(in order): C<proc_nr>, C<serial>, C<position>, C<total>."
3480 #: ../src/guestfs.pod:1745
3482 "The units of C<total> are not defined, although for some operations C<total> "
3483 "may relate in some way to the amount of data to be transferred (eg. in bytes "
3484 "or megabytes), and C<position> may be the portion which has been transferred."
3488 #: ../src/guestfs.pod:1750
3489 msgid "The only defined and stable parts of the API are:"
3493 #: ../src/guestfs.pod:1756
3495 "The callback can display to the user some type of progress bar or indicator "
3496 "which shows the ratio of C<position>:C<total>."
3500 #: ../src/guestfs.pod:1761
3501 msgid "0 E<lt>= C<position> E<lt>= C<total>"
3505 #: ../src/guestfs.pod:1765
3507 "If any progress notification is sent during a call, then a final progress "
3508 "notification is always sent when C<position> = C<total> (I<unless> the call "
3509 "fails with an error)."
3513 #: ../src/guestfs.pod:1769
3515 "This is to simplify caller code, so callers can easily set the progress "
3516 "indicator to \"100%\" at the end of the operation, without requiring special "
3517 "code to detect this case."
3521 #: ../src/guestfs.pod:1775
3523 "For some calls we are unable to estimate the progress of the call, but we "
3524 "can still generate progress messages to indicate activity. This is known as "
3525 "\"pulse mode\", and is directly supported by certain progress bar "
3526 "implementations (eg. GtkProgressBar)."
3530 #: ../src/guestfs.pod:1780
3532 "For these calls, zero or more progress messages are generated with "
3533 "C<position = 0> and C<total = 1>, followed by a final message with "
3534 "C<position = total = 1>."
3538 #: ../src/guestfs.pod:1784
3540 "As noted above, if the call fails with an error then the final message may "
3545 #: ../src/guestfs.pod:1789
3547 "The callback also receives the procedure number (C<proc_nr>) and serial "
3548 "number (C<serial>) of the call. These are only useful for debugging "
3549 "protocol issues, and the callback can normally ignore them. The callback "
3550 "may want to print these numbers in error messages or debugging messages."
3554 #: ../src/guestfs.pod:1795
3555 msgid "If no callback is registered: progress messages are discarded."
3559 #: ../src/guestfs.pod:1797
3560 msgid "GUESTFS_EVENT_APPLIANCE (payload type: message buffer)"
3564 #: ../src/guestfs.pod:1800
3566 "The callback function is called whenever a log message is generated by qemu, "
3567 "the appliance kernel, guestfsd (daemon), or utility programs."
3571 #: ../src/guestfs.pod:1803
3573 "If the verbose flag (L</guestfs_set_verbose>) is set before launch (L</"
3574 "guestfs_launch>) then additional debug messages are generated."
3578 #: ../src/guestfs.pod:1806 ../src/guestfs.pod:1820
3580 "If no callback is registered: the messages are discarded unless the verbose "
3581 "flag is set in which case they are sent to stderr. You can override the "
3582 "printing of verbose messages to stderr by setting up a callback."
3586 #: ../src/guestfs.pod:1811
3587 msgid "GUESTFS_EVENT_LIBRARY (payload type: message buffer)"
3591 #: ../src/guestfs.pod:1814
3593 "The callback function is called whenever a log message is generated by the "
3594 "library part of libguestfs."
3598 #: ../src/guestfs.pod:1817
3600 "If the verbose flag (L</guestfs_set_verbose>) is set then additional debug "
3601 "messages are generated."
3605 #: ../src/guestfs.pod:1825
3606 msgid "GUESTFS_EVENT_TRACE (payload type: message buffer)"
3610 #: ../src/guestfs.pod:1828
3612 "The callback function is called whenever a trace message is generated. This "
3613 "only applies if the trace flag (L</guestfs_set_trace>) is set."
3617 #: ../src/guestfs.pod:1831
3619 "If no callback is registered: the messages are sent to stderr. You can "
3620 "override the printing of trace messages to stderr by setting up a callback."
3624 #: ../src/guestfs.pod:1837
3625 msgid "guestfs_set_event_callback"
3629 #: ../src/guestfs.pod:1839
3632 " int guestfs_set_event_callback (guestfs_h *g,\n"
3633 " guestfs_event_callback cb,\n"
3634 " uint64_t event_bitmask,\n"
3641 #: ../src/guestfs.pod:1845
3643 "This function registers a callback (C<cb>) for all event classes in the "
3648 #: ../src/guestfs.pod:1848
3650 "For example, to register for all log message events, you could call this "
3651 "function with the bitmask C<GUESTFS_EVENT_APPLIANCE|GUESTFS_EVENT_LIBRARY>. "
3652 "To register a single callback for all possible classes of events, use "
3653 "C<GUESTFS_EVENT_ALL>."
3657 #: ../src/guestfs.pod:1854
3658 msgid "C<flags> should always be passed as 0."
3662 #: ../src/guestfs.pod:1856
3664 "C<opaque> is an opaque pointer which is passed to the callback. You can use "
3665 "it for any purpose."
3669 #: ../src/guestfs.pod:1859
3671 "The return value is the event handle (an integer) which you can use to "
3672 "delete the callback (see below)."
3676 #: ../src/guestfs.pod:1862
3678 "If there is an error, this function returns C<-1>, and sets the error in the "
3679 "handle in the usual way (see L</guestfs_last_error> etc.)"
3683 #: ../src/guestfs.pod:1865
3685 "Callbacks remain in effect until they are deleted, or until the handle is "
3690 #: ../src/guestfs.pod:1868
3692 "In the case where multiple callbacks are registered for a particular event "
3693 "class, all of the callbacks are called. The order in which multiple "
3694 "callbacks are called is not defined."
3698 #: ../src/guestfs.pod:1872
3699 msgid "guestfs_delete_event_callback"
3703 #: ../src/guestfs.pod:1874
3706 " void guestfs_delete_event_callback (guestfs_h *g, int event_handle);\n"
3711 #: ../src/guestfs.pod:1876
3713 "Delete a callback that was previously registered. C<event_handle> should be "
3714 "the integer that was returned by a previous call to "
3715 "C<guestfs_set_event_callback> on the same handle."
3719 #: ../src/guestfs.pod:1880
3720 msgid "guestfs_event_callback"
3724 #: ../src/guestfs.pod:1882
3727 " typedef void (*guestfs_event_callback) (\n"
3730 " uint64_t event,\n"
3731 " int event_handle,\n"
3733 " const char *buf, size_t buf_len,\n"
3734 " const uint64_t *array, size_t array_len);\n"
3739 #: ../src/guestfs.pod:1891
3741 "This is the type of the event callback function that you have to provide."
3745 #: ../src/guestfs.pod:1894
3747 "The basic parameters are: the handle (C<g>), the opaque user pointer "
3748 "(C<opaque>), the event class (eg. C<GUESTFS_EVENT_PROGRESS>), the event "
3749 "handle, and C<flags> which in the current API you should ignore."
3753 #: ../src/guestfs.pod:1898
3755 "The remaining parameters contain the event payload (if any). Each event may "
3756 "contain a payload, which usually relates to the event class, but for future "
3757 "proofing your code should be written to handle any payload for any event "
3762 #: ../src/guestfs.pod:1903
3764 "C<buf> and C<buf_len> contain a message buffer (if C<buf_len == 0>, then "
3765 "there is no message buffer). Note that this message buffer can contain "
3766 "arbitrary 8 bit data, including NUL bytes."
3770 #: ../src/guestfs.pod:1907
3772 "C<array> and C<array_len> is an array of 64 bit unsigned integers. At the "
3773 "moment this is only used for progress messages."
3777 #: ../src/guestfs.pod:1910
3778 msgid "EXAMPLE: CAPTURING LOG MESSAGES"
3782 #: ../src/guestfs.pod:1912
3784 "One motivation for the generic event API was to allow GUI programs to "
3785 "capture debug and other messages. In libguestfs E<le> 1.8 these were sent "
3786 "unconditionally to C<stderr>."
3790 #: ../src/guestfs.pod:1916
3792 "Events associated with log messages are: C<GUESTFS_EVENT_LIBRARY>, "
3793 "C<GUESTFS_EVENT_APPLIANCE> and C<GUESTFS_EVENT_TRACE>. (Note that error "
3794 "messages are not events; you must capture error messages separately)."
3798 #: ../src/guestfs.pod:1921
3800 "Programs have to set up a callback to capture the classes of events of "
3805 #: ../src/guestfs.pod:1924
3809 " guestfs_set_event_callback\n"
3810 " (g, message_callback,\n"
3811 " GUESTFS_EVENT_LIBRARY|GUESTFS_EVENT_APPLIANCE|\n"
3812 " GUESTFS_EVENT_TRACE,\n"
3813 " 0, NULL) == -1)\n"
3814 " if (eh == -1) {\n"
3815 " // handle error in the usual way\n"
3821 #: ../src/guestfs.pod:1934
3823 "The callback can then direct messages to the appropriate place. In this "
3824 "example, messages are directed to syslog:"
3828 #: ../src/guestfs.pod:1937
3832 " message_callback (\n"
3835 " uint64_t event,\n"
3836 " int event_handle,\n"
3838 " const char *buf, size_t buf_len,\n"
3839 " const uint64_t *array, size_t array_len)\n"
3841 " const int priority = LOG_USER|LOG_INFO;\n"
3842 " if (buf_len > 0)\n"
3843 " syslog (priority, \"event 0x%lx: %s\", event, buf);\n"
3849 #: ../src/guestfs.pod:1952
3850 msgid "PRIVATE DATA AREA"
3854 #: ../src/guestfs.pod:1954
3856 "You can attach named pieces of private data to the libguestfs handle, fetch "
3857 "them by name, and walk over them, for the lifetime of the handle. This is "
3858 "called the private data area and is only available from the C API."
3862 #: ../src/guestfs.pod:1959
3863 msgid "To attach a named piece of data, use the following call:"
3867 #: ../src/guestfs.pod:1961
3870 " void guestfs_set_private (guestfs_h *g, const char *key, void *data);\n"
3875 #: ../src/guestfs.pod:1963
3877 "C<key> is the name to associate with this data, and C<data> is an arbitrary "
3878 "pointer (which can be C<NULL>). Any previous item with the same key is "
3883 #: ../src/guestfs.pod:1967
3885 "You can use any C<key> you want, but your key should I<not> start with an "
3886 "underscore character. Keys beginning with an underscore character are "
3887 "reserved for internal libguestfs purposes (eg. for implementing language "
3888 "bindings). It is recommended that you prefix the key with some unique "
3889 "string to avoid collisions with other users."
3893 #: ../src/guestfs.pod:1973
3894 msgid "To retrieve the pointer, use:"
3898 #: ../src/guestfs.pod:1975
3901 " void *guestfs_get_private (guestfs_h *g, const char *key);\n"
3906 #: ../src/guestfs.pod:1977
3908 "This function returns C<NULL> if either no data is found associated with "
3909 "C<key>, or if the user previously set the C<key>'s C<data> pointer to "
3914 #: ../src/guestfs.pod:1981
3916 "Libguestfs does not try to look at or interpret the C<data> pointer in any "
3917 "way. As far as libguestfs is concerned, it need not be a valid pointer at "
3918 "all. In particular, libguestfs does I<not> try to free the data when the "
3919 "handle is closed. If the data must be freed, then the caller must either "
3920 "free it before calling L</guestfs_close> or must set up a close callback to "
3921 "do it (see L</GUESTFS_EVENT_CLOSE>)."
3925 #: ../src/guestfs.pod:1988
3926 msgid "To walk over all entries, use these two functions:"
3930 #: ../src/guestfs.pod:1990
3933 " void *guestfs_first_private (guestfs_h *g, const char **key_rtn);\n"
3938 #: ../src/guestfs.pod:1992
3941 " void *guestfs_next_private (guestfs_h *g, const char **key_rtn);\n"
3946 #: ../src/guestfs.pod:1994
3948 "C<guestfs_first_private> returns the first key, pointer pair (\"first\" does "
3949 "not have any particular meaning -- keys are not returned in any defined "
3950 "order). A pointer to the key is returned in C<*key_rtn> and the "
3951 "corresponding data pointer is returned from the function. C<NULL> is "
3952 "returned if there are no keys stored in the handle."
3956 #: ../src/guestfs.pod:2000
3958 "C<guestfs_next_private> returns the next key, pointer pair. The return "
3959 "value of this function is also C<NULL> is there are no further entries to "
3964 #: ../src/guestfs.pod:2004
3965 msgid "Notes about walking over entries:"
3969 #: ../src/guestfs.pod:2010
3971 "You must not call C<guestfs_set_private> while walking over the entries."
3975 #: ../src/guestfs.pod:2015
3977 "The handle maintains an internal iterator which is reset when you call "
3978 "C<guestfs_first_private>. This internal iterator is invalidated when you "
3979 "call C<guestfs_set_private>."
3983 #: ../src/guestfs.pod:2021
3984 msgid "If you have set the data pointer associated with a key to C<NULL>, ie:"
3988 #: ../src/guestfs.pod:2023
3991 " guestfs_set_private (g, key, NULL);\n"
3996 #: ../src/guestfs.pod:2025
3997 msgid "then that C<key> is not returned when walking."
4001 #: ../src/guestfs.pod:2029
4003 "C<*key_rtn> is only valid until the next call to C<guestfs_first_private>, "
4004 "C<guestfs_next_private> or C<guestfs_set_private>."
4008 #: ../src/guestfs.pod:2035
4010 "The following example code shows how to print all keys and data pointers "
4011 "that are associated with the handle C<g>:"
4015 #: ../src/guestfs.pod:2038
4018 " const char *key;\n"
4019 " void *data = guestfs_first_private (g, &key);\n"
4020 " while (data != NULL)\n"
4022 " printf (\"key = %s, data = %p\\n\", key, data);\n"
4023 " data = guestfs_next_private (g, &key);\n"
4029 #: ../src/guestfs.pod:2046
4031 "More commonly you are only interested in keys that begin with an application-"
4032 "specific prefix C<foo_>. Modify the loop like so:"
4036 #: ../src/guestfs.pod:2049
4039 " const char *key;\n"
4040 " void *data = guestfs_first_private (g, &key);\n"
4041 " while (data != NULL)\n"
4043 " if (strncmp (key, \"foo_\", strlen (\"foo_\")) == 0)\n"
4044 " printf (\"key = %s, data = %p\\n\", key, data);\n"
4045 " data = guestfs_next_private (g, &key);\n"
4051 #: ../src/guestfs.pod:2058
4053 "If you need to modify keys while walking, then you have to jump back to the "
4054 "beginning of the loop. For example, to delete all keys prefixed with "
4059 #: ../src/guestfs.pod:2062
4062 " const char *key;\n"
4065 " data = guestfs_first_private (g, &key);\n"
4066 " while (data != NULL)\n"
4068 " if (strncmp (key, \"foo_\", strlen (\"foo_\")) == 0)\n"
4070 " guestfs_set_private (g, key, NULL);\n"
4071 " /* note that 'key' pointer is now invalid, and so is\n"
4072 " the internal iterator */\n"
4075 " data = guestfs_next_private (g, &key);\n"
4081 #: ../src/guestfs.pod:2078
4083 "Note that the above loop is guaranteed to terminate because the keys are "
4084 "being deleted, but other manipulations of keys within the loop might not "
4085 "terminate unless you also maintain an indication of which keys have been "
4090 #: ../src/guestfs.pod:2083 ../src/guestfs.pod:2088
4095 #: ../src/guestfs.pod:2085
4097 "<!-- old anchor for the next section --> <a name="
4098 "\"state_machine_and_low_level_event_api\"/>"
4100 "<!-- old anchor for the next section --> <a name="
4101 "\"state_machine_and_low_level_event_api\"/>"
4104 #: ../src/guestfs.pod:2090
4105 msgid "ARCHITECTURE"
4106 msgstr "АРХІТЕКТУРА"
4109 #: ../src/guestfs.pod:2092
4111 "Internally, libguestfs is implemented by running an appliance (a special "
4112 "type of small virtual machine) using L<qemu(1)>. Qemu runs as a child "
4113 "process of the main program."
4117 #: ../src/guestfs.pod:2096
4120 " ___________________\n"
4122 " | main program |\n"
4124 " | | child process / appliance\n"
4125 " | | __________________________\n"
4127 " +-------------------+ RPC | +-----------------+ |\n"
4128 " | libguestfs <--------------------> guestfsd | |\n"
4129 " | | | +-----------------+ |\n"
4130 " \\___________________/ | | Linux kernel | |\n"
4131 " | +--^--------------+ |\n"
4132 " \\_________|________________/\n"
4138 " \\______________/\n"
4143 #: ../src/guestfs.pod:2116
4145 "The library, linked to the main program, creates the child process and hence "
4146 "the appliance in the L</guestfs_launch> function."
4150 #: ../src/guestfs.pod:2119
4152 "Inside the appliance is a Linux kernel and a complete stack of userspace "
4153 "tools (such as LVM and ext2 programs) and a small controlling daemon called "
4154 "L</guestfsd>. The library talks to L</guestfsd> using remote procedure "
4155 "calls (RPC). There is a mostly one-to-one correspondence between libguestfs "
4156 "API calls and RPC calls to the daemon. Lastly the disk image(s) are "
4157 "attached to the qemu process which translates device access by the "
4158 "appliance's Linux kernel into accesses to the image."
4162 #: ../src/guestfs.pod:2128
4164 "A common misunderstanding is that the appliance \"is\" the virtual machine. "
4165 "Although the disk image you are attached to might also be used by some "
4166 "virtual machine, libguestfs doesn't know or care about this. (But you will "
4167 "care if both libguestfs's qemu process and your virtual machine are trying "
4168 "to update the disk image at the same time, since these usually results in "
4169 "massive disk corruption)."
4173 #: ../src/guestfs.pod:2135
4174 msgid "STATE MACHINE"
4175 msgstr "СКІНЧЕННИЙ АВТОМАТ"
4178 #: ../src/guestfs.pod:2137
4179 msgid "libguestfs uses a state machine to model the child process:"
4183 #: ../src/guestfs.pod:2139
4195 " / | \\ \\ guestfs_launch\n"
4196 " / | _\\__V______\n"
4198 " / | | LAUNCHING |\n"
4199 " / | \\___________/\n"
4201 " / | guestfs_launch\n"
4203 " ______ / __|____V\n"
4204 " / \\ ------> / \\\n"
4205 " | BUSY | | READY |\n"
4206 " \\______/ <------ \\________/\n"
4211 #: ../src/guestfs.pod:2161
4213 "The normal transitions are (1) CONFIG (when the handle is created, but there "
4214 "is no child process), (2) LAUNCHING (when the child process is booting up), "
4215 "(3) alternating between READY and BUSY as commands are issued to, and "
4216 "carried out by, the child process."
4220 #: ../src/guestfs.pod:2166
4222 "The guest may be killed by L</guestfs_kill_subprocess>, or may die "
4223 "asynchronously at any time (eg. due to some internal error), and that causes "
4224 "the state to transition back to CONFIG."
4228 #: ../src/guestfs.pod:2170
4230 "Configuration commands for qemu such as L</guestfs_add_drive> can only be "
4231 "issued when in the CONFIG state."
4235 #: ../src/guestfs.pod:2173
4237 "The API offers one call that goes from CONFIG through LAUNCHING to READY. "
4238 "L</guestfs_launch> blocks until the child process is READY to accept "
4239 "commands (or until some failure or timeout). L</guestfs_launch> internally "
4240 "moves the state from CONFIG to LAUNCHING while it is running."
4244 #: ../src/guestfs.pod:2179
4246 "API actions such as L</guestfs_mount> can only be issued when in the READY "
4247 "state. These API calls block waiting for the command to be carried out (ie. "
4248 "the state to transition to BUSY and then back to READY). There are no non-"
4249 "blocking versions, and no way to issue more than one command per handle at "
4254 #: ../src/guestfs.pod:2185
4256 "Finally, the child process sends asynchronous messages back to the main "
4257 "program, such as kernel log messages. You can register a callback to "
4258 "receive these messages."
4262 #: ../src/guestfs.pod:2189
4267 #: ../src/guestfs.pod:2191
4268 msgid "COMMUNICATION PROTOCOL"
4272 #: ../src/guestfs.pod:2193
4274 "Don't rely on using this protocol directly. This section documents how it "
4275 "currently works, but it may change at any time."
4279 #: ../src/guestfs.pod:2196
4281 "The protocol used to talk between the library and the daemon running inside "
4282 "the qemu virtual machine is a simple RPC mechanism built on top of XDR (RFC "
4283 "1014, RFC 1832, RFC 4506)."
4287 #: ../src/guestfs.pod:2200
4289 "The detailed format of structures is in C<src/guestfs_protocol.x> (note: "
4290 "this file is automatically generated)."
4294 #: ../src/guestfs.pod:2203
4296 "There are two broad cases, ordinary functions that don't have any C<FileIn> "
4297 "and C<FileOut> parameters, which are handled with very simple request/reply "
4298 "messages. Then there are functions that have any C<FileIn> or C<FileOut> "
4299 "parameters, which use the same request and reply messages, but they may also "
4300 "be followed by files sent using a chunked encoding."
4304 #: ../src/guestfs.pod:2210
4305 msgid "ORDINARY FUNCTIONS (NO FILEIN/FILEOUT PARAMS)"
4309 #: ../src/guestfs.pod:2212
4310 msgid "For ordinary functions, the request message is:"
4314 #: ../src/guestfs.pod:2214
4317 " total length (header + arguments,\n"
4318 " but not including the length word itself)\n"
4319 " struct guestfs_message_header (encoded as XDR)\n"
4320 " struct guestfs_<foo>_args (encoded as XDR)\n"
4325 #: ../src/guestfs.pod:2219
4327 "The total length field allows the daemon to allocate a fixed size buffer "
4328 "into which it slurps the rest of the message. As a result, the total length "
4329 "is limited to C<GUESTFS_MESSAGE_MAX> bytes (currently 4MB), which means the "
4330 "effective size of any request is limited to somewhere under this size."
4334 #: ../src/guestfs.pod:2225
4336 "Note also that many functions don't take any arguments, in which case the "
4337 "C<guestfs_I<foo>_args> is completely omitted."
4341 #: ../src/guestfs.pod:2228
4343 "The header contains the procedure number (C<guestfs_proc>) which is how the "
4344 "receiver knows what type of args structure to expect, or none at all."
4348 #: ../src/guestfs.pod:2232
4350 "For functions that take optional arguments, the optional arguments are "
4351 "encoded in the C<guestfs_I<foo>_args> structure in the same way as ordinary "
4352 "arguments. A bitmask in the header indicates which optional arguments are "
4353 "meaningful. The bitmask is also checked to see if it contains bits set "
4354 "which the daemon does not know about (eg. if more optional arguments were "
4355 "added in a later version of the library), and this causes the call to be "
4360 #: ../src/guestfs.pod:2240
4361 msgid "The reply message for ordinary functions is:"
4365 #: ../src/guestfs.pod:2242
4368 " total length (header + ret,\n"
4369 " but not including the length word itself)\n"
4370 " struct guestfs_message_header (encoded as XDR)\n"
4371 " struct guestfs_<foo>_ret (encoded as XDR)\n"
4376 #: ../src/guestfs.pod:2247
4378 "As above the C<guestfs_I<foo>_ret> structure may be completely omitted for "
4379 "functions that return no formal return values."
4383 #: ../src/guestfs.pod:2250
4385 "As above the total length of the reply is limited to C<GUESTFS_MESSAGE_MAX>."
4389 #: ../src/guestfs.pod:2253
4391 "In the case of an error, a flag is set in the header, and the reply message "
4392 "is slightly changed:"
4396 #: ../src/guestfs.pod:2256
4399 " total length (header + error,\n"
4400 " but not including the length word itself)\n"
4401 " struct guestfs_message_header (encoded as XDR)\n"
4402 " struct guestfs_message_error (encoded as XDR)\n"
4407 #: ../src/guestfs.pod:2261
4409 "The C<guestfs_message_error> structure contains the error message as a "
4414 #: ../src/guestfs.pod:2264
4415 msgid "FUNCTIONS THAT HAVE FILEIN PARAMETERS"
4419 #: ../src/guestfs.pod:2266
4421 "A C<FileIn> parameter indicates that we transfer a file I<into> the guest. "
4422 "The normal request message is sent (see above). However this is followed by "
4423 "a sequence of file chunks."
4427 #: ../src/guestfs.pod:2270
4430 " total length (header + arguments,\n"
4431 " but not including the length word itself,\n"
4432 " and not including the chunks)\n"
4433 " struct guestfs_message_header (encoded as XDR)\n"
4434 " struct guestfs_<foo>_args (encoded as XDR)\n"
4435 " sequence of chunks for FileIn param #0\n"
4436 " sequence of chunks for FileIn param #1 etc.\n"
4441 #: ../src/guestfs.pod:2278
4442 msgid "The \"sequence of chunks\" is:"
4446 #: ../src/guestfs.pod:2280
4449 " length of chunk (not including length word itself)\n"
4450 " struct guestfs_chunk (encoded as XDR)\n"
4451 " length of chunk\n"
4452 " struct guestfs_chunk (encoded as XDR)\n"
4454 " length of chunk\n"
4455 " struct guestfs_chunk (with data.data_len == 0)\n"
4460 #: ../src/guestfs.pod:2288
4462 "The final chunk has the C<data_len> field set to zero. Additionally a flag "
4463 "is set in the final chunk to indicate either successful completion or early "
4468 #: ../src/guestfs.pod:2292
4470 "At time of writing there are no functions that have more than one FileIn "
4471 "parameter. However this is (theoretically) supported, by sending the "
4472 "sequence of chunks for each FileIn parameter one after another (from left to "
4477 #: ../src/guestfs.pod:2297
4479 "Both the library (sender) I<and> the daemon (receiver) may cancel the "
4480 "transfer. The library does this by sending a chunk with a special flag set "
4481 "to indicate cancellation. When the daemon sees this, it cancels the whole "
4482 "RPC, does I<not> send any reply, and goes back to reading the next request."
4486 #: ../src/guestfs.pod:2303
4488 "The daemon may also cancel. It does this by writing a special word "
4489 "C<GUESTFS_CANCEL_FLAG> to the socket. The library listens for this during "
4490 "the transfer, and if it gets it, it will cancel the transfer (it sends a "
4491 "cancel chunk). The special word is chosen so that even if cancellation "
4492 "happens right at the end of the transfer (after the library has finished "
4493 "writing and has started listening for the reply), the \"spurious\" cancel "
4494 "flag will not be confused with the reply message."
4498 #: ../src/guestfs.pod:2312
4500 "This protocol allows the transfer of arbitrary sized files (no 32 bit "
4501 "limit), and also files where the size is not known in advance (eg. from "
4502 "pipes or sockets). However the chunks are rather small "
4503 "(C<GUESTFS_MAX_CHUNK_SIZE>), so that neither the library nor the daemon need "
4504 "to keep much in memory."
4508 #: ../src/guestfs.pod:2318
4509 msgid "FUNCTIONS THAT HAVE FILEOUT PARAMETERS"
4513 #: ../src/guestfs.pod:2320
4515 "The protocol for FileOut parameters is exactly the same as for FileIn "
4516 "parameters, but with the roles of daemon and library reversed."
4520 #: ../src/guestfs.pod:2323
4523 " total length (header + ret,\n"
4524 " but not including the length word itself,\n"
4525 " and not including the chunks)\n"
4526 " struct guestfs_message_header (encoded as XDR)\n"
4527 " struct guestfs_<foo>_ret (encoded as XDR)\n"
4528 " sequence of chunks for FileOut param #0\n"
4529 " sequence of chunks for FileOut param #1 etc.\n"
4534 #: ../src/guestfs.pod:2331
4535 msgid "INITIAL MESSAGE"
4539 #: ../src/guestfs.pod:2333
4541 "When the daemon launches it sends an initial word (C<GUESTFS_LAUNCH_FLAG>) "
4542 "which indicates that the guest and daemon is alive. This is what L</"
4543 "guestfs_launch> waits for."
4547 #: ../src/guestfs.pod:2337
4548 msgid "PROGRESS NOTIFICATION MESSAGES"
4552 #: ../src/guestfs.pod:2339
4554 "The daemon may send progress notification messages at any time. These are "
4555 "distinguished by the normal length word being replaced by "
4556 "C<GUESTFS_PROGRESS_FLAG>, followed by a fixed size progress message."
4560 #: ../src/guestfs.pod:2343
4562 "The library turns them into progress callbacks (see L</"
4563 "GUESTFS_EVENT_PROGRESS>) if there is a callback registered, or discards them "
4568 #: ../src/guestfs.pod:2347
4570 "The daemon self-limits the frequency of progress messages it sends (see "
4571 "C<daemon/proto.c:notify_progress>). Not all calls generate progress "
4576 #: ../src/guestfs.pod:2351
4577 msgid "LIBGUESTFS VERSION NUMBERS"
4581 #: ../src/guestfs.pod:2353
4583 "Since April 2010, libguestfs has started to make separate development and "
4584 "stable releases, along with corresponding branches in our git repository. "
4585 "These separate releases can be identified by version number:"
4589 #: ../src/guestfs.pod:2358
4592 " even numbers for stable: 1.2.x, 1.4.x, ...\n"
4593 " .-------- odd numbers for development: 1.3.x, 1.5.x, ...\n"
4599 " | `-------- sub-version\n"
4601 " `------ always '1' because we don't change the ABI\n"
4606 #: ../src/guestfs.pod:2369
4607 msgid "Thus \"1.3.5\" is the 5th update to the development branch \"1.3\"."
4611 #: ../src/guestfs.pod:2371
4613 "As time passes we cherry pick fixes from the development branch and backport "
4614 "those into the stable branch, the effect being that the stable branch should "
4615 "get more stable and less buggy over time. So the stable releases are ideal "
4616 "for people who don't need new features but would just like the software to "
4621 #: ../src/guestfs.pod:2377
4622 msgid "Our criteria for backporting changes are:"
4626 #: ../src/guestfs.pod:2383
4628 "Documentation changes which don't affect any code are backported unless the "
4629 "documentation refers to a future feature which is not in stable."
4633 #: ../src/guestfs.pod:2389
4635 "Bug fixes which are not controversial, fix obvious problems, and have been "
4636 "well tested are backported."
4640 #: ../src/guestfs.pod:2394
4642 "Simple rearrangements of code which shouldn't affect how it works get "
4643 "backported. This is so that the code in the two branches doesn't get too "
4644 "far out of step, allowing us to backport future fixes more easily."
4648 #: ../src/guestfs.pod:2400
4650 "We I<don't> backport new features, new APIs, new tools etc, except in one "
4651 "exceptional case: the new feature is required in order to implement an "
4652 "important bug fix."
4656 #: ../src/guestfs.pod:2406
4658 "A new stable branch starts when we think the new features in development are "
4659 "substantial and compelling enough over the current stable branch to warrant "
4660 "it. When that happens we create new stable and development versions 1.N.0 "
4661 "and 1.(N+1).0 [N is even]. The new dot-oh release won't necessarily be so "
4662 "stable at this point, but by backporting fixes from development, that branch "
4663 "will stabilize over time."
4667 #: ../src/guestfs.pod:2414
4668 msgid "EXTENDING LIBGUESTFS"
4672 #: ../src/guestfs.pod:2416
4673 msgid "ADDING A NEW API ACTION"
4677 #: ../src/guestfs.pod:2418
4679 "Large amounts of boilerplate code in libguestfs (RPC, bindings, "
4680 "documentation) are generated, and this makes it easy to extend the "
4685 #: ../src/guestfs.pod:2422
4686 msgid "To add a new API action there are two changes:"
4690 #: ../src/guestfs.pod:2428
4692 "You need to add a description of the call (name, parameters, return type, "
4693 "tests, documentation) to C<generator/generator_actions.ml>."
4697 #: ../src/guestfs.pod:2431
4699 "There are two sorts of API action, depending on whether the call goes "
4700 "through to the daemon in the appliance, or is serviced entirely by the "
4701 "library (see L</ARCHITECTURE> above). L</guestfs_sync> is an example of the "
4702 "former, since the sync is done in the appliance. L</guestfs_set_trace> is "
4703 "an example of the latter, since a trace flag is maintained in the handle and "
4704 "all tracing is done on the library side."
4708 #: ../src/guestfs.pod:2439
4710 "Most new actions are of the first type, and get added to the "
4711 "C<daemon_functions> list. Each function has a unique procedure number used "
4712 "in the RPC protocol which is assigned to that action when we publish "
4713 "libguestfs and cannot be reused. Take the latest procedure number and "
4718 #: ../src/guestfs.pod:2445
4720 "For library-only actions of the second type, add to the "
4721 "C<non_daemon_functions> list. Since these functions are serviced by the "
4722 "library and do not travel over the RPC mechanism to the daemon, these "
4723 "functions do not need a procedure number, and so the procedure number is set "
4728 #: ../src/guestfs.pod:2453
4729 msgid "Implement the action (in C):"
4733 #: ../src/guestfs.pod:2455
4735 "For daemon actions, implement the function C<do_E<lt>nameE<gt>> in the "
4736 "C<daemon/> directory."
4740 #: ../src/guestfs.pod:2458
4742 "For library actions, implement the function C<guestfs__E<lt>nameE<gt>> "
4743 "(note: double underscore) in the C<src/> directory."
4747 #: ../src/guestfs.pod:2461
4748 msgid "In either case, use another function as an example of what to do."
4752 #: ../src/guestfs.pod:2465
4753 msgid "After making these changes, use C<make> to compile."
4757 #: ../src/guestfs.pod:2467
4759 "Note that you don't need to implement the RPC, language bindings, manual "
4760 "pages or anything else. It's all automatically generated from the OCaml "
4765 #: ../src/guestfs.pod:2471
4766 msgid "ADDING TESTS FOR AN API ACTION"
4770 #: ../src/guestfs.pod:2473
4772 "You can supply zero or as many tests as you want per API call. The tests "
4773 "can either be added as part of the API description (C<generator/"
4774 "generator_actions.ml>), or in some rarer cases you may want to drop a script "
4775 "into C<regressions/>. Note that adding a script to C<regressions/> is "
4776 "slower, so if possible use the first method."
4780 #: ../src/guestfs.pod:2479
4782 "The following describes the test environment used when you add an API test "
4783 "in C<generator_actions.ml>."
4787 #: ../src/guestfs.pod:2482
4788 msgid "The test environment has 4 block devices:"
4792 #: ../src/guestfs.pod:2486
4793 msgid "C</dev/sda> 500MB"
4797 #: ../src/guestfs.pod:2488
4798 msgid "General block device for testing."
4802 #: ../src/guestfs.pod:2490
4803 msgid "C</dev/sdb> 50MB"
4807 #: ../src/guestfs.pod:2492
4809 "C</dev/sdb1> is an ext2 filesystem used for testing filesystem write "
4814 #: ../src/guestfs.pod:2495
4815 msgid "C</dev/sdc> 10MB"
4819 #: ../src/guestfs.pod:2497
4820 msgid "Used in a few tests where two block devices are needed."
4824 #: ../src/guestfs.pod:2499
4826 msgstr "C</dev/sdd>"
4829 #: ../src/guestfs.pod:2501
4830 msgid "ISO with fixed content (see C<images/test.iso>)."
4834 #: ../src/guestfs.pod:2505
4836 "To be able to run the tests in a reasonable amount of time, the libguestfs "
4837 "appliance and block devices are reused between tests. So don't try testing "
4838 "L</guestfs_kill_subprocess> :-x"
4842 #: ../src/guestfs.pod:2509
4844 "Each test starts with an initial scenario, selected using one of the "
4845 "C<Init*> expressions, described in C<generator/generator_types.ml>. These "
4846 "initialize the disks mentioned above in a particular way as documented in "
4847 "C<generator_types.ml>. You should not assume anything about the previous "
4848 "contents of other disks that are not initialized."
4852 #: ../src/guestfs.pod:2515
4854 "You can add a prerequisite clause to any individual test. This is a run-"
4855 "time check, which, if it fails, causes the test to be skipped. Useful if "
4856 "testing a command which might not work on all variations of libguestfs "
4857 "builds. A test that has prerequisite of C<Always> means to run "
4862 #: ../src/guestfs.pod:2521
4864 "In addition, packagers can skip individual tests by setting environment "
4865 "variables before running C<make check>."
4869 #: ../src/guestfs.pod:2524
4872 " SKIP_TEST_<CMD>_<NUM>=1\n"
4877 #: ../src/guestfs.pod:2526
4878 msgid "eg: C<SKIP_TEST_COMMAND_3=1> skips test #3 of L</guestfs_command>."
4882 #: ../src/guestfs.pod:2528