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-04-05 20:38+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-edit.pl:32 ../tools/virt-win-reg.pl:35
25 #: ../tools/virt-resize.pl:40 ../tools/virt-list-filesystems.pl:30
26 #: ../tools/virt-tar.pl:31 ../tools/virt-make-fs.pl:35
27 #: ../tools/virt-list-partitions.pl:30
32 #: ../src/guestfs.pod:5
33 msgid "guestfs - Library for accessing and modifying virtual machine images"
35 "guestfs — бібліотека для доступу та внесення змін до образів віртуальних "
39 #: ../src/guestfs.pod:7 ../fish/guestfish.pod:7
40 #: ../test-tool/libguestfs-test-tool.pod:7 ../fuse/guestmount.pod:7
41 #: ../tools/virt-edit.pl:36 ../tools/virt-win-reg.pl:39
42 #: ../tools/virt-resize.pl:44 ../tools/virt-list-filesystems.pl:34
43 #: ../tools/virt-tar.pl:35 ../tools/virt-make-fs.pl:39
44 #: ../tools/virt-list-partitions.pl:34
46 msgstr "КОРОТКИЙ ОПИС"
49 #: ../src/guestfs.pod:9
52 " #include <guestfs.h>\n"
55 " #include <guestfs.h>\n"
59 #: ../src/guestfs.pod:11
62 " guestfs_h *g = guestfs_create ();\n"
63 " guestfs_add_drive (g, \"guest.img\");\n"
64 " guestfs_launch (g);\n"
65 " guestfs_mount (g, \"/dev/sda1\", \"/\");\n"
66 " guestfs_touch (g, \"/hello\");\n"
67 " guestfs_umount (g, \"/\");\n"
68 " guestfs_close (g);\n"
71 " guestfs_h *g = guestfs_create ();\n"
72 " guestfs_add_drive (g, \"guest.img\");\n"
73 " guestfs_launch (g);\n"
74 " guestfs_mount (g, \"/dev/sda1\", \"/\");\n"
75 " guestfs_touch (g, \"/hello\");\n"
76 " guestfs_umount (g, \"/\");\n"
77 " guestfs_close (g);\n"
81 #: ../src/guestfs.pod:19
84 " cc prog.c -o prog -lguestfs\n"
86 " cc prog.c -o prog `pkg-config libguestfs --cflags --libs`\n"
89 " cc prog.c -o prog -lguestfs\n"
91 " cc prog.c -o prog `pkg-config libguestfs --cflags --libs`\n"
95 #: ../src/guestfs.pod:23 ../fish/guestfish.pod:30
96 #: ../test-tool/libguestfs-test-tool.pod:11 ../fuse/guestmount.pod:20
97 #: ../tools/virt-edit.pl:50 ../tools/virt-win-reg.pl:63
98 #: ../tools/virt-resize.pl:50 ../tools/virt-list-filesystems.pl:40
99 #: ../tools/virt-tar.pl:77 ../tools/virt-make-fs.pl:47
100 #: ../tools/virt-list-partitions.pl:40
105 #: ../src/guestfs.pod:25
107 "Libguestfs is a library for accessing and modifying guest disk images. "
108 "Amongst the things this is good for: making batch configuration changes to "
109 "guests, getting disk used/free statistics (see also: virt-df), migrating "
110 "between virtualization systems (see also: virt-p2v), performing partial "
111 "backups, performing partial guest clones, cloning guests and changing "
112 "registry/UUID/hostname info, and much else besides."
116 #: ../src/guestfs.pod:33
118 "Libguestfs uses Linux kernel and qemu code, and can access any type of guest "
119 "filesystem that Linux and qemu can, including but not limited to: ext2/3/4, "
120 "btrfs, FAT and NTFS, LVM, many different disk partition schemes, qcow, "
125 #: ../src/guestfs.pod:38
127 "Libguestfs provides ways to enumerate guest storage (eg. partitions, LVs, "
128 "what filesystem is in each LV, etc.). It can also run commands in the "
129 "context of the guest. Also you can access filesystems over FUSE."
133 #: ../src/guestfs.pod:43
135 "Libguestfs is a library that can be linked with C and C++ management "
136 "programs (or management programs written in OCaml, Perl, Python, Ruby, Java, "
137 "PHP, Haskell or C#). You can also use it from shell scripts or the command "
142 #: ../src/guestfs.pod:48
144 "You don't need to be root to use libguestfs, although obviously you do need "
145 "enough permissions to access the disk images."
149 #: ../src/guestfs.pod:51
151 "Libguestfs is a large API because it can do many things. For a gentle "
152 "introduction, please read the L</API OVERVIEW> section next."
156 #: ../src/guestfs.pod:54
158 "There are also some example programs in the L<guestfs-examples(3)> manual "
163 #: ../src/guestfs.pod:57
168 #: ../src/guestfs.pod:59
170 "This section provides a gentler overview of the libguestfs API. We also try "
171 "to group API calls together, where that may not be obvious from reading "
172 "about the individual calls in the main section of this manual."
176 #: ../src/guestfs.pod:64
181 #: ../src/guestfs.pod:66
183 "Before you can use libguestfs calls, you have to create a handle. Then you "
184 "must add at least one disk image to the handle, followed by launching the "
185 "handle, then performing whatever operations you want, and finally closing "
186 "the handle. By convention we use the single letter C<g> for the name of the "
187 "handle variable, although of course you can use any name you want."
191 #: ../src/guestfs.pod:73
192 msgid "The general structure of all libguestfs-using programs looks like this:"
196 #: ../src/guestfs.pod:76
199 " guestfs_h *g = guestfs_create ();\n"
202 " guestfs_h *g = guestfs_create ();\n"
206 #: ../src/guestfs.pod:78
209 " /* Call guestfs_add_drive additional times if there are\n"
210 " * multiple disk images.\n"
212 " guestfs_add_drive (g, \"guest.img\");\n"
217 #: ../src/guestfs.pod:83
220 " /* Most manipulation calls won't work until you've launched\n"
221 " * the handle 'g'. You have to do this _after_ adding drives\n"
222 " * and _before_ other commands.\n"
224 " guestfs_launch (g);\n"
229 #: ../src/guestfs.pod:89
232 " /* Now you can examine what partitions, LVs etc are available.\n"
234 " char **partitions = guestfs_list_partitions (g);\n"
235 " char **logvols = guestfs_lvs (g);\n"
240 #: ../src/guestfs.pod:94
243 " /* To access a filesystem in the image, you must mount it.\n"
245 " guestfs_mount (g, \"/dev/sda1\", \"/\");\n"
248 " /* Щоб отримати доступ до файлової системи на образі, вам слід його змонтувати.\n"
250 " guestfs_mount (g, \"/dev/sda1\", \"/\");\n"
254 #: ../src/guestfs.pod:98
257 #| " /* Now you can perform filesystem actions on the guest\n"
258 #| " * disk image.\n"
260 #| " guestfs_touch (g, \"/hello\");\n"
263 " /* Now you can perform filesystem actions on the guest\n"
266 " guestfs_touch (g, \"/hello\");\n"
269 " /* Тепер ви можете виконувати дії з файловою системою на\n"
270 " * образі диска операційної системи.\n"
272 " guestfs_touch (g, \"/hello\");\n"
276 #: ../src/guestfs.pod:103
279 " /* This is only needed for libguestfs < 1.5.24. Since then\n"
280 " * it is done automatically when you close the handle. See\n"
281 " * discussion of autosync in this page.\n"
283 " guestfs_sync (g);\n"
288 #: ../src/guestfs.pod:109
291 " /* Close the handle 'g'. */\n"
292 " guestfs_close (g);\n"
297 #: ../src/guestfs.pod:112
299 "The code above doesn't include any error checking. In real code you should "
300 "check return values carefully for errors. In general all functions that "
301 "return integers return C<-1> on error, and all functions that return "
302 "pointers return C<NULL> on error. See section L</ERROR HANDLING> below for "
303 "how to handle errors, and consult the documentation for each function call "
304 "below to see precisely how they return error indications. See L<guestfs-"
305 "examples(3)> for fully worked examples."
309 #: ../src/guestfs.pod:121
314 #: ../src/guestfs.pod:123
316 "The image filename (C<\"guest.img\"> in the example above) could be a disk "
317 "image from a virtual machine, a L<dd(1)> copy of a physical hard disk, an "
318 "actual block device, or simply an empty file of zeroes that you have created "
319 "through L<posix_fallocate(3)>. Libguestfs lets you do useful things to all "
324 #: ../src/guestfs.pod:129
326 "The call you should use in modern code for adding drives is L</"
327 "guestfs_add_drive_opts>. To add a disk image, allowing writes, and "
328 "specifying that the format is raw, do:"
332 #: ../src/guestfs.pod:133
335 " guestfs_add_drive_opts (g, filename,\n"
336 " GUESTFS_ADD_DRIVE_OPTS_FORMAT, \"raw\",\n"
342 #: ../src/guestfs.pod:137
343 msgid "You can add a disk read-only using:"
347 #: ../src/guestfs.pod:139
350 " guestfs_add_drive_opts (g, filename,\n"
351 " GUESTFS_ADD_DRIVE_OPTS_FORMAT, \"raw\",\n"
352 " GUESTFS_ADD_DRIVE_OPTS_READONLY, 1,\n"
358 #: ../src/guestfs.pod:144
360 "or by calling the older function L</guestfs_add_drive_ro>. In either case "
361 "libguestfs won't modify the file."
365 #: ../src/guestfs.pod:147
367 "Be extremely cautious if the disk image is in use, eg. if it is being used "
368 "by a virtual machine. Adding it read-write will almost certainly cause disk "
369 "corruption, but adding it read-only is safe."
373 #: ../src/guestfs.pod:151
375 "You must add at least one disk image, and you may add multiple disk images. "
376 "In the API, the disk images are usually referred to as C</dev/sda> (for the "
377 "first one you added), C</dev/sdb> (for the second one you added), etc."
381 #: ../src/guestfs.pod:156
383 "Once L</guestfs_launch> has been called you cannot add any more images. You "
384 "can call L</guestfs_list_devices> to get a list of the device names, in the "
385 "order that you added them. See also L</BLOCK DEVICE NAMING> below."
389 #: ../src/guestfs.pod:161
394 #: ../src/guestfs.pod:163
396 "Before you can read or write files, create directories and so on in a disk "
397 "image that contains filesystems, you have to mount those filesystems using "
398 "L</guestfs_mount_options> or L</guestfs_mount_ro>. If you already know that "
399 "a disk image contains (for example) one partition with a filesystem on that "
400 "partition, then you can mount it directly:"
404 #: ../src/guestfs.pod:170
407 " guestfs_mount_options (g, \"\", \"/dev/sda1\", \"/\");\n"
412 #: ../src/guestfs.pod:172
414 "where C</dev/sda1> means literally the first partition (C<1>) of the first "
415 "disk image that we added (C</dev/sda>). If the disk contains Linux LVM2 "
416 "logical volumes you could refer to those instead (eg. C</dev/VG/LV>). Note "
417 "that these are libguestfs virtual devices, and are nothing to do with host "
422 #: ../src/guestfs.pod:178
424 "If you are given a disk image and you don't know what it contains then you "
425 "have to find out. Libguestfs can do that too: use L</"
426 "guestfs_list_partitions> and L</guestfs_lvs> to list possible partitions and "
427 "LVs, and either try mounting each to see what is mountable, or else examine "
428 "them with L</guestfs_vfs_type> or L</guestfs_file>. To list just "
429 "filesystems, use L</guestfs_list_filesystems>."
433 #: ../src/guestfs.pod:186
435 "Libguestfs also has a set of APIs for inspection of unknown disk images (see "
436 "L</INSPECTION> below). But you might find it easier to look at higher level "
437 "programs built on top of libguestfs, in particular L<virt-inspector(1)>."
441 #: ../src/guestfs.pod:191
443 "To mount a filesystem read-only, use L</guestfs_mount_ro>. There are "
444 "several other variations of the C<guestfs_mount_*> call."
448 #: ../src/guestfs.pod:194
449 msgid "FILESYSTEM ACCESS AND MODIFICATION"
453 #: ../src/guestfs.pod:196
455 "The majority of the libguestfs API consists of fairly low-level calls for "
456 "accessing and modifying the files, directories, symlinks etc on mounted "
457 "filesystems. There are over a hundred such calls which you can find listed "
458 "in detail below in this man page, and we don't even pretend to cover them "
459 "all in this overview."
463 #: ../src/guestfs.pod:202
465 "Specify filenames as full paths, starting with C<\"/\"> and including the "
470 #: ../src/guestfs.pod:205
472 "For example, if you mounted a filesystem at C<\"/\"> and you want to read "
473 "the file called C<\"etc/passwd\"> then you could do:"
477 #: ../src/guestfs.pod:208
480 " char *data = guestfs_cat (g, \"/etc/passwd\");\n"
485 #: ../src/guestfs.pod:210
487 "This would return C<data> as a newly allocated buffer containing the full "
488 "content of that file (with some conditions: see also L</DOWNLOADING> below), "
489 "or C<NULL> if there was an error."
493 #: ../src/guestfs.pod:214
495 "As another example, to create a top-level directory on that filesystem "
496 "called C<\"var\"> you would do:"
500 #: ../src/guestfs.pod:217
503 " guestfs_mkdir (g, \"/var\");\n"
508 #: ../src/guestfs.pod:219
509 msgid "To create a symlink you could do:"
513 #: ../src/guestfs.pod:221
516 " guestfs_ln_s (g, \"/etc/init.d/portmap\",\n"
517 " \"/etc/rc3.d/S30portmap\");\n"
522 #: ../src/guestfs.pod:224
524 "Libguestfs will reject attempts to use relative paths and there is no "
525 "concept of a current working directory."
529 #: ../src/guestfs.pod:227
531 "Libguestfs can return errors in many situations: for example if the "
532 "filesystem isn't writable, or if a file or directory that you requested "
533 "doesn't exist. If you are using the C API (documented here) you have to "
534 "check for those error conditions after each call. (Other language bindings "
535 "turn these errors into exceptions)."
539 #: ../src/guestfs.pod:233
541 "File writes are affected by the per-handle umask, set by calling L</"
542 "guestfs_umask> and defaulting to 022. See L</UMASK>."
546 #: ../src/guestfs.pod:236
548 msgstr "ПОДІЛ НА РОЗДІЛИ"
551 #: ../src/guestfs.pod:238
553 "Libguestfs contains API calls to read, create and modify partition tables on "
558 #: ../src/guestfs.pod:241
560 "In the common case where you want to create a single partition covering the "
561 "whole disk, you should use the L</guestfs_part_disk> call:"
565 #: ../src/guestfs.pod:245
568 " const char *parttype = \"mbr\";\n"
569 " if (disk_is_larger_than_2TB)\n"
570 " parttype = \"gpt\";\n"
571 " guestfs_part_disk (g, \"/dev/sda\", parttype);\n"
576 #: ../src/guestfs.pod:250
578 "Obviously this effectively wipes anything that was on that disk image before."
582 #: ../src/guestfs.pod:253
587 #: ../src/guestfs.pod:255
589 "Libguestfs provides access to a large part of the LVM2 API, such as L</"
590 "guestfs_lvcreate> and L</guestfs_vgremove>. It won't make much sense unless "
591 "you familiarize yourself with the concepts of physical volumes, volume "
592 "groups and logical volumes."
596 #: ../src/guestfs.pod:260
598 "This author strongly recommends reading the LVM HOWTO, online at L<http://"
599 "tldp.org/HOWTO/LVM-HOWTO/>."
603 #: ../src/guestfs.pod:263
608 #: ../src/guestfs.pod:265
610 "Use L</guestfs_cat> to download small, text only files. This call is "
611 "limited to files which are less than 2 MB and which cannot contain any ASCII "
612 "NUL (C<\\0>) characters. However the API is very simple to use."
616 #: ../src/guestfs.pod:269
618 "L</guestfs_read_file> can be used to read files which contain arbitrary 8 "
619 "bit data, since it returns a (pointer, size) pair. However it is still "
620 "limited to \"small\" files, less than 2 MB."
624 #: ../src/guestfs.pod:273
626 "L</guestfs_download> can be used to download any file, with no limits on "
627 "content or size (even files larger than 4 GB)."
631 #: ../src/guestfs.pod:276
633 "To download multiple files, see L</guestfs_tar_out> and L</guestfs_tgz_out>."
637 #: ../src/guestfs.pod:279
639 msgstr "ВИВАНТАЖЕННЯ"
642 #: ../src/guestfs.pod:281
644 "It's often the case that you want to write a file or files to the disk image."
648 #: ../src/guestfs.pod:284
650 "To write a small file with fixed content, use L</guestfs_write>. To create "
651 "a file of all zeroes, use L</guestfs_truncate_size> (sparse) or L</"
652 "guestfs_fallocate64> (with all disk blocks allocated). There are a variety "
653 "of other functions for creating test files, for example L</guestfs_fill> and "
654 "L</guestfs_fill_pattern>."
658 #: ../src/guestfs.pod:290
660 "To upload a single file, use L</guestfs_upload>. This call has no limits on "
661 "file content or size (even files larger than 4 GB)."
665 #: ../src/guestfs.pod:293
667 "To upload multiple files, see L</guestfs_tar_in> and L</guestfs_tgz_in>."
671 #: ../src/guestfs.pod:295
673 "However the fastest way to upload I<large numbers of arbitrary files> is to "
674 "turn them into a squashfs or CD ISO (see L<mksquashfs(8)> and L<mkisofs(8)"
675 ">), then attach this using L</guestfs_add_drive_ro>. If you add the drive "
676 "in a predictable way (eg. adding it last after all other drives) then you "
677 "can get the device name from L</guestfs_list_devices> and mount it directly "
678 "using L</guestfs_mount_ro>. Note that squashfs images are sometimes non-"
679 "portable between kernel versions, and they don't support labels or UUIDs. "
680 "If you want to pre-build an image or you need to mount it using a label or "
681 "UUID, use an ISO image instead."
685 #: ../src/guestfs.pod:306
690 #: ../src/guestfs.pod:308
692 "There are various different commands for copying between files and devices "
693 "and in and out of the guest filesystem. These are summarised in the table "
698 #: ../src/guestfs.pod:314
699 msgid "B<file> to B<file>"
703 #: ../src/guestfs.pod:316
705 "Use L</guestfs_cp> to copy a single file, or L</guestfs_cp_a> to copy "
706 "directories recursively."
710 #: ../src/guestfs.pod:319
711 msgid "B<file or device> to B<file or device>"
715 #: ../src/guestfs.pod:321
717 "Use L</guestfs_dd> which efficiently uses L<dd(1)> to copy between files and "
718 "devices in the guest."
722 #: ../src/guestfs.pod:324
723 msgid "Example: duplicate the contents of an LV:"
727 #: ../src/guestfs.pod:326
730 " guestfs_dd (g, \"/dev/VG/Original\", \"/dev/VG/Copy\");\n"
735 #: ../src/guestfs.pod:328
737 "The destination (C</dev/VG/Copy>) must be at least as large as the source "
738 "(C</dev/VG/Original>). To copy less than the whole source device, use L</"
739 "guestfs_copy_size>."
743 #: ../src/guestfs.pod:332
744 msgid "B<file on the host> to B<file or device>"
748 #: ../src/guestfs.pod:334
749 msgid "Use L</guestfs_upload>. See L</UPLOADING> above."
753 #: ../src/guestfs.pod:336
754 msgid "B<file or device> to B<file on the host>"
758 #: ../src/guestfs.pod:338
759 msgid "Use L</guestfs_download>. See L</DOWNLOADING> above."
763 #: ../src/guestfs.pod:342
764 msgid "UPLOADING AND DOWNLOADING TO PIPES AND FILE DESCRIPTORS"
768 #: ../src/guestfs.pod:344
770 "Calls like L</guestfs_upload>, L</guestfs_download>, L</guestfs_tar_in>, L</"
771 "guestfs_tar_out> etc appear to only take filenames as arguments, so it "
772 "appears you can only upload and download to files. However many Un*x-like "
773 "hosts let you use the special device files C</dev/stdin>, C</dev/stdout>, C</"
774 "dev/stderr> and C</dev/fd/N> to read and write from stdin, stdout, stderr, "
775 "and arbitrary file descriptor N."
779 #: ../src/guestfs.pod:352
780 msgid "For example, L<virt-cat(1)> writes its output to stdout by doing:"
784 #: ../src/guestfs.pod:355
787 " guestfs_download (g, filename, \"/dev/stdout\");\n"
792 #: ../src/guestfs.pod:357
793 msgid "and you can write tar output to a pipe C<fd> by doing:"
797 #: ../src/guestfs.pod:359
801 " snprintf (devfd, sizeof devfd, \"/dev/fd/%d\", fd);\n"
802 " guestfs_tar_out (g, \"/\", devfd);\n"
807 #: ../src/guestfs.pod:363
808 msgid "LISTING FILES"
812 #: ../src/guestfs.pod:365
814 "L</guestfs_ll> is just designed for humans to read (mainly when using the "
815 "L<guestfish(1)>-equivalent command C<ll>)."
819 #: ../src/guestfs.pod:368
821 "L</guestfs_ls> is a quick way to get a list of files in a directory from "
822 "programs, as a flat list of strings."
826 #: ../src/guestfs.pod:371
828 "L</guestfs_readdir> is a programmatic way to get a list of files in a "
829 "directory, plus additional information about each one. It is more "
830 "equivalent to using the L<readdir(3)> call on a local filesystem."
834 #: ../src/guestfs.pod:375
836 "L</guestfs_find> and L</guestfs_find0> can be used to recursively list files."
840 #: ../src/guestfs.pod:378
841 msgid "RUNNING COMMANDS"
845 #: ../src/guestfs.pod:380
847 "Although libguestfs is primarily an API for manipulating files inside guest "
848 "images, we also provide some limited facilities for running commands inside "
853 #: ../src/guestfs.pod:384
854 msgid "There are many limitations to this:"
858 #: ../src/guestfs.pod:388 ../src/guestfs.pod:393 ../src/guestfs.pod:398
859 #: ../src/guestfs.pod:402 ../src/guestfs.pod:407 ../src/guestfs.pod:411
860 #: ../src/guestfs.pod:416 ../src/guestfs.pod:421 ../src/guestfs.pod:1088
861 #: ../src/guestfs.pod:1092 ../src/guestfs.pod:1096 ../src/guestfs.pod:1101
862 #: ../src/guestfs.pod:1109 ../src/guestfs.pod:1128 ../src/guestfs.pod:1136
863 #: ../src/guestfs.pod:1158 ../src/guestfs.pod:1162 ../src/guestfs.pod:1166
864 #: ../src/guestfs.pod:1170 ../src/guestfs.pod:1174 ../src/guestfs.pod:1178
865 #: ../src/guestfs.pod:1660 ../src/guestfs.pod:1665 ../src/guestfs.pod:1669
866 #: ../src/guestfs.pod:1770 ../src/guestfs.pod:1775 ../src/guestfs.pod:1779
867 #: ../src/guestfs.pod:1789 ../src/guestfs.pod:2023 ../src/guestfs.pod:2028
868 #: ../src/guestfs.pod:2034 ../src/guestfs.pod:2042 ../src/guestfs.pod:2396
869 #: ../src/guestfs.pod:2402 ../src/guestfs.pod:2407 ../src/guestfs.pod:2413
870 #: ../src/guestfs.pod:2878 ../src/guestfs.pod:2882 ../src/guestfs.pod:2886
871 #: ../src/guestfs.pod:2890 ../src/guestfs-actions.pod:15
872 #: ../src/guestfs-actions.pod:22 ../src/guestfs-actions.pod:577
873 #: ../src/guestfs-actions.pod:585 ../src/guestfs-actions.pod:592
874 #: ../src/guestfs-actions.pod:599 ../src/guestfs-actions.pod:1600
875 #: ../src/guestfs-actions.pod:1604 ../src/guestfs-actions.pod:1608
876 #: ../src/guestfs-actions.pod:1612 ../src/guestfs-actions.pod:1620
877 #: ../src/guestfs-actions.pod:1624 ../src/guestfs-actions.pod:1628
878 #: ../src/guestfs-actions.pod:1638 ../src/guestfs-actions.pod:1642
879 #: ../src/guestfs-actions.pod:1646 ../src/guestfs-actions.pod:1784
880 #: ../src/guestfs-actions.pod:1788 ../src/guestfs-actions.pod:1793
881 #: ../src/guestfs-actions.pod:1798 ../src/guestfs-actions.pod:1859
882 #: ../src/guestfs-actions.pod:1863 ../src/guestfs-actions.pod:1868
883 #: ../fish/guestfish.pod:443 ../fish/guestfish.pod:447
884 #: ../fish/guestfish.pod:451 ../fish/guestfish.pod:455
885 #: ../fish/guestfish-actions.pod:13 ../fish/guestfish-actions.pod:20
886 #: ../fish/guestfish-actions.pod:380 ../fish/guestfish-actions.pod:388
887 #: ../fish/guestfish-actions.pod:395 ../fish/guestfish-actions.pod:402
888 #: ../fish/guestfish-actions.pod:1072 ../fish/guestfish-actions.pod:1076
889 #: ../fish/guestfish-actions.pod:1080 ../fish/guestfish-actions.pod:1084
890 #: ../fish/guestfish-actions.pod:1092 ../fish/guestfish-actions.pod:1096
891 #: ../fish/guestfish-actions.pod:1100 ../fish/guestfish-actions.pod:1110
892 #: ../fish/guestfish-actions.pod:1114 ../fish/guestfish-actions.pod:1118
893 #: ../fish/guestfish-actions.pod:1208 ../fish/guestfish-actions.pod:1212
894 #: ../fish/guestfish-actions.pod:1217 ../fish/guestfish-actions.pod:1222
895 #: ../fish/guestfish-actions.pod:1264 ../fish/guestfish-actions.pod:1268
896 #: ../fish/guestfish-actions.pod:1273 ../tools/virt-edit.pl:351
897 #: ../tools/virt-edit.pl:356 ../tools/virt-edit.pl:361
898 #: ../tools/virt-edit.pl:372 ../tools/virt-edit.pl:376
899 #: ../tools/virt-win-reg.pl:536 ../tools/virt-win-reg.pl:542
900 #: ../tools/virt-win-reg.pl:548 ../tools/virt-resize.pl:345
901 #: ../tools/virt-resize.pl:350 ../tools/virt-resize.pl:360
906 #: ../src/guestfs.pod:390
908 "The kernel version that the command runs under will be different from what "
913 #: ../src/guestfs.pod:395
915 "If the command needs to communicate with daemons, then most likely they "
920 #: ../src/guestfs.pod:400
921 msgid "The command will be running in limited memory."
925 #: ../src/guestfs.pod:404
927 "The network may not be available unless you enable it (see L</"
928 "guestfs_set_network>)."
932 #: ../src/guestfs.pod:409
933 msgid "Only supports Linux guests (not Windows, BSD, etc)."
937 #: ../src/guestfs.pod:413
939 "Architecture limitations (eg. won't work for a PPC guest on an X86 host)."
943 #: ../src/guestfs.pod:418
945 "For SELinux guests, you may need to enable SELinux and load policy first. "
946 "See L</SELINUX> in this manpage."
950 #: ../src/guestfs.pod:423
952 "I<Security:> It is not safe to run commands from untrusted, possibly "
953 "malicious guests. These commands may attempt to exploit your program by "
954 "sending unexpected output. They could also try to exploit the Linux kernel "
955 "or qemu provided by the libguestfs appliance. They could use the network "
956 "provided by the libguestfs appliance to bypass ordinary network partitions "
957 "and firewalls. They could use the elevated privileges or different SELinux "
958 "context of your program to their advantage."
962 #: ../src/guestfs.pod:432
964 "A secure alternative is to use libguestfs to install a \"firstboot\" script "
965 "(a script which runs when the guest next boots normally), and to have this "
966 "script run the commands you want in the normal context of the running guest, "
967 "network security and so on. For information about other security issues, "
972 #: ../src/guestfs.pod:440
974 "The two main API calls to run commands are L</guestfs_command> and L</"
975 "guestfs_sh> (there are also variations)."
979 #: ../src/guestfs.pod:443
981 "The difference is that L</guestfs_sh> runs commands using the shell, so any "
982 "shell globs, redirections, etc will work."
986 #: ../src/guestfs.pod:446
987 msgid "CONFIGURATION FILES"
988 msgstr "ФАЙЛИ НАЛАШТУВАННЯ"
991 #: ../src/guestfs.pod:448
993 "To read and write configuration files in Linux guest filesystems, we "
994 "strongly recommend using Augeas. For example, Augeas understands how to "
995 "read and write, say, a Linux shadow password file or X.org configuration "
996 "file, and so avoids you having to write that code."
1000 #: ../src/guestfs.pod:453
1002 "The main Augeas calls are bound through the C<guestfs_aug_*> APIs. We don't "
1003 "document Augeas itself here because there is excellent documentation on the "
1004 "L<http://augeas.net/> website."
1008 #: ../src/guestfs.pod:457
1010 "If you don't want to use Augeas (you fool!) then try calling L</"
1011 "guestfs_read_lines> to get the file as a list of lines which you can iterate "
1016 #: ../src/guestfs.pod:461
1021 #: ../src/guestfs.pod:463
1023 "We support SELinux guests. To ensure that labeling happens correctly in "
1024 "SELinux guests, you need to enable SELinux and load the guest's policy:"
1028 #: ../src/guestfs.pod:469 ../src/guestfs.pod:1281 ../src/guestfs.pod:1412
1029 #: ../src/guestfs.pod:2441
1034 #: ../src/guestfs.pod:471
1035 msgid "Before launching, do:"
1039 #: ../src/guestfs.pod:473
1042 " guestfs_set_selinux (g, 1);\n"
1047 #: ../src/guestfs.pod:475 ../src/guestfs.pod:1285 ../src/guestfs.pod:1416
1048 #: ../src/guestfs.pod:2466
1053 #: ../src/guestfs.pod:477
1055 "After mounting the guest's filesystem(s), load the policy. This is best "
1056 "done by running the L<load_policy(8)> command in the guest itself:"
1060 #: ../src/guestfs.pod:481
1063 " guestfs_sh (g, \"/usr/sbin/load_policy\");\n"
1068 #: ../src/guestfs.pod:483
1070 "(Older versions of C<load_policy> require you to specify the name of the "
1075 #: ../src/guestfs.pod:486 ../src/guestfs.pod:1422
1080 #: ../src/guestfs.pod:488
1082 "Optionally, set the security context for the API. The correct security "
1083 "context to use can only be known by inspecting the guest. As an example:"
1087 #: ../src/guestfs.pod:492
1090 " guestfs_setcon (g, \"unconfined_u:unconfined_r:unconfined_t:s0\");\n"
1095 #: ../src/guestfs.pod:496
1096 msgid "This will work for running commands and editing existing files."
1100 #: ../src/guestfs.pod:498
1102 "When new files are created, you may need to label them explicitly, for "
1103 "example by running the external command C<restorecon pathname>."
1107 #: ../src/guestfs.pod:502
1112 #: ../src/guestfs.pod:504
1114 "Certain calls are affected by the current file mode creation mask (the "
1115 "\"umask\"). In particular ones which create files or directories, such as "
1116 "L</guestfs_touch>, L</guestfs_mknod> or L</guestfs_mkdir>. This affects "
1117 "either the default mode that the file is created with or modifies the mode "
1122 #: ../src/guestfs.pod:510
1124 "The default umask is C<022>, so files are created with modes such as C<0644> "
1125 "and directories with C<0755>."
1129 #: ../src/guestfs.pod:513
1131 "There are two ways to avoid being affected by umask. Either set umask to 0 "
1132 "(call C<guestfs_umask (g, 0)> early after launching). Or call L</"
1133 "guestfs_chmod> after creating each file or directory."
1137 #: ../src/guestfs.pod:517
1138 msgid "For more information about umask, see L<umask(2)>."
1142 #: ../src/guestfs.pod:519 ../fish/guestfish.pod:765
1143 msgid "ENCRYPTED DISKS"
1147 #: ../src/guestfs.pod:521
1149 "Libguestfs allows you to access Linux guests which have been encrypted using "
1150 "whole disk encryption that conforms to the Linux Unified Key Setup (LUKS) "
1151 "standard. This includes nearly all whole disk encryption systems used by "
1152 "modern Linux guests."
1156 #: ../src/guestfs.pod:527
1158 "Use L</guestfs_vfs_type> to identify LUKS-encrypted block devices (it "
1159 "returns the string C<crypto_LUKS>)."
1163 #: ../src/guestfs.pod:530
1165 "Then open these devices by calling L</guestfs_luks_open>. Obviously you "
1166 "will require the passphrase!"
1170 #: ../src/guestfs.pod:533
1172 "Opening a LUKS device creates a new device mapper device called C</dev/"
1173 "mapper/mapname> (where C<mapname> is the string you supply to L</"
1174 "guestfs_luks_open>). Reads and writes to this mapper device are decrypted "
1175 "from and encrypted to the underlying block device respectively."
1179 #: ../src/guestfs.pod:539
1181 "LVM volume groups on the device can be made visible by calling L</"
1182 "guestfs_vgscan> followed by L</guestfs_vg_activate_all>. The logical volume"
1183 "(s) can now be mounted in the usual way."
1187 #: ../src/guestfs.pod:543
1189 "Use the reverse process to close a LUKS device. Unmount any logical volumes "
1190 "on it, deactivate the volume groups by caling C<guestfs_vg_activate (g, 0, "
1191 "[\"/dev/VG\"])>. Then close the mapper device by calling L</"
1192 "guestfs_luks_close> on the C</dev/mapper/mapname> device (I<not> the "
1193 "underlying encrypted block device)."
1197 #: ../src/guestfs.pod:550
1202 #: ../src/guestfs.pod:552
1204 "Libguestfs has APIs for inspecting an unknown disk image to find out if it "
1205 "contains operating systems, an install CD or a live CD. (These APIs used to "
1206 "be in a separate Perl-only library called L<Sys::Guestfs::Lib(3)> but since "
1207 "version 1.5.3 the most frequently used part of this library has been "
1208 "rewritten in C and moved into the core code)."
1212 #: ../src/guestfs.pod:559
1214 "Add all disks belonging to the unknown virtual machine and call L</"
1215 "guestfs_launch> in the usual way."
1219 #: ../src/guestfs.pod:562
1221 "Then call L</guestfs_inspect_os>. This function uses other libguestfs calls "
1222 "and certain heuristics, and returns a list of operating systems that were "
1223 "found. An empty list means none were found. A single element is the root "
1224 "filesystem of the operating system. For dual- or multi-boot guests, "
1225 "multiple roots can be returned, each one corresponding to a separate "
1226 "operating system. (Multi-boot virtual machines are extremely rare in the "
1227 "world of virtualization, but since this scenario can happen, we have built "
1228 "libguestfs to deal with it.)"
1232 #: ../src/guestfs.pod:571
1234 "For each root, you can then call various C<guestfs_inspect_get_*> functions "
1235 "to get additional details about that operating system. For example, call L</"
1236 "guestfs_inspect_get_type> to return the string C<windows> or C<linux> for "
1237 "Windows and Linux-based operating systems respectively."
1241 #: ../src/guestfs.pod:577
1243 "Un*x-like and Linux-based operating systems usually consist of several "
1244 "filesystems which are mounted at boot time (for example, a separate boot "
1245 "partition mounted on C</boot>). The inspection rules are able to detect how "
1246 "filesystems correspond to mount points. Call "
1247 "C<guestfs_inspect_get_mountpoints> to get this mapping. It might return a "
1248 "hash table like this example:"
1252 #: ../src/guestfs.pod:584
1255 " /boot => /dev/sda1\n"
1256 " / => /dev/vg_guest/lv_root\n"
1257 " /usr => /dev/vg_guest/lv_usr\n"
1262 #: ../src/guestfs.pod:588
1264 "The caller can then make calls to L</guestfs_mount_options> to mount the "
1265 "filesystems as suggested."
1269 #: ../src/guestfs.pod:591
1271 "Be careful to mount filesystems in the right order (eg. C</> before C</"
1272 "usr>). Sorting the keys of the hash by length, shortest first, should work."
1276 #: ../src/guestfs.pod:595
1278 "Inspection currently only works for some common operating systems. "
1279 "Contributors are welcome to send patches for other operating systems that we "
1280 "currently cannot detect."
1284 #: ../src/guestfs.pod:599
1286 "Encrypted disks must be opened before inspection. See L</ENCRYPTED DISKS> "
1287 "for more details. The L</guestfs_inspect_os> function just ignores any "
1288 "encrypted devices."
1292 #: ../src/guestfs.pod:603
1294 "A note on the implementation: The call L</guestfs_inspect_os> performs "
1295 "inspection and caches the results in the guest handle. Subsequent calls to "
1296 "C<guestfs_inspect_get_*> return this cached information, but I<do not> re-"
1297 "read the disks. If you change the content of the guest disks, you can redo "
1298 "inspection by calling L</guestfs_inspect_os> again. (L</"
1299 "guestfs_inspect_list_applications> works a little differently from the other "
1300 "calls and does read the disks. See documentation for that function for "
1305 #: ../src/guestfs.pod:612
1306 msgid "INSPECTING INSTALL DISKS"
1310 #: ../src/guestfs.pod:614
1312 "Libguestfs (since 1.9.4) can detect some install disks, install CDs, live "
1317 #: ../src/guestfs.pod:617
1319 "Call L</guestfs_inspect_get_format> to return the format of the operating "
1320 "system, which currently can be C<installed> (a regular operating system) or "
1321 "C<installer> (some sort of install disk)."
1325 #: ../src/guestfs.pod:621
1327 "Further information is available about the operating system that can be "
1328 "installed using the regular inspection APIs like L</"
1329 "guestfs_inspect_get_product_name>, L</guestfs_inspect_get_major_version> etc."
1333 #: ../src/guestfs.pod:626
1335 "Some additional information specific to installer disks is also available "
1336 "from the L</guestfs_inspect_is_live>, L</guestfs_inspect_is_netinst> and L</"
1337 "guestfs_inspect_is_multipart> calls."
1341 #: ../src/guestfs.pod:631
1342 msgid "SPECIAL CONSIDERATIONS FOR WINDOWS GUESTS"
1346 #: ../src/guestfs.pod:633
1348 "Libguestfs can mount NTFS partitions. It does this using the L<http://www."
1349 "ntfs-3g.org/> driver."
1353 #: ../src/guestfs.pod:636
1354 msgid "DRIVE LETTERS AND PATHS"
1358 #: ../src/guestfs.pod:638
1360 "DOS and Windows still use drive letters, and the filesystems are always "
1361 "treated as case insensitive by Windows itself, and therefore you might find "
1362 "a Windows configuration file referring to a path like C<c:\\windows"
1363 "\\system32>. When the filesystem is mounted in libguestfs, that directory "
1364 "might be referred to as C</WINDOWS/System32>."
1368 #: ../src/guestfs.pod:644
1370 "Drive letter mappings are outside the scope of libguestfs. You have to use "
1371 "libguestfs to read the appropriate Windows Registry and configuration files, "
1372 "to determine yourself how drives are mapped (see also L<hivex(3)> and L<virt-"
1377 #: ../src/guestfs.pod:649
1379 "Replacing backslash characters with forward slash characters is also outside "
1380 "the scope of libguestfs, but something that you can easily do."
1384 #: ../src/guestfs.pod:652
1386 "Where we can help is in resolving the case insensitivity of paths. For "
1387 "this, call L</guestfs_case_sensitive_path>."
1391 #: ../src/guestfs.pod:655
1392 msgid "ACCESSING THE WINDOWS REGISTRY"
1396 #: ../src/guestfs.pod:657
1398 "Libguestfs also provides some help for decoding Windows Registry \"hive\" "
1399 "files, through the library C<hivex> which is part of the libguestfs project "
1400 "although ships as a separate tarball. You have to locate and download the "
1401 "hive file(s) yourself, and then pass them to C<hivex> functions. See also "
1402 "the programs L<hivexml(1)>, L<hivexsh(1)>, L<hivexregedit(1)> and L<virt-win-"
1403 "reg(1)> for more help on this issue."
1407 #: ../src/guestfs.pod:665
1408 msgid "SYMLINKS ON NTFS-3G FILESYSTEMS"
1412 #: ../src/guestfs.pod:667
1414 "Ntfs-3g tries to rewrite \"Junction Points\" and NTFS \"symbolic links\" to "
1415 "provide something which looks like a Linux symlink. The way it tries to do "
1416 "the rewriting is described here:"
1420 #: ../src/guestfs.pod:671
1422 "L<http://www.tuxera.com/community/ntfs-3g-advanced/junction-points-and-"
1425 "L<http://www.tuxera.com/community/ntfs-3g-advanced/junction-points-and-"
1429 #: ../src/guestfs.pod:673
1431 "The essential problem is that ntfs-3g simply does not have enough "
1432 "information to do a correct job. NTFS links can contain drive letters and "
1433 "references to external device GUIDs that ntfs-3g has no way of resolving. "
1434 "It is almost certainly the case that libguestfs callers should ignore what "
1435 "ntfs-3g does (ie. don't use L</guestfs_readlink> on NTFS volumes)."
1439 #: ../src/guestfs.pod:680
1441 "Instead if you encounter a symbolic link on an ntfs-3g filesystem, use L</"
1442 "guestfs_lgetxattr> to read the C<system.ntfs_reparse_data> extended "
1443 "attribute, and read the raw reparse data from that (you can find the format "
1444 "documented in various places around the web)."
1448 #: ../src/guestfs.pod:685
1449 msgid "EXTENDED ATTRIBUTES ON NTFS-3G FILESYSTEMS"
1453 #: ../src/guestfs.pod:687
1455 "There are other useful extended attributes that can be read from ntfs-3g "
1456 "filesystems (using L</guestfs_getxattr>). See:"
1460 #: ../src/guestfs.pod:690
1462 "L<http://www.tuxera.com/community/ntfs-3g-advanced/extended-attributes/>"
1464 "L<http://www.tuxera.com/community/ntfs-3g-advanced/extended-attributes/>"
1467 #: ../src/guestfs.pod:692
1468 msgid "USING LIBGUESTFS WITH OTHER PROGRAMMING LANGUAGES"
1472 #: ../src/guestfs.pod:694
1474 "Although we don't want to discourage you from using the C API, we will "
1475 "mention here that the same API is also available in other languages."
1479 #: ../src/guestfs.pod:697
1481 "The API is broadly identical in all supported languages. This means that "
1482 "the C call C<guestfs_add_drive_ro(g,file)> is C<$g-E<gt>add_drive_ro($file)> "
1483 "in Perl, C<g.add_drive_ro(file)> in Python, and C<g#add_drive_ro file> in "
1484 "OCaml. In other words, a straightforward, predictable isomorphism between "
1489 #: ../src/guestfs.pod:703
1491 "Error messages are automatically transformed into exceptions if the language "
1496 #: ../src/guestfs.pod:706
1498 "We don't try to \"object orientify\" parts of the API in OO languages, "
1499 "although contributors are welcome to write higher level APIs above what we "
1500 "provide in their favourite languages if they wish."
1504 #: ../src/guestfs.pod:712
1509 #: ../src/guestfs.pod:714
1511 "You can use the I<guestfs.h> header file from C++ programs. The C++ API is "
1512 "identical to the C API. C++ classes and exceptions are not used."
1516 #: ../src/guestfs.pod:718
1521 #: ../src/guestfs.pod:720
1523 "The C# bindings are highly experimental. Please read the warnings at the "
1524 "top of C<csharp/Libguestfs.cs>."
1528 #: ../src/guestfs.pod:723
1533 #: ../src/guestfs.pod:725
1535 "This is the only language binding that is working but incomplete. Only "
1536 "calls which return simple integers have been bound in Haskell, and we are "
1537 "looking for help to complete this binding."
1541 #: ../src/guestfs.pod:729
1546 #: ../src/guestfs.pod:731
1548 "Full documentation is contained in the Javadoc which is distributed with "
1553 #: ../src/guestfs.pod:734
1558 #: ../src/guestfs.pod:736
1559 msgid "See L<guestfs-ocaml(3)>."
1560 msgstr "Див. L<guestfs-ocaml(3)>."
1563 #: ../src/guestfs.pod:738
1568 #: ../src/guestfs.pod:740
1569 msgid "See L<guestfs-perl(3)> and L<Sys::Guestfs(3)>."
1570 msgstr "Див. L<guestfs-perl(3)> та L<Sys::Guestfs(3)>."
1573 #: ../src/guestfs.pod:742
1578 #: ../src/guestfs.pod:744
1580 "For documentation see C<README-PHP> supplied with libguestfs sources or in "
1581 "the php-libguestfs package for your distribution."
1585 #: ../src/guestfs.pod:747
1586 msgid "The PHP binding only works correctly on 64 bit machines."
1590 #: ../src/guestfs.pod:749
1595 #: ../src/guestfs.pod:751
1596 msgid "See L<guestfs-python(3)>."
1597 msgstr "Див. L<guestfs-python(3)>."
1600 #: ../src/guestfs.pod:753
1605 #: ../src/guestfs.pod:755
1606 msgid "See L<guestfs-ruby(3)>."
1607 msgstr "Див. L<guestfs-ruby(3)>."
1610 #: ../src/guestfs.pod:757
1611 msgid "B<shell scripts>"
1612 msgstr "B<скрипти оболонки>"
1615 #: ../src/guestfs.pod:759
1616 msgid "See L<guestfish(1)>."
1617 msgstr "Див. L<guestfish(1)>."
1620 #: ../src/guestfs.pod:763
1621 msgid "LIBGUESTFS GOTCHAS"
1625 #: ../src/guestfs.pod:765
1627 "L<http://en.wikipedia.org/wiki/Gotcha_(programming)>: \"A feature of a "
1628 "system [...] that works in the way it is documented but is counterintuitive "
1629 "and almost invites mistakes.\""
1633 #: ../src/guestfs.pod:769
1635 "Since we developed libguestfs and the associated tools, there are several "
1636 "things we would have designed differently, but are now stuck with for "
1637 "backwards compatibility or other reasons. If there is ever a libguestfs 2.0 "
1638 "release, you can expect these to change. Beware of them."
1642 #: ../src/guestfs.pod:777
1643 msgid "Autosync / forgetting to sync."
1647 #: ../src/guestfs.pod:779
1649 "When modifying a filesystem from C or another language, you B<must> unmount "
1650 "all filesystems and call L</guestfs_sync> explicitly before you close the "
1651 "libguestfs handle. You can also call:"
1655 #: ../src/guestfs.pod:783
1658 " guestfs_set_autosync (g, 1);\n"
1663 #: ../src/guestfs.pod:785
1665 "to have the unmount/sync done automatically for you when the handle 'g' is "
1666 "closed. (This feature is called \"autosync\", L</guestfs_set_autosync> q.v.)"
1670 #: ../src/guestfs.pod:789
1672 "If you forget to do this, then it is entirely possible that your changes "
1673 "won't be written out, or will be partially written, or (very rarely) that "
1674 "you'll get disk corruption."
1678 #: ../src/guestfs.pod:793
1680 "Note that in L<guestfish(3)> autosync is the default. So quick and dirty "
1681 "guestfish scripts that forget to sync will work just fine, which can make "
1682 "this very puzzling if you are trying to debug a problem."
1686 #: ../src/guestfs.pod:797
1688 "Update: Autosync is enabled by default for all API users starting from "
1689 "libguestfs 1.5.24."
1693 #: ../src/guestfs.pod:800
1694 msgid "Mount option C<-o sync> should not be the default."
1698 #: ../src/guestfs.pod:802
1700 "If you use L</guestfs_mount>, then C<-o sync,noatime> are added implicitly. "
1701 "However C<-o sync> does not add any reliability benefit, but does have a "
1702 "very large performance impact."
1706 #: ../src/guestfs.pod:806
1708 "The work around is to use L</guestfs_mount_options> and set the mount "
1709 "options that you actually want to use."
1713 #: ../src/guestfs.pod:809
1714 msgid "Read-only should be the default."
1718 #: ../src/guestfs.pod:811
1720 "In L<guestfish(3)>, I<--ro> should be the default, and you should have to "
1721 "specify I<--rw> if you want to make changes to the image."
1725 #: ../src/guestfs.pod:814
1726 msgid "This would reduce the potential to corrupt live VM images."
1730 #: ../src/guestfs.pod:816
1732 "Note that many filesystems change the disk when you just mount and unmount, "
1733 "even if you didn't perform any writes. You need to use L</"
1734 "guestfs_add_drive_ro> to guarantee that the disk is not changed."
1738 #: ../src/guestfs.pod:820
1739 msgid "guestfish command line is hard to use."
1743 #: ../src/guestfs.pod:822
1745 "C<guestfish disk.img> doesn't do what people expect (open C<disk.img> for "
1746 "examination). It tries to run a guestfish command C<disk.img> which doesn't "
1747 "exist, so it fails. In earlier versions of guestfish the error message was "
1748 "also unintuitive, but we have corrected this since. Like the Bourne shell, "
1749 "we should have used C<guestfish -c command> to run commands."
1753 #: ../src/guestfs.pod:829
1754 msgid "guestfish megabyte modifiers don't work right on all commands"
1758 #: ../src/guestfs.pod:831
1760 "In recent guestfish you can use C<1M> to mean 1 megabyte (and similarly for "
1761 "other modifiers). What guestfish actually does is to multiply the number "
1762 "part by the modifier part and pass the result to the C API. However this "
1763 "doesn't work for a few APIs which aren't expecting bytes, but are already "
1764 "expecting some other unit (eg. megabytes)."
1768 #: ../src/guestfs.pod:838
1769 msgid "The most common is L</guestfs_lvcreate>. The guestfish command:"
1773 #: ../src/guestfs.pod:840
1776 " lvcreate LV VG 100M\n"
1781 #: ../src/guestfs.pod:842
1783 "does not do what you might expect. Instead because L</guestfs_lvcreate> is "
1784 "already expecting megabytes, this tries to create a 100 I<terabyte> (100 "
1785 "megabytes * megabytes) logical volume. The error message you get from this "
1786 "is also a little obscure."
1790 #: ../src/guestfs.pod:847
1792 "This could be fixed in the generator by specially marking parameters and "
1793 "return values which take bytes or other units."
1797 #: ../src/guestfs.pod:850
1798 msgid "Ambiguity between devices and paths"
1802 #: ../src/guestfs.pod:852
1804 "There is a subtle ambiguity in the API between a device name (eg. C</dev/"
1805 "sdb2>) and a similar pathname. A file might just happen to be called "
1806 "C<sdb2> in the directory C</dev> (consider some non-Unix VM image)."
1810 #: ../src/guestfs.pod:857
1812 "In the current API we usually resolve this ambiguity by having two separate "
1813 "calls, for example L</guestfs_checksum> and L</guestfs_checksum_device>. "
1814 "Some API calls are ambiguous and (incorrectly) resolve the problem by "
1815 "detecting if the path supplied begins with C</dev/>."
1819 #: ../src/guestfs.pod:863
1821 "To avoid both the ambiguity and the need to duplicate some calls, we could "
1822 "make paths/devices into structured names. One way to do this would be to "
1823 "use a notation like grub (C<hd(0,0)>), although nobody really likes this "
1824 "aspect of grub. Another way would be to use a structured type, equivalent "
1825 "to this OCaml type:"
1829 #: ../src/guestfs.pod:869
1832 " type path = Path of string | Device of int | Partition of int * int\n"
1837 #: ../src/guestfs.pod:871
1838 msgid "which would allow you to pass arguments like:"
1842 #: ../src/guestfs.pod:873
1845 " Path \"/foo/bar\"\n"
1846 " Device 1 (* /dev/sdb, or perhaps /dev/sda *)\n"
1847 " Partition (1, 2) (* /dev/sdb2 (or is it /dev/sda2 or /dev/sdb3?) *)\n"
1848 " Path \"/dev/sdb2\" (* not a device *)\n"
1853 #: ../src/guestfs.pod:878
1855 "As you can see there are still problems to resolve even with this "
1856 "representation. Also consider how it might work in guestfish."
1860 #: ../src/guestfs.pod:883
1861 msgid "PROTOCOL LIMITS"
1865 #: ../src/guestfs.pod:885
1867 "Internally libguestfs uses a message-based protocol to pass API calls and "
1868 "their responses to and from a small \"appliance\" (see L</INTERNALS> for "
1869 "plenty more detail about this). The maximum message size used by the "
1870 "protocol is slightly less than 4 MB. For some API calls you may need to be "
1871 "aware of this limit. The API calls which may be affected are individually "
1872 "documented, with a link back to this section of the documentation."
1876 #: ../src/guestfs.pod:893
1878 "A simple call such as L</guestfs_cat> returns its result (the file data) in "
1879 "a simple string. Because this string is at some point internally encoded as "
1880 "a message, the maximum size that it can return is slightly under 4 MB. If "
1881 "the requested file is larger than this then you will get an error."
1885 #: ../src/guestfs.pod:899
1887 "In order to transfer large files into and out of the guest filesystem, you "
1888 "need to use particular calls that support this. The sections L</UPLOADING> "
1889 "and L</DOWNLOADING> document how to do this."
1893 #: ../src/guestfs.pod:903
1895 "You might also consider mounting the disk image using our FUSE filesystem "
1896 "support (L<guestmount(1)>)."
1900 #: ../src/guestfs.pod:906
1901 msgid "KEYS AND PASSPHRASES"
1905 #: ../src/guestfs.pod:908
1907 "Certain libguestfs calls take a parameter that contains sensitive key "
1908 "material, passed in as a C string."
1912 #: ../src/guestfs.pod:911
1914 "In the future we would hope to change the libguestfs implementation so that "
1915 "keys are L<mlock(2)>-ed into physical RAM, and thus can never end up in "
1916 "swap. However this is I<not> done at the moment, because of the complexity "
1917 "of such an implementation."
1921 #: ../src/guestfs.pod:916
1923 "Therefore you should be aware that any key parameter you pass to libguestfs "
1924 "might end up being written out to the swap partition. If this is a concern, "
1925 "scrub the swap partition or don't use libguestfs on encrypted devices."
1929 #: ../src/guestfs.pod:921
1930 msgid "MULTIPLE HANDLES AND MULTIPLE THREADS"
1934 #: ../src/guestfs.pod:923
1936 "All high-level libguestfs actions are synchronous. If you want to use "
1937 "libguestfs asynchronously then you must create a thread."
1941 #: ../src/guestfs.pod:926
1943 "Only use the handle from a single thread. Either use the handle exclusively "
1944 "from one thread, or provide your own mutex so that two threads cannot issue "
1945 "calls on the same handle at the same time."
1949 #: ../src/guestfs.pod:930
1951 "See the graphical program guestfs-browser for one possible architecture for "
1952 "multithreaded programs using libvirt and libguestfs."
1956 #: ../src/guestfs.pod:933
1961 #: ../src/guestfs.pod:935
1963 "Libguestfs needs a supermin appliance, which it finds by looking along an "
1968 #: ../src/guestfs.pod:938
1970 "By default it looks for these in the directory C<$libdir/guestfs> (eg. C</"
1971 "usr/local/lib/guestfs> or C</usr/lib64/guestfs>)."
1975 #: ../src/guestfs.pod:941
1977 "Use L</guestfs_set_path> or set the environment variable L</LIBGUESTFS_PATH> "
1978 "to change the directories that libguestfs will search in. The value is a "
1979 "colon-separated list of paths. The current directory is I<not> searched "
1980 "unless the path contains an empty element or C<.>. For example "
1981 "C<LIBGUESTFS_PATH=:/usr/lib/guestfs> would search the current directory and "
1982 "then C</usr/lib/guestfs>."
1986 #: ../src/guestfs.pod:948
1987 msgid "QEMU WRAPPERS"
1991 #: ../src/guestfs.pod:950
1993 "If you want to compile your own qemu, run qemu from a non-standard location, "
1994 "or pass extra arguments to qemu, then you can write a shell-script wrapper "
1999 #: ../src/guestfs.pod:954
2001 "There is one important rule to remember: you I<must C<exec qemu>> as the "
2002 "last command in the shell script (so that qemu replaces the shell and "
2003 "becomes the direct child of the libguestfs-using program). If you don't do "
2004 "this, then the qemu process won't be cleaned up correctly."
2008 #: ../src/guestfs.pod:959
2010 "Here is an example of a wrapper, where I have built my own copy of qemu from "
2015 #: ../src/guestfs.pod:962
2019 " qemudir=/home/rjones/d/qemu\n"
2020 " exec $qemudir/x86_64-softmmu/qemu-system-x86_64 -L $qemudir/pc-bios \"$@\"\n"
2025 #: ../src/guestfs.pod:966
2027 "Save this script as C</tmp/qemu.wrapper> (or wherever), C<chmod +x>, and "
2028 "then use it by setting the LIBGUESTFS_QEMU environment variable. For "
2033 #: ../src/guestfs.pod:970
2036 " LIBGUESTFS_QEMU=/tmp/qemu.wrapper guestfish\n"
2041 #: ../src/guestfs.pod:972
2043 "Note that libguestfs also calls qemu with the -help and -version options in "
2044 "order to determine features."
2048 #: ../src/guestfs.pod:975
2049 msgid "ATTACHING TO RUNNING DAEMONS"
2053 #: ../src/guestfs.pod:977
2055 "I<Note (1):> This is B<highly experimental> and has a tendency to eat "
2056 "babies. Use with caution."
2060 #: ../src/guestfs.pod:980
2062 "I<Note (2):> This section explains how to attach to a running daemon from a "
2063 "low level perspective. For most users, simply using virt tools such as "
2064 "L<guestfish(1)> with the I<--live> option will \"just work\"."
2068 #: ../src/guestfs.pod:984
2069 msgid "Using guestfs_set_attach_method"
2073 #: ../src/guestfs.pod:986
2075 "By calling L</guestfs_set_attach_method> you can change how the library "
2076 "connects to the C<guestfsd> daemon in L</guestfs_launch> (read L</"
2077 "ARCHITECTURE> for some background)."
2081 #: ../src/guestfs.pod:990
2083 "The normal attach method is C<appliance>, where a small appliance is created "
2084 "containing the daemon, and then the library connects to this."
2088 #: ../src/guestfs.pod:993
2090 "Setting attach method to C<unix:I<path>> (where I<path> is the path of a "
2091 "Unix domain socket) causes L</guestfs_launch> to connect to an existing "
2092 "daemon over the Unix domain socket."
2096 #: ../src/guestfs.pod:997
2098 "The normal use for this is to connect to a running virtual machine that "
2099 "contains a C<guestfsd> daemon, and send commands so you can read and write "
2100 "files inside the live virtual machine."
2104 #: ../src/guestfs.pod:1001
2105 msgid "Using guestfs_add_domain with live flag"
2109 #: ../src/guestfs.pod:1003
2111 "L</guestfs_add_domain> provides some help for getting the correct attach "
2112 "method. If you pass the C<live> option to this function, then (if the "
2113 "virtual machine is running) it will examine the libvirt XML looking for a "
2114 "virtio-serial channel to connect to:"
2118 #: ../src/guestfs.pod:1009
2125 " <channel type='unix'>\n"
2126 " <source mode='bind' path='/path/to/socket'/>\n"
2127 " <target type='virtio' name='org.libguestfs.channel.0'/>\n"
2136 #: ../src/guestfs.pod:1021
2138 "L</guestfs_add_domain> extracts C</path/to/socket> and sets the attach "
2139 "method to C<unix:/path/to/socket>."
2143 #: ../src/guestfs.pod:1024
2145 "Some of the libguestfs tools (including guestfish) support a I<--live> "
2146 "option which is passed through to L</guestfs_add_domain> thus allowing you "
2147 "to attach to and modify live virtual machines."
2151 #: ../src/guestfs.pod:1028
2153 "The virtual machine needs to have been set up beforehand so that it has the "
2154 "virtio-serial channel and so that guestfsd is running inside it."
2158 #: ../src/guestfs.pod:1032
2159 msgid "ABI GUARANTEE"
2163 #: ../src/guestfs.pod:1034
2165 "We guarantee the libguestfs ABI (binary interface), for public, high-level "
2166 "actions as outlined in this section. Although we will deprecate some "
2167 "actions, for example if they get replaced by newer calls, we will keep the "
2168 "old actions forever. This allows you the developer to program in confidence "
2169 "against the libguestfs API."
2173 #: ../src/guestfs.pod:1040
2174 msgid "BLOCK DEVICE NAMING"
2178 #: ../src/guestfs.pod:1042
2180 "In the kernel there is now quite a profusion of schemata for naming block "
2181 "devices (in this context, by I<block device> I mean a physical or virtual "
2182 "hard drive). The original Linux IDE driver used names starting with C</dev/"
2183 "hd*>. SCSI devices have historically used a different naming scheme, C</dev/"
2184 "sd*>. When the Linux kernel I<libata> driver became a popular replacement "
2185 "for the old IDE driver (particularly for SATA devices) those devices also "
2186 "used the C</dev/sd*> scheme. Additionally we now have virtual machines with "
2187 "paravirtualized drivers. This has created several different naming systems, "
2188 "such as C</dev/vd*> for virtio disks and C</dev/xvd*> for Xen PV disks."
2192 #: ../src/guestfs.pod:1054
2194 "As discussed above, libguestfs uses a qemu appliance running an embedded "
2195 "Linux kernel to access block devices. We can run a variety of appliances "
2196 "based on a variety of Linux kernels."
2200 #: ../src/guestfs.pod:1058
2202 "This causes a problem for libguestfs because many API calls use device or "
2203 "partition names. Working scripts and the recipe (example) scripts that we "
2204 "make available over the internet could fail if the naming scheme changes."
2208 #: ../src/guestfs.pod:1063
2210 "Therefore libguestfs defines C</dev/sd*> as the I<standard naming scheme>. "
2211 "Internally C</dev/sd*> names are translated, if necessary, to other names as "
2212 "required. For example, under RHEL 5 which uses the C</dev/hd*> scheme, any "
2213 "device parameter C</dev/sda2> is translated to C</dev/hda2> transparently."
2217 #: ../src/guestfs.pod:1069
2219 "Note that this I<only> applies to parameters. The L</guestfs_list_devices>, "
2220 "L</guestfs_list_partitions> and similar calls return the true names of the "
2221 "devices and partitions as known to the appliance."
2225 #: ../src/guestfs.pod:1074
2226 msgid "ALGORITHM FOR BLOCK DEVICE NAME TRANSLATION"
2230 #: ../src/guestfs.pod:1076
2232 "Usually this translation is transparent. However in some (very rare) cases "
2233 "you may need to know the exact algorithm. Such cases include where you use "
2234 "L</guestfs_config> to add a mixture of virtio and IDE devices to the qemu-"
2235 "based appliance, so have a mixture of C</dev/sd*> and C</dev/vd*> devices."
2239 #: ../src/guestfs.pod:1082
2241 "The algorithm is applied only to I<parameters> which are known to be either "
2242 "device or partition names. Return values from functions such as L</"
2243 "guestfs_list_devices> are never changed."
2247 #: ../src/guestfs.pod:1090
2248 msgid "Is the string a parameter which is a device or partition name?"
2252 #: ../src/guestfs.pod:1094
2253 msgid "Does the string begin with C</dev/sd>?"
2257 #: ../src/guestfs.pod:1098
2259 "Does the named device exist? If so, we use that device. However if I<not> "
2260 "then we continue with this algorithm."
2264 #: ../src/guestfs.pod:1103
2265 msgid "Replace initial C</dev/sd> string with C</dev/hd>."
2269 #: ../src/guestfs.pod:1105
2270 msgid "For example, change C</dev/sda2> to C</dev/hda2>."
2274 #: ../src/guestfs.pod:1107
2275 msgid "If that named device exists, use it. If not, continue."
2279 #: ../src/guestfs.pod:1111
2280 msgid "Replace initial C</dev/sd> string with C</dev/vd>."
2284 #: ../src/guestfs.pod:1113
2285 msgid "If that named device exists, use it. If not, return an error."
2289 #: ../src/guestfs.pod:1117
2290 msgid "PORTABILITY CONCERNS WITH BLOCK DEVICE NAMING"
2294 #: ../src/guestfs.pod:1119
2296 "Although the standard naming scheme and automatic translation is useful for "
2297 "simple programs and guestfish scripts, for larger programs it is best not to "
2298 "rely on this mechanism."
2302 #: ../src/guestfs.pod:1123
2304 "Where possible for maximum future portability programs using libguestfs "
2305 "should use these future-proof techniques:"
2309 #: ../src/guestfs.pod:1130
2311 "Use L</guestfs_list_devices> or L</guestfs_list_partitions> to list actual "
2312 "device names, and then use those names directly."
2316 #: ../src/guestfs.pod:1133
2318 "Since those device names exist by definition, they will never be translated."
2322 #: ../src/guestfs.pod:1138
2324 "Use higher level ways to identify filesystems, such as LVM names, UUIDs and "
2325 "filesystem labels."
2329 #: ../src/guestfs.pod:1143
2334 #: ../src/guestfs.pod:1145
2336 "This section discusses security implications of using libguestfs, "
2337 "particularly with untrusted or malicious guests or disk images."
2341 #: ../src/guestfs.pod:1148
2342 msgid "GENERAL SECURITY CONSIDERATIONS"
2346 #: ../src/guestfs.pod:1150
2348 "Be careful with any files or data that you download from a guest (by "
2349 "\"download\" we mean not just the L</guestfs_download> command but any "
2350 "command that reads files, filenames, directories or anything else from a "
2351 "disk image). An attacker could manipulate the data to fool your program "
2352 "into doing the wrong thing. Consider cases such as:"
2356 #: ../src/guestfs.pod:1160
2357 msgid "the data (file etc) not being present"
2361 #: ../src/guestfs.pod:1164
2362 msgid "being present but empty"
2366 #: ../src/guestfs.pod:1168
2367 msgid "being much larger than normal"
2371 #: ../src/guestfs.pod:1172
2372 msgid "containing arbitrary 8 bit data"
2376 #: ../src/guestfs.pod:1176
2377 msgid "being in an unexpected character encoding"
2381 #: ../src/guestfs.pod:1180
2382 msgid "containing homoglyphs."
2386 #: ../src/guestfs.pod:1184
2387 msgid "SECURITY OF MOUNTING FILESYSTEMS"
2391 #: ../src/guestfs.pod:1186
2393 "When you mount a filesystem under Linux, mistakes in the kernel filesystem "
2394 "(VFS) module can sometimes be escalated into exploits by deliberately "
2395 "creating a malicious, malformed filesystem. These exploits are very severe "
2396 "for two reasons. Firstly there are very many filesystem drivers in the "
2397 "kernel, and many of them are infrequently used and not much developer "
2398 "attention has been paid to the code. Linux userspace helps potential "
2399 "crackers by detecting the filesystem type and automatically choosing the "
2400 "right VFS driver, even if that filesystem type is obscure or unexpected for "
2401 "the administrator. Secondly, a kernel-level exploit is like a local root "
2402 "exploit (worse in some ways), giving immediate and total access to the "
2403 "system right down to the hardware level."
2407 #: ../src/guestfs.pod:1199
2409 "That explains why you should never mount a filesystem from an untrusted "
2410 "guest on your host kernel. How about libguestfs? We run a Linux kernel "
2411 "inside a qemu virtual machine, usually running as a non-root user. The "
2412 "attacker would need to write a filesystem which first exploited the kernel, "
2413 "and then exploited either qemu virtualization (eg. a faulty qemu driver) or "
2414 "the libguestfs protocol, and finally to be as serious as the host kernel "
2415 "exploit it would need to escalate its privileges to root. This multi-step "
2416 "escalation, performed by a static piece of data, is thought to be extremely "
2417 "hard to do, although we never say 'never' about security issues."
2421 #: ../src/guestfs.pod:1210
2423 "In any case callers can reduce the attack surface by forcing the filesystem "
2424 "type when mounting (use L</guestfs_mount_vfs>)."
2428 #: ../src/guestfs.pod:1213
2429 msgid "PROTOCOL SECURITY"
2433 #: ../src/guestfs.pod:1215
2435 "The protocol is designed to be secure, being based on RFC 4506 (XDR) with a "
2436 "defined upper message size. However a program that uses libguestfs must "
2437 "also take care - for example you can write a program that downloads a binary "
2438 "from a disk image and executes it locally, and no amount of protocol "
2439 "security will save you from the consequences."
2443 #: ../src/guestfs.pod:1221
2444 msgid "INSPECTION SECURITY"
2448 #: ../src/guestfs.pod:1223
2450 "Parts of the inspection API (see L</INSPECTION>) return untrusted strings "
2451 "directly from the guest, and these could contain any 8 bit data. Callers "
2452 "should be careful to escape these before printing them to a structured file "
2453 "(for example, use HTML escaping if creating a web page)."
2457 #: ../src/guestfs.pod:1229
2459 "Guest configuration may be altered in unusual ways by the administrator of "
2460 "the virtual machine, and may not reflect reality (particularly for untrusted "
2461 "or actively malicious guests). For example we parse the hostname from "
2462 "configuration files like C</etc/sysconfig/network> that we find in the "
2463 "guest, but the guest administrator can easily manipulate these files to "
2464 "provide the wrong hostname."
2468 #: ../src/guestfs.pod:1237
2470 "The inspection API parses guest configuration using two external libraries: "
2471 "Augeas (Linux configuration) and hivex (Windows Registry). Both are "
2472 "designed to be robust in the face of malicious data, although denial of "
2473 "service attacks are still possible, for example with oversized configuration "
2478 #: ../src/guestfs.pod:1243
2479 msgid "RUNNING UNTRUSTED GUEST COMMANDS"
2483 #: ../src/guestfs.pod:1245
2485 "Be very cautious about running commands from the guest. By running a "
2486 "command in the guest, you are giving CPU time to a binary that you do not "
2487 "control, under the same user account as the library, albeit wrapped in qemu "
2488 "virtualization. More information and alternatives can be found in the "
2489 "section L</RUNNING COMMANDS>."
2493 #: ../src/guestfs.pod:1251
2494 msgid "CVE-2010-3851"
2495 msgstr "CVE-2010-3851"
2498 #: ../src/guestfs.pod:1253
2499 msgid "https://bugzilla.redhat.com/642934"
2500 msgstr "https://bugzilla.redhat.com/642934"
2503 #: ../src/guestfs.pod:1255
2505 "This security bug concerns the automatic disk format detection that qemu "
2506 "does on disk images."
2510 #: ../src/guestfs.pod:1258
2512 "A raw disk image is just the raw bytes, there is no header. Other disk "
2513 "images like qcow2 contain a special header. Qemu deals with this by looking "
2514 "for one of the known headers, and if none is found then assuming the disk "
2515 "image must be raw."
2519 #: ../src/guestfs.pod:1263
2521 "This allows a guest which has been given a raw disk image to write some "
2522 "other header. At next boot (or when the disk image is accessed by "
2523 "libguestfs) qemu would do autodetection and think the disk image format was, "
2524 "say, qcow2 based on the header written by the guest."
2528 #: ../src/guestfs.pod:1268
2530 "This in itself would not be a problem, but qcow2 offers many features, one "
2531 "of which is to allow a disk image to refer to another image (called the "
2532 "\"backing disk\"). It does this by placing the path to the backing disk "
2533 "into the qcow2 header. This path is not validated and could point to any "
2534 "host file (eg. \"/etc/passwd\"). The backing disk is then exposed through "
2535 "\"holes\" in the qcow2 disk image, which of course is completely under the "
2536 "control of the attacker."
2540 #: ../src/guestfs.pod:1276
2542 "In libguestfs this is rather hard to exploit except under two circumstances:"
2546 #: ../src/guestfs.pod:1283
2547 msgid "You have enabled the network or have opened the disk in write mode."
2551 #: ../src/guestfs.pod:1287
2553 "You are also running untrusted code from the guest (see L</RUNNING "
2558 #: ../src/guestfs.pod:1292
2560 "The way to avoid this is to specify the expected disk format when adding "
2561 "disks (the optional C<format> option to L</guestfs_add_drive_opts>). You "
2562 "should always do this if the disk is raw format, and it's a good idea for "
2567 #: ../src/guestfs.pod:1297
2569 "For disks added from libvirt using calls like L</guestfs_add_domain>, the "
2570 "format is fetched from libvirt and passed through."
2574 #: ../src/guestfs.pod:1300
2576 "For libguestfs tools, use the I<--format> command line parameter as "
2581 #: ../src/guestfs.pod:1303
2582 msgid "CONNECTION MANAGEMENT"
2586 #: ../src/guestfs.pod:1305
2591 #: ../src/guestfs.pod:1307
2593 "C<guestfs_h> is the opaque type representing a connection handle. Create a "
2594 "handle by calling L</guestfs_create>. Call L</guestfs_close> to free the "
2595 "handle and release all resources used."
2599 #: ../src/guestfs.pod:1311
2601 "For information on using multiple handles and threads, see the section L</"
2602 "MULTIPLE HANDLES AND MULTIPLE THREADS> below."
2606 #: ../src/guestfs.pod:1314
2607 msgid "guestfs_create"
2611 #: ../src/guestfs.pod:1316
2614 " guestfs_h *guestfs_create (void);\n"
2619 #: ../src/guestfs.pod:1318
2620 msgid "Create a connection handle."
2624 #: ../src/guestfs.pod:1320
2626 "You have to call L</guestfs_add_drive_opts> (or one of the equivalent calls) "
2627 "on the handle at least once."
2631 #: ../src/guestfs.pod:1323
2633 "This function returns a non-NULL pointer to a handle on success or NULL on "
2638 #: ../src/guestfs.pod:1326
2639 msgid "After configuring the handle, you have to call L</guestfs_launch>."
2643 #: ../src/guestfs.pod:1328
2645 "You may also want to configure error handling for the handle. See L</ERROR "
2646 "HANDLING> section below."
2650 #: ../src/guestfs.pod:1331
2651 msgid "guestfs_close"
2655 #: ../src/guestfs.pod:1333
2658 " void guestfs_close (guestfs_h *g);\n"
2663 #: ../src/guestfs.pod:1335
2664 msgid "This closes the connection handle and frees up all resources used."
2668 #: ../src/guestfs.pod:1337
2669 msgid "ERROR HANDLING"
2670 msgstr "ОБРОБКА ПОМИЛОК"
2673 #: ../src/guestfs.pod:1339
2675 "API functions can return errors. For example, almost all functions that "
2676 "return C<int> will return C<-1> to indicate an error."
2680 #: ../src/guestfs.pod:1342
2682 "Additional information is available for errors: an error message string and "
2683 "optionally an error number (errno) if the thing that failed was a system "
2688 #: ../src/guestfs.pod:1346
2690 "You can get at the additional information about the last error on the handle "
2691 "by calling L</guestfs_last_error>, L</guestfs_last_errno>, and/or by setting "
2692 "up an error handler with L</guestfs_set_error_handler>."
2696 #: ../src/guestfs.pod:1351
2698 "When the handle is created, a default error handler is installed which "
2699 "prints the error message string to C<stderr>. For small short-running "
2700 "command line programs it is sufficient to do:"
2704 #: ../src/guestfs.pod:1355
2707 " if (guestfs_launch (g) == -1)\n"
2708 " exit (EXIT_FAILURE);\n"
2713 #: ../src/guestfs.pod:1358
2715 "since the default error handler will ensure that an error message has been "
2716 "printed to C<stderr> before the program exits."
2720 #: ../src/guestfs.pod:1361
2722 "For other programs the caller will almost certainly want to install an "
2723 "alternate error handler or do error handling in-line like this:"
2727 #: ../src/guestfs.pod:1364
2730 " g = guestfs_create ();\n"
2735 #: ../src/guestfs.pod:1366
2738 " /* This disables the default behaviour of printing errors\n"
2740 " guestfs_set_error_handler (g, NULL, NULL);\n"
2745 #: ../src/guestfs.pod:1370
2748 " if (guestfs_launch (g) == -1) {\n"
2749 " /* Examine the error message and print it etc. */\n"
2750 " char *msg = guestfs_last_error (g);\n"
2751 " int errnum = guestfs_last_errno (g);\n"
2752 " fprintf (stderr, \"%s\\n\", msg);\n"
2759 #: ../src/guestfs.pod:1378
2761 "Out of memory errors are handled differently. The default action is to call "
2762 "L<abort(3)>. If this is undesirable, then you can set a handler using L</"
2763 "guestfs_set_out_of_memory_handler>."
2767 #: ../src/guestfs.pod:1382
2769 "L</guestfs_create> returns C<NULL> if the handle cannot be created, and "
2770 "because there is no handle if this happens there is no way to get additional "
2771 "error information. However L</guestfs_create> is supposed to be a "
2772 "lightweight operation which can only fail because of insufficient memory (it "
2773 "returns NULL in this case)."
2777 #: ../src/guestfs.pod:1388
2778 msgid "guestfs_last_error"
2782 #: ../src/guestfs.pod:1390
2785 " const char *guestfs_last_error (guestfs_h *g);\n"
2790 #: ../src/guestfs.pod:1392
2792 "This returns the last error message that happened on C<g>. If there has not "
2793 "been an error since the handle was created, then this returns C<NULL>."
2797 #: ../src/guestfs.pod:1396
2799 "The lifetime of the returned string is until the next error occurs, or L</"
2800 "guestfs_close> is called."
2804 #: ../src/guestfs.pod:1399
2805 msgid "guestfs_last_errno"
2809 #: ../src/guestfs.pod:1401
2812 " int guestfs_last_errno (guestfs_h *g);\n"
2817 #: ../src/guestfs.pod:1403
2818 msgid "This returns the last error number (errno) that happened on C<g>."
2822 #: ../src/guestfs.pod:1405
2823 msgid "If successful, an errno integer not equal to zero is returned."
2827 #: ../src/guestfs.pod:1407
2829 "If no error, this returns 0. This call can return 0 in three situations:"
2833 #: ../src/guestfs.pod:1414
2834 msgid "There has not been any error on the handle."
2838 #: ../src/guestfs.pod:1418
2840 "There has been an error but the errno was meaningless. This corresponds to "
2841 "the case where the error did not come from a failed system call, but for "
2842 "some other reason."
2846 #: ../src/guestfs.pod:1424
2848 "There was an error from a failed system call, but for some reason the errno "
2849 "was not captured and returned. This usually indicates a bug in libguestfs."
2853 #: ../src/guestfs.pod:1430
2855 "Libguestfs tries to convert the errno from inside the applicance into a "
2856 "corresponding errno for the caller (not entirely trivial: the appliance "
2857 "might be running a completely different operating system from the library "
2858 "and error numbers are not standardized across Un*xen). If this could not be "
2859 "done, then the error is translated to C<EINVAL>. In practice this should "
2860 "only happen in very rare circumstances."
2864 #: ../src/guestfs.pod:1438
2865 msgid "guestfs_set_error_handler"
2869 #: ../src/guestfs.pod:1440
2872 " typedef void (*guestfs_error_handler_cb) (guestfs_h *g,\n"
2874 " const char *msg);\n"
2875 " void guestfs_set_error_handler (guestfs_h *g,\n"
2876 " guestfs_error_handler_cb cb,\n"
2882 #: ../src/guestfs.pod:1447
2884 "The callback C<cb> will be called if there is an error. The parameters "
2885 "passed to the callback are an opaque data pointer and the error message "
2890 #: ../src/guestfs.pod:1451
2892 "C<errno> is not passed to the callback. To get that the callback must call "
2893 "L</guestfs_last_errno>."
2897 #: ../src/guestfs.pod:1454
2899 "Note that the message string C<msg> is freed as soon as the callback "
2900 "function returns, so if you want to stash it somewhere you must make your "
2905 #: ../src/guestfs.pod:1458
2906 msgid "The default handler prints messages on C<stderr>."
2910 #: ../src/guestfs.pod:1460
2911 msgid "If you set C<cb> to C<NULL> then I<no> handler is called."
2915 #: ../src/guestfs.pod:1462
2916 msgid "guestfs_get_error_handler"
2920 #: ../src/guestfs.pod:1464
2923 " guestfs_error_handler_cb guestfs_get_error_handler (guestfs_h *g,\n"
2924 " void **opaque_rtn);\n"
2929 #: ../src/guestfs.pod:1467
2930 msgid "Returns the current error handler callback."
2934 #: ../src/guestfs.pod:1469
2935 msgid "guestfs_set_out_of_memory_handler"
2939 #: ../src/guestfs.pod:1471
2942 " typedef void (*guestfs_abort_cb) (void);\n"
2943 " int guestfs_set_out_of_memory_handler (guestfs_h *g,\n"
2944 " guestfs_abort_cb);\n"
2949 #: ../src/guestfs.pod:1475
2951 "The callback C<cb> will be called if there is an out of memory situation. "
2952 "I<Note this callback must not return>."
2956 #: ../src/guestfs.pod:1478
2957 msgid "The default is to call L<abort(3)>."
2961 #: ../src/guestfs.pod:1480
2963 "You cannot set C<cb> to C<NULL>. You can't ignore out of memory situations."
2967 #: ../src/guestfs.pod:1483
2968 msgid "guestfs_get_out_of_memory_handler"
2972 #: ../src/guestfs.pod:1485
2975 " guestfs_abort_fn guestfs_get_out_of_memory_handler (guestfs_h *g);\n"
2980 #: ../src/guestfs.pod:1487
2981 msgid "This returns the current out of memory handler."
2985 #: ../src/guestfs.pod:1489
2990 #: ../src/guestfs.pod:1491 ../fish/guestfish.pod:1003
2995 #: ../src/guestfs.pod:1493
3000 #: ../src/guestfs.pod:1495
3005 #: ../src/guestfs.pod:1497
3006 msgid "AVAILABILITY"
3010 #: ../src/guestfs.pod:1499
3011 msgid "GROUPS OF FUNCTIONALITY IN THE APPLIANCE"
3015 #: ../src/guestfs.pod:1501
3017 "Using L</guestfs_available> you can test availability of the following "
3018 "groups of functions. This test queries the appliance to see if the "
3019 "appliance you are currently using supports the functionality."
3023 #: ../src/guestfs.pod:1506
3024 msgid "@AVAILABILITY@"
3028 #: ../src/guestfs.pod:1508
3029 msgid "GUESTFISH supported COMMAND"
3033 #: ../src/guestfs.pod:1510
3035 "In L<guestfish(3)> there is a handy interactive command C<supported> which "
3036 "prints out the available groups and whether they are supported by this build "
3037 "of libguestfs. Note however that you have to do C<run> first."
3041 #: ../src/guestfs.pod:1515
3042 msgid "SINGLE CALLS AT COMPILE TIME"
3046 #: ../src/guestfs.pod:1517
3048 "Since version 1.5.8, C<E<lt>guestfs.hE<gt>> defines symbols for each C API "
3049 "function, such as:"
3053 #: ../src/guestfs.pod:1520
3056 " #define LIBGUESTFS_HAVE_DD 1\n"
3061 #: ../src/guestfs.pod:1522
3062 msgid "if L</guestfs_dd> is available."
3066 #: ../src/guestfs.pod:1524
3068 "Before version 1.5.8, if you needed to test whether a single libguestfs "
3069 "function is available at compile time, we recommended using build tools such "
3070 "as autoconf or cmake. For example in autotools you could use:"
3074 #: ../src/guestfs.pod:1529
3077 " AC_CHECK_LIB([guestfs],[guestfs_create])\n"
3078 " AC_CHECK_FUNCS([guestfs_dd])\n"
3083 #: ../src/guestfs.pod:1532
3085 "which would result in C<HAVE_GUESTFS_DD> being either defined or not defined "
3090 #: ../src/guestfs.pod:1535
3091 msgid "SINGLE CALLS AT RUN TIME"
3095 #: ../src/guestfs.pod:1537
3097 "Testing at compile time doesn't guarantee that a function really exists in "
3098 "the library. The reason is that you might be dynamically linked against a "
3099 "previous I<libguestfs.so> (dynamic library) which doesn't have the call. "
3100 "This situation unfortunately results in a segmentation fault, which is a "
3101 "shortcoming of the C dynamic linking system itself."
3105 #: ../src/guestfs.pod:1544
3107 "You can use L<dlopen(3)> to test if a function is available at run time, as "
3108 "in this example program (note that you still need the compile time check as "
3113 #: ../src/guestfs.pod:1548
3116 " #include <stdio.h>\n"
3117 " #include <stdlib.h>\n"
3118 " #include <unistd.h>\n"
3119 " #include <dlfcn.h>\n"
3120 " #include <guestfs.h>\n"
3125 #: ../src/guestfs.pod:1554
3130 " #ifdef LIBGUESTFS_HAVE_DD\n"
3132 " int has_function;\n"
3137 #: ../src/guestfs.pod:1560
3140 " /* Test if the function guestfs_dd is really available. */\n"
3141 " dl = dlopen (NULL, RTLD_LAZY);\n"
3143 " fprintf (stderr, \"dlopen: %s\\n\", dlerror ());\n"
3144 " exit (EXIT_FAILURE);\n"
3146 " has_function = dlsym (dl, \"guestfs_dd\") != NULL;\n"
3152 #: ../src/guestfs.pod:1569
3155 " if (!has_function)\n"
3156 " printf (\"this libguestfs.so does NOT have guestfs_dd function\\n\");\n"
3158 " printf (\"this libguestfs.so has guestfs_dd function\\n\");\n"
3159 " /* Now it's safe to call\n"
3160 " guestfs_dd (g, \"foo\", \"bar\");\n"
3164 " printf (\"guestfs_dd function was not found at compile time\\n\");\n"
3171 #: ../src/guestfs.pod:1582
3173 "You may think the above is an awful lot of hassle, and it is. There are "
3174 "other ways outside of the C linking system to ensure that this kind of "
3175 "incompatibility never arises, such as using package versioning:"
3179 #: ../src/guestfs.pod:1587
3182 " Requires: libguestfs >= 1.0.80\n"
3187 #: ../src/guestfs.pod:1589
3188 msgid "CALLS WITH OPTIONAL ARGUMENTS"
3192 #: ../src/guestfs.pod:1591
3194 "A recent feature of the API is the introduction of calls which take optional "
3195 "arguments. In C these are declared 3 ways. The main way is as a call which "
3196 "takes variable arguments (ie. C<...>), as in this example:"
3200 #: ../src/guestfs.pod:1596
3203 " int guestfs_add_drive_opts (guestfs_h *g, const char *filename, ...);\n"
3208 #: ../src/guestfs.pod:1598
3210 "Call this with a list of optional arguments, terminated by C<-1>. So to "
3211 "call with no optional arguments specified:"
3215 #: ../src/guestfs.pod:1601
3218 " guestfs_add_drive_opts (g, filename, -1);\n"
3223 #: ../src/guestfs.pod:1603
3224 msgid "With a single optional argument:"
3228 #: ../src/guestfs.pod:1605
3231 " guestfs_add_drive_opts (g, filename,\n"
3232 " GUESTFS_ADD_DRIVE_OPTS_FORMAT, \"qcow2\",\n"
3238 #: ../src/guestfs.pod:1609
3243 #: ../src/guestfs.pod:1611
3246 " guestfs_add_drive_opts (g, filename,\n"
3247 " GUESTFS_ADD_DRIVE_OPTS_FORMAT, \"qcow2\",\n"
3248 " GUESTFS_ADD_DRIVE_OPTS_READONLY, 1,\n"
3254 #: ../src/guestfs.pod:1616
3256 "and so forth. Don't forget the terminating C<-1> otherwise Bad Things will "
3261 #: ../src/guestfs.pod:1619
3262 msgid "USING va_list FOR OPTIONAL ARGUMENTS"
3266 #: ../src/guestfs.pod:1621
3268 "The second variant has the same name with the suffix C<_va>, which works the "
3269 "same way but takes a C<va_list>. See the C manual for details. For the "
3270 "example function, this is declared:"
3274 #: ../src/guestfs.pod:1625
3277 " int guestfs_add_drive_opts_va (guestfs_h *g, const char *filename,\n"
3283 #: ../src/guestfs.pod:1628
3284 msgid "CONSTRUCTING OPTIONAL ARGUMENTS"
3288 #: ../src/guestfs.pod:1630
3290 "The third variant is useful where you need to construct these calls. You "
3291 "pass in a structure where you fill in the optional fields. The structure "
3292 "has a bitmask as the first element which you must set to indicate which "
3293 "fields you have filled in. For our example function the structure and call "
3298 #: ../src/guestfs.pod:1636
3301 " struct guestfs_add_drive_opts_argv {\n"
3302 " uint64_t bitmask;\n"
3304 " const char *format;\n"
3307 " int guestfs_add_drive_opts_argv (guestfs_h *g, const char *filename,\n"
3308 " const struct guestfs_add_drive_opts_argv *optargs);\n"
3313 #: ../src/guestfs.pod:1645
3314 msgid "You could call it like this:"
3318 #: ../src/guestfs.pod:1647
3321 " struct guestfs_add_drive_opts_argv optargs = {\n"
3322 " .bitmask = GUESTFS_ADD_DRIVE_OPTS_READONLY_BITMASK |\n"
3323 " GUESTFS_ADD_DRIVE_OPTS_FORMAT_BITMASK,\n"
3325 " .format = \"qcow2\"\n"
3331 #: ../src/guestfs.pod:1654
3334 " guestfs_add_drive_opts_argv (g, filename, &optargs);\n"
3339 #: ../src/guestfs.pod:1656 ../src/guestfs-actions.pod:11
3340 #: ../src/guestfs-actions.pod:1855 ../fish/guestfish-actions.pod:9
3341 #: ../fish/guestfish-actions.pod:1260 ../tools/virt-win-reg.pl:532
3346 #: ../src/guestfs.pod:1662
3347 msgid "The C<_BITMASK> suffix on each option name when specifying the bitmask."
3351 #: ../src/guestfs.pod:1667
3352 msgid "You do not need to fill in all fields of the structure."
3356 #: ../src/guestfs.pod:1671
3358 "There must be a one-to-one correspondence between fields of the structure "
3359 "that are filled in, and bits set in the bitmask."
3363 #: ../src/guestfs.pod:1676
3364 msgid "OPTIONAL ARGUMENTS IN OTHER LANGUAGES"
3368 #: ../src/guestfs.pod:1678
3370 "In other languages, optional arguments are expressed in the way that is "
3371 "natural for that language. We refer you to the language-specific "
3372 "documentation for more details on that."
3376 #: ../src/guestfs.pod:1682
3377 msgid "For guestfish, see L<guestfish(1)/OPTIONAL ARGUMENTS>."
3381 #: ../src/guestfs.pod:1684
3382 msgid "SETTING CALLBACKS TO HANDLE EVENTS"
3386 #: ../src/guestfs.pod:1686
3388 "B<Note:> This section documents the generic event mechanism introduced in "
3389 "libguestfs 1.10, which you should use in new code if possible. The old "
3390 "functions C<guestfs_set_log_message_callback>, "
3391 "C<guestfs_set_subprocess_quit_callback>, "
3392 "C<guestfs_set_launch_done_callback>, C<guestfs_set_close_callback> and "
3393 "C<guestfs_set_progress_callback> are no longer documented in this manual "
3398 #: ../src/guestfs.pod:1694
3400 "Handles generate events when certain things happen, such as log messages "
3401 "being generated, progress messages during long-running operations, or the "
3402 "handle being closed. The API calls described below let you register a "
3403 "callback to be called when events happen. You can register multiple "
3404 "callbacks (for the same, different or overlapping sets of events), and "
3405 "individually remove callbacks. If callbacks are not removed, then they "
3406 "remain in force until the handle is closed."
3410 #: ../src/guestfs.pod:1702
3412 "In the current implementation, events are only generated synchronously: that "
3413 "means that events (and hence callbacks) can only happen while you are in the "
3414 "middle of making another libguestfs call. The callback is called in the "
3419 #: ../src/guestfs.pod:1707
3421 "Events may contain a payload, usually nothing (void), an array of 64 bit "
3422 "unsigned integers, or a message buffer. Payloads are discussed later on."
3426 #: ../src/guestfs.pod:1711
3427 msgid "CLASSES OF EVENTS"
3431 #: ../src/guestfs.pod:1715
3432 msgid "GUESTFS_EVENT_CLOSE (payload type: void)"
3436 #: ../src/guestfs.pod:1718
3438 "The callback function will be called while the handle is being closed "
3439 "(synchronously from L</guestfs_close>)."
3443 #: ../src/guestfs.pod:1721
3445 "Note that libguestfs installs an L<atexit(3)> handler to try to clean up "
3446 "handles that are open when the program exits. This means that this callback "
3447 "might be called indirectly from L<exit(3)>, which can cause unexpected "
3448 "problems in higher-level languages (eg. if your HLL interpreter has already "
3449 "been cleaned up by the time this is called, and if your callback then jumps "
3450 "into some HLL function)."
3454 #: ../src/guestfs.pod:1728
3456 "If no callback is registered: the handle is closed without any callback "
3461 #: ../src/guestfs.pod:1731
3462 msgid "GUESTFS_EVENT_SUBPROCESS_QUIT (payload type: void)"
3466 #: ../src/guestfs.pod:1734
3468 "The callback function will be called when the child process quits, either "
3469 "asynchronously or if killed by L</guestfs_kill_subprocess>. (This "
3470 "corresponds to a transition from any state to the CONFIG state)."
3474 #: ../src/guestfs.pod:1738 ../src/guestfs.pod:1747
3475 msgid "If no callback is registered: the event is ignored."
3479 #: ../src/guestfs.pod:1740
3480 msgid "GUESTFS_EVENT_LAUNCH_DONE (payload type: void)"
3484 #: ../src/guestfs.pod:1743
3486 "The callback function will be called when the child process becomes ready "
3487 "first time after it has been launched. (This corresponds to a transition "
3488 "from LAUNCHING to the READY state)."
3492 #: ../src/guestfs.pod:1749
3493 msgid "GUESTFS_EVENT_PROGRESS (payload type: array of 4 x uint64_t)"
3497 #: ../src/guestfs.pod:1752
3499 "Some long-running operations can generate progress messages. If this "
3500 "callback is registered, then it will be called each time a progress message "
3501 "is generated (usually two seconds after the operation started, and three "
3502 "times per second thereafter until it completes, although the frequency may "
3503 "change in future versions)."
3507 #: ../src/guestfs.pod:1758
3509 "The callback receives in the payload four unsigned 64 bit numbers which are "
3510 "(in order): C<proc_nr>, C<serial>, C<position>, C<total>."
3514 #: ../src/guestfs.pod:1761
3516 "The units of C<total> are not defined, although for some operations C<total> "
3517 "may relate in some way to the amount of data to be transferred (eg. in bytes "
3518 "or megabytes), and C<position> may be the portion which has been transferred."
3522 #: ../src/guestfs.pod:1766
3523 msgid "The only defined and stable parts of the API are:"
3527 #: ../src/guestfs.pod:1772
3529 "The callback can display to the user some type of progress bar or indicator "
3530 "which shows the ratio of C<position>:C<total>."
3534 #: ../src/guestfs.pod:1777
3535 msgid "0 E<lt>= C<position> E<lt>= C<total>"
3539 #: ../src/guestfs.pod:1781
3541 "If any progress notification is sent during a call, then a final progress "
3542 "notification is always sent when C<position> = C<total> (I<unless> the call "
3543 "fails with an error)."
3547 #: ../src/guestfs.pod:1785
3549 "This is to simplify caller code, so callers can easily set the progress "
3550 "indicator to \"100%\" at the end of the operation, without requiring special "
3551 "code to detect this case."
3555 #: ../src/guestfs.pod:1791
3557 "For some calls we are unable to estimate the progress of the call, but we "
3558 "can still generate progress messages to indicate activity. This is known as "
3559 "\"pulse mode\", and is directly supported by certain progress bar "
3560 "implementations (eg. GtkProgressBar)."
3564 #: ../src/guestfs.pod:1796
3566 "For these calls, zero or more progress messages are generated with "
3567 "C<position = 0> and C<total = 1>, followed by a final message with "
3568 "C<position = total = 1>."
3572 #: ../src/guestfs.pod:1800
3574 "As noted above, if the call fails with an error then the final message may "
3579 #: ../src/guestfs.pod:1805
3581 "The callback also receives the procedure number (C<proc_nr>) and serial "
3582 "number (C<serial>) of the call. These are only useful for debugging "
3583 "protocol issues, and the callback can normally ignore them. The callback "
3584 "may want to print these numbers in error messages or debugging messages."
3588 #: ../src/guestfs.pod:1811
3589 msgid "If no callback is registered: progress messages are discarded."
3593 #: ../src/guestfs.pod:1813
3594 msgid "GUESTFS_EVENT_APPLIANCE (payload type: message buffer)"
3598 #: ../src/guestfs.pod:1816
3600 "The callback function is called whenever a log message is generated by qemu, "
3601 "the appliance kernel, guestfsd (daemon), or utility programs."
3605 #: ../src/guestfs.pod:1819
3607 "If the verbose flag (L</guestfs_set_verbose>) is set before launch (L</"
3608 "guestfs_launch>) then additional debug messages are generated."
3612 #: ../src/guestfs.pod:1822 ../src/guestfs.pod:1836
3614 "If no callback is registered: the messages are discarded unless the verbose "
3615 "flag is set in which case they are sent to stderr. You can override the "
3616 "printing of verbose messages to stderr by setting up a callback."
3620 #: ../src/guestfs.pod:1827
3621 msgid "GUESTFS_EVENT_LIBRARY (payload type: message buffer)"
3625 #: ../src/guestfs.pod:1830
3627 "The callback function is called whenever a log message is generated by the "
3628 "library part of libguestfs."
3632 #: ../src/guestfs.pod:1833
3634 "If the verbose flag (L</guestfs_set_verbose>) is set then additional debug "
3635 "messages are generated."
3639 #: ../src/guestfs.pod:1841
3640 msgid "GUESTFS_EVENT_TRACE (payload type: message buffer)"
3644 #: ../src/guestfs.pod:1844
3646 "The callback function is called whenever a trace message is generated. This "
3647 "only applies if the trace flag (L</guestfs_set_trace>) is set."
3651 #: ../src/guestfs.pod:1847
3653 "If no callback is registered: the messages are sent to stderr. You can "
3654 "override the printing of trace messages to stderr by setting up a callback."
3658 #: ../src/guestfs.pod:1853
3659 msgid "guestfs_set_event_callback"
3663 #: ../src/guestfs.pod:1855
3666 " int guestfs_set_event_callback (guestfs_h *g,\n"
3667 " guestfs_event_callback cb,\n"
3668 " uint64_t event_bitmask,\n"
3675 #: ../src/guestfs.pod:1861
3677 "This function registers a callback (C<cb>) for all event classes in the "
3682 #: ../src/guestfs.pod:1864
3684 "For example, to register for all log message events, you could call this "
3685 "function with the bitmask C<GUESTFS_EVENT_APPLIANCE|GUESTFS_EVENT_LIBRARY>. "
3686 "To register a single callback for all possible classes of events, use "
3687 "C<GUESTFS_EVENT_ALL>."
3691 #: ../src/guestfs.pod:1870
3692 msgid "C<flags> should always be passed as 0."
3696 #: ../src/guestfs.pod:1872
3698 "C<opaque> is an opaque pointer which is passed to the callback. You can use "
3699 "it for any purpose."
3703 #: ../src/guestfs.pod:1875
3705 "The return value is the event handle (an integer) which you can use to "
3706 "delete the callback (see below)."
3710 #: ../src/guestfs.pod:1878
3712 "If there is an error, this function returns C<-1>, and sets the error in the "
3713 "handle in the usual way (see L</guestfs_last_error> etc.)"
3717 #: ../src/guestfs.pod:1881
3719 "Callbacks remain in effect until they are deleted, or until the handle is "
3724 #: ../src/guestfs.pod:1884
3726 "In the case where multiple callbacks are registered for a particular event "
3727 "class, all of the callbacks are called. The order in which multiple "
3728 "callbacks are called is not defined."
3732 #: ../src/guestfs.pod:1888
3733 msgid "guestfs_delete_event_callback"
3737 #: ../src/guestfs.pod:1890
3740 " void guestfs_delete_event_callback (guestfs_h *g, int event_handle);\n"
3745 #: ../src/guestfs.pod:1892
3747 "Delete a callback that was previously registered. C<event_handle> should be "
3748 "the integer that was returned by a previous call to "
3749 "C<guestfs_set_event_callback> on the same handle."
3753 #: ../src/guestfs.pod:1896
3754 msgid "guestfs_event_callback"
3758 #: ../src/guestfs.pod:1898
3761 " typedef void (*guestfs_event_callback) (\n"
3764 " uint64_t event,\n"
3765 " int event_handle,\n"
3767 " const char *buf, size_t buf_len,\n"
3768 " const uint64_t *array, size_t array_len);\n"
3773 #: ../src/guestfs.pod:1907
3775 "This is the type of the event callback function that you have to provide."
3779 #: ../src/guestfs.pod:1910
3781 "The basic parameters are: the handle (C<g>), the opaque user pointer "
3782 "(C<opaque>), the event class (eg. C<GUESTFS_EVENT_PROGRESS>), the event "
3783 "handle, and C<flags> which in the current API you should ignore."
3787 #: ../src/guestfs.pod:1914
3789 "The remaining parameters contain the event payload (if any). Each event may "
3790 "contain a payload, which usually relates to the event class, but for future "
3791 "proofing your code should be written to handle any payload for any event "
3796 #: ../src/guestfs.pod:1919
3798 "C<buf> and C<buf_len> contain a message buffer (if C<buf_len == 0>, then "
3799 "there is no message buffer). Note that this message buffer can contain "
3800 "arbitrary 8 bit data, including NUL bytes."
3804 #: ../src/guestfs.pod:1923
3806 "C<array> and C<array_len> is an array of 64 bit unsigned integers. At the "
3807 "moment this is only used for progress messages."
3811 #: ../src/guestfs.pod:1926
3812 msgid "EXAMPLE: CAPTURING LOG MESSAGES"
3816 #: ../src/guestfs.pod:1928
3818 "One motivation for the generic event API was to allow GUI programs to "
3819 "capture debug and other messages. In libguestfs E<le> 1.8 these were sent "
3820 "unconditionally to C<stderr>."
3824 #: ../src/guestfs.pod:1932
3826 "Events associated with log messages are: C<GUESTFS_EVENT_LIBRARY>, "
3827 "C<GUESTFS_EVENT_APPLIANCE> and C<GUESTFS_EVENT_TRACE>. (Note that error "
3828 "messages are not events; you must capture error messages separately)."
3832 #: ../src/guestfs.pod:1937
3834 "Programs have to set up a callback to capture the classes of events of "
3839 #: ../src/guestfs.pod:1940
3843 " guestfs_set_event_callback\n"
3844 " (g, message_callback,\n"
3845 " GUESTFS_EVENT_LIBRARY|GUESTFS_EVENT_APPLIANCE|\n"
3846 " GUESTFS_EVENT_TRACE,\n"
3847 " 0, NULL) == -1)\n"
3848 " if (eh == -1) {\n"
3849 " // handle error in the usual way\n"
3855 #: ../src/guestfs.pod:1950
3857 "The callback can then direct messages to the appropriate place. In this "
3858 "example, messages are directed to syslog:"
3862 #: ../src/guestfs.pod:1953
3866 " message_callback (\n"
3869 " uint64_t event,\n"
3870 " int event_handle,\n"
3872 " const char *buf, size_t buf_len,\n"
3873 " const uint64_t *array, size_t array_len)\n"
3875 " const int priority = LOG_USER|LOG_INFO;\n"
3876 " if (buf_len > 0)\n"
3877 " syslog (priority, \"event 0x%lx: %s\", event, buf);\n"
3883 #: ../src/guestfs.pod:1968
3884 msgid "PRIVATE DATA AREA"
3888 #: ../src/guestfs.pod:1970
3890 "You can attach named pieces of private data to the libguestfs handle, fetch "
3891 "them by name, and walk over them, for the lifetime of the handle. This is "
3892 "called the private data area and is only available from the C API."
3896 #: ../src/guestfs.pod:1975
3897 msgid "To attach a named piece of data, use the following call:"
3901 #: ../src/guestfs.pod:1977
3904 " void guestfs_set_private (guestfs_h *g, const char *key, void *data);\n"
3909 #: ../src/guestfs.pod:1979
3911 "C<key> is the name to associate with this data, and C<data> is an arbitrary "
3912 "pointer (which can be C<NULL>). Any previous item with the same name is "
3917 #: ../src/guestfs.pod:1983
3919 "You can use any C<key> you want, but names beginning with an underscore "
3920 "character are reserved for internal libguestfs purposes (for implementing "
3921 "language bindings). It is recommended to prefix the name with some unique "
3922 "string to avoid collisions with other users."
3926 #: ../src/guestfs.pod:1988
3927 msgid "To retrieve the pointer, use:"
3931 #: ../src/guestfs.pod:1990
3934 " void *guestfs_get_private (guestfs_h *g, const char *key);\n"
3939 #: ../src/guestfs.pod:1992
3941 "This function returns C<NULL> if either no data is found associated with "
3942 "C<key>, or if the user previously set the C<key>'s C<data> pointer to "
3947 #: ../src/guestfs.pod:1996
3949 "Libguestfs does not try to look at or interpret the C<data> pointer in any "
3950 "way. As far as libguestfs is concerned, it need not be a valid pointer at "
3951 "all. In particular, libguestfs does I<not> try to free the data when the "
3952 "handle is closed. If the data must be freed, then the caller must either "
3953 "free it before calling L</guestfs_close> or must set up a close callback to "
3954 "do it (see L</GUESTFS_EVENT_CLOSE>)."
3958 #: ../src/guestfs.pod:2003
3959 msgid "To walk over all entries, use these two functions:"
3963 #: ../src/guestfs.pod:2005
3966 " void *guestfs_first_private (guestfs_h *g, const char **key_rtn);\n"
3971 #: ../src/guestfs.pod:2007
3974 " void *guestfs_next_private (guestfs_h *g, const char **key_rtn);\n"
3979 #: ../src/guestfs.pod:2009
3981 "C<guestfs_first_private> returns the first key, pointer pair (\"first\" does "
3982 "not have any particular meaning -- keys are not returned in any defined "
3983 "order). A pointer to the key is returned in C<*key_rtn> and the "
3984 "corresponding data pointer is returned from the function. C<NULL> is "
3985 "returned if there are no keys stored in the handle."
3989 #: ../src/guestfs.pod:2015
3991 "C<guestfs_next_private> returns the next key, pointer pair. The return "
3992 "value of this function is also C<NULL> is there are no further entries to "
3997 #: ../src/guestfs.pod:2019
3998 msgid "Notes about walking over entries:"
4002 #: ../src/guestfs.pod:2025
4004 "You must not call C<guestfs_set_private> while walking over the entries."
4008 #: ../src/guestfs.pod:2030
4010 "The handle maintains an internal iterator which is reset when you call "
4011 "C<guestfs_first_private>. This internal iterator is invalidated when you "
4012 "call C<guestfs_set_private>."
4016 #: ../src/guestfs.pod:2036
4017 msgid "If you have set the data pointer associated with a key to C<NULL>, ie:"
4021 #: ../src/guestfs.pod:2038
4024 " guestfs_set_private (g, key, NULL);\n"
4029 #: ../src/guestfs.pod:2040
4030 msgid "then that C<key> is not returned when walking."
4034 #: ../src/guestfs.pod:2044
4036 "C<*key_rtn> is only valid until the next call to C<guestfs_first_private>, "
4037 "C<guestfs_next_private> or C<guestfs_set_private>."
4041 #: ../src/guestfs.pod:2050
4043 "The following example code shows how to print all keys and data pointers "
4044 "that are associated with the handle C<g>:"
4048 #: ../src/guestfs.pod:2053
4051 " const char *key;\n"
4052 " void *data = guestfs_first_private (g, &key);\n"
4053 " while (data != NULL)\n"
4055 " printf (\"key = %s, data = %p\\n\", key, data);\n"
4056 " data = guestfs_next_private (g, &key);\n"
4062 #: ../src/guestfs.pod:2061
4064 "More commonly you are only interested in keys that begin with an application-"
4065 "specific prefix C<foo_>. Modify the loop like so:"
4069 #: ../src/guestfs.pod:2064
4072 " const char *key;\n"
4073 " void *data = guestfs_first_private (g, &key);\n"
4074 " while (data != NULL)\n"
4076 " if (strncmp (key, \"foo_\", strlen (\"foo_\")) == 0)\n"
4077 " printf (\"key = %s, data = %p\\n\", key, data);\n"
4078 " data = guestfs_next_private (g, &key);\n"
4084 #: ../src/guestfs.pod:2073
4086 "If you need to modify keys while walking, then you have to jump back to the "
4087 "beginning of the loop. For example, to delete all keys prefixed with "
4092 #: ../src/guestfs.pod:2077
4095 " const char *key;\n"
4098 " data = guestfs_first_private (g, &key);\n"
4099 " while (data != NULL)\n"
4101 " if (strncmp (key, \"foo_\", strlen (\"foo_\")) == 0)\n"
4103 " guestfs_set_private (g, key, NULL);\n"
4104 " /* note that 'key' pointer is now invalid, and so is\n"
4105 " the internal iterator */\n"
4108 " data = guestfs_next_private (g, &key);\n"
4114 #: ../src/guestfs.pod:2093
4116 "Note that the above loop is guaranteed to terminate because the keys are "
4117 "being deleted, but other manipulations of keys within the loop might not "
4118 "terminate unless you also maintain an indication of which keys have been "
4123 #: ../src/guestfs.pod:2098 ../src/guestfs.pod:2103
4128 #: ../src/guestfs.pod:2100
4130 "<!-- old anchor for the next section --> <a name="
4131 "\"state_machine_and_low_level_event_api\"/>"
4133 "<!-- old anchor for the next section --> <a name="
4134 "\"state_machine_and_low_level_event_api\"/>"
4137 #: ../src/guestfs.pod:2105
4138 msgid "ARCHITECTURE"
4139 msgstr "АРХІТЕКТУРА"
4142 #: ../src/guestfs.pod:2107
4144 "Internally, libguestfs is implemented by running an appliance (a special "
4145 "type of small virtual machine) using L<qemu(1)>. Qemu runs as a child "
4146 "process of the main program."
4150 #: ../src/guestfs.pod:2111
4153 " ___________________\n"
4155 " | main program |\n"
4157 " | | child process / appliance\n"
4158 " | | __________________________\n"
4160 " +-------------------+ RPC | +-----------------+ |\n"
4161 " | libguestfs <--------------------> guestfsd | |\n"
4162 " | | | +-----------------+ |\n"
4163 " \\___________________/ | | Linux kernel | |\n"
4164 " | +--^--------------+ |\n"
4165 " \\_________|________________/\n"
4171 " \\______________/\n"
4176 #: ../src/guestfs.pod:2131
4178 "The library, linked to the main program, creates the child process and hence "
4179 "the appliance in the L</guestfs_launch> function."
4183 #: ../src/guestfs.pod:2134
4185 "Inside the appliance is a Linux kernel and a complete stack of userspace "
4186 "tools (such as LVM and ext2 programs) and a small controlling daemon called "
4187 "L</guestfsd>. The library talks to L</guestfsd> using remote procedure "
4188 "calls (RPC). There is a mostly one-to-one correspondence between libguestfs "
4189 "API calls and RPC calls to the daemon. Lastly the disk image(s) are "
4190 "attached to the qemu process which translates device access by the "
4191 "appliance's Linux kernel into accesses to the image."
4195 #: ../src/guestfs.pod:2143
4197 "A common misunderstanding is that the appliance \"is\" the virtual machine. "
4198 "Although the disk image you are attached to might also be used by some "
4199 "virtual machine, libguestfs doesn't know or care about this. (But you will "
4200 "care if both libguestfs's qemu process and your virtual machine are trying "
4201 "to update the disk image at the same time, since these usually results in "
4202 "massive disk corruption)."
4206 #: ../src/guestfs.pod:2150
4207 msgid "STATE MACHINE"
4208 msgstr "СКІНЧЕННИЙ АВТОМАТ"
4211 #: ../src/guestfs.pod:2152
4212 msgid "libguestfs uses a state machine to model the child process:"
4216 #: ../src/guestfs.pod:2154
4228 " / | \\ \\ guestfs_launch\n"
4229 " / | _\\__V______\n"
4231 " / | | LAUNCHING |\n"
4232 " / | \\___________/\n"
4234 " / | guestfs_launch\n"
4236 " ______ / __|____V\n"
4237 " / \\ ------> / \\\n"
4238 " | BUSY | | READY |\n"
4239 " \\______/ <------ \\________/\n"
4244 #: ../src/guestfs.pod:2176
4246 "The normal transitions are (1) CONFIG (when the handle is created, but there "
4247 "is no child process), (2) LAUNCHING (when the child process is booting up), "
4248 "(3) alternating between READY and BUSY as commands are issued to, and "
4249 "carried out by, the child process."
4253 #: ../src/guestfs.pod:2181
4255 "The guest may be killed by L</guestfs_kill_subprocess>, or may die "
4256 "asynchronously at any time (eg. due to some internal error), and that causes "
4257 "the state to transition back to CONFIG."
4261 #: ../src/guestfs.pod:2185
4263 "Configuration commands for qemu such as L</guestfs_add_drive> can only be "
4264 "issued when in the CONFIG state."
4268 #: ../src/guestfs.pod:2188
4270 "The API offers one call that goes from CONFIG through LAUNCHING to READY. "
4271 "L</guestfs_launch> blocks until the child process is READY to accept "
4272 "commands (or until some failure or timeout). L</guestfs_launch> internally "
4273 "moves the state from CONFIG to LAUNCHING while it is running."
4277 #: ../src/guestfs.pod:2194
4279 "API actions such as L</guestfs_mount> can only be issued when in the READY "
4280 "state. These API calls block waiting for the command to be carried out (ie. "
4281 "the state to transition to BUSY and then back to READY). There are no non-"
4282 "blocking versions, and no way to issue more than one command per handle at "
4287 #: ../src/guestfs.pod:2200
4289 "Finally, the child process sends asynchronous messages back to the main "
4290 "program, such as kernel log messages. You can register a callback to "
4291 "receive these messages."
4295 #: ../src/guestfs.pod:2204
4300 #: ../src/guestfs.pod:2206
4301 msgid "COMMUNICATION PROTOCOL"
4305 #: ../src/guestfs.pod:2208
4307 "Don't rely on using this protocol directly. This section documents how it "
4308 "currently works, but it may change at any time."
4312 #: ../src/guestfs.pod:2211
4314 "The protocol used to talk between the library and the daemon running inside "
4315 "the qemu virtual machine is a simple RPC mechanism built on top of XDR (RFC "
4316 "1014, RFC 1832, RFC 4506)."
4320 #: ../src/guestfs.pod:2215
4322 "The detailed format of structures is in C<src/guestfs_protocol.x> (note: "
4323 "this file is automatically generated)."
4327 #: ../src/guestfs.pod:2218
4329 "There are two broad cases, ordinary functions that don't have any C<FileIn> "
4330 "and C<FileOut> parameters, which are handled with very simple request/reply "
4331 "messages. Then there are functions that have any C<FileIn> or C<FileOut> "
4332 "parameters, which use the same request and reply messages, but they may also "
4333 "be followed by files sent using a chunked encoding."
4337 #: ../src/guestfs.pod:2225
4338 msgid "ORDINARY FUNCTIONS (NO FILEIN/FILEOUT PARAMS)"
4342 #: ../src/guestfs.pod:2227
4343 msgid "For ordinary functions, the request message is:"
4347 #: ../src/guestfs.pod:2229
4350 " total length (header + arguments,\n"
4351 " but not including the length word itself)\n"
4352 " struct guestfs_message_header (encoded as XDR)\n"
4353 " struct guestfs_<foo>_args (encoded as XDR)\n"
4358 #: ../src/guestfs.pod:2234
4360 "The total length field allows the daemon to allocate a fixed size buffer "
4361 "into which it slurps the rest of the message. As a result, the total length "
4362 "is limited to C<GUESTFS_MESSAGE_MAX> bytes (currently 4MB), which means the "
4363 "effective size of any request is limited to somewhere under this size."
4367 #: ../src/guestfs.pod:2240
4369 "Note also that many functions don't take any arguments, in which case the "
4370 "C<guestfs_I<foo>_args> is completely omitted."
4374 #: ../src/guestfs.pod:2243
4376 "The header contains the procedure number (C<guestfs_proc>) which is how the "
4377 "receiver knows what type of args structure to expect, or none at all."
4381 #: ../src/guestfs.pod:2247
4383 "For functions that take optional arguments, the optional arguments are "
4384 "encoded in the C<guestfs_I<foo>_args> structure in the same way as ordinary "
4385 "arguments. A bitmask in the header indicates which optional arguments are "
4386 "meaningful. The bitmask is also checked to see if it contains bits set "
4387 "which the daemon does not know about (eg. if more optional arguments were "
4388 "added in a later version of the library), and this causes the call to be "
4393 #: ../src/guestfs.pod:2255
4394 msgid "The reply message for ordinary functions is:"
4398 #: ../src/guestfs.pod:2257
4401 " total length (header + ret,\n"
4402 " but not including the length word itself)\n"
4403 " struct guestfs_message_header (encoded as XDR)\n"
4404 " struct guestfs_<foo>_ret (encoded as XDR)\n"
4409 #: ../src/guestfs.pod:2262
4411 "As above the C<guestfs_I<foo>_ret> structure may be completely omitted for "
4412 "functions that return no formal return values."
4416 #: ../src/guestfs.pod:2265
4418 "As above the total length of the reply is limited to C<GUESTFS_MESSAGE_MAX>."
4422 #: ../src/guestfs.pod:2268
4424 "In the case of an error, a flag is set in the header, and the reply message "
4425 "is slightly changed:"
4429 #: ../src/guestfs.pod:2271
4432 " total length (header + error,\n"
4433 " but not including the length word itself)\n"
4434 " struct guestfs_message_header (encoded as XDR)\n"
4435 " struct guestfs_message_error (encoded as XDR)\n"
4440 #: ../src/guestfs.pod:2276
4442 "The C<guestfs_message_error> structure contains the error message as a "
4447 #: ../src/guestfs.pod:2279
4448 msgid "FUNCTIONS THAT HAVE FILEIN PARAMETERS"
4452 #: ../src/guestfs.pod:2281
4454 "A C<FileIn> parameter indicates that we transfer a file I<into> the guest. "
4455 "The normal request message is sent (see above). However this is followed by "
4456 "a sequence of file chunks."
4460 #: ../src/guestfs.pod:2285
4463 " total length (header + arguments,\n"
4464 " but not including the length word itself,\n"
4465 " and not including the chunks)\n"
4466 " struct guestfs_message_header (encoded as XDR)\n"
4467 " struct guestfs_<foo>_args (encoded as XDR)\n"
4468 " sequence of chunks for FileIn param #0\n"
4469 " sequence of chunks for FileIn param #1 etc.\n"
4474 #: ../src/guestfs.pod:2293
4475 msgid "The \"sequence of chunks\" is:"
4479 #: ../src/guestfs.pod:2295
4482 " length of chunk (not including length word itself)\n"
4483 " struct guestfs_chunk (encoded as XDR)\n"
4484 " length of chunk\n"
4485 " struct guestfs_chunk (encoded as XDR)\n"
4487 " length of chunk\n"
4488 " struct guestfs_chunk (with data.data_len == 0)\n"
4493 #: ../src/guestfs.pod:2303
4495 "The final chunk has the C<data_len> field set to zero. Additionally a flag "
4496 "is set in the final chunk to indicate either successful completion or early "
4501 #: ../src/guestfs.pod:2307
4503 "At time of writing there are no functions that have more than one FileIn "
4504 "parameter. However this is (theoretically) supported, by sending the "
4505 "sequence of chunks for each FileIn parameter one after another (from left to "
4510 #: ../src/guestfs.pod:2312
4512 "Both the library (sender) I<and> the daemon (receiver) may cancel the "
4513 "transfer. The library does this by sending a chunk with a special flag set "
4514 "to indicate cancellation. When the daemon sees this, it cancels the whole "
4515 "RPC, does I<not> send any reply, and goes back to reading the next request."
4519 #: ../src/guestfs.pod:2318
4521 "The daemon may also cancel. It does this by writing a special word "
4522 "C<GUESTFS_CANCEL_FLAG> to the socket. The library listens for this during "
4523 "the transfer, and if it gets it, it will cancel the transfer (it sends a "
4524 "cancel chunk). The special word is chosen so that even if cancellation "
4525 "happens right at the end of the transfer (after the library has finished "
4526 "writing and has started listening for the reply), the \"spurious\" cancel "
4527 "flag will not be confused with the reply message."
4531 #: ../src/guestfs.pod:2327
4533 "This protocol allows the transfer of arbitrary sized files (no 32 bit "
4534 "limit), and also files where the size is not known in advance (eg. from "
4535 "pipes or sockets). However the chunks are rather small "
4536 "(C<GUESTFS_MAX_CHUNK_SIZE>), so that neither the library nor the daemon need "
4537 "to keep much in memory."
4541 #: ../src/guestfs.pod:2333
4542 msgid "FUNCTIONS THAT HAVE FILEOUT PARAMETERS"
4546 #: ../src/guestfs.pod:2335
4548 "The protocol for FileOut parameters is exactly the same as for FileIn "
4549 "parameters, but with the roles of daemon and library reversed."
4553 #: ../src/guestfs.pod:2338
4556 " total length (header + ret,\n"
4557 " but not including the length word itself,\n"
4558 " and not including the chunks)\n"
4559 " struct guestfs_message_header (encoded as XDR)\n"
4560 " struct guestfs_<foo>_ret (encoded as XDR)\n"
4561 " sequence of chunks for FileOut param #0\n"
4562 " sequence of chunks for FileOut param #1 etc.\n"
4567 #: ../src/guestfs.pod:2346
4568 msgid "INITIAL MESSAGE"
4572 #: ../src/guestfs.pod:2348
4574 "When the daemon launches it sends an initial word (C<GUESTFS_LAUNCH_FLAG>) "
4575 "which indicates that the guest and daemon is alive. This is what L</"
4576 "guestfs_launch> waits for."
4580 #: ../src/guestfs.pod:2352
4581 msgid "PROGRESS NOTIFICATION MESSAGES"
4585 #: ../src/guestfs.pod:2354
4587 "The daemon may send progress notification messages at any time. These are "
4588 "distinguished by the normal length word being replaced by "
4589 "C<GUESTFS_PROGRESS_FLAG>, followed by a fixed size progress message."
4593 #: ../src/guestfs.pod:2358
4595 "The library turns them into progress callbacks (see L</"
4596 "GUESTFS_EVENT_PROGRESS>) if there is a callback registered, or discards them "
4601 #: ../src/guestfs.pod:2362
4603 "The daemon self-limits the frequency of progress messages it sends (see "
4604 "C<daemon/proto.c:notify_progress>). Not all calls generate progress "
4609 #: ../src/guestfs.pod:2366
4610 msgid "LIBGUESTFS VERSION NUMBERS"
4614 #: ../src/guestfs.pod:2368
4616 "Since April 2010, libguestfs has started to make separate development and "
4617 "stable releases, along with corresponding branches in our git repository. "
4618 "These separate releases can be identified by version number:"
4622 #: ../src/guestfs.pod:2373
4625 " even numbers for stable: 1.2.x, 1.4.x, ...\n"
4626 " .-------- odd numbers for development: 1.3.x, 1.5.x, ...\n"
4632 " | `-------- sub-version\n"
4634 " `------ always '1' because we don't change the ABI\n"
4639 #: ../src/guestfs.pod:2384
4640 msgid "Thus \"1.3.5\" is the 5th update to the development branch \"1.3\"."
4644 #: ../src/guestfs.pod:2386
4646 "As time passes we cherry pick fixes from the development branch and backport "
4647 "those into the stable branch, the effect being that the stable branch should "
4648 "get more stable and less buggy over time. So the stable releases are ideal "
4649 "for people who don't need new features but would just like the software to "
4654 #: ../src/guestfs.pod:2392
4655 msgid "Our criteria for backporting changes are:"
4659 #: ../src/guestfs.pod:2398
4661 "Documentation changes which don't affect any code are backported unless the "
4662 "documentation refers to a future feature which is not in stable."
4666 #: ../src/guestfs.pod:2404
4668 "Bug fixes which are not controversial, fix obvious problems, and have been "
4669 "well tested are backported."
4673 #: ../src/guestfs.pod:2409
4675 "Simple rearrangements of code which shouldn't affect how it works get "
4676 "backported. This is so that the code in the two branches doesn't get too "
4677 "far out of step, allowing us to backport future fixes more easily."
4681 #: ../src/guestfs.pod:2415
4683 "We I<don't> backport new features, new APIs, new tools etc, except in one "
4684 "exceptional case: the new feature is required in order to implement an "
4685 "important bug fix."
4689 #: ../src/guestfs.pod:2421
4691 "A new stable branch starts when we think the new features in development are "
4692 "substantial and compelling enough over the current stable branch to warrant "
4693 "it. When that happens we create new stable and development versions 1.N.0 "
4694 "and 1.(N+1).0 [N is even]. The new dot-oh release won't necessarily be so "
4695 "stable at this point, but by backporting fixes from development, that branch "
4696 "will stabilize over time."
4700 #: ../src/guestfs.pod:2429
4701 msgid "EXTENDING LIBGUESTFS"
4705 #: ../src/guestfs.pod:2431
4706 msgid "ADDING A NEW API ACTION"
4710 #: ../src/guestfs.pod:2433
4712 "Large amounts of boilerplate code in libguestfs (RPC, bindings, "
4713 "documentation) are generated, and this makes it easy to extend the "
4718 #: ../src/guestfs.pod:2437
4719 msgid "To add a new API action there are two changes:"
4723 #: ../src/guestfs.pod:2443
4725 "You need to add a description of the call (name, parameters, return type, "
4726 "tests, documentation) to C<generator/generator_actions.ml>."
4730 #: ../src/guestfs.pod:2446
4732 "There are two sorts of API action, depending on whether the call goes "
4733 "through to the daemon in the appliance, or is serviced entirely by the "
4734 "library (see L</ARCHITECTURE> above). L</guestfs_sync> is an example of the "
4735 "former, since the sync is done in the appliance. L</guestfs_set_trace> is "
4736 "an example of the latter, since a trace flag is maintained in the handle and "
4737 "all tracing is done on the library side."
4741 #: ../src/guestfs.pod:2454
4743 "Most new actions are of the first type, and get added to the "
4744 "C<daemon_functions> list. Each function has a unique procedure number used "
4745 "in the RPC protocol which is assigned to that action when we publish "
4746 "libguestfs and cannot be reused. Take the latest procedure number and "
4751 #: ../src/guestfs.pod:2460
4753 "For library-only actions of the second type, add to the "
4754 "C<non_daemon_functions> list. Since these functions are serviced by the "
4755 "library and do not travel over the RPC mechanism to the daemon, these "
4756 "functions do not need a procedure number, and so the procedure number is set "
4761 #: ../src/guestfs.pod:2468
4762 msgid "Implement the action (in C):"
4766 #: ../src/guestfs.pod:2470
4768 "For daemon actions, implement the function C<do_E<lt>nameE<gt>> in the "
4769 "C<daemon/> directory."
4773 #: ../src/guestfs.pod:2473
4775 "For library actions, implement the function C<guestfs__E<lt>nameE<gt>> "
4776 "(note: double underscore) in the C<src/> directory."
4780 #: ../src/guestfs.pod:2476
4781 msgid "In either case, use another function as an example of what to do."
4785 #: ../src/guestfs.pod:2480
4786 msgid "After making these changes, use C<make> to compile."
4790 #: ../src/guestfs.pod:2482
4792 "Note that you don't need to implement the RPC, language bindings, manual "
4793 "pages or anything else. It's all automatically generated from the OCaml "
4798 #: ../src/guestfs.pod:2486
4799 msgid "ADDING TESTS FOR AN API ACTION"
4803 #: ../src/guestfs.pod:2488
4805 "You can supply zero or as many tests as you want per API call. The tests "
4806 "can either be added as part of the API description (C<generator/"
4807 "generator_actions.ml>), or in some rarer cases you may want to drop a script "
4808 "into C<regressions/>. Note that adding a script to C<regressions/> is "
4809 "slower, so if possible use the first method."
4813 #: ../src/guestfs.pod:2494
4815 "The following describes the test environment used when you add an API test "
4816 "in C<generator_actions.ml>."
4820 #: ../src/guestfs.pod:2497
4821 msgid "The test environment has 4 block devices:"
4825 #: ../src/guestfs.pod:2501
4826 msgid "C</dev/sda> 500MB"
4830 #: ../src/guestfs.pod:2503
4831 msgid "General block device for testing."
4835 #: ../src/guestfs.pod:2505
4836 msgid "C</dev/sdb> 50MB"
4840 #: ../src/guestfs.pod:2507
4842 "C</dev/sdb1> is an ext2 filesystem used for testing filesystem write "
4847 #: ../src/guestfs.pod:2510
4848 msgid "C</dev/sdc> 10MB"
4852 #: ../src/guestfs.pod:2512
4853 msgid "Used in a few tests where two block devices are needed."
4857 #: ../src/guestfs.pod:2514
4859 msgstr "C</dev/sdd>"
4862 #: ../src/guestfs.pod:2516
4863 msgid "ISO with fixed content (see C<images/test.iso>)."
4867 #: ../src/guestfs.pod:2520
4869 "To be able to run the tests in a reasonable amount of time, the libguestfs "
4870 "appliance and block devices are reused between tests. So don't try testing "
4871 "L</guestfs_kill_subprocess> :-x"
4875 #: ../src/guestfs.pod:2524
4877 "Each test starts with an initial scenario, selected using one of the "
4878 "C<Init*> expressions, described in C<generator/generator_types.ml>. These "
4879 "initialize the disks mentioned above in a particular way as documented in "
4880 "C<generator_types.ml>. You should not assume anything about the previous "
4881 "contents of other disks that are not initialized."