1 # SOME DESCRIPTIVE TITLE
2 # Copyright (C) YEAR Red Hat Inc.
3 # This file is distributed under the same license as the libguestfs package.
5 # Yuri Chornoivan <yurchor@ukr.net>, 2011.
8 "Project-Id-Version: libguestfs\n"
9 "Report-Msgid-Bugs-To: https://bugzilla.redhat.com/\n"
10 "POT-Creation-Date: 2011-07-15 17:18+0200\n"
11 "PO-Revision-Date: 2011-07-17 20:50+0000\n"
12 "Last-Translator: rjones <rjones@redhat.com>\n"
13 "Language-Team: Ukrainian <trans-uk@lists.fedoraproject.org>\n"
15 "Content-Type: text/plain; charset=UTF-8\n"
16 "Content-Transfer-Encoding: 8bit\n"
18 "Plural-Forms: nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2)\n"
21 #: ../src/guestfs.pod:3 ../fish/guestfish.pod:3
22 #: ../test-tool/libguestfs-test-tool.pod:3 ../fuse/guestmount.pod:3
23 #: ../tools/virt-win-reg.pl:35 ../tools/virt-list-filesystems.pl:30
24 #: ../tools/virt-tar.pl:31 ../tools/virt-make-fs.pl:35
25 #: ../tools/virt-list-partitions.pl:30
30 #: ../src/guestfs.pod:5
31 msgid "guestfs - Library for accessing and modifying virtual machine images"
33 "guestfs — бібліотека для доступу та внесення змін до образів віртуальних "
37 #: ../src/guestfs.pod:7 ../fish/guestfish.pod:7
38 #: ../test-tool/libguestfs-test-tool.pod:7 ../fuse/guestmount.pod:7
39 #: ../tools/virt-win-reg.pl:39 ../tools/virt-list-filesystems.pl:34
40 #: ../tools/virt-tar.pl:35 ../tools/virt-make-fs.pl:39
41 #: ../tools/virt-list-partitions.pl:34
43 msgstr "КОРОТКИЙ ОПИС"
46 #: ../src/guestfs.pod:9
49 " #include <guestfs.h>\n"
52 " #include <guestfs.h>\n"
56 #: ../src/guestfs.pod:11
59 " guestfs_h *g = guestfs_create ();\n"
60 " guestfs_add_drive (g, \"guest.img\");\n"
61 " guestfs_launch (g);\n"
62 " guestfs_mount (g, \"/dev/sda1\", \"/\");\n"
63 " guestfs_touch (g, \"/hello\");\n"
64 " guestfs_umount (g, \"/\");\n"
65 " guestfs_close (g);\n"
68 " guestfs_h *g = guestfs_create ();\n"
69 " guestfs_add_drive (g, \"guest.img\");\n"
70 " guestfs_launch (g);\n"
71 " guestfs_mount (g, \"/dev/sda1\", \"/\");\n"
72 " guestfs_touch (g, \"/hello\");\n"
73 " guestfs_umount (g, \"/\");\n"
74 " guestfs_close (g);\n"
78 #: ../src/guestfs.pod:19
81 " cc prog.c -o prog -lguestfs\n"
83 " cc prog.c -o prog `pkg-config libguestfs --cflags --libs`\n"
86 " cc prog.c -o prog -lguestfs\n"
88 " cc prog.c -o prog `pkg-config libguestfs --cflags --libs`\n"
92 #: ../src/guestfs.pod:23 ../fish/guestfish.pod:30
93 #: ../test-tool/libguestfs-test-tool.pod:11 ../fuse/guestmount.pod:20
94 #: ../tools/virt-win-reg.pl:63 ../tools/virt-list-filesystems.pl:40
95 #: ../tools/virt-tar.pl:77 ../tools/virt-make-fs.pl:47
96 #: ../tools/virt-list-partitions.pl:40
101 #: ../src/guestfs.pod:25
103 "Libguestfs is a library for accessing and modifying guest disk images. "
104 "Amongst the things this is good for: making batch configuration changes to "
105 "guests, getting disk used/free statistics (see also: virt-df), migrating "
106 "between virtualization systems (see also: virt-p2v), performing partial "
107 "backups, performing partial guest clones, cloning guests and changing "
108 "registry/UUID/hostname info, and much else besides."
112 #: ../src/guestfs.pod:33
114 "Libguestfs uses Linux kernel and qemu code, and can access any type of guest"
115 " filesystem that Linux and qemu can, including but not limited to: ext2/3/4,"
116 " btrfs, FAT and NTFS, LVM, many different disk partition schemes, qcow, "
121 #: ../src/guestfs.pod:38
123 "Libguestfs provides ways to enumerate guest storage (eg. partitions, LVs, "
124 "what filesystem is in each LV, etc.). It can also run commands in the "
125 "context of the guest. Also you can access filesystems over FUSE."
129 #: ../src/guestfs.pod:43
131 "Libguestfs is a library that can be linked with C and C++ management "
132 "programs (or management programs written in OCaml, Perl, Python, Ruby, Java,"
133 " PHP, Haskell or C#). You can also use it from shell scripts or the command"
138 #: ../src/guestfs.pod:48
140 "You don't need to be root to use libguestfs, although obviously you do need "
141 "enough permissions to access the disk images."
145 #: ../src/guestfs.pod:51
147 "Libguestfs is a large API because it can do many things. For a gentle "
148 "introduction, please read the L</API OVERVIEW> section next."
152 #: ../src/guestfs.pod:54
154 "There are also some example programs in the L<guestfs-examples(3)> manual "
159 #: ../src/guestfs.pod:57
164 #: ../src/guestfs.pod:59
166 "This section provides a gentler overview of the libguestfs API. We also try"
167 " to group API calls together, where that may not be obvious from reading "
168 "about the individual calls in the main section of this manual."
172 #: ../src/guestfs.pod:64
177 #: ../src/guestfs.pod:66
179 "Before you can use libguestfs calls, you have to create a handle. Then you "
180 "must add at least one disk image to the handle, followed by launching the "
181 "handle, then performing whatever operations you want, and finally closing "
182 "the handle. By convention we use the single letter C<g> for the name of the"
183 " handle variable, although of course you can use any name you want."
187 #: ../src/guestfs.pod:73
189 "The general structure of all libguestfs-using programs looks like this:"
193 #: ../src/guestfs.pod:76
196 " guestfs_h *g = guestfs_create ();\n"
199 " guestfs_h *g = guestfs_create ();\n"
203 #: ../src/guestfs.pod:78
206 " /* Call guestfs_add_drive additional times if there are\n"
207 " * multiple disk images.\n"
209 " guestfs_add_drive (g, \"guest.img\");\n"
214 #: ../src/guestfs.pod:83
217 " /* Most manipulation calls won't work until you've launched\n"
218 " * the handle 'g'. You have to do this _after_ adding drives\n"
219 " * and _before_ other commands.\n"
221 " guestfs_launch (g);\n"
226 #: ../src/guestfs.pod:89
229 " /* Now you can examine what partitions, LVs etc are available.\n"
231 " char **partitions = guestfs_list_partitions (g);\n"
232 " char **logvols = guestfs_lvs (g);\n"
235 " /* Тепер можна перевірити, які розділи, логічні томи тощо доступні.\n"
237 " char **partitions = guestfs_list_partitions (g);\n"
238 " char **logvols = guestfs_lvs (g);\n"
242 #: ../src/guestfs.pod:94
245 " /* To access a filesystem in the image, you must mount it.\n"
247 " guestfs_mount (g, \"/dev/sda1\", \"/\");\n"
250 " /* Щоб отримати доступ до файлової системи на образі, вам слід його змонтувати.\n"
252 " guestfs_mount (g, \"/dev/sda1\", \"/\");\n"
256 #: ../src/guestfs.pod:98
259 " /* Now you can perform filesystem actions on the guest\n"
262 " guestfs_touch (g, \"/hello\");\n"
267 #: ../src/guestfs.pod:103
270 " /* This is only needed for libguestfs < 1.5.24. Since then\n"
271 " * it is done automatically when you close the handle. See\n"
272 " * discussion of autosync in this page.\n"
274 " guestfs_sync (g);\n"
279 #: ../src/guestfs.pod:109
282 " /* Close the handle 'g'. */\n"
283 " guestfs_close (g);\n"
286 " /* Закрити дескриптор 'g'. */\n"
287 " guestfs_close (g);\n"
291 #: ../src/guestfs.pod:112
293 "The code above doesn't include any error checking. In real code you should "
294 "check return values carefully for errors. In general all functions that "
295 "return integers return C<-1> on error, and all functions that return "
296 "pointers return C<NULL> on error. See section L</ERROR HANDLING> below for "
297 "how to handle errors, and consult the documentation for each function call "
298 "below to see precisely how they return error indications. See L<guestfs-"
299 "examples(3)> for fully worked examples."
303 #: ../src/guestfs.pod:121
305 msgstr "ОБРАЗИ ДИСКІВ"
308 #: ../src/guestfs.pod:123
310 "The image filename (C<\"guest.img\"> in the example above) could be a disk "
311 "image from a virtual machine, a L<dd(1)> copy of a physical hard disk, an "
312 "actual block device, or simply an empty file of zeroes that you have created"
313 " through L<posix_fallocate(3)>. Libguestfs lets you do useful things to all"
318 #: ../src/guestfs.pod:129
320 "The call you should use in modern code for adding drives is "
321 "L</guestfs_add_drive_opts>. To add a disk image, allowing writes, and "
322 "specifying that the format is raw, do:"
326 #: ../src/guestfs.pod:133
329 " guestfs_add_drive_opts (g, filename,\n"
330 " GUESTFS_ADD_DRIVE_OPTS_FORMAT, \"raw\",\n"
334 " guestfs_add_drive_opts (g, filename,\n"
335 " GUESTFS_ADD_DRIVE_OPTS_FORMAT, \"raw\",\n"
340 #: ../src/guestfs.pod:137
341 msgid "You can add a disk read-only using:"
342 msgstr "Ви можете додати диск у режимі лише читання:"
345 #: ../src/guestfs.pod:139
348 " guestfs_add_drive_opts (g, filename,\n"
349 " GUESTFS_ADD_DRIVE_OPTS_FORMAT, \"raw\",\n"
350 " GUESTFS_ADD_DRIVE_OPTS_READONLY, 1,\n"
354 " guestfs_add_drive_opts (g, filename,\n"
355 " GUESTFS_ADD_DRIVE_OPTS_FORMAT, \"raw\",\n"
356 " GUESTFS_ADD_DRIVE_OPTS_READONLY, 1,\n"
361 #: ../src/guestfs.pod:144
363 "or by calling the older function L</guestfs_add_drive_ro>. In either case "
364 "libguestfs won't modify the file."
368 #: ../src/guestfs.pod:147
370 "Be extremely cautious if the disk image is in use, eg. if it is being used "
371 "by a virtual machine. Adding it read-write will almost certainly cause disk"
372 " corruption, but adding it read-only is safe."
376 #: ../src/guestfs.pod:151
378 "You must add at least one disk image, and you may add multiple disk images."
379 " In the API, the disk images are usually referred to as C</dev/sda> (for "
380 "the first one you added), C</dev/sdb> (for the second one you added), etc."
384 #: ../src/guestfs.pod:156
386 "Once L</guestfs_launch> has been called you cannot add any more images. You"
387 " can call L</guestfs_list_devices> to get a list of the device names, in the"
388 " order that you added them. See also L</BLOCK DEVICE NAMING> below."
392 #: ../src/guestfs.pod:161
397 #: ../src/guestfs.pod:163
399 "Before you can read or write files, create directories and so on in a disk "
400 "image that contains filesystems, you have to mount those filesystems using "
401 "L</guestfs_mount_options> or L</guestfs_mount_ro>. If you already know that"
402 " a disk image contains (for example) one partition with a filesystem on that"
403 " partition, then you can mount it directly:"
407 #: ../src/guestfs.pod:170
410 " guestfs_mount_options (g, \"\", \"/dev/sda1\", \"/\");\n"
413 " guestfs_mount_options (g, \"\", \"/dev/sda1\", \"/\");\n"
417 #: ../src/guestfs.pod:172
419 "where C</dev/sda1> means literally the first partition (C<1>) of the first "
420 "disk image that we added (C</dev/sda>). If the disk contains Linux LVM2 "
421 "logical volumes you could refer to those instead (eg. C</dev/VG/LV>). Note "
422 "that these are libguestfs virtual devices, and are nothing to do with host "
427 #: ../src/guestfs.pod:178
429 "If you are given a disk image and you don't know what it contains then you "
430 "have to find out. Libguestfs can do that too: use "
431 "L</guestfs_list_partitions> and L</guestfs_lvs> to list possible partitions "
432 "and LVs, and either try mounting each to see what is mountable, or else "
433 "examine them with L</guestfs_vfs_type> or L</guestfs_file>. To list just "
434 "filesystems, use L</guestfs_list_filesystems>."
438 #: ../src/guestfs.pod:186
440 "Libguestfs also has a set of APIs for inspection of unknown disk images (see"
441 " L</INSPECTION> below). But you might find it easier to look at higher "
442 "level programs built on top of libguestfs, in particular L<virt-"
447 #: ../src/guestfs.pod:191
449 "To mount a filesystem read-only, use L</guestfs_mount_ro>. There are "
450 "several other variations of the C<guestfs_mount_*> call."
454 #: ../src/guestfs.pod:194
455 msgid "FILESYSTEM ACCESS AND MODIFICATION"
456 msgstr "ДОСТУП ТА ВНЕСЕННЯ ЗМІН ДО ФАЙЛОВИХ СИСТЕМ"
459 #: ../src/guestfs.pod:196
461 "The majority of the libguestfs API consists of fairly low-level calls for "
462 "accessing and modifying the files, directories, symlinks etc on mounted "
463 "filesystems. There are over a hundred such calls which you can find listed "
464 "in detail below in this man page, and we don't even pretend to cover them "
465 "all in this overview."
469 #: ../src/guestfs.pod:202
471 "Specify filenames as full paths, starting with C<\"/\"> and including the "
474 "Вказуйте адреси і назви файлів повністю, починаючи з C<\"/\">, разом з "
478 #: ../src/guestfs.pod:205
480 "For example, if you mounted a filesystem at C<\"/\"> and you want to read "
481 "the file called C<\"etc/passwd\"> then you could do:"
483 "Наприклад, якщо вами змонтовано файлову систему до C<\"/\">, і ви бажаєте "
484 "виконати читання файла з назвою C<\"etc/passwd\">, ви можете скористатися "
488 #: ../src/guestfs.pod:208
491 " char *data = guestfs_cat (g, \"/etc/passwd\");\n"
494 " char *data = guestfs_cat (g, \"/etc/passwd\");\n"
498 #: ../src/guestfs.pod:210
500 "This would return C<data> as a newly allocated buffer containing the full "
501 "content of that file (with some conditions: see also L</DOWNLOADING> below),"
502 " or C<NULL> if there was an error."
506 #: ../src/guestfs.pod:214
508 "As another example, to create a top-level directory on that filesystem "
509 "called C<\"var\"> you would do:"
513 #: ../src/guestfs.pod:217
516 " guestfs_mkdir (g, \"/var\");\n"
519 " guestfs_mkdir (g, \"/var\");\n"
523 #: ../src/guestfs.pod:219
524 msgid "To create a symlink you could do:"
526 "Щоб створити символічне посилання, ви можете скористатися таким кодом:"
529 #: ../src/guestfs.pod:221
532 " guestfs_ln_s (g, \"/etc/init.d/portmap\",\n"
533 " \"/etc/rc3.d/S30portmap\");\n"
536 " guestfs_ln_s (g, \"/etc/init.d/portmap\",\n"
537 " \"/etc/rc3.d/S30portmap\");\n"
541 #: ../src/guestfs.pod:224
543 "Libguestfs will reject attempts to use relative paths and there is no "
544 "concept of a current working directory."
548 #: ../src/guestfs.pod:227
550 "Libguestfs can return errors in many situations: for example if the "
551 "filesystem isn't writable, or if a file or directory that you requested "
552 "doesn't exist. If you are using the C API (documented here) you have to "
553 "check for those error conditions after each call. (Other language bindings "
554 "turn these errors into exceptions)."
558 #: ../src/guestfs.pod:233
560 "File writes are affected by the per-handle umask, set by calling "
561 "L</guestfs_umask> and defaulting to 022. See L</UMASK>."
565 #: ../src/guestfs.pod:236
567 msgstr "ПОДІЛ НА РОЗДІЛИ"
570 #: ../src/guestfs.pod:238
572 "Libguestfs contains API calls to read, create and modify partition tables on"
577 #: ../src/guestfs.pod:241
579 "In the common case where you want to create a single partition covering the "
580 "whole disk, you should use the L</guestfs_part_disk> call:"
584 #: ../src/guestfs.pod:245
587 " const char *parttype = \"mbr\";\n"
588 " if (disk_is_larger_than_2TB)\n"
589 " parttype = \"gpt\";\n"
590 " guestfs_part_disk (g, \"/dev/sda\", parttype);\n"
593 " const char *parttype = \"mbr\";\n"
594 " if (disk_is_larger_than_2TB)\n"
595 " parttype = \"gpt\";\n"
596 " guestfs_part_disk (g, \"/dev/sda\", parttype);\n"
600 #: ../src/guestfs.pod:250
602 "Obviously this effectively wipes anything that was on that disk image "
607 #: ../src/guestfs.pod:253
612 #: ../src/guestfs.pod:255
614 "Libguestfs provides access to a large part of the LVM2 API, such as "
615 "L</guestfs_lvcreate> and L</guestfs_vgremove>. It won't make much sense "
616 "unless you familiarize yourself with the concepts of physical volumes, "
617 "volume groups and logical volumes."
621 #: ../src/guestfs.pod:260
623 "This author strongly recommends reading the LVM HOWTO, online at "
624 "L<http://tldp.org/HOWTO/LVM-HOWTO/>."
628 #: ../src/guestfs.pod:263
630 msgstr "ОТРИМАННЯ ДАНИХ"
633 #: ../src/guestfs.pod:265
635 "Use L</guestfs_cat> to download small, text only files. This call is "
636 "limited to files which are less than 2 MB and which cannot contain any ASCII"
637 " NUL (C<\\0>) characters. However the API is very simple to use."
641 #: ../src/guestfs.pod:269
643 "L</guestfs_read_file> can be used to read files which contain arbitrary 8 "
644 "bit data, since it returns a (pointer, size) pair. However it is still "
645 "limited to \"small\" files, less than 2 MB."
649 #: ../src/guestfs.pod:273
651 "L</guestfs_download> can be used to download any file, with no limits on "
652 "content or size (even files larger than 4 GB)."
656 #: ../src/guestfs.pod:276
658 "To download multiple files, see L</guestfs_tar_out> and L</guestfs_tgz_out>."
662 #: ../src/guestfs.pod:279
664 msgstr "ВИВАНТАЖЕННЯ"
667 #: ../src/guestfs.pod:281
669 "It's often the case that you want to write a file or files to the disk "
674 #: ../src/guestfs.pod:284
676 "To write a small file with fixed content, use L</guestfs_write>. To create "
677 "a file of all zeroes, use L</guestfs_truncate_size> (sparse) or "
678 "L</guestfs_fallocate64> (with all disk blocks allocated). There are a "
679 "variety of other functions for creating test files, for example "
680 "L</guestfs_fill> and L</guestfs_fill_pattern>."
684 #: ../src/guestfs.pod:290
686 "To upload a single file, use L</guestfs_upload>. This call has no limits on"
687 " file content or size (even files larger than 4 GB)."
691 #: ../src/guestfs.pod:293
693 "To upload multiple files, see L</guestfs_tar_in> and L</guestfs_tgz_in>."
697 #: ../src/guestfs.pod:295
699 "However the fastest way to upload I<large numbers of arbitrary files> is to "
700 "turn them into a squashfs or CD ISO (see L<mksquashfs(8)> and "
701 "L<mkisofs(8)>), then attach this using L</guestfs_add_drive_ro>. If you add"
702 " the drive in a predictable way (eg. adding it last after all other drives) "
703 "then you can get the device name from L</guestfs_list_devices> and mount it "
704 "directly using L</guestfs_mount_ro>. Note that squashfs images are "
705 "sometimes non-portable between kernel versions, and they don't support "
706 "labels or UUIDs. If you want to pre-build an image or you need to mount it "
707 "using a label or UUID, use an ISO image instead."
711 #: ../src/guestfs.pod:306
716 #: ../src/guestfs.pod:308
718 "There are various different commands for copying between files and devices "
719 "and in and out of the guest filesystem. These are summarised in the table "
724 #: ../src/guestfs.pod:314
725 msgid "B<file> to B<file>"
726 msgstr "B<файл> у B<файл>"
729 #: ../src/guestfs.pod:316
731 "Use L</guestfs_cp> to copy a single file, or L</guestfs_cp_a> to copy "
732 "directories recursively."
736 #: ../src/guestfs.pod:319
737 msgid "B<file or device> to B<file or device>"
738 msgstr "B<файл або пристрій> у B<файл або пристрій>"
741 #: ../src/guestfs.pod:321
743 "Use L</guestfs_dd> which efficiently uses L<dd(1)> to copy between files and"
744 " devices in the guest."
748 #: ../src/guestfs.pod:324
749 msgid "Example: duplicate the contents of an LV:"
753 #: ../src/guestfs.pod:326
756 " guestfs_dd (g, \"/dev/VG/Original\", \"/dev/VG/Copy\");\n"
759 " guestfs_dd (g, \"/dev/VG/Original\", \"/dev/VG/Copy\");\n"
763 #: ../src/guestfs.pod:328
765 "The destination (C</dev/VG/Copy>) must be at least as large as the source "
766 "(C</dev/VG/Original>). To copy less than the whole source device, use "
767 "L</guestfs_copy_size>."
771 #: ../src/guestfs.pod:332
772 msgid "B<file on the host> to B<file or device>"
776 #: ../src/guestfs.pod:334
777 msgid "Use L</guestfs_upload>. See L</UPLOADING> above."
781 #: ../src/guestfs.pod:336
782 msgid "B<file or device> to B<file on the host>"
786 #: ../src/guestfs.pod:338
787 msgid "Use L</guestfs_download>. See L</DOWNLOADING> above."
791 #: ../src/guestfs.pod:342
792 msgid "UPLOADING AND DOWNLOADING TO PIPES AND FILE DESCRIPTORS"
796 #: ../src/guestfs.pod:344
798 "Calls like L</guestfs_upload>, L</guestfs_download>, L</guestfs_tar_in>, "
799 "L</guestfs_tar_out> etc appear to only take filenames as arguments, so it "
800 "appears you can only upload and download to files. However many Un*x-like "
801 "hosts let you use the special device files C</dev/stdin>, C</dev/stdout>, "
802 "C</dev/stderr> and C</dev/fd/N> to read and write from stdin, stdout, "
803 "stderr, and arbitrary file descriptor N."
807 #: ../src/guestfs.pod:352
808 msgid "For example, L<virt-cat(1)> writes its output to stdout by doing:"
812 #: ../src/guestfs.pod:355
815 " guestfs_download (g, filename, \"/dev/stdout\");\n"
818 " guestfs_download (g, filename, \"/dev/stdout\");\n"
822 #: ../src/guestfs.pod:357
823 msgid "and you can write tar output to a file descriptor C<fd> by doing:"
827 #: ../src/guestfs.pod:359
831 " snprintf (devfd, sizeof devfd, \"/dev/fd/%d\", fd);\n"
832 " guestfs_tar_out (g, \"/\", devfd);\n"
836 " snprintf (devfd, sizeof devfd, \"/dev/fd/%d\", fd);\n"
837 " guestfs_tar_out (g, \"/\", devfd);\n"
841 #: ../src/guestfs.pod:363
842 msgid "LISTING FILES"
843 msgstr "СПИСКИ ФАЙЛІВ"
846 #: ../src/guestfs.pod:365
848 "L</guestfs_ll> is just designed for humans to read (mainly when using the "
849 "L<guestfish(1)>-equivalent command C<ll>)."
853 #: ../src/guestfs.pod:368
855 "L</guestfs_ls> is a quick way to get a list of files in a directory from "
856 "programs, as a flat list of strings."
860 #: ../src/guestfs.pod:371
862 "L</guestfs_readdir> is a programmatic way to get a list of files in a "
863 "directory, plus additional information about each one. It is more "
864 "equivalent to using the L<readdir(3)> call on a local filesystem."
868 #: ../src/guestfs.pod:375
870 "L</guestfs_find> and L</guestfs_find0> can be used to recursively list "
875 #: ../src/guestfs.pod:378
876 msgid "RUNNING COMMANDS"
877 msgstr "ВИКОНАННЯ КОМАНД"
880 #: ../src/guestfs.pod:380
882 "Although libguestfs is primarily an API for manipulating files inside guest "
883 "images, we also provide some limited facilities for running commands inside "
888 #: ../src/guestfs.pod:384
889 msgid "There are many limitations to this:"
893 #: ../src/guestfs.pod:388 ../src/guestfs.pod:393 ../src/guestfs.pod:398
894 #: ../src/guestfs.pod:402 ../src/guestfs.pod:407 ../src/guestfs.pod:411
895 #: ../src/guestfs.pod:416 ../src/guestfs.pod:421 ../src/guestfs.pod:1064
896 #: ../src/guestfs.pod:1068 ../src/guestfs.pod:1072 ../src/guestfs.pod:1077
897 #: ../src/guestfs.pod:1085 ../src/guestfs.pod:1104 ../src/guestfs.pod:1112
898 #: ../src/guestfs.pod:1134 ../src/guestfs.pod:1138 ../src/guestfs.pod:1142
899 #: ../src/guestfs.pod:1146 ../src/guestfs.pod:1150 ../src/guestfs.pod:1154
900 #: ../src/guestfs.pod:1643 ../src/guestfs.pod:1648 ../src/guestfs.pod:1652
901 #: ../src/guestfs.pod:1754 ../src/guestfs.pod:1759 ../src/guestfs.pod:1763
902 #: ../src/guestfs.pod:1773 ../src/guestfs.pod:2047 ../src/guestfs.pod:2052
903 #: ../src/guestfs.pod:2058 ../src/guestfs.pod:2066 ../src/guestfs.pod:2420
904 #: ../src/guestfs.pod:2426 ../src/guestfs.pod:2431 ../src/guestfs.pod:2437
905 #: ../src/guestfs.pod:3011 ../src/guestfs.pod:3015 ../src/guestfs.pod:3019
906 #: ../src/guestfs.pod:3023 ../src/guestfs-actions.pod:15
907 #: ../src/guestfs-actions.pod:22 ../src/guestfs-actions.pod:583
908 #: ../src/guestfs-actions.pod:591 ../src/guestfs-actions.pod:598
909 #: ../src/guestfs-actions.pod:605 ../src/guestfs-actions.pod:1662
910 #: ../src/guestfs-actions.pod:1666 ../src/guestfs-actions.pod:1670
911 #: ../src/guestfs-actions.pod:1674 ../src/guestfs-actions.pod:1682
912 #: ../src/guestfs-actions.pod:1686 ../src/guestfs-actions.pod:1690
913 #: ../src/guestfs-actions.pod:1700 ../src/guestfs-actions.pod:1704
914 #: ../src/guestfs-actions.pod:1708 ../src/guestfs-actions.pod:1846
915 #: ../src/guestfs-actions.pod:1850 ../src/guestfs-actions.pod:1855
916 #: ../src/guestfs-actions.pod:1860 ../src/guestfs-actions.pod:1921
917 #: ../src/guestfs-actions.pod:1925 ../src/guestfs-actions.pod:1930
918 #: ../src/guestfs-actions.pod:2857 ../src/guestfs-actions.pod:2863
919 #: ../src/guestfs-actions.pod:2871 ../src/guestfs-actions.pod:2878
920 #: ../src/guestfs-actions.pod:2885 ../fish/guestfish.pod:445
921 #: ../fish/guestfish.pod:449 ../fish/guestfish.pod:453
922 #: ../fish/guestfish.pod:457 ../fish/guestfish-actions.pod:13
923 #: ../fish/guestfish-actions.pod:20 ../fish/guestfish-actions.pod:385
924 #: ../fish/guestfish-actions.pod:393 ../fish/guestfish-actions.pod:400
925 #: ../fish/guestfish-actions.pod:407 ../fish/guestfish-actions.pod:1099
926 #: ../fish/guestfish-actions.pod:1103 ../fish/guestfish-actions.pod:1107
927 #: ../fish/guestfish-actions.pod:1111 ../fish/guestfish-actions.pod:1119
928 #: ../fish/guestfish-actions.pod:1123 ../fish/guestfish-actions.pod:1127
929 #: ../fish/guestfish-actions.pod:1137 ../fish/guestfish-actions.pod:1141
930 #: ../fish/guestfish-actions.pod:1145 ../fish/guestfish-actions.pod:1235
931 #: ../fish/guestfish-actions.pod:1239 ../fish/guestfish-actions.pod:1244
932 #: ../fish/guestfish-actions.pod:1249 ../fish/guestfish-actions.pod:1291
933 #: ../fish/guestfish-actions.pod:1295 ../fish/guestfish-actions.pod:1300
934 #: ../fish/guestfish-actions.pod:1933 ../fish/guestfish-actions.pod:1939
935 #: ../fish/guestfish-actions.pod:1947 ../fish/guestfish-actions.pod:1954
936 #: ../fish/guestfish-actions.pod:1961 ../tools/virt-win-reg.pl:195
937 #: ../tools/virt-win-reg.pl:200 ../tools/virt-win-reg.pl:206
938 #: ../tools/virt-win-reg.pl:708 ../tools/virt-win-reg.pl:714
939 #: ../tools/virt-win-reg.pl:720
944 #: ../src/guestfs.pod:390
946 "The kernel version that the command runs under will be different from what "
951 #: ../src/guestfs.pod:395
953 "If the command needs to communicate with daemons, then most likely they "
958 #: ../src/guestfs.pod:400
959 msgid "The command will be running in limited memory."
963 #: ../src/guestfs.pod:404
965 "The network may not be available unless you enable it (see "
966 "L</guestfs_set_network>)."
970 #: ../src/guestfs.pod:409
971 msgid "Only supports Linux guests (not Windows, BSD, etc)."
975 #: ../src/guestfs.pod:413
977 "Architecture limitations (eg. won't work for a PPC guest on an X86 host)."
981 #: ../src/guestfs.pod:418
983 "For SELinux guests, you may need to enable SELinux and load policy first. "
984 "See L</SELINUX> in this manpage."
988 #: ../src/guestfs.pod:423
990 "I<Security:> It is not safe to run commands from untrusted, possibly "
991 "malicious guests. These commands may attempt to exploit your program by "
992 "sending unexpected output. They could also try to exploit the Linux kernel "
993 "or qemu provided by the libguestfs appliance. They could use the network "
994 "provided by the libguestfs appliance to bypass ordinary network partitions "
995 "and firewalls. They could use the elevated privileges or different SELinux "
996 "context of your program to their advantage."
1000 #: ../src/guestfs.pod:432
1002 "A secure alternative is to use libguestfs to install a \"firstboot\" script "
1003 "(a script which runs when the guest next boots normally), and to have this "
1004 "script run the commands you want in the normal context of the running guest,"
1005 " network security and so on. For information about other security issues, "
1010 #: ../src/guestfs.pod:440
1012 "The two main API calls to run commands are L</guestfs_command> and "
1013 "L</guestfs_sh> (there are also variations)."
1017 #: ../src/guestfs.pod:443
1019 "The difference is that L</guestfs_sh> runs commands using the shell, so any "
1020 "shell globs, redirections, etc will work."
1024 #: ../src/guestfs.pod:446
1025 msgid "CONFIGURATION FILES"
1026 msgstr "ФАЙЛИ НАЛАШТУВАННЯ"
1029 #: ../src/guestfs.pod:448
1031 "To read and write configuration files in Linux guest filesystems, we "
1032 "strongly recommend using Augeas. For example, Augeas understands how to "
1033 "read and write, say, a Linux shadow password file or X.org configuration "
1034 "file, and so avoids you having to write that code."
1038 #: ../src/guestfs.pod:453
1040 "The main Augeas calls are bound through the C<guestfs_aug_*> APIs. We don't"
1041 " document Augeas itself here because there is excellent documentation on the"
1042 " L<http://augeas.net/> website."
1046 #: ../src/guestfs.pod:457
1048 "If you don't want to use Augeas (you fool!) then try calling "
1049 "L</guestfs_read_lines> to get the file as a list of lines which you can "
1054 #: ../src/guestfs.pod:461
1059 #: ../src/guestfs.pod:463
1061 "We support SELinux guests. To ensure that labeling happens correctly in "
1062 "SELinux guests, you need to enable SELinux and load the guest's policy:"
1066 #: ../src/guestfs.pod:469 ../src/guestfs.pod:1257 ../src/guestfs.pod:1395
1067 #: ../src/guestfs.pod:2465
1072 #: ../src/guestfs.pod:471
1073 msgid "Before launching, do:"
1077 #: ../src/guestfs.pod:473
1080 " guestfs_set_selinux (g, 1);\n"
1083 " guestfs_set_selinux (g, 1);\n"
1087 #: ../src/guestfs.pod:475 ../src/guestfs.pod:1261 ../src/guestfs.pod:1399
1088 #: ../src/guestfs.pod:2490
1093 #: ../src/guestfs.pod:477
1095 "After mounting the guest's filesystem(s), load the policy. This is best "
1096 "done by running the L<load_policy(8)> command in the guest itself:"
1100 #: ../src/guestfs.pod:481
1103 " guestfs_sh (g, \"/usr/sbin/load_policy\");\n"
1106 " guestfs_sh (g, \"/usr/sbin/load_policy\");\n"
1110 #: ../src/guestfs.pod:483
1112 "(Older versions of C<load_policy> require you to specify the name of the "
1117 #: ../src/guestfs.pod:486 ../src/guestfs.pod:1405
1122 #: ../src/guestfs.pod:488
1124 "Optionally, set the security context for the API. The correct security "
1125 "context to use can only be known by inspecting the guest. As an example:"
1129 #: ../src/guestfs.pod:492
1132 " guestfs_setcon (g, \"unconfined_u:unconfined_r:unconfined_t:s0\");\n"
1135 " guestfs_setcon (g, \"unconfined_u:unconfined_r:unconfined_t:s0\");\n"
1139 #: ../src/guestfs.pod:496
1140 msgid "This will work for running commands and editing existing files."
1144 #: ../src/guestfs.pod:498
1146 "When new files are created, you may need to label them explicitly, for "
1147 "example by running the external command C<restorecon pathname>."
1151 #: ../src/guestfs.pod:502
1156 #: ../src/guestfs.pod:504
1158 "Certain calls are affected by the current file mode creation mask (the "
1159 "\"umask\"). In particular ones which create files or directories, such as "
1160 "L</guestfs_touch>, L</guestfs_mknod> or L</guestfs_mkdir>. This affects "
1161 "either the default mode that the file is created with or modifies the mode "
1166 #: ../src/guestfs.pod:510
1168 "The default umask is C<022>, so files are created with modes such as C<0644>"
1169 " and directories with C<0755>."
1173 #: ../src/guestfs.pod:513
1175 "There are two ways to avoid being affected by umask. Either set umask to 0 "
1176 "(call C<guestfs_umask (g, 0)> early after launching). Or call "
1177 "L</guestfs_chmod> after creating each file or directory."
1181 #: ../src/guestfs.pod:517
1182 msgid "For more information about umask, see L<umask(2)>."
1186 #: ../src/guestfs.pod:519 ../fish/guestfish.pod:825
1187 msgid "ENCRYPTED DISKS"
1188 msgstr "ЗАШИФРОВАНІ ДИСКИ"
1191 #: ../src/guestfs.pod:521
1193 "Libguestfs allows you to access Linux guests which have been encrypted using"
1194 " whole disk encryption that conforms to the Linux Unified Key Setup (LUKS) "
1195 "standard. This includes nearly all whole disk encryption systems used by "
1196 "modern Linux guests."
1200 #: ../src/guestfs.pod:527
1202 "Use L</guestfs_vfs_type> to identify LUKS-encrypted block devices (it "
1203 "returns the string C<crypto_LUKS>)."
1207 #: ../src/guestfs.pod:530
1209 "Then open these devices by calling L</guestfs_luks_open>. Obviously you "
1210 "will require the passphrase!"
1214 #: ../src/guestfs.pod:533
1216 "Opening a LUKS device creates a new device mapper device called "
1217 "C</dev/mapper/mapname> (where C<mapname> is the string you supply to "
1218 "L</guestfs_luks_open>). Reads and writes to this mapper device are "
1219 "decrypted from and encrypted to the underlying block device respectively."
1223 #: ../src/guestfs.pod:539
1225 "LVM volume groups on the device can be made visible by calling "
1226 "L</guestfs_vgscan> followed by L</guestfs_vg_activate_all>. The logical "
1227 "volume(s) can now be mounted in the usual way."
1231 #: ../src/guestfs.pod:543
1233 "Use the reverse process to close a LUKS device. Unmount any logical volumes"
1234 " on it, deactivate the volume groups by caling C<guestfs_vg_activate (g, 0, "
1235 "[\"/dev/VG\"])>. Then close the mapper device by calling "
1236 "L</guestfs_luks_close> on the C</dev/mapper/mapname> device (I<not> the "
1237 "underlying encrypted block device)."
1241 #: ../src/guestfs.pod:550
1246 #: ../src/guestfs.pod:552
1248 "Libguestfs has APIs for inspecting an unknown disk image to find out if it "
1249 "contains operating systems, an install CD or a live CD. (These APIs used to"
1250 " be in a separate Perl-only library called L<Sys::Guestfs::Lib(3)> but since"
1251 " version 1.5.3 the most frequently used part of this library has been "
1252 "rewritten in C and moved into the core code)."
1256 #: ../src/guestfs.pod:559
1258 "Add all disks belonging to the unknown virtual machine and call "
1259 "L</guestfs_launch> in the usual way."
1263 #: ../src/guestfs.pod:562
1265 "Then call L</guestfs_inspect_os>. This function uses other libguestfs calls"
1266 " and certain heuristics, and returns a list of operating systems that were "
1267 "found. An empty list means none were found. A single element is the root "
1268 "filesystem of the operating system. For dual- or multi-boot guests, "
1269 "multiple roots can be returned, each one corresponding to a separate "
1270 "operating system. (Multi-boot virtual machines are extremely rare in the "
1271 "world of virtualization, but since this scenario can happen, we have built "
1272 "libguestfs to deal with it.)"
1276 #: ../src/guestfs.pod:571
1278 "For each root, you can then call various C<guestfs_inspect_get_*> functions "
1279 "to get additional details about that operating system. For example, call "
1280 "L</guestfs_inspect_get_type> to return the string C<windows> or C<linux> for"
1281 " Windows and Linux-based operating systems respectively."
1285 #: ../src/guestfs.pod:577
1287 "Un*x-like and Linux-based operating systems usually consist of several "
1288 "filesystems which are mounted at boot time (for example, a separate boot "
1289 "partition mounted on C</boot>). The inspection rules are able to detect how"
1290 " filesystems correspond to mount points. Call "
1291 "C<guestfs_inspect_get_mountpoints> to get this mapping. It might return a "
1292 "hash table like this example:"
1296 #: ../src/guestfs.pod:584
1299 " /boot => /dev/sda1\n"
1300 " / => /dev/vg_guest/lv_root\n"
1301 " /usr => /dev/vg_guest/lv_usr\n"
1304 " /boot => /dev/sda1\n"
1305 " / => /dev/vg_guest/lv_root\n"
1306 " /usr => /dev/vg_guest/lv_usr\n"
1310 #: ../src/guestfs.pod:588
1312 "The caller can then make calls to L</guestfs_mount_options> to mount the "
1313 "filesystems as suggested."
1317 #: ../src/guestfs.pod:591
1319 "Be careful to mount filesystems in the right order (eg. C</> before "
1320 "C</usr>). Sorting the keys of the hash by length, shortest first, should "
1325 #: ../src/guestfs.pod:595
1327 "Inspection currently only works for some common operating systems. "
1328 "Contributors are welcome to send patches for other operating systems that we"
1329 " currently cannot detect."
1333 #: ../src/guestfs.pod:599
1335 "Encrypted disks must be opened before inspection. See L</ENCRYPTED DISKS> "
1336 "for more details. The L</guestfs_inspect_os> function just ignores any "
1337 "encrypted devices."
1341 #: ../src/guestfs.pod:603
1343 "A note on the implementation: The call L</guestfs_inspect_os> performs "
1344 "inspection and caches the results in the guest handle. Subsequent calls to "
1345 "C<guestfs_inspect_get_*> return this cached information, but I<do not> re-"
1346 "read the disks. If you change the content of the guest disks, you can redo "
1347 "inspection by calling L</guestfs_inspect_os> again. "
1348 "(L</guestfs_inspect_list_applications> works a little differently from the "
1349 "other calls and does read the disks. See documentation for that function "
1354 #: ../src/guestfs.pod:612
1355 msgid "INSPECTING INSTALL DISKS"
1359 #: ../src/guestfs.pod:614
1361 "Libguestfs (since 1.9.4) can detect some install disks, install CDs, live "
1366 #: ../src/guestfs.pod:617
1368 "Call L</guestfs_inspect_get_format> to return the format of the operating "
1369 "system, which currently can be C<installed> (a regular operating system) or "
1370 "C<installer> (some sort of install disk)."
1374 #: ../src/guestfs.pod:621
1376 "Further information is available about the operating system that can be "
1377 "installed using the regular inspection APIs like "
1378 "L</guestfs_inspect_get_product_name>, L</guestfs_inspect_get_major_version> "
1383 #: ../src/guestfs.pod:626
1385 "Some additional information specific to installer disks is also available "
1386 "from the L</guestfs_inspect_is_live>, L</guestfs_inspect_is_netinst> and "
1387 "L</guestfs_inspect_is_multipart> calls."
1391 #: ../src/guestfs.pod:631
1392 msgid "SPECIAL CONSIDERATIONS FOR WINDOWS GUESTS"
1396 #: ../src/guestfs.pod:633
1398 "Libguestfs can mount NTFS partitions. It does this using the L<http://www"
1399 ".ntfs-3g.org/> driver."
1403 #: ../src/guestfs.pod:636
1404 msgid "DRIVE LETTERS AND PATHS"
1405 msgstr "ЛІТЕРИ ДИСКІВ ТА ШЛЯХИ"
1408 #: ../src/guestfs.pod:638
1410 "DOS and Windows still use drive letters, and the filesystems are always "
1411 "treated as case insensitive by Windows itself, and therefore you might find "
1412 "a Windows configuration file referring to a path like "
1413 "C<c:\\windows\\system32>. When the filesystem is mounted in libguestfs, "
1414 "that directory might be referred to as C</WINDOWS/System32>."
1418 #: ../src/guestfs.pod:644
1420 "Drive letter mappings can be found using inspection (see L</INSPECTION> and "
1421 "L</guestfs_inspect_get_drive_mappings>)"
1425 #: ../src/guestfs.pod:647
1427 "Dealing with separator characters (backslash vs forward slash) is outside "
1428 "the scope of libguestfs, but usually a simple character replacement will "
1433 #: ../src/guestfs.pod:651
1435 "To resolve the case insensitivity of paths, call "
1436 "L</guestfs_case_sensitive_path>."
1440 #: ../src/guestfs.pod:654
1441 msgid "ACCESSING THE WINDOWS REGISTRY"
1442 msgstr "ДОСТУП ДО РЕГІСТРУ WINDOWS"
1445 #: ../src/guestfs.pod:656
1447 "Libguestfs also provides some help for decoding Windows Registry \"hive\" "
1448 "files, through the library C<hivex> which is part of the libguestfs project "
1449 "although ships as a separate tarball. You have to locate and download the "
1450 "hive file(s) yourself, and then pass them to C<hivex> functions. See also "
1451 "the programs L<hivexml(1)>, L<hivexsh(1)>, L<hivexregedit(1)> and L<virt-"
1452 "win-reg(1)> for more help on this issue."
1456 #: ../src/guestfs.pod:664
1457 msgid "SYMLINKS ON NTFS-3G FILESYSTEMS"
1458 msgstr "СИМВОЛІЧНІ ПОСИЛАННЯ У ФАЙЛОВИХ СИСТЕМАХ NTFS-3G"
1461 #: ../src/guestfs.pod:666
1463 "Ntfs-3g tries to rewrite \"Junction Points\" and NTFS \"symbolic links\" to "
1464 "provide something which looks like a Linux symlink. The way it tries to do "
1465 "the rewriting is described here:"
1469 #: ../src/guestfs.pod:670
1471 "L<http://www.tuxera.com/community/ntfs-3g-advanced/junction-points-and-"
1474 "L<http://www.tuxera.com/community/ntfs-3g-advanced/junction-points-and-"
1478 #: ../src/guestfs.pod:672
1480 "The essential problem is that ntfs-3g simply does not have enough "
1481 "information to do a correct job. NTFS links can contain drive letters and "
1482 "references to external device GUIDs that ntfs-3g has no way of resolving. "
1483 "It is almost certainly the case that libguestfs callers should ignore what "
1484 "ntfs-3g does (ie. don't use L</guestfs_readlink> on NTFS volumes)."
1488 #: ../src/guestfs.pod:679
1490 "Instead if you encounter a symbolic link on an ntfs-3g filesystem, use "
1491 "L</guestfs_lgetxattr> to read the C<system.ntfs_reparse_data> extended "
1492 "attribute, and read the raw reparse data from that (you can find the format "
1493 "documented in various places around the web)."
1497 #: ../src/guestfs.pod:684
1498 msgid "EXTENDED ATTRIBUTES ON NTFS-3G FILESYSTEMS"
1502 #: ../src/guestfs.pod:686
1504 "There are other useful extended attributes that can be read from ntfs-3g "
1505 "filesystems (using L</guestfs_getxattr>). See:"
1509 #: ../src/guestfs.pod:689
1511 "L<http://www.tuxera.com/community/ntfs-3g-advanced/extended-attributes/>"
1513 "L<http://www.tuxera.com/community/ntfs-3g-advanced/extended-attributes/>"
1516 #: ../src/guestfs.pod:691
1517 msgid "USING LIBGUESTFS WITH OTHER PROGRAMMING LANGUAGES"
1518 msgstr "ВИКОРИСТАННЯ LIBGUESTFS ЗА ДОПОМОГОЮ ІНШИХ МОВ ПРОГРАМУВАННЯ"
1521 #: ../src/guestfs.pod:693
1523 "Although we don't want to discourage you from using the C API, we will "
1524 "mention here that the same API is also available in other languages."
1528 #: ../src/guestfs.pod:696
1530 "The API is broadly identical in all supported languages. This means that "
1531 "the C call C<guestfs_add_drive_ro(g,file)> is C<$g-E<gt>add_drive_ro($file)>"
1532 " in Perl, C<g.add_drive_ro(file)> in Python, and C<g#add_drive_ro file> in "
1533 "OCaml. In other words, a straightforward, predictable isomorphism between "
1538 #: ../src/guestfs.pod:702
1540 "Error messages are automatically transformed into exceptions if the language"
1545 #: ../src/guestfs.pod:705
1547 "We don't try to \"object orientify\" parts of the API in OO languages, "
1548 "although contributors are welcome to write higher level APIs above what we "
1549 "provide in their favourite languages if they wish."
1553 #: ../src/guestfs.pod:711
1558 #: ../src/guestfs.pod:713
1560 "You can use the I<guestfs.h> header file from C++ programs. The C++ API is "
1561 "identical to the C API. C++ classes and exceptions are not used."
1565 #: ../src/guestfs.pod:717
1570 #: ../src/guestfs.pod:719
1572 "The C# bindings are highly experimental. Please read the warnings at the "
1573 "top of C<csharp/Libguestfs.cs>."
1577 #: ../src/guestfs.pod:722
1582 #: ../src/guestfs.pod:724
1584 "This is the only language binding that is working but incomplete. Only "
1585 "calls which return simple integers have been bound in Haskell, and we are "
1586 "looking for help to complete this binding."
1590 #: ../src/guestfs.pod:728
1595 #: ../src/guestfs.pod:730
1597 "Full documentation is contained in the Javadoc which is distributed with "
1602 #: ../src/guestfs.pod:733
1607 #: ../src/guestfs.pod:735
1608 msgid "See L<guestfs-ocaml(3)>."
1609 msgstr "Див. L<guestfs-ocaml(3)>."
1612 #: ../src/guestfs.pod:737
1617 #: ../src/guestfs.pod:739
1618 msgid "See L<guestfs-perl(3)> and L<Sys::Guestfs(3)>."
1619 msgstr "Див. L<guestfs-perl(3)> та L<Sys::Guestfs(3)>."
1622 #: ../src/guestfs.pod:741
1627 #: ../src/guestfs.pod:743
1629 "For documentation see C<README-PHP> supplied with libguestfs sources or in "
1630 "the php-libguestfs package for your distribution."
1634 #: ../src/guestfs.pod:746
1635 msgid "The PHP binding only works correctly on 64 bit machines."
1639 #: ../src/guestfs.pod:748
1644 #: ../src/guestfs.pod:750
1645 msgid "See L<guestfs-python(3)>."
1646 msgstr "Див. L<guestfs-python(3)>."
1649 #: ../src/guestfs.pod:752
1654 #: ../src/guestfs.pod:754
1655 msgid "See L<guestfs-ruby(3)>."
1656 msgstr "Див. L<guestfs-ruby(3)>."
1659 #: ../src/guestfs.pod:756
1660 msgid "B<shell scripts>"
1661 msgstr "B<скрипти оболонки>"
1664 #: ../src/guestfs.pod:758
1665 msgid "See L<guestfish(1)>."
1666 msgstr "Див. L<guestfish(1)>."
1669 #: ../src/guestfs.pod:762
1670 msgid "LIBGUESTFS GOTCHAS"
1674 #: ../src/guestfs.pod:764
1676 "L<http://en.wikipedia.org/wiki/Gotcha_(programming)>: \"A feature of a "
1677 "system [...] that works in the way it is documented but is counterintuitive "
1678 "and almost invites mistakes.\""
1682 #: ../src/guestfs.pod:768
1684 "Since we developed libguestfs and the associated tools, there are several "
1685 "things we would have designed differently, but are now stuck with for "
1686 "backwards compatibility or other reasons. If there is ever a libguestfs 2.0"
1687 " release, you can expect these to change. Beware of them."
1691 #: ../src/guestfs.pod:776
1692 msgid "Autosync / forgetting to sync."
1696 #: ../src/guestfs.pod:778
1698 "I<Update:> Autosync is enabled by default for all API users starting from "
1699 "libguestfs 1.5.24. This section only applies to older versions."
1703 #: ../src/guestfs.pod:781
1705 "When modifying a filesystem from C or another language, you B<must> unmount "
1706 "all filesystems and call L</guestfs_sync> explicitly before you close the "
1707 "libguestfs handle. You can also call:"
1711 #: ../src/guestfs.pod:785
1714 " guestfs_set_autosync (g, 1);\n"
1717 " guestfs_set_autosync (g, 1);\n"
1721 #: ../src/guestfs.pod:787
1723 "to have the unmount/sync done automatically for you when the handle 'g' is "
1724 "closed. (This feature is called \"autosync\", L</guestfs_set_autosync> "
1729 #: ../src/guestfs.pod:791
1731 "If you forget to do this, then it is entirely possible that your changes "
1732 "won't be written out, or will be partially written, or (very rarely) that "
1733 "you'll get disk corruption."
1737 #: ../src/guestfs.pod:795
1739 "Note that in L<guestfish(3)> autosync is the default. So quick and dirty "
1740 "guestfish scripts that forget to sync will work just fine, which can make "
1741 "this very puzzling if you are trying to debug a problem."
1745 #: ../src/guestfs.pod:799
1746 msgid "Mount option C<-o sync> should not be the default."
1750 #: ../src/guestfs.pod:801
1752 "If you use L</guestfs_mount>, then C<-o sync,noatime> are added implicitly."
1753 " However C<-o sync> does not add any reliability benefit, but does have a "
1754 "very large performance impact."
1758 #: ../src/guestfs.pod:805
1760 "The work around is to use L</guestfs_mount_options> and set the mount "
1761 "options that you actually want to use."
1765 #: ../src/guestfs.pod:808
1766 msgid "Read-only should be the default."
1770 #: ../src/guestfs.pod:810
1772 "In L<guestfish(3)>, I<--ro> should be the default, and you should have to "
1773 "specify I<--rw> if you want to make changes to the image."
1777 #: ../src/guestfs.pod:813
1778 msgid "This would reduce the potential to corrupt live VM images."
1782 #: ../src/guestfs.pod:815
1784 "Note that many filesystems change the disk when you just mount and unmount, "
1785 "even if you didn't perform any writes. You need to use "
1786 "L</guestfs_add_drive_ro> to guarantee that the disk is not changed."
1790 #: ../src/guestfs.pod:819
1791 msgid "guestfish command line is hard to use."
1795 #: ../src/guestfs.pod:821
1797 "C<guestfish disk.img> doesn't do what people expect (open C<disk.img> for "
1798 "examination). It tries to run a guestfish command C<disk.img> which doesn't"
1799 " exist, so it fails. In earlier versions of guestfish the error message was"
1800 " also unintuitive, but we have corrected this since. Like the Bourne shell,"
1801 " we should have used C<guestfish -c command> to run commands."
1805 #: ../src/guestfs.pod:828
1806 msgid "guestfish megabyte modifiers don't work right on all commands"
1810 #: ../src/guestfs.pod:830
1812 "In recent guestfish you can use C<1M> to mean 1 megabyte (and similarly for "
1813 "other modifiers). What guestfish actually does is to multiply the number "
1814 "part by the modifier part and pass the result to the C API. However this "
1815 "doesn't work for a few APIs which aren't expecting bytes, but are already "
1816 "expecting some other unit (eg. megabytes)."
1820 #: ../src/guestfs.pod:837
1821 msgid "The most common is L</guestfs_lvcreate>. The guestfish command:"
1825 #: ../src/guestfs.pod:839
1828 " lvcreate LV VG 100M\n"
1831 " lvcreate LV VG 100M\n"
1835 #: ../src/guestfs.pod:841
1837 "does not do what you might expect. Instead because L</guestfs_lvcreate> is "
1838 "already expecting megabytes, this tries to create a 100 I<terabyte> (100 "
1839 "megabytes * megabytes) logical volume. The error message you get from this "
1840 "is also a little obscure."
1844 #: ../src/guestfs.pod:846
1846 "This could be fixed in the generator by specially marking parameters and "
1847 "return values which take bytes or other units."
1851 #: ../src/guestfs.pod:849
1852 msgid "Ambiguity between devices and paths"
1856 #: ../src/guestfs.pod:851
1858 "There is a subtle ambiguity in the API between a device name (eg. "
1859 "C</dev/sdb2>) and a similar pathname. A file might just happen to be called"
1860 " C<sdb2> in the directory C</dev> (consider some non-Unix VM image)."
1864 #: ../src/guestfs.pod:856
1866 "In the current API we usually resolve this ambiguity by having two separate "
1867 "calls, for example L</guestfs_checksum> and L</guestfs_checksum_device>. "
1868 "Some API calls are ambiguous and (incorrectly) resolve the problem by "
1869 "detecting if the path supplied begins with C</dev/>."
1873 #: ../src/guestfs.pod:862
1875 "To avoid both the ambiguity and the need to duplicate some calls, we could "
1876 "make paths/devices into structured names. One way to do this would be to "
1877 "use a notation like grub (C<hd(0,0)>), although nobody really likes this "
1878 "aspect of grub. Another way would be to use a structured type, equivalent "
1879 "to this OCaml type:"
1883 #: ../src/guestfs.pod:868
1886 " type path = Path of string | Device of int | Partition of int * int\n"
1891 #: ../src/guestfs.pod:870
1892 msgid "which would allow you to pass arguments like:"
1896 #: ../src/guestfs.pod:872
1899 " Path \"/foo/bar\"\n"
1900 " Device 1 (* /dev/sdb, or perhaps /dev/sda *)\n"
1901 " Partition (1, 2) (* /dev/sdb2 (or is it /dev/sda2 or /dev/sdb3?) *)\n"
1902 " Path \"/dev/sdb2\" (* not a device *)\n"
1907 #: ../src/guestfs.pod:877
1909 "As you can see there are still problems to resolve even with this "
1910 "representation. Also consider how it might work in guestfish."
1914 #: ../src/guestfs.pod:882
1915 msgid "KEYS AND PASSPHRASES"
1916 msgstr "КЛЮЧІ І ПАРОЛІ"
1919 #: ../src/guestfs.pod:884
1921 "Certain libguestfs calls take a parameter that contains sensitive key "
1922 "material, passed in as a C string."
1926 #: ../src/guestfs.pod:887
1928 "In the future we would hope to change the libguestfs implementation so that "
1929 "keys are L<mlock(2)>-ed into physical RAM, and thus can never end up in "
1930 "swap. However this is I<not> done at the moment, because of the complexity "
1931 "of such an implementation."
1935 #: ../src/guestfs.pod:892
1937 "Therefore you should be aware that any key parameter you pass to libguestfs "
1938 "might end up being written out to the swap partition. If this is a concern,"
1939 " scrub the swap partition or don't use libguestfs on encrypted devices."
1943 #: ../src/guestfs.pod:897
1944 msgid "MULTIPLE HANDLES AND MULTIPLE THREADS"
1948 #: ../src/guestfs.pod:899
1950 "All high-level libguestfs actions are synchronous. If you want to use "
1951 "libguestfs asynchronously then you must create a thread."
1955 #: ../src/guestfs.pod:902
1957 "Only use the handle from a single thread. Either use the handle exclusively"
1958 " from one thread, or provide your own mutex so that two threads cannot issue"
1959 " calls on the same handle at the same time."
1963 #: ../src/guestfs.pod:906
1965 "See the graphical program guestfs-browser for one possible architecture for "
1966 "multithreaded programs using libvirt and libguestfs."
1970 #: ../src/guestfs.pod:909
1975 #: ../src/guestfs.pod:911
1977 "Libguestfs needs a supermin appliance, which it finds by looking along an "
1982 #: ../src/guestfs.pod:914
1984 "By default it looks for these in the directory C<$libdir/guestfs> (eg. "
1985 "C</usr/local/lib/guestfs> or C</usr/lib64/guestfs>)."
1989 #: ../src/guestfs.pod:917
1991 "Use L</guestfs_set_path> or set the environment variable L</LIBGUESTFS_PATH>"
1992 " to change the directories that libguestfs will search in. The value is a "
1993 "colon-separated list of paths. The current directory is I<not> searched "
1994 "unless the path contains an empty element or C<.>. For example "
1995 "C<LIBGUESTFS_PATH=:/usr/lib/guestfs> would search the current directory and "
1996 "then C</usr/lib/guestfs>."
2000 #: ../src/guestfs.pod:924
2001 msgid "QEMU WRAPPERS"
2005 #: ../src/guestfs.pod:926
2007 "If you want to compile your own qemu, run qemu from a non-standard location,"
2008 " or pass extra arguments to qemu, then you can write a shell-script wrapper "
2013 #: ../src/guestfs.pod:930
2015 "There is one important rule to remember: you I<must C<exec qemu>> as the "
2016 "last command in the shell script (so that qemu replaces the shell and "
2017 "becomes the direct child of the libguestfs-using program). If you don't do "
2018 "this, then the qemu process won't be cleaned up correctly."
2022 #: ../src/guestfs.pod:935
2024 "Here is an example of a wrapper, where I have built my own copy of qemu from"
2029 #: ../src/guestfs.pod:938
2033 " qemudir=/home/rjones/d/qemu\n"
2034 " exec $qemudir/x86_64-softmmu/qemu-system-x86_64 -L $qemudir/pc-bios \"$@\"\n"
2038 " qemudir=/home/rjones/d/qemu\n"
2039 " exec $qemudir/x86_64-softmmu/qemu-system-x86_64 -L $qemudir/pc-bios \"$@\"\n"
2043 #: ../src/guestfs.pod:942
2045 "Save this script as C</tmp/qemu.wrapper> (or wherever), C<chmod +x>, and "
2046 "then use it by setting the LIBGUESTFS_QEMU environment variable. For "
2051 #: ../src/guestfs.pod:946
2054 " LIBGUESTFS_QEMU=/tmp/qemu.wrapper guestfish\n"
2057 " LIBGUESTFS_QEMU=/tmp/qemu.wrapper guestfish\n"
2061 #: ../src/guestfs.pod:948
2063 "Note that libguestfs also calls qemu with the -help and -version options in "
2064 "order to determine features."
2068 #: ../src/guestfs.pod:951
2069 msgid "ATTACHING TO RUNNING DAEMONS"
2070 msgstr "ДОЛУЧЕННЯ ДО ЗАПУЩЕНИХ ФОНОВИХ СЛУЖБ"
2073 #: ../src/guestfs.pod:953
2075 "I<Note (1):> This is B<highly experimental> and has a tendency to eat "
2076 "babies. Use with caution."
2080 #: ../src/guestfs.pod:956
2082 "I<Note (2):> This section explains how to attach to a running daemon from a "
2083 "low level perspective. For most users, simply using virt tools such as "
2084 "L<guestfish(1)> with the I<--live> option will \"just work\"."
2088 #: ../src/guestfs.pod:960
2089 msgid "Using guestfs_set_attach_method"
2090 msgstr "За допомогою guestfs_set_attach_method"
2093 #: ../src/guestfs.pod:962
2095 "By calling L</guestfs_set_attach_method> you can change how the library "
2096 "connects to the C<guestfsd> daemon in L</guestfs_launch> (read "
2097 "L</ARCHITECTURE> for some background)."
2101 #: ../src/guestfs.pod:966
2103 "The normal attach method is C<appliance>, where a small appliance is created"
2104 " containing the daemon, and then the library connects to this."
2108 #: ../src/guestfs.pod:969
2110 "Setting attach method to C<unix:I<path>> (where I<path> is the path of a "
2111 "Unix domain socket) causes L</guestfs_launch> to connect to an existing "
2112 "daemon over the Unix domain socket."
2116 #: ../src/guestfs.pod:973
2118 "The normal use for this is to connect to a running virtual machine that "
2119 "contains a C<guestfsd> daemon, and send commands so you can read and write "
2120 "files inside the live virtual machine."
2124 #: ../src/guestfs.pod:977
2125 msgid "Using guestfs_add_domain with live flag"
2126 msgstr "За допомогою guestfs_add_domain з прапорцем live"
2129 #: ../src/guestfs.pod:979
2131 "L</guestfs_add_domain> provides some help for getting the correct attach "
2132 "method. If you pass the C<live> option to this function, then (if the "
2133 "virtual machine is running) it will examine the libvirt XML looking for a "
2134 "virtio-serial channel to connect to:"
2138 #: ../src/guestfs.pod:985
2145 " <channel type='unix'>\n"
2146 " <source mode='bind' path='/path/to/socket'/>\n"
2147 " <target type='virtio' name='org.libguestfs.channel.0'/>\n"
2158 " <channel type='unix'>\n"
2159 " <source mode='bind' path='/path/to/socket'/>\n"
2160 " <target type='virtio' name='org.libguestfs.channel.0'/>\n"
2168 #: ../src/guestfs.pod:997
2170 "L</guestfs_add_domain> extracts C</path/to/socket> and sets the attach "
2171 "method to C<unix:/path/to/socket>."
2175 #: ../src/guestfs.pod:1000
2177 "Some of the libguestfs tools (including guestfish) support a I<--live> "
2178 "option which is passed through to L</guestfs_add_domain> thus allowing you "
2179 "to attach to and modify live virtual machines."
2183 #: ../src/guestfs.pod:1004
2185 "The virtual machine needs to have been set up beforehand so that it has the "
2186 "virtio-serial channel and so that guestfsd is running inside it."
2190 #: ../src/guestfs.pod:1008
2191 msgid "ABI GUARANTEE"
2192 msgstr "ГАРАНТІЯ ЩОДО ABI"
2195 #: ../src/guestfs.pod:1010
2197 "We guarantee the libguestfs ABI (binary interface), for public, high-level "
2198 "actions as outlined in this section. Although we will deprecate some "
2199 "actions, for example if they get replaced by newer calls, we will keep the "
2200 "old actions forever. This allows you the developer to program in confidence"
2201 " against the libguestfs API."
2205 #: ../src/guestfs.pod:1016
2206 msgid "BLOCK DEVICE NAMING"
2207 msgstr "ІМЕНУВАННЯ БЛОКОВИХ ПРИСТРОЇВ"
2210 #: ../src/guestfs.pod:1018
2212 "In the kernel there is now quite a profusion of schemata for naming block "
2213 "devices (in this context, by I<block device> I mean a physical or virtual "
2214 "hard drive). The original Linux IDE driver used names starting with "
2215 "C</dev/hd*>. SCSI devices have historically used a different naming scheme,"
2216 " C</dev/sd*>. When the Linux kernel I<libata> driver became a popular "
2217 "replacement for the old IDE driver (particularly for SATA devices) those "
2218 "devices also used the C</dev/sd*> scheme. Additionally we now have virtual "
2219 "machines with paravirtualized drivers. This has created several different "
2220 "naming systems, such as C</dev/vd*> for virtio disks and C</dev/xvd*> for "
2225 #: ../src/guestfs.pod:1030
2227 "As discussed above, libguestfs uses a qemu appliance running an embedded "
2228 "Linux kernel to access block devices. We can run a variety of appliances "
2229 "based on a variety of Linux kernels."
2233 #: ../src/guestfs.pod:1034
2235 "This causes a problem for libguestfs because many API calls use device or "
2236 "partition names. Working scripts and the recipe (example) scripts that we "
2237 "make available over the internet could fail if the naming scheme changes."
2241 #: ../src/guestfs.pod:1039
2243 "Therefore libguestfs defines C</dev/sd*> as the I<standard naming scheme>. "
2244 "Internally C</dev/sd*> names are translated, if necessary, to other names as"
2245 " required. For example, under RHEL 5 which uses the C</dev/hd*> scheme, any"
2246 " device parameter C</dev/sda2> is translated to C</dev/hda2> transparently."
2250 #: ../src/guestfs.pod:1045
2252 "Note that this I<only> applies to parameters. The L</guestfs_list_devices>,"
2253 " L</guestfs_list_partitions> and similar calls return the true names of the "
2254 "devices and partitions as known to the appliance."
2258 #: ../src/guestfs.pod:1050
2259 msgid "ALGORITHM FOR BLOCK DEVICE NAME TRANSLATION"
2263 #: ../src/guestfs.pod:1052
2265 "Usually this translation is transparent. However in some (very rare) cases"
2266 " you may need to know the exact algorithm. Such cases include where you use"
2267 " L</guestfs_config> to add a mixture of virtio and IDE devices to the qemu-"
2268 "based appliance, so have a mixture of C</dev/sd*> and C</dev/vd*> devices."
2272 #: ../src/guestfs.pod:1058
2274 "The algorithm is applied only to I<parameters> which are known to be either "
2275 "device or partition names. Return values from functions such as "
2276 "L</guestfs_list_devices> are never changed."
2280 #: ../src/guestfs.pod:1066
2281 msgid "Is the string a parameter which is a device or partition name?"
2285 #: ../src/guestfs.pod:1070
2286 msgid "Does the string begin with C</dev/sd>?"
2287 msgstr "Чи починається рядок з C</dev/sd>?"
2290 #: ../src/guestfs.pod:1074
2292 "Does the named device exist? If so, we use that device. However if I<not> "
2293 "then we continue with this algorithm."
2297 #: ../src/guestfs.pod:1079
2298 msgid "Replace initial C</dev/sd> string with C</dev/hd>."
2302 #: ../src/guestfs.pod:1081
2303 msgid "For example, change C</dev/sda2> to C</dev/hda2>."
2307 #: ../src/guestfs.pod:1083
2308 msgid "If that named device exists, use it. If not, continue."
2312 #: ../src/guestfs.pod:1087
2313 msgid "Replace initial C</dev/sd> string with C</dev/vd>."
2317 #: ../src/guestfs.pod:1089
2318 msgid "If that named device exists, use it. If not, return an error."
2322 #: ../src/guestfs.pod:1093
2323 msgid "PORTABILITY CONCERNS WITH BLOCK DEVICE NAMING"
2327 #: ../src/guestfs.pod:1095
2329 "Although the standard naming scheme and automatic translation is useful for "
2330 "simple programs and guestfish scripts, for larger programs it is best not to"
2331 " rely on this mechanism."
2335 #: ../src/guestfs.pod:1099
2337 "Where possible for maximum future portability programs using libguestfs "
2338 "should use these future-proof techniques:"
2342 #: ../src/guestfs.pod:1106
2344 "Use L</guestfs_list_devices> or L</guestfs_list_partitions> to list actual "
2345 "device names, and then use those names directly."
2349 #: ../src/guestfs.pod:1109
2351 "Since those device names exist by definition, they will never be translated."
2355 #: ../src/guestfs.pod:1114
2357 "Use higher level ways to identify filesystems, such as LVM names, UUIDs and "
2358 "filesystem labels."
2362 #: ../src/guestfs.pod:1119
2367 #: ../src/guestfs.pod:1121
2369 "This section discusses security implications of using libguestfs, "
2370 "particularly with untrusted or malicious guests or disk images."
2374 #: ../src/guestfs.pod:1124
2375 msgid "GENERAL SECURITY CONSIDERATIONS"
2376 msgstr "ЗАГАЛЬНІ ЗАУВАЖЕННЯ ЩОДО ЗАХИСТУ"
2379 #: ../src/guestfs.pod:1126
2381 "Be careful with any files or data that you download from a guest (by "
2382 "\"download\" we mean not just the L</guestfs_download> command but any "
2383 "command that reads files, filenames, directories or anything else from a "
2384 "disk image). An attacker could manipulate the data to fool your program "
2385 "into doing the wrong thing. Consider cases such as:"
2389 #: ../src/guestfs.pod:1136
2390 msgid "the data (file etc) not being present"
2394 #: ../src/guestfs.pod:1140
2395 msgid "being present but empty"
2399 #: ../src/guestfs.pod:1144
2400 msgid "being much larger than normal"
2404 #: ../src/guestfs.pod:1148
2405 msgid "containing arbitrary 8 bit data"
2409 #: ../src/guestfs.pod:1152
2410 msgid "being in an unexpected character encoding"
2414 #: ../src/guestfs.pod:1156
2415 msgid "containing homoglyphs."
2419 #: ../src/guestfs.pod:1160
2420 msgid "SECURITY OF MOUNTING FILESYSTEMS"
2421 msgstr "ЗАХИСТ ФАЙЛОВИХ СИСТЕМ МОНТУВАННЯ"
2424 #: ../src/guestfs.pod:1162
2426 "When you mount a filesystem under Linux, mistakes in the kernel filesystem "
2427 "(VFS) module can sometimes be escalated into exploits by deliberately "
2428 "creating a malicious, malformed filesystem. These exploits are very severe "
2429 "for two reasons. Firstly there are very many filesystem drivers in the "
2430 "kernel, and many of them are infrequently used and not much developer "
2431 "attention has been paid to the code. Linux userspace helps potential "
2432 "crackers by detecting the filesystem type and automatically choosing the "
2433 "right VFS driver, even if that filesystem type is obscure or unexpected for "
2434 "the administrator. Secondly, a kernel-level exploit is like a local root "
2435 "exploit (worse in some ways), giving immediate and total access to the "
2436 "system right down to the hardware level."
2440 #: ../src/guestfs.pod:1175
2442 "That explains why you should never mount a filesystem from an untrusted "
2443 "guest on your host kernel. How about libguestfs? We run a Linux kernel "
2444 "inside a qemu virtual machine, usually running as a non-root user. The "
2445 "attacker would need to write a filesystem which first exploited the kernel, "
2446 "and then exploited either qemu virtualization (eg. a faulty qemu driver) or "
2447 "the libguestfs protocol, and finally to be as serious as the host kernel "
2448 "exploit it would need to escalate its privileges to root. This multi-step "
2449 "escalation, performed by a static piece of data, is thought to be extremely "
2450 "hard to do, although we never say 'never' about security issues."
2454 #: ../src/guestfs.pod:1186
2456 "In any case callers can reduce the attack surface by forcing the filesystem "
2457 "type when mounting (use L</guestfs_mount_vfs>)."
2461 #: ../src/guestfs.pod:1189
2462 msgid "PROTOCOL SECURITY"
2463 msgstr "ЗАХИСТ ПРОТОКОЛУ"
2466 #: ../src/guestfs.pod:1191
2468 "The protocol is designed to be secure, being based on RFC 4506 (XDR) with a"
2469 " defined upper message size. However a program that uses libguestfs must "
2470 "also take care - for example you can write a program that downloads a binary"
2471 " from a disk image and executes it locally, and no amount of protocol "
2472 "security will save you from the consequences."
2476 #: ../src/guestfs.pod:1197
2477 msgid "INSPECTION SECURITY"
2481 #: ../src/guestfs.pod:1199
2483 "Parts of the inspection API (see L</INSPECTION>) return untrusted strings "
2484 "directly from the guest, and these could contain any 8 bit data. Callers "
2485 "should be careful to escape these before printing them to a structured file "
2486 "(for example, use HTML escaping if creating a web page)."
2490 #: ../src/guestfs.pod:1205
2492 "Guest configuration may be altered in unusual ways by the administrator of "
2493 "the virtual machine, and may not reflect reality (particularly for untrusted"
2494 " or actively malicious guests). For example we parse the hostname from "
2495 "configuration files like C</etc/sysconfig/network> that we find in the "
2496 "guest, but the guest administrator can easily manipulate these files to "
2497 "provide the wrong hostname."
2501 #: ../src/guestfs.pod:1213
2503 "The inspection API parses guest configuration using two external libraries: "
2504 "Augeas (Linux configuration) and hivex (Windows Registry). Both are "
2505 "designed to be robust in the face of malicious data, although denial of "
2506 "service attacks are still possible, for example with oversized configuration"
2511 #: ../src/guestfs.pod:1219
2512 msgid "RUNNING UNTRUSTED GUEST COMMANDS"
2513 msgstr "ЗАПУСК НЕЗАХИЩЕНИХ КОМАНД ГОСТЬОВОЇ СИСТЕМИ"
2516 #: ../src/guestfs.pod:1221
2518 "Be very cautious about running commands from the guest. By running a "
2519 "command in the guest, you are giving CPU time to a binary that you do not "
2520 "control, under the same user account as the library, albeit wrapped in qemu "
2521 "virtualization. More information and alternatives can be found in the "
2522 "section L</RUNNING COMMANDS>."
2526 #: ../src/guestfs.pod:1227
2527 msgid "CVE-2010-3851"
2528 msgstr "CVE-2010-3851"
2531 #: ../src/guestfs.pod:1229
2532 msgid "https://bugzilla.redhat.com/642934"
2533 msgstr "https://bugzilla.redhat.com/642934"
2536 #: ../src/guestfs.pod:1231
2538 "This security bug concerns the automatic disk format detection that qemu "
2539 "does on disk images."
2543 #: ../src/guestfs.pod:1234
2545 "A raw disk image is just the raw bytes, there is no header. Other disk "
2546 "images like qcow2 contain a special header. Qemu deals with this by looking"
2547 " for one of the known headers, and if none is found then assuming the disk "
2548 "image must be raw."
2552 #: ../src/guestfs.pod:1239
2554 "This allows a guest which has been given a raw disk image to write some "
2555 "other header. At next boot (or when the disk image is accessed by "
2556 "libguestfs) qemu would do autodetection and think the disk image format was,"
2557 " say, qcow2 based on the header written by the guest."
2561 #: ../src/guestfs.pod:1244
2563 "This in itself would not be a problem, but qcow2 offers many features, one "
2564 "of which is to allow a disk image to refer to another image (called the "
2565 "\"backing disk\"). It does this by placing the path to the backing disk "
2566 "into the qcow2 header. This path is not validated and could point to any "
2567 "host file (eg. \"/etc/passwd\"). The backing disk is then exposed through "
2568 "\"holes\" in the qcow2 disk image, which of course is completely under the "
2569 "control of the attacker."
2573 #: ../src/guestfs.pod:1252
2575 "In libguestfs this is rather hard to exploit except under two circumstances:"
2579 #: ../src/guestfs.pod:1259
2580 msgid "You have enabled the network or have opened the disk in write mode."
2584 #: ../src/guestfs.pod:1263
2586 "You are also running untrusted code from the guest (see L</RUNNING "
2591 #: ../src/guestfs.pod:1268
2593 "The way to avoid this is to specify the expected disk format when adding "
2594 "disks (the optional C<format> option to L</guestfs_add_drive_opts>). You "
2595 "should always do this if the disk is raw format, and it's a good idea for "
2600 #: ../src/guestfs.pod:1273
2602 "For disks added from libvirt using calls like L</guestfs_add_domain>, the "
2603 "format is fetched from libvirt and passed through."
2607 #: ../src/guestfs.pod:1276
2609 "For libguestfs tools, use the I<--format> command line parameter as "
2614 #: ../src/guestfs.pod:1279
2615 msgid "CONNECTION MANAGEMENT"
2616 msgstr "КЕРУВАННЯ З’ЄДНАННЯМ"
2619 #: ../src/guestfs.pod:1281
2621 msgstr "guestfs_h *"
2624 #: ../src/guestfs.pod:1283
2626 "C<guestfs_h> is the opaque type representing a connection handle. Create a "
2627 "handle by calling L</guestfs_create>. Call L</guestfs_close> to free the "
2628 "handle and release all resources used."
2632 #: ../src/guestfs.pod:1287
2634 "For information on using multiple handles and threads, see the section "
2635 "L</MULTIPLE HANDLES AND MULTIPLE THREADS> above."
2639 #: ../src/guestfs.pod:1290
2640 msgid "guestfs_create"
2641 msgstr "guestfs_create"
2644 #: ../src/guestfs.pod:1292
2647 " guestfs_h *guestfs_create (void);\n"
2650 " guestfs_h *guestfs_create (void);\n"
2654 #: ../src/guestfs.pod:1294
2655 msgid "Create a connection handle."
2656 msgstr "Створити дескриптор з’єднання."
2659 #: ../src/guestfs.pod:1296
2661 "On success this returns a non-NULL pointer to a handle. On error it returns"
2666 #: ../src/guestfs.pod:1299
2668 "You have to \"configure\" the handle after creating it. This includes "
2669 "calling L</guestfs_add_drive_opts> (or one of the equivalent calls) on the "
2670 "handle at least once."
2674 #: ../src/guestfs.pod:1303
2675 msgid "After configuring the handle, you have to call L</guestfs_launch>."
2679 #: ../src/guestfs.pod:1305
2681 "You may also want to configure error handling for the handle. See the "
2682 "L</ERROR HANDLING> section below."
2686 #: ../src/guestfs.pod:1308
2687 msgid "guestfs_close"
2688 msgstr "guestfs_close"
2691 #: ../src/guestfs.pod:1310
2694 " void guestfs_close (guestfs_h *g);\n"
2697 " void guestfs_close (guestfs_h *g);\n"
2701 #: ../src/guestfs.pod:1312
2702 msgid "This closes the connection handle and frees up all resources used."
2706 #: ../src/guestfs.pod:1314
2708 "If autosync was set on the handle and the handle was launched, then this "
2709 "implicitly calls various functions to unmount filesystems and sync the disk."
2710 " See L</guestfs_set_autosync> for more details."
2714 #: ../src/guestfs.pod:1318
2715 msgid "If a close callback was set on the handle, then it is called."
2719 #: ../src/guestfs.pod:1320
2720 msgid "ERROR HANDLING"
2721 msgstr "ОБРОБКА ПОМИЛОК"
2724 #: ../src/guestfs.pod:1322
2726 "API functions can return errors. For example, almost all functions that "
2727 "return C<int> will return C<-1> to indicate an error."
2731 #: ../src/guestfs.pod:1325
2733 "Additional information is available for errors: an error message string and "
2734 "optionally an error number (errno) if the thing that failed was a system "
2739 #: ../src/guestfs.pod:1329
2741 "You can get at the additional information about the last error on the handle"
2742 " by calling L</guestfs_last_error>, L</guestfs_last_errno>, and/or by "
2743 "setting up an error handler with L</guestfs_set_error_handler>."
2747 #: ../src/guestfs.pod:1334
2749 "When the handle is created, a default error handler is installed which "
2750 "prints the error message string to C<stderr>. For small short-running "
2751 "command line programs it is sufficient to do:"
2755 #: ../src/guestfs.pod:1338
2758 " if (guestfs_launch (g) == -1)\n"
2759 " exit (EXIT_FAILURE);\n"
2762 " if (guestfs_launch (g) == -1)\n"
2763 " exit (EXIT_FAILURE);\n"
2767 #: ../src/guestfs.pod:1341
2769 "since the default error handler will ensure that an error message has been "
2770 "printed to C<stderr> before the program exits."
2774 #: ../src/guestfs.pod:1344
2776 "For other programs the caller will almost certainly want to install an "
2777 "alternate error handler or do error handling in-line like this:"
2781 #: ../src/guestfs.pod:1347
2784 " g = guestfs_create ();\n"
2787 " g = guestfs_create ();\n"
2791 #: ../src/guestfs.pod:1349
2794 " /* This disables the default behaviour of printing errors\n"
2796 " guestfs_set_error_handler (g, NULL, NULL);\n"
2801 #: ../src/guestfs.pod:1353
2804 " if (guestfs_launch (g) == -1) {\n"
2805 " /* Examine the error message and print it etc. */\n"
2806 " char *msg = guestfs_last_error (g);\n"
2807 " int errnum = guestfs_last_errno (g);\n"
2808 " fprintf (stderr, \"%s\\n\", msg);\n"
2813 " if (guestfs_launch (g) == -1) {\n"
2814 " /* Вивчити повідомлення про помилку і вивести його тощо. */\n"
2815 " char *msg = guestfs_last_error (g);\n"
2816 " int errnum = guestfs_last_errno (g);\n"
2817 " fprintf (stderr, \"%s\\n\", msg);\n"
2823 #: ../src/guestfs.pod:1361
2825 "Out of memory errors are handled differently. The default action is to call"
2826 " L<abort(3)>. If this is undesirable, then you can set a handler using "
2827 "L</guestfs_set_out_of_memory_handler>."
2831 #: ../src/guestfs.pod:1365
2833 "L</guestfs_create> returns C<NULL> if the handle cannot be created, and "
2834 "because there is no handle if this happens there is no way to get additional"
2835 " error information. However L</guestfs_create> is supposed to be a "
2836 "lightweight operation which can only fail because of insufficient memory (it"
2837 " returns NULL in this case)."
2841 #: ../src/guestfs.pod:1371
2842 msgid "guestfs_last_error"
2843 msgstr "guestfs_last_error"
2846 #: ../src/guestfs.pod:1373
2849 " const char *guestfs_last_error (guestfs_h *g);\n"
2852 " const char *guestfs_last_error (guestfs_h *g);\n"
2856 #: ../src/guestfs.pod:1375
2858 "This returns the last error message that happened on C<g>. If there has not"
2859 " been an error since the handle was created, then this returns C<NULL>."
2863 #: ../src/guestfs.pod:1379
2865 "The lifetime of the returned string is until the next error occurs, or "
2866 "L</guestfs_close> is called."
2870 #: ../src/guestfs.pod:1382
2871 msgid "guestfs_last_errno"
2872 msgstr "guestfs_last_errno"
2875 #: ../src/guestfs.pod:1384
2878 " int guestfs_last_errno (guestfs_h *g);\n"
2881 " int guestfs_last_errno (guestfs_h *g);\n"
2885 #: ../src/guestfs.pod:1386
2886 msgid "This returns the last error number (errno) that happened on C<g>."
2890 #: ../src/guestfs.pod:1388
2891 msgid "If successful, an errno integer not equal to zero is returned."
2895 #: ../src/guestfs.pod:1390
2897 "If no error, this returns 0. This call can return 0 in three situations:"
2901 #: ../src/guestfs.pod:1397
2902 msgid "There has not been any error on the handle."
2906 #: ../src/guestfs.pod:1401
2908 "There has been an error but the errno was meaningless. This corresponds to "
2909 "the case where the error did not come from a failed system call, but for "
2910 "some other reason."
2914 #: ../src/guestfs.pod:1407
2916 "There was an error from a failed system call, but for some reason the errno "
2917 "was not captured and returned. This usually indicates a bug in libguestfs."
2921 #: ../src/guestfs.pod:1413
2923 "Libguestfs tries to convert the errno from inside the applicance into a "
2924 "corresponding errno for the caller (not entirely trivial: the appliance "
2925 "might be running a completely different operating system from the library "
2926 "and error numbers are not standardized across Un*xen). If this could not be"
2927 " done, then the error is translated to C<EINVAL>. In practice this should "
2928 "only happen in very rare circumstances."
2932 #: ../src/guestfs.pod:1421
2933 msgid "guestfs_set_error_handler"
2934 msgstr "guestfs_set_error_handler"
2937 #: ../src/guestfs.pod:1423
2940 " typedef void (*guestfs_error_handler_cb) (guestfs_h *g,\n"
2942 " const char *msg);\n"
2943 " void guestfs_set_error_handler (guestfs_h *g,\n"
2944 " guestfs_error_handler_cb cb,\n"
2948 " typedef void (*guestfs_error_handler_cb) (guestfs_h *g,\n"
2950 " const char *msg);\n"
2951 " void guestfs_set_error_handler (guestfs_h *g,\n"
2952 " guestfs_error_handler_cb cb,\n"
2957 #: ../src/guestfs.pod:1430
2959 "The callback C<cb> will be called if there is an error. The parameters "
2960 "passed to the callback are an opaque data pointer and the error message "
2965 #: ../src/guestfs.pod:1434
2967 "C<errno> is not passed to the callback. To get that the callback must call "
2968 "L</guestfs_last_errno>."
2972 #: ../src/guestfs.pod:1437
2974 "Note that the message string C<msg> is freed as soon as the callback "
2975 "function returns, so if you want to stash it somewhere you must make your "
2980 #: ../src/guestfs.pod:1441
2981 msgid "The default handler prints messages on C<stderr>."
2985 #: ../src/guestfs.pod:1443
2986 msgid "If you set C<cb> to C<NULL> then I<no> handler is called."
2990 #: ../src/guestfs.pod:1445
2991 msgid "guestfs_get_error_handler"
2992 msgstr "guestfs_get_error_handler"
2995 #: ../src/guestfs.pod:1447
2998 " guestfs_error_handler_cb guestfs_get_error_handler (guestfs_h *g,\n"
2999 " void **opaque_rtn);\n"
3002 " guestfs_error_handler_cb guestfs_get_error_handler (guestfs_h *g,\n"
3003 " void **opaque_rtn);\n"
3007 #: ../src/guestfs.pod:1450
3008 msgid "Returns the current error handler callback."
3012 #: ../src/guestfs.pod:1452
3013 msgid "guestfs_set_out_of_memory_handler"
3014 msgstr "guestfs_set_out_of_memory_handler"
3017 #: ../src/guestfs.pod:1454
3020 " typedef void (*guestfs_abort_cb) (void);\n"
3021 " int guestfs_set_out_of_memory_handler (guestfs_h *g,\n"
3022 " guestfs_abort_cb);\n"
3025 " typedef void (*guestfs_abort_cb) (void);\n"
3026 " int guestfs_set_out_of_memory_handler (guestfs_h *g,\n"
3027 " guestfs_abort_cb);\n"
3031 #: ../src/guestfs.pod:1458
3033 "The callback C<cb> will be called if there is an out of memory situation. "
3034 "I<Note this callback must not return>."
3038 #: ../src/guestfs.pod:1461
3039 msgid "The default is to call L<abort(3)>."
3043 #: ../src/guestfs.pod:1463
3045 "You cannot set C<cb> to C<NULL>. You can't ignore out of memory situations."
3049 #: ../src/guestfs.pod:1466
3050 msgid "guestfs_get_out_of_memory_handler"
3051 msgstr "guestfs_get_out_of_memory_handler"
3054 #: ../src/guestfs.pod:1468
3057 " guestfs_abort_fn guestfs_get_out_of_memory_handler (guestfs_h *g);\n"
3060 " guestfs_abort_fn guestfs_get_out_of_memory_handler (guestfs_h *g);\n"
3064 #: ../src/guestfs.pod:1470
3065 msgid "This returns the current out of memory handler."
3069 #: ../src/guestfs.pod:1472
3071 msgstr "ВИКЛИКИ API"
3074 #: ../src/guestfs.pod:1474 ../fish/guestfish.pod:1068
3079 #: ../src/guestfs.pod:1476
3084 #: ../src/guestfs.pod:1478
3089 #: ../src/guestfs.pod:1480
3090 msgid "AVAILABILITY"
3091 msgstr "ДОСТУПНІСТЬ"
3094 #: ../src/guestfs.pod:1482
3095 msgid "GROUPS OF FUNCTIONALITY IN THE APPLIANCE"
3096 msgstr "ГРУПИ ФУНКЦІОНАЛЬНИХ МОЖЛИВОСТЕЙ У ОБРАЗІ ОСНОВНОЇ СИСТЕМИ"
3099 #: ../src/guestfs.pod:1484
3101 "Using L</guestfs_available> you can test availability of the following "
3102 "groups of functions. This test queries the appliance to see if the "
3103 "appliance you are currently using supports the functionality."
3107 #: ../src/guestfs.pod:1489
3108 msgid "@AVAILABILITY@"
3109 msgstr "@AVAILABILITY@"
3112 #: ../src/guestfs.pod:1491
3113 msgid "GUESTFISH supported COMMAND"
3117 #: ../src/guestfs.pod:1493
3119 "In L<guestfish(3)> there is a handy interactive command C<supported> which "
3120 "prints out the available groups and whether they are supported by this build"
3121 " of libguestfs. Note however that you have to do C<run> first."
3125 #: ../src/guestfs.pod:1498
3126 msgid "SINGLE CALLS AT COMPILE TIME"
3130 #: ../src/guestfs.pod:1500
3132 "Since version 1.5.8, C<E<lt>guestfs.hE<gt>> defines symbols for each C API "
3133 "function, such as:"
3137 #: ../src/guestfs.pod:1503
3140 " #define LIBGUESTFS_HAVE_DD 1\n"
3143 " #define LIBGUESTFS_HAVE_DD 1\n"
3147 #: ../src/guestfs.pod:1505
3148 msgid "if L</guestfs_dd> is available."
3152 #: ../src/guestfs.pod:1507
3154 "Before version 1.5.8, if you needed to test whether a single libguestfs "
3155 "function is available at compile time, we recommended using build tools such"
3156 " as autoconf or cmake. For example in autotools you could use:"
3160 #: ../src/guestfs.pod:1512
3163 " AC_CHECK_LIB([guestfs],[guestfs_create])\n"
3164 " AC_CHECK_FUNCS([guestfs_dd])\n"
3167 " AC_CHECK_LIB([guestfs],[guestfs_create])\n"
3168 " AC_CHECK_FUNCS([guestfs_dd])\n"
3172 #: ../src/guestfs.pod:1515
3174 "which would result in C<HAVE_GUESTFS_DD> being either defined or not defined"
3179 #: ../src/guestfs.pod:1518
3180 msgid "SINGLE CALLS AT RUN TIME"
3184 #: ../src/guestfs.pod:1520
3186 "Testing at compile time doesn't guarantee that a function really exists in "
3187 "the library. The reason is that you might be dynamically linked against a "
3188 "previous I<libguestfs.so> (dynamic library) which doesn't have the call. "
3189 "This situation unfortunately results in a segmentation fault, which is a "
3190 "shortcoming of the C dynamic linking system itself."
3194 #: ../src/guestfs.pod:1527
3196 "You can use L<dlopen(3)> to test if a function is available at run time, as "
3197 "in this example program (note that you still need the compile time check as "
3202 #: ../src/guestfs.pod:1531
3205 " #include <stdio.h>\n"
3206 " #include <stdlib.h>\n"
3207 " #include <unistd.h>\n"
3208 " #include <dlfcn.h>\n"
3209 " #include <guestfs.h>\n"
3212 " #include <stdio.h>\n"
3213 " #include <stdlib.h>\n"
3214 " #include <unistd.h>\n"
3215 " #include <dlfcn.h>\n"
3216 " #include <guestfs.h>\n"
3220 #: ../src/guestfs.pod:1537
3225 " #ifdef LIBGUESTFS_HAVE_DD\n"
3227 " int has_function;\n"
3232 " #ifdef LIBGUESTFS_HAVE_DD\n"
3234 " int has_function;\n"
3238 #: ../src/guestfs.pod:1543
3241 " /* Test if the function guestfs_dd is really available. */\n"
3242 " dl = dlopen (NULL, RTLD_LAZY);\n"
3244 " fprintf (stderr, \"dlopen: %s\\n\", dlerror ());\n"
3245 " exit (EXIT_FAILURE);\n"
3247 " has_function = dlsym (dl, \"guestfs_dd\") != NULL;\n"
3253 #: ../src/guestfs.pod:1552
3256 " if (!has_function)\n"
3257 " printf (\"this libguestfs.so does NOT have guestfs_dd function\\n\");\n"
3259 " printf (\"this libguestfs.so has guestfs_dd function\\n\");\n"
3260 " /* Now it's safe to call\n"
3261 " guestfs_dd (g, \"foo\", \"bar\");\n"
3265 " printf (\"guestfs_dd function was not found at compile time\\n\");\n"
3272 #: ../src/guestfs.pod:1565
3274 "You may think the above is an awful lot of hassle, and it is. There are "
3275 "other ways outside of the C linking system to ensure that this kind of "
3276 "incompatibility never arises, such as using package versioning:"
3280 #: ../src/guestfs.pod:1570
3283 " Requires: libguestfs >= 1.0.80\n"
3288 #: ../src/guestfs.pod:1572
3289 msgid "CALLS WITH OPTIONAL ARGUMENTS"
3293 #: ../src/guestfs.pod:1574
3295 "A recent feature of the API is the introduction of calls which take optional"
3296 " arguments. In C these are declared 3 ways. The main way is as a call "
3297 "which takes variable arguments (ie. C<...>), as in this example:"
3301 #: ../src/guestfs.pod:1579
3304 " int guestfs_add_drive_opts (guestfs_h *g, const char *filename, ...);\n"
3307 " int guestfs_add_drive_opts (guestfs_h *g, const char *filename, ...);\n"
3311 #: ../src/guestfs.pod:1581
3313 "Call this with a list of optional arguments, terminated by C<-1>. So to "
3314 "call with no optional arguments specified:"
3318 #: ../src/guestfs.pod:1584
3321 " guestfs_add_drive_opts (g, filename, -1);\n"
3324 " guestfs_add_drive_opts (g, filename, -1);\n"
3328 #: ../src/guestfs.pod:1586
3329 msgid "With a single optional argument:"
3333 #: ../src/guestfs.pod:1588
3336 " guestfs_add_drive_opts (g, filename,\n"
3337 " GUESTFS_ADD_DRIVE_OPTS_FORMAT, \"qcow2\",\n"
3341 " guestfs_add_drive_opts (g, filename,\n"
3342 " GUESTFS_ADD_DRIVE_OPTS_FORMAT, \"qcow2\",\n"
3347 #: ../src/guestfs.pod:1592
3352 #: ../src/guestfs.pod:1594
3355 " guestfs_add_drive_opts (g, filename,\n"
3356 " GUESTFS_ADD_DRIVE_OPTS_FORMAT, \"qcow2\",\n"
3357 " GUESTFS_ADD_DRIVE_OPTS_READONLY, 1,\n"
3361 " guestfs_add_drive_opts (g, filename,\n"
3362 " GUESTFS_ADD_DRIVE_OPTS_FORMAT, \"qcow2\",\n"
3363 " GUESTFS_ADD_DRIVE_OPTS_READONLY, 1,\n"
3368 #: ../src/guestfs.pod:1599
3370 "and so forth. Don't forget the terminating C<-1> otherwise Bad Things will "
3375 #: ../src/guestfs.pod:1602
3376 msgid "USING va_list FOR OPTIONAL ARGUMENTS"
3380 #: ../src/guestfs.pod:1604
3382 "The second variant has the same name with the suffix C<_va>, which works the"
3383 " same way but takes a C<va_list>. See the C manual for details. For the "
3384 "example function, this is declared:"
3388 #: ../src/guestfs.pod:1608
3391 " int guestfs_add_drive_opts_va (guestfs_h *g, const char *filename,\n"
3395 " int guestfs_add_drive_opts_va (guestfs_h *g, const char *filename,\n"
3400 #: ../src/guestfs.pod:1611
3401 msgid "CONSTRUCTING OPTIONAL ARGUMENTS"
3405 #: ../src/guestfs.pod:1613
3407 "The third variant is useful where you need to construct these calls. You "
3408 "pass in a structure where you fill in the optional fields. The structure "
3409 "has a bitmask as the first element which you must set to indicate which "
3410 "fields you have filled in. For our example function the structure and call "
3415 #: ../src/guestfs.pod:1619
3418 " struct guestfs_add_drive_opts_argv {\n"
3419 " uint64_t bitmask;\n"
3421 " const char *format;\n"
3424 " int guestfs_add_drive_opts_argv (guestfs_h *g, const char *filename,\n"
3425 " const struct guestfs_add_drive_opts_argv *optargs);\n"
3428 " struct guestfs_add_drive_opts_argv {\n"
3429 " uint64_t bitmask;\n"
3431 " const char *format;\n"
3434 " int guestfs_add_drive_opts_argv (guestfs_h *g, const char *filename,\n"
3435 " const struct guestfs_add_drive_opts_argv *optargs);\n"
3439 #: ../src/guestfs.pod:1628
3440 msgid "You could call it like this:"
3444 #: ../src/guestfs.pod:1630
3447 " struct guestfs_add_drive_opts_argv optargs = {\n"
3448 " .bitmask = GUESTFS_ADD_DRIVE_OPTS_READONLY_BITMASK |\n"
3449 " GUESTFS_ADD_DRIVE_OPTS_FORMAT_BITMASK,\n"
3451 " .format = \"qcow2\"\n"
3455 " struct guestfs_add_drive_opts_argv optargs = {\n"
3456 " .bitmask = GUESTFS_ADD_DRIVE_OPTS_READONLY_BITMASK |\n"
3457 " GUESTFS_ADD_DRIVE_OPTS_FORMAT_BITMASK,\n"
3459 " .format = \"qcow2\"\n"
3464 #: ../src/guestfs.pod:1637
3467 " guestfs_add_drive_opts_argv (g, filename, &optargs);\n"
3470 " guestfs_add_drive_opts_argv (g, filename, &optargs);\n"
3474 #: ../src/guestfs.pod:1639 ../src/guestfs-actions.pod:11
3475 #: ../src/guestfs-actions.pod:1917 ../src/guestfs-actions.pod:2853
3476 #: ../fish/guestfish-actions.pod:9 ../fish/guestfish-actions.pod:1287
3477 #: ../fish/guestfish-actions.pod:1929 ../tools/virt-win-reg.pl:704
3482 #: ../src/guestfs.pod:1645
3484 "The C<_BITMASK> suffix on each option name when specifying the bitmask."
3488 #: ../src/guestfs.pod:1650
3489 msgid "You do not need to fill in all fields of the structure."
3493 #: ../src/guestfs.pod:1654
3495 "There must be a one-to-one correspondence between fields of the structure "
3496 "that are filled in, and bits set in the bitmask."
3500 #: ../src/guestfs.pod:1659
3501 msgid "OPTIONAL ARGUMENTS IN OTHER LANGUAGES"
3505 #: ../src/guestfs.pod:1661
3507 "In other languages, optional arguments are expressed in the way that is "
3508 "natural for that language. We refer you to the language-specific "
3509 "documentation for more details on that."
3513 #: ../src/guestfs.pod:1665
3514 msgid "For guestfish, see L<guestfish(1)/OPTIONAL ARGUMENTS>."
3518 #: ../src/guestfs.pod:1667
3519 msgid "SETTING CALLBACKS TO HANDLE EVENTS"
3523 #: ../src/guestfs.pod:1669
3525 "B<Note:> This section documents the generic event mechanism introduced in "
3526 "libguestfs 1.10, which you should use in new code if possible. The old "
3527 "functions C<guestfs_set_log_message_callback>, "
3528 "C<guestfs_set_subprocess_quit_callback>, "
3529 "C<guestfs_set_launch_done_callback>, C<guestfs_set_close_callback> and "
3530 "C<guestfs_set_progress_callback> are no longer documented in this manual "
3531 "page. Because of the ABI guarantee, the old functions continue to work."
3535 #: ../src/guestfs.pod:1678
3537 "Handles generate events when certain things happen, such as log messages "
3538 "being generated, progress messages during long-running operations, or the "
3539 "handle being closed. The API calls described below let you register a "
3540 "callback to be called when events happen. You can register multiple "
3541 "callbacks (for the same, different or overlapping sets of events), and "
3542 "individually remove callbacks. If callbacks are not removed, then they "
3543 "remain in force until the handle is closed."
3547 #: ../src/guestfs.pod:1686
3549 "In the current implementation, events are only generated synchronously: that"
3550 " means that events (and hence callbacks) can only happen while you are in "
3551 "the middle of making another libguestfs call. The callback is called in the"
3556 #: ../src/guestfs.pod:1691
3558 "Events may contain a payload, usually nothing (void), an array of 64 bit "
3559 "unsigned integers, or a message buffer. Payloads are discussed later on."
3563 #: ../src/guestfs.pod:1695
3564 msgid "CLASSES OF EVENTS"
3568 #: ../src/guestfs.pod:1699
3569 msgid "GUESTFS_EVENT_CLOSE (payload type: void)"
3573 #: ../src/guestfs.pod:1702
3575 "The callback function will be called while the handle is being closed "
3576 "(synchronously from L</guestfs_close>)."
3580 #: ../src/guestfs.pod:1705
3582 "Note that libguestfs installs an L<atexit(3)> handler to try to clean up "
3583 "handles that are open when the program exits. This means that this callback"
3584 " might be called indirectly from L<exit(3)>, which can cause unexpected "
3585 "problems in higher-level languages (eg. if your HLL interpreter has already "
3586 "been cleaned up by the time this is called, and if your callback then jumps "
3587 "into some HLL function)."
3591 #: ../src/guestfs.pod:1712
3593 "If no callback is registered: the handle is closed without any callback "
3598 #: ../src/guestfs.pod:1715
3599 msgid "GUESTFS_EVENT_SUBPROCESS_QUIT (payload type: void)"
3603 #: ../src/guestfs.pod:1718
3605 "The callback function will be called when the child process quits, either "
3606 "asynchronously or if killed by L</guestfs_kill_subprocess>. (This "
3607 "corresponds to a transition from any state to the CONFIG state)."
3611 #: ../src/guestfs.pod:1722 ../src/guestfs.pod:1731
3612 msgid "If no callback is registered: the event is ignored."
3616 #: ../src/guestfs.pod:1724
3617 msgid "GUESTFS_EVENT_LAUNCH_DONE (payload type: void)"
3621 #: ../src/guestfs.pod:1727
3623 "The callback function will be called when the child process becomes ready "
3624 "first time after it has been launched. (This corresponds to a transition "
3625 "from LAUNCHING to the READY state)."
3629 #: ../src/guestfs.pod:1733
3630 msgid "GUESTFS_EVENT_PROGRESS (payload type: array of 4 x uint64_t)"
3634 #: ../src/guestfs.pod:1736
3636 "Some long-running operations can generate progress messages. If this "
3637 "callback is registered, then it will be called each time a progress message "
3638 "is generated (usually two seconds after the operation started, and three "
3639 "times per second thereafter until it completes, although the frequency may "
3640 "change in future versions)."
3644 #: ../src/guestfs.pod:1742
3646 "The callback receives in the payload four unsigned 64 bit numbers which are "
3647 "(in order): C<proc_nr>, C<serial>, C<position>, C<total>."
3651 #: ../src/guestfs.pod:1745
3653 "The units of C<total> are not defined, although for some operations C<total>"
3654 " may relate in some way to the amount of data to be transferred (eg. in "
3655 "bytes or megabytes), and C<position> may be the portion which has been "
3660 #: ../src/guestfs.pod:1750
3661 msgid "The only defined and stable parts of the API are:"
3665 #: ../src/guestfs.pod:1756
3667 "The callback can display to the user some type of progress bar or indicator "
3668 "which shows the ratio of C<position>:C<total>."
3672 #: ../src/guestfs.pod:1761
3673 msgid "0 E<lt>= C<position> E<lt>= C<total>"
3677 #: ../src/guestfs.pod:1765
3679 "If any progress notification is sent during a call, then a final progress "
3680 "notification is always sent when C<position> = C<total> (I<unless> the call "
3681 "fails with an error)."
3685 #: ../src/guestfs.pod:1769
3687 "This is to simplify caller code, so callers can easily set the progress "
3688 "indicator to \"100%\" at the end of the operation, without requiring special"
3689 " code to detect this case."
3693 #: ../src/guestfs.pod:1775
3695 "For some calls we are unable to estimate the progress of the call, but we "
3696 "can still generate progress messages to indicate activity. This is known as"
3697 " \"pulse mode\", and is directly supported by certain progress bar "
3698 "implementations (eg. GtkProgressBar)."
3702 #: ../src/guestfs.pod:1780
3704 "For these calls, zero or more progress messages are generated with "
3705 "C<position = 0> and C<total = 1>, followed by a final message with "
3706 "C<position = total = 1>."
3710 #: ../src/guestfs.pod:1784
3712 "As noted above, if the call fails with an error then the final message may "
3717 #: ../src/guestfs.pod:1789
3719 "The callback also receives the procedure number (C<proc_nr>) and serial "
3720 "number (C<serial>) of the call. These are only useful for debugging "
3721 "protocol issues, and the callback can normally ignore them. The callback "
3722 "may want to print these numbers in error messages or debugging messages."
3726 #: ../src/guestfs.pod:1795
3727 msgid "If no callback is registered: progress messages are discarded."
3731 #: ../src/guestfs.pod:1797
3732 msgid "GUESTFS_EVENT_APPLIANCE (payload type: message buffer)"
3736 #: ../src/guestfs.pod:1800
3738 "The callback function is called whenever a log message is generated by qemu,"
3739 " the appliance kernel, guestfsd (daemon), or utility programs."
3743 #: ../src/guestfs.pod:1803
3745 "If the verbose flag (L</guestfs_set_verbose>) is set before launch "
3746 "(L</guestfs_launch>) then additional debug messages are generated."
3750 #: ../src/guestfs.pod:1806 ../src/guestfs.pod:1820
3752 "If no callback is registered: the messages are discarded unless the verbose "
3753 "flag is set in which case they are sent to stderr. You can override the "
3754 "printing of verbose messages to stderr by setting up a callback."
3758 #: ../src/guestfs.pod:1811
3759 msgid "GUESTFS_EVENT_LIBRARY (payload type: message buffer)"
3763 #: ../src/guestfs.pod:1814
3765 "The callback function is called whenever a log message is generated by the "
3766 "library part of libguestfs."
3770 #: ../src/guestfs.pod:1817
3772 "If the verbose flag (L</guestfs_set_verbose>) is set then additional debug "
3773 "messages are generated."
3777 #: ../src/guestfs.pod:1825
3778 msgid "GUESTFS_EVENT_TRACE (payload type: message buffer)"
3782 #: ../src/guestfs.pod:1828
3784 "The callback function is called whenever a trace message is generated. This"
3785 " only applies if the trace flag (L</guestfs_set_trace>) is set."
3789 #: ../src/guestfs.pod:1831
3791 "If no callback is registered: the messages are sent to stderr. You can "
3792 "override the printing of trace messages to stderr by setting up a callback."
3796 #: ../src/guestfs.pod:1837
3797 msgid "guestfs_set_event_callback"
3801 #: ../src/guestfs.pod:1839
3804 " int guestfs_set_event_callback (guestfs_h *g,\n"
3805 " guestfs_event_callback cb,\n"
3806 " uint64_t event_bitmask,\n"
3813 #: ../src/guestfs.pod:1845
3815 "This function registers a callback (C<cb>) for all event classes in the "
3820 #: ../src/guestfs.pod:1848
3822 "For example, to register for all log message events, you could call this "
3823 "function with the bitmask C<GUESTFS_EVENT_APPLIANCE|GUESTFS_EVENT_LIBRARY>."
3824 " To register a single callback for all possible classes of events, use "
3825 "C<GUESTFS_EVENT_ALL>."
3829 #: ../src/guestfs.pod:1854
3830 msgid "C<flags> should always be passed as 0."
3834 #: ../src/guestfs.pod:1856
3836 "C<opaque> is an opaque pointer which is passed to the callback. You can use"
3837 " it for any purpose."
3841 #: ../src/guestfs.pod:1859
3843 "The return value is the event handle (an integer) which you can use to "
3844 "delete the callback (see below)."
3848 #: ../src/guestfs.pod:1862
3850 "If there is an error, this function returns C<-1>, and sets the error in the"
3851 " handle in the usual way (see L</guestfs_last_error> etc.)"
3855 #: ../src/guestfs.pod:1865
3857 "Callbacks remain in effect until they are deleted, or until the handle is "
3862 #: ../src/guestfs.pod:1868
3864 "In the case where multiple callbacks are registered for a particular event "
3865 "class, all of the callbacks are called. The order in which multiple "
3866 "callbacks are called is not defined."
3870 #: ../src/guestfs.pod:1872
3871 msgid "guestfs_delete_event_callback"
3875 #: ../src/guestfs.pod:1874
3878 " void guestfs_delete_event_callback (guestfs_h *g, int event_handle);\n"
3883 #: ../src/guestfs.pod:1876
3885 "Delete a callback that was previously registered. C<event_handle> should be"
3886 " the integer that was returned by a previous call to "
3887 "C<guestfs_set_event_callback> on the same handle."
3891 #: ../src/guestfs.pod:1880
3892 msgid "guestfs_event_callback"
3896 #: ../src/guestfs.pod:1882
3899 " typedef void (*guestfs_event_callback) (\n"
3902 " uint64_t event,\n"
3903 " int event_handle,\n"
3905 " const char *buf, size_t buf_len,\n"
3906 " const uint64_t *array, size_t array_len);\n"
3911 #: ../src/guestfs.pod:1891
3913 "This is the type of the event callback function that you have to provide."
3917 #: ../src/guestfs.pod:1894
3919 "The basic parameters are: the handle (C<g>), the opaque user pointer "
3920 "(C<opaque>), the event class (eg. C<GUESTFS_EVENT_PROGRESS>), the event "
3921 "handle, and C<flags> which in the current API you should ignore."
3925 #: ../src/guestfs.pod:1898
3927 "The remaining parameters contain the event payload (if any). Each event may"
3928 " contain a payload, which usually relates to the event class, but for future"
3929 " proofing your code should be written to handle any payload for any event "
3934 #: ../src/guestfs.pod:1903
3936 "C<buf> and C<buf_len> contain a message buffer (if C<buf_len == 0>, then "
3937 "there is no message buffer). Note that this message buffer can contain "
3938 "arbitrary 8 bit data, including NUL bytes."
3942 #: ../src/guestfs.pod:1907
3944 "C<array> and C<array_len> is an array of 64 bit unsigned integers. At the "
3945 "moment this is only used for progress messages."
3949 #: ../src/guestfs.pod:1910
3950 msgid "EXAMPLE: CAPTURING LOG MESSAGES"
3954 #: ../src/guestfs.pod:1912
3956 "One motivation for the generic event API was to allow GUI programs to "
3957 "capture debug and other messages. In libguestfs E<le> 1.8 these were sent "
3958 "unconditionally to C<stderr>."
3962 #: ../src/guestfs.pod:1916
3964 "Events associated with log messages are: C<GUESTFS_EVENT_LIBRARY>, "
3965 "C<GUESTFS_EVENT_APPLIANCE> and C<GUESTFS_EVENT_TRACE>. (Note that error "
3966 "messages are not events; you must capture error messages separately)."
3970 #: ../src/guestfs.pod:1921
3972 "Programs have to set up a callback to capture the classes of events of "
3977 #: ../src/guestfs.pod:1924
3981 " guestfs_set_event_callback\n"
3982 " (g, message_callback,\n"
3983 " GUESTFS_EVENT_LIBRARY|GUESTFS_EVENT_APPLIANCE|\n"
3984 " GUESTFS_EVENT_TRACE,\n"
3985 " 0, NULL) == -1)\n"
3986 " if (eh == -1) {\n"
3987 " // handle error in the usual way\n"
3993 #: ../src/guestfs.pod:1934
3995 "The callback can then direct messages to the appropriate place. In this "
3996 "example, messages are directed to syslog:"
4000 #: ../src/guestfs.pod:1937
4004 " message_callback (\n"
4007 " uint64_t event,\n"
4008 " int event_handle,\n"
4010 " const char *buf, size_t buf_len,\n"
4011 " const uint64_t *array, size_t array_len)\n"
4013 " const int priority = LOG_USER|LOG_INFO;\n"
4014 " if (buf_len > 0)\n"
4015 " syslog (priority, \"event 0x%lx: %s\", event, buf);\n"
4021 #: ../src/guestfs.pod:1952
4022 msgid "CANCELLING LONG TRANSFERS"
4026 #: ../src/guestfs.pod:1954
4028 "Some operations can be cancelled by the caller while they are in progress. "
4029 "Currently only operations that involve uploading or downloading data can be "
4030 "cancelled (technically: operations that have C<FileIn> or C<FileOut> "
4031 "parameters in the generator)."
4035 #: ../src/guestfs.pod:1959
4036 msgid "guestfs_user_cancel"
4040 #: ../src/guestfs.pod:1961
4043 " void guestfs_user_cancel (guestfs_h *g);\n"
4048 #: ../src/guestfs.pod:1963
4050 "C<guestfs_user_cancel> cancels the current upload or download operation."
4054 #: ../src/guestfs.pod:1966
4056 "Unlike most other libguestfs calls, this function is signal safe and thread "
4057 "safe. You can call it from a signal handler or from another thread, without"
4058 " needing to do any locking."
4062 #: ../src/guestfs.pod:1970
4064 "The transfer that was in progress (if there is one) will stop shortly "
4065 "afterwards, and will return an error. The errno (see "
4066 "L</guestfs_last_errno>) is set to C<EINTR>, so you can test for this to find"
4067 " out if the operation was cancelled or failed because of another error."
4071 #: ../src/guestfs.pod:1976
4073 "No cleanup is performed: for example, if a file was being uploaded then "
4074 "after cancellation there may be a partially uploaded file. It is the "
4075 "caller's responsibility to clean up if necessary."
4079 #: ../src/guestfs.pod:1980
4081 "There are two common places that you might call C<guestfs_user_cancel>."
4085 #: ../src/guestfs.pod:1982
4087 "In an interactive text-based program, you might call it from a C<SIGINT> "
4088 "signal handler so that pressing C<^C> cancels the current operation. (You "
4089 "also need to call L</guestfs_set_pgroup> so that child processes don't "
4090 "receive the C<^C> signal)."
4094 #: ../src/guestfs.pod:1987
4096 "In a graphical program, when the main thread is displaying a progress bar "
4097 "with a cancel button, wire up the cancel button to call this function."
4101 #: ../src/guestfs.pod:1991
4102 msgid "PRIVATE DATA AREA"
4106 #: ../src/guestfs.pod:1993
4108 "You can attach named pieces of private data to the libguestfs handle, fetch "
4109 "them by name, and walk over them, for the lifetime of the handle. This is "
4110 "called the private data area and is only available from the C API."
4114 #: ../src/guestfs.pod:1998
4115 msgid "To attach a named piece of data, use the following call:"
4119 #: ../src/guestfs.pod:2000
4122 " void guestfs_set_private (guestfs_h *g, const char *key, void *data);\n"
4125 " void guestfs_set_private (guestfs_h *g, const char *key, void *data);\n"
4129 #: ../src/guestfs.pod:2002
4131 "C<key> is the name to associate with this data, and C<data> is an arbitrary "
4132 "pointer (which can be C<NULL>). Any previous item with the same key is "
4137 #: ../src/guestfs.pod:2006
4139 "You can use any C<key> you want, but your key should I<not> start with an "
4140 "underscore character. Keys beginning with an underscore character are "
4141 "reserved for internal libguestfs purposes (eg. for implementing language "
4142 "bindings). It is recommended that you prefix the key with some unique "
4143 "string to avoid collisions with other users."
4147 #: ../src/guestfs.pod:2012
4148 msgid "To retrieve the pointer, use:"
4152 #: ../src/guestfs.pod:2014
4155 " void *guestfs_get_private (guestfs_h *g, const char *key);\n"
4158 " void *guestfs_get_private (guestfs_h *g, const char *key);\n"
4162 #: ../src/guestfs.pod:2016
4164 "This function returns C<NULL> if either no data is found associated with "
4165 "C<key>, or if the user previously set the C<key>'s C<data> pointer to "
4170 #: ../src/guestfs.pod:2020
4172 "Libguestfs does not try to look at or interpret the C<data> pointer in any "
4173 "way. As far as libguestfs is concerned, it need not be a valid pointer at "
4174 "all. In particular, libguestfs does I<not> try to free the data when the "
4175 "handle is closed. If the data must be freed, then the caller must either "
4176 "free it before calling L</guestfs_close> or must set up a close callback to "
4177 "do it (see L</GUESTFS_EVENT_CLOSE>)."
4181 #: ../src/guestfs.pod:2027
4182 msgid "To walk over all entries, use these two functions:"
4186 #: ../src/guestfs.pod:2029
4189 " void *guestfs_first_private (guestfs_h *g, const char **key_rtn);\n"
4194 #: ../src/guestfs.pod:2031
4197 " void *guestfs_next_private (guestfs_h *g, const char **key_rtn);\n"
4202 #: ../src/guestfs.pod:2033
4204 "C<guestfs_first_private> returns the first key, pointer pair (\"first\" does"
4205 " not have any particular meaning -- keys are not returned in any defined "
4206 "order). A pointer to the key is returned in C<*key_rtn> and the "
4207 "corresponding data pointer is returned from the function. C<NULL> is "
4208 "returned if there are no keys stored in the handle."
4212 #: ../src/guestfs.pod:2039
4214 "C<guestfs_next_private> returns the next key, pointer pair. The return "
4215 "value of this function is also C<NULL> is there are no further entries to "
4220 #: ../src/guestfs.pod:2043
4221 msgid "Notes about walking over entries:"
4225 #: ../src/guestfs.pod:2049
4227 "You must not call C<guestfs_set_private> while walking over the entries."
4231 #: ../src/guestfs.pod:2054
4233 "The handle maintains an internal iterator which is reset when you call "
4234 "C<guestfs_first_private>. This internal iterator is invalidated when you "
4235 "call C<guestfs_set_private>."
4239 #: ../src/guestfs.pod:2060
4240 msgid "If you have set the data pointer associated with a key to C<NULL>, ie:"
4244 #: ../src/guestfs.pod:2062
4247 " guestfs_set_private (g, key, NULL);\n"
4252 #: ../src/guestfs.pod:2064
4253 msgid "then that C<key> is not returned when walking."
4257 #: ../src/guestfs.pod:2068
4259 "C<*key_rtn> is only valid until the next call to C<guestfs_first_private>, "
4260 "C<guestfs_next_private> or C<guestfs_set_private>."
4264 #: ../src/guestfs.pod:2074
4266 "The following example code shows how to print all keys and data pointers "
4267 "that are associated with the handle C<g>:"
4271 #: ../src/guestfs.pod:2077
4274 " const char *key;\n"
4275 " void *data = guestfs_first_private (g, &key);\n"
4276 " while (data != NULL)\n"
4278 " printf (\"key = %s, data = %p\\n\", key, data);\n"
4279 " data = guestfs_next_private (g, &key);\n"
4285 #: ../src/guestfs.pod:2085
4287 "More commonly you are only interested in keys that begin with an "
4288 "application-specific prefix C<foo_>. Modify the loop like so:"
4292 #: ../src/guestfs.pod:2088
4295 " const char *key;\n"
4296 " void *data = guestfs_first_private (g, &key);\n"
4297 " while (data != NULL)\n"
4299 " if (strncmp (key, \"foo_\", strlen (\"foo_\")) == 0)\n"
4300 " printf (\"key = %s, data = %p\\n\", key, data);\n"
4301 " data = guestfs_next_private (g, &key);\n"
4307 #: ../src/guestfs.pod:2097
4309 "If you need to modify keys while walking, then you have to jump back to the "
4310 "beginning of the loop. For example, to delete all keys prefixed with "
4315 #: ../src/guestfs.pod:2101
4318 " const char *key;\n"
4321 " data = guestfs_first_private (g, &key);\n"
4322 " while (data != NULL)\n"
4324 " if (strncmp (key, \"foo_\", strlen (\"foo_\")) == 0)\n"
4326 " guestfs_set_private (g, key, NULL);\n"
4327 " /* note that 'key' pointer is now invalid, and so is\n"
4328 " the internal iterator */\n"
4331 " data = guestfs_next_private (g, &key);\n"
4337 #: ../src/guestfs.pod:2117
4339 "Note that the above loop is guaranteed to terminate because the keys are "
4340 "being deleted, but other manipulations of keys within the loop might not "
4341 "terminate unless you also maintain an indication of which keys have been "
4346 #: ../src/guestfs.pod:2122 ../src/guestfs.pod:2127
4351 #: ../src/guestfs.pod:2124
4353 "<!-- old anchor for the next section --> <a "
4354 "name=\"state_machine_and_low_level_event_api\"/>"
4356 "<!-- old anchor for the next section --> <a "
4357 "name=\"state_machine_and_low_level_event_api\"/>"
4360 #: ../src/guestfs.pod:2129
4361 msgid "ARCHITECTURE"
4362 msgstr "АРХІТЕКТУРА"
4365 #: ../src/guestfs.pod:2131
4367 "Internally, libguestfs is implemented by running an appliance (a special "
4368 "type of small virtual machine) using L<qemu(1)>. Qemu runs as a child "
4369 "process of the main program."
4373 #: ../src/guestfs.pod:2135
4376 " ___________________\n"
4378 " | main program |\n"
4380 " | | child process / appliance\n"
4381 " | | __________________________\n"
4383 " +-------------------+ RPC | +-----------------+ |\n"
4384 " | libguestfs <--------------------> guestfsd | |\n"
4385 " | | | +-----------------+ |\n"
4386 " \\___________________/ | | Linux kernel | |\n"
4387 " | +--^--------------+ |\n"
4388 " \\_________|________________/\n"
4394 " \\______________/\n"
4399 #: ../src/guestfs.pod:2155
4401 "The library, linked to the main program, creates the child process and hence"
4402 " the appliance in the L</guestfs_launch> function."
4406 #: ../src/guestfs.pod:2158
4408 "Inside the appliance is a Linux kernel and a complete stack of userspace "
4409 "tools (such as LVM and ext2 programs) and a small controlling daemon called "
4410 "L</guestfsd>. The library talks to L</guestfsd> using remote procedure "
4411 "calls (RPC). There is a mostly one-to-one correspondence between libguestfs"
4412 " API calls and RPC calls to the daemon. Lastly the disk image(s) are "
4413 "attached to the qemu process which translates device access by the "
4414 "appliance's Linux kernel into accesses to the image."
4418 #: ../src/guestfs.pod:2167
4420 "A common misunderstanding is that the appliance \"is\" the virtual machine."
4421 " Although the disk image you are attached to might also be used by some "
4422 "virtual machine, libguestfs doesn't know or care about this. (But you will "
4423 "care if both libguestfs's qemu process and your virtual machine are trying "
4424 "to update the disk image at the same time, since these usually results in "
4425 "massive disk corruption)."
4429 #: ../src/guestfs.pod:2174
4430 msgid "STATE MACHINE"
4431 msgstr "СКІНЧЕННИЙ АВТОМАТ"
4434 #: ../src/guestfs.pod:2176
4435 msgid "libguestfs uses a state machine to model the child process:"
4439 #: ../src/guestfs.pod:2178
4451 " / | \\ \\ guestfs_launch\n"
4452 " / | _\\__V______\n"
4454 " / | | LAUNCHING |\n"
4455 " / | \\___________/\n"
4457 " / | guestfs_launch\n"
4459 " ______ / __|____V\n"
4460 " / \\ ------> / \\\n"
4461 " | BUSY | | READY |\n"
4462 " \\______/ <------ \\________/\n"
4467 #: ../src/guestfs.pod:2200
4469 "The normal transitions are (1) CONFIG (when the handle is created, but there"
4470 " is no child process), (2) LAUNCHING (when the child process is booting up),"
4471 " (3) alternating between READY and BUSY as commands are issued to, and "
4472 "carried out by, the child process."
4476 #: ../src/guestfs.pod:2205
4478 "The guest may be killed by L</guestfs_kill_subprocess>, or may die "
4479 "asynchronously at any time (eg. due to some internal error), and that causes"
4480 " the state to transition back to CONFIG."
4484 #: ../src/guestfs.pod:2209
4486 "Configuration commands for qemu such as L</guestfs_add_drive> can only be "
4487 "issued when in the CONFIG state."
4491 #: ../src/guestfs.pod:2212
4493 "The API offers one call that goes from CONFIG through LAUNCHING to READY. "
4494 "L</guestfs_launch> blocks until the child process is READY to accept "
4495 "commands (or until some failure or timeout). L</guestfs_launch> internally "
4496 "moves the state from CONFIG to LAUNCHING while it is running."
4500 #: ../src/guestfs.pod:2218
4502 "API actions such as L</guestfs_mount> can only be issued when in the READY "
4503 "state. These API calls block waiting for the command to be carried out (ie."
4504 " the state to transition to BUSY and then back to READY). There are no non-"
4505 "blocking versions, and no way to issue more than one command per handle at "
4510 #: ../src/guestfs.pod:2224
4512 "Finally, the child process sends asynchronous messages back to the main "
4513 "program, such as kernel log messages. You can register a callback to "
4514 "receive these messages."
4518 #: ../src/guestfs.pod:2228
4523 #: ../src/guestfs.pod:2230
4524 msgid "COMMUNICATION PROTOCOL"
4528 #: ../src/guestfs.pod:2232
4530 "Don't rely on using this protocol directly. This section documents how it "
4531 "currently works, but it may change at any time."
4535 #: ../src/guestfs.pod:2235
4537 "The protocol used to talk between the library and the daemon running inside "
4538 "the qemu virtual machine is a simple RPC mechanism built on top of XDR (RFC "
4539 "1014, RFC 1832, RFC 4506)."
4543 #: ../src/guestfs.pod:2239
4545 "The detailed format of structures is in C<src/guestfs_protocol.x> (note: "
4546 "this file is automatically generated)."
4550 #: ../src/guestfs.pod:2242
4552 "There are two broad cases, ordinary functions that don't have any C<FileIn> "
4553 "and C<FileOut> parameters, which are handled with very simple request/reply "
4554 "messages. Then there are functions that have any C<FileIn> or C<FileOut> "
4555 "parameters, which use the same request and reply messages, but they may also"
4556 " be followed by files sent using a chunked encoding."
4560 #: ../src/guestfs.pod:2249
4561 msgid "ORDINARY FUNCTIONS (NO FILEIN/FILEOUT PARAMS)"
4565 #: ../src/guestfs.pod:2251
4566 msgid "For ordinary functions, the request message is:"
4570 #: ../src/guestfs.pod:2253
4573 " total length (header + arguments,\n"
4574 " but not including the length word itself)\n"
4575 " struct guestfs_message_header (encoded as XDR)\n"
4576 " struct guestfs_<foo>_args (encoded as XDR)\n"
4581 #: ../src/guestfs.pod:2258
4583 "The total length field allows the daemon to allocate a fixed size buffer "
4584 "into which it slurps the rest of the message. As a result, the total length"
4585 " is limited to C<GUESTFS_MESSAGE_MAX> bytes (currently 4MB), which means the"
4586 " effective size of any request is limited to somewhere under this size."
4590 #: ../src/guestfs.pod:2264
4592 "Note also that many functions don't take any arguments, in which case the "
4593 "C<guestfs_I<foo>_args> is completely omitted."
4597 #: ../src/guestfs.pod:2267
4599 "The header contains the procedure number (C<guestfs_proc>) which is how the "
4600 "receiver knows what type of args structure to expect, or none at all."
4604 #: ../src/guestfs.pod:2271
4606 "For functions that take optional arguments, the optional arguments are "
4607 "encoded in the C<guestfs_I<foo>_args> structure in the same way as ordinary "
4608 "arguments. A bitmask in the header indicates which optional arguments are "
4609 "meaningful. The bitmask is also checked to see if it contains bits set "
4610 "which the daemon does not know about (eg. if more optional arguments were "
4611 "added in a later version of the library), and this causes the call to be "
4616 #: ../src/guestfs.pod:2279
4617 msgid "The reply message for ordinary functions is:"
4621 #: ../src/guestfs.pod:2281
4624 " total length (header + ret,\n"
4625 " but not including the length word itself)\n"
4626 " struct guestfs_message_header (encoded as XDR)\n"
4627 " struct guestfs_<foo>_ret (encoded as XDR)\n"
4632 #: ../src/guestfs.pod:2286
4634 "As above the C<guestfs_I<foo>_ret> structure may be completely omitted for "
4635 "functions that return no formal return values."
4639 #: ../src/guestfs.pod:2289
4641 "As above the total length of the reply is limited to C<GUESTFS_MESSAGE_MAX>."
4645 #: ../src/guestfs.pod:2292
4647 "In the case of an error, a flag is set in the header, and the reply message "
4648 "is slightly changed:"
4652 #: ../src/guestfs.pod:2295
4655 " total length (header + error,\n"
4656 " but not including the length word itself)\n"
4657 " struct guestfs_message_header (encoded as XDR)\n"
4658 " struct guestfs_message_error (encoded as XDR)\n"
4663 #: ../src/guestfs.pod:2300
4665 "The C<guestfs_message_error> structure contains the error message as a "
4670 #: ../src/guestfs.pod:2303
4671 msgid "FUNCTIONS THAT HAVE FILEIN PARAMETERS"
4675 #: ../src/guestfs.pod:2305
4677 "A C<FileIn> parameter indicates that we transfer a file I<into> the guest. "
4678 "The normal request message is sent (see above). However this is followed by"
4679 " a sequence of file chunks."
4683 #: ../src/guestfs.pod:2309
4686 " total length (header + arguments,\n"
4687 " but not including the length word itself,\n"
4688 " and not including the chunks)\n"
4689 " struct guestfs_message_header (encoded as XDR)\n"
4690 " struct guestfs_<foo>_args (encoded as XDR)\n"
4691 " sequence of chunks for FileIn param #0\n"
4692 " sequence of chunks for FileIn param #1 etc.\n"
4697 #: ../src/guestfs.pod:2317
4698 msgid "The \"sequence of chunks\" is:"
4702 #: ../src/guestfs.pod:2319
4705 " length of chunk (not including length word itself)\n"
4706 " struct guestfs_chunk (encoded as XDR)\n"
4707 " length of chunk\n"
4708 " struct guestfs_chunk (encoded as XDR)\n"
4710 " length of chunk\n"
4711 " struct guestfs_chunk (with data.data_len == 0)\n"
4716 #: ../src/guestfs.pod:2327
4718 "The final chunk has the C<data_len> field set to zero. Additionally a flag "
4719 "is set in the final chunk to indicate either successful completion or early "
4724 #: ../src/guestfs.pod:2331
4726 "At time of writing there are no functions that have more than one FileIn "
4727 "parameter. However this is (theoretically) supported, by sending the "
4728 "sequence of chunks for each FileIn parameter one after another (from left to"
4733 #: ../src/guestfs.pod:2336
4735 "Both the library (sender) I<and> the daemon (receiver) may cancel the "
4736 "transfer. The library does this by sending a chunk with a special flag set "
4737 "to indicate cancellation. When the daemon sees this, it cancels the whole "
4738 "RPC, does I<not> send any reply, and goes back to reading the next request."
4742 #: ../src/guestfs.pod:2342
4744 "The daemon may also cancel. It does this by writing a special word "
4745 "C<GUESTFS_CANCEL_FLAG> to the socket. The library listens for this during "
4746 "the transfer, and if it gets it, it will cancel the transfer (it sends a "
4747 "cancel chunk). The special word is chosen so that even if cancellation "
4748 "happens right at the end of the transfer (after the library has finished "
4749 "writing and has started listening for the reply), the \"spurious\" cancel "
4750 "flag will not be confused with the reply message."
4754 #: ../src/guestfs.pod:2351
4756 "This protocol allows the transfer of arbitrary sized files (no 32 bit "
4757 "limit), and also files where the size is not known in advance (eg. from "
4758 "pipes or sockets). However the chunks are rather small "
4759 "(C<GUESTFS_MAX_CHUNK_SIZE>), so that neither the library nor the daemon need"
4760 " to keep much in memory."
4764 #: ../src/guestfs.pod:2357
4765 msgid "FUNCTIONS THAT HAVE FILEOUT PARAMETERS"
4769 #: ../src/guestfs.pod:2359
4771 "The protocol for FileOut parameters is exactly the same as for FileIn "
4772 "parameters, but with the roles of daemon and library reversed."
4776 #: ../src/guestfs.pod:2362
4779 " total length (header + ret,\n"
4780 " but not including the length word itself,\n"
4781 " and not including the chunks)\n"
4782 " struct guestfs_message_header (encoded as XDR)\n"
4783 " struct guestfs_<foo>_ret (encoded as XDR)\n"
4784 " sequence of chunks for FileOut param #0\n"
4785 " sequence of chunks for FileOut param #1 etc.\n"
4790 #: ../src/guestfs.pod:2370
4791 msgid "INITIAL MESSAGE"
4795 #: ../src/guestfs.pod:2372
4797 "When the daemon launches it sends an initial word (C<GUESTFS_LAUNCH_FLAG>) "
4798 "which indicates that the guest and daemon is alive. This is what "
4799 "L</guestfs_launch> waits for."
4803 #: ../src/guestfs.pod:2376
4804 msgid "PROGRESS NOTIFICATION MESSAGES"
4808 #: ../src/guestfs.pod:2378
4810 "The daemon may send progress notification messages at any time. These are "
4811 "distinguished by the normal length word being replaced by "
4812 "C<GUESTFS_PROGRESS_FLAG>, followed by a fixed size progress message."
4816 #: ../src/guestfs.pod:2382
4818 "The library turns them into progress callbacks (see "
4819 "L</GUESTFS_EVENT_PROGRESS>) if there is a callback registered, or discards "
4824 #: ../src/guestfs.pod:2386
4826 "The daemon self-limits the frequency of progress messages it sends (see "
4827 "C<daemon/proto.c:notify_progress>). Not all calls generate progress "
4832 #: ../src/guestfs.pod:2390
4833 msgid "LIBGUESTFS VERSION NUMBERS"
4837 #: ../src/guestfs.pod:2392
4839 "Since April 2010, libguestfs has started to make separate development and "
4840 "stable releases, along with corresponding branches in our git repository. "
4841 "These separate releases can be identified by version number:"
4845 #: ../src/guestfs.pod:2397
4848 " even numbers for stable: 1.2.x, 1.4.x, ...\n"
4849 " .-------- odd numbers for development: 1.3.x, 1.5.x, ...\n"
4855 " | `-------- sub-version\n"
4857 " `------ always '1' because we don't change the