1 # SOME DESCRIPTIVE TITLE
2 # Copyright (C) YEAR Red Hat Inc.
3 # This file is distributed under the same license as the libguestfs package.
4 # FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
8 "Project-Id-Version: libguestfs\n"
9 "Report-Msgid-Bugs-To: libguestfs@redhat.com\n"
10 "POT-Creation-Date: 2011-04-01 20:21+0200\n"
11 "PO-Revision-Date: 2011-04-01 15:39+0000\n"
12 "Last-Translator: yurchor <yurchor@ukr.net>\n"
13 "Language-Team: Ukrainian <trans-uk@lists.fedoraproject.org>\n"
16 "Content-Type: text/plain; charset=UTF-8\n"
17 "Content-Transfer-Encoding: 8bit\n"
18 "Plural-Forms: nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n"
19 "%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2)\n"
22 #: ../src/guestfs.pod:3 ../fish/guestfish.pod:3
23 #: ../test-tool/libguestfs-test-tool.pod:3 ../fuse/guestmount.pod:3
24 #: ../tools/virt-edit.pl:32 ../tools/virt-win-reg.pl:35
25 #: ../tools/virt-resize.pl:40 ../tools/virt-list-filesystems.pl:30
26 #: ../tools/virt-tar.pl:31 ../tools/virt-make-fs.pl:35
27 #: ../tools/virt-list-partitions.pl:30
32 #: ../src/guestfs.pod:5
33 msgid "guestfs - Library for accessing and modifying virtual machine images"
35 "guestfs — бібліотека для доступу та внесення змін до образів віртуальних "
39 #: ../src/guestfs.pod:7 ../fish/guestfish.pod:7
40 #: ../test-tool/libguestfs-test-tool.pod:7 ../fuse/guestmount.pod:7
41 #: ../tools/virt-edit.pl:36 ../tools/virt-win-reg.pl:39
42 #: ../tools/virt-resize.pl:44 ../tools/virt-list-filesystems.pl:34
43 #: ../tools/virt-tar.pl:35 ../tools/virt-make-fs.pl:39
44 #: ../tools/virt-list-partitions.pl:34
46 msgstr "КОРОТКИЙ ОПИС"
49 #: ../src/guestfs.pod:9
52 " #include <guestfs.h>\n"
55 " #include <guestfs.h>\n"
59 #: ../src/guestfs.pod:11
62 " guestfs_h *g = guestfs_create ();\n"
63 " guestfs_add_drive (g, \"guest.img\");\n"
64 " guestfs_launch (g);\n"
65 " guestfs_mount (g, \"/dev/sda1\", \"/\");\n"
66 " guestfs_touch (g, \"/hello\");\n"
67 " guestfs_umount (g, \"/\");\n"
68 " guestfs_close (g);\n"
71 " guestfs_h *g = guestfs_create ();\n"
72 " guestfs_add_drive (g, \"guest.img\");\n"
73 " guestfs_launch (g);\n"
74 " guestfs_mount (g, \"/dev/sda1\", \"/\");\n"
75 " guestfs_touch (g, \"/hello\");\n"
76 " guestfs_umount (g, \"/\");\n"
77 " guestfs_close (g);\n"
81 #: ../src/guestfs.pod:19
84 " cc prog.c -o prog -lguestfs\n"
86 " cc prog.c -o prog `pkg-config libguestfs --cflags --libs`\n"
89 " cc prog.c -o prog -lguestfs\n"
91 " cc prog.c -o prog `pkg-config libguestfs --cflags --libs`\n"
95 #: ../src/guestfs.pod:23 ../fish/guestfish.pod:30
96 #: ../test-tool/libguestfs-test-tool.pod:11 ../fuse/guestmount.pod:20
97 #: ../tools/virt-edit.pl:50 ../tools/virt-win-reg.pl:63
98 #: ../tools/virt-resize.pl:50 ../tools/virt-list-filesystems.pl:40
99 #: ../tools/virt-tar.pl:77 ../tools/virt-make-fs.pl:47
100 #: ../tools/virt-list-partitions.pl:40
105 #: ../src/guestfs.pod:25
107 "Libguestfs is a library for accessing and modifying guest disk images. "
108 "Amongst the things this is good for: making batch configuration changes to "
109 "guests, getting disk used/free statistics (see also: virt-df), migrating "
110 "between virtualization systems (see also: virt-p2v), performing partial "
111 "backups, performing partial guest clones, cloning guests and changing "
112 "registry/UUID/hostname info, and much else besides."
116 #: ../src/guestfs.pod:33
118 "Libguestfs uses Linux kernel and qemu code, and can access any type of guest "
119 "filesystem that Linux and qemu can, including but not limited to: ext2/3/4, "
120 "btrfs, FAT and NTFS, LVM, many different disk partition schemes, qcow, "
125 #: ../src/guestfs.pod:38
127 "Libguestfs provides ways to enumerate guest storage (eg. partitions, LVs, "
128 "what filesystem is in each LV, etc.). It can also run commands in the "
129 "context of the guest. Also you can access filesystems over FUSE."
133 #: ../src/guestfs.pod:43
135 "Libguestfs is a library that can be linked with C and C++ management "
136 "programs (or management programs written in OCaml, Perl, Python, Ruby, Java, "
137 "PHP, Haskell or C#). You can also use it from shell scripts or the command "
142 #: ../src/guestfs.pod:48
144 "You don't need to be root to use libguestfs, although obviously you do need "
145 "enough permissions to access the disk images."
149 #: ../src/guestfs.pod:51
151 "Libguestfs is a large API because it can do many things. For a gentle "
152 "introduction, please read the L</API OVERVIEW> section next."
156 #: ../src/guestfs.pod:54
158 "There are also some example programs in the L<guestfs-examples(3)> manual "
163 #: ../src/guestfs.pod:57
168 #: ../src/guestfs.pod:59
170 "This section provides a gentler overview of the libguestfs API. We also try "
171 "to group API calls together, where that may not be obvious from reading "
172 "about the individual calls in the main section of this manual."
176 #: ../src/guestfs.pod:64
181 #: ../src/guestfs.pod:66
183 "Before you can use libguestfs calls, you have to create a handle. Then you "
184 "must add at least one disk image to the handle, followed by launching the "
185 "handle, then performing whatever operations you want, and finally closing "
186 "the handle. By convention we use the single letter C<g> for the name of the "
187 "handle variable, although of course you can use any name you want."
191 #: ../src/guestfs.pod:73
192 msgid "The general structure of all libguestfs-using programs looks like this:"
196 #: ../src/guestfs.pod:76
199 " guestfs_h *g = guestfs_create ();\n"
202 " guestfs_h *g = guestfs_create ();\n"
206 #: ../src/guestfs.pod:78
209 " /* Call guestfs_add_drive additional times if there are\n"
210 " * multiple disk images.\n"
212 " guestfs_add_drive (g, \"guest.img\");\n"
217 #: ../src/guestfs.pod:83
220 " /* Most manipulation calls won't work until you've launched\n"
221 " * the handle 'g'. You have to do this _after_ adding drives\n"
222 " * and _before_ other commands.\n"
224 " guestfs_launch (g);\n"
229 #: ../src/guestfs.pod:89
232 " /* Now you can examine what partitions, LVs etc are available.\n"
234 " char **partitions = guestfs_list_partitions (g);\n"
235 " char **logvols = guestfs_lvs (g);\n"
240 #: ../src/guestfs.pod:94
243 " /* To access a filesystem in the image, you must mount it.\n"
245 " guestfs_mount (g, \"/dev/sda1\", \"/\");\n"
248 " /* Щоб отримати доступ до файлової системи на образі, вам слід його змонтувати.\n"
250 " guestfs_mount (g, \"/dev/sda1\", \"/\");\n"
254 #: ../src/guestfs.pod:98
257 #| " /* Now you can perform filesystem actions on the guest\n"
258 #| " * disk image.\n"
260 #| " guestfs_touch (g, \"/hello\");\n"
263 " /* Now you can perform filesystem actions on the guest\n"
266 " guestfs_touch (g, \"/hello\");\n"
269 " /* Тепер ви можете виконувати дії з файловою системою на\n"
270 " * образі диска операційної системи.\n"
272 " guestfs_touch (g, \"/hello\");\n"
276 #: ../src/guestfs.pod:103
279 " /* This is only needed for libguestfs < 1.5.24. Since then\n"
280 " * it is done automatically when you close the handle. See\n"
281 " * discussion of autosync in this page.\n"
283 " guestfs_sync (g);\n"
288 #: ../src/guestfs.pod:109
291 " /* Close the handle 'g'. */\n"
292 " guestfs_close (g);\n"
297 #: ../src/guestfs.pod:112
299 "The code above doesn't include any error checking. In real code you should "
300 "check return values carefully for errors. In general all functions that "
301 "return integers return C<-1> on error, and all functions that return "
302 "pointers return C<NULL> on error. See section L</ERROR HANDLING> below for "
303 "how to handle errors, and consult the documentation for each function call "
304 "below to see precisely how they return error indications. See L<guestfs-"
305 "examples(3)> for fully worked examples."
309 #: ../src/guestfs.pod:121
314 #: ../src/guestfs.pod:123
316 "The image filename (C<\"guest.img\"> in the example above) could be a disk "
317 "image from a virtual machine, a L<dd(1)> copy of a physical hard disk, an "
318 "actual block device, or simply an empty file of zeroes that you have created "
319 "through L<posix_fallocate(3)>. Libguestfs lets you do useful things to all "
324 #: ../src/guestfs.pod:129
326 "The call you should use in modern code for adding drives is L</"
327 "guestfs_add_drive_opts>. To add a disk image, allowing writes, and "
328 "specifying that the format is raw, do:"
332 #: ../src/guestfs.pod:133
335 " guestfs_add_drive_opts (g, filename,\n"
336 " GUESTFS_ADD_DRIVE_OPTS_FORMAT, \"raw\",\n"
342 #: ../src/guestfs.pod:137
343 msgid "You can add a disk read-only using:"
347 #: ../src/guestfs.pod:139
350 " guestfs_add_drive_opts (g, filename,\n"
351 " GUESTFS_ADD_DRIVE_OPTS_FORMAT, \"raw\",\n"
352 " GUESTFS_ADD_DRIVE_OPTS_READONLY, 1,\n"
358 #: ../src/guestfs.pod:144
360 "or by calling the older function L</guestfs_add_drive_ro>. In either case "
361 "libguestfs won't modify the file."
365 #: ../src/guestfs.pod:147
367 "Be extremely cautious if the disk image is in use, eg. if it is being used "
368 "by a virtual machine. Adding it read-write will almost certainly cause disk "
369 "corruption, but adding it read-only is safe."
373 #: ../src/guestfs.pod:151
375 "You must add at least one disk image, and you may add multiple disk images. "
376 "In the API, the disk images are usually referred to as C</dev/sda> (for the "
377 "first one you added), C</dev/sdb> (for the second one you added), etc."
381 #: ../src/guestfs.pod:156
383 "Once L</guestfs_launch> has been called you cannot add any more images. You "
384 "can call L</guestfs_list_devices> to get a list of the device names, in the "
385 "order that you added them. See also L</BLOCK DEVICE NAMING> below."
389 #: ../src/guestfs.pod:161
394 #: ../src/guestfs.pod:163
396 "Before you can read or write files, create directories and so on in a disk "
397 "image that contains filesystems, you have to mount those filesystems using "
398 "L</guestfs_mount_options> or L</guestfs_mount_ro>. If you already know that "
399 "a disk image contains (for example) one partition with a filesystem on that "
400 "partition, then you can mount it directly:"
404 #: ../src/guestfs.pod:170
407 " guestfs_mount_options (g, \"\", \"/dev/sda1\", \"/\");\n"
412 #: ../src/guestfs.pod:172
414 "where C</dev/sda1> means literally the first partition (C<1>) of the first "
415 "disk image that we added (C</dev/sda>). If the disk contains Linux LVM2 "
416 "logical volumes you could refer to those instead (eg. C</dev/VG/LV>). Note "
417 "that these are libguestfs virtual devices, and are nothing to do with host "
422 #: ../src/guestfs.pod:178
424 "If you are given a disk image and you don't know what it contains then you "
425 "have to find out. Libguestfs can do that too: use L</"
426 "guestfs_list_partitions> and L</guestfs_lvs> to list possible partitions and "
427 "LVs, and either try mounting each to see what is mountable, or else examine "
428 "them with L</guestfs_vfs_type> or L</guestfs_file>. To list just "
429 "filesystems, use L</guestfs_list_filesystems>."
433 #: ../src/guestfs.pod:186
435 "Libguestfs also has a set of APIs for inspection of unknown disk images (see "
436 "L</INSPECTION> below). But you might find it easier to look at higher level "
437 "programs built on top of libguestfs, in particular L<virt-inspector(1)>."
441 #: ../src/guestfs.pod:191
443 "To mount a filesystem read-only, use L</guestfs_mount_ro>. There are "
444 "several other variations of the C<guestfs_mount_*> call."
448 #: ../src/guestfs.pod:194
449 msgid "FILESYSTEM ACCESS AND MODIFICATION"
453 #: ../src/guestfs.pod:196
455 "The majority of the libguestfs API consists of fairly low-level calls for "
456 "accessing and modifying the files, directories, symlinks etc on mounted "
457 "filesystems. There are over a hundred such calls which you can find listed "
458 "in detail below in this man page, and we don't even pretend to cover them "
459 "all in this overview."
463 #: ../src/guestfs.pod:202
465 "Specify filenames as full paths, starting with C<\"/\"> and including the "
470 #: ../src/guestfs.pod:205
472 "For example, if you mounted a filesystem at C<\"/\"> and you want to read "
473 "the file called C<\"etc/passwd\"> then you could do:"
477 #: ../src/guestfs.pod:208
480 " char *data = guestfs_cat (g, \"/etc/passwd\");\n"
485 #: ../src/guestfs.pod:210
487 "This would return C<data> as a newly allocated buffer containing the full "
488 "content of that file (with some conditions: see also L</DOWNLOADING> below), "
489 "or C<NULL> if there was an error."
493 #: ../src/guestfs.pod:214
495 "As another example, to create a top-level directory on that filesystem "
496 "called C<\"var\"> you would do:"
500 #: ../src/guestfs.pod:217
503 " guestfs_mkdir (g, \"/var\");\n"
508 #: ../src/guestfs.pod:219
509 msgid "To create a symlink you could do:"
513 #: ../src/guestfs.pod:221
516 " guestfs_ln_s (g, \"/etc/init.d/portmap\",\n"
517 " \"/etc/rc3.d/S30portmap\");\n"
522 #: ../src/guestfs.pod:224
524 "Libguestfs will reject attempts to use relative paths and there is no "
525 "concept of a current working directory."
529 #: ../src/guestfs.pod:227
531 "Libguestfs can return errors in many situations: for example if the "
532 "filesystem isn't writable, or if a file or directory that you requested "
533 "doesn't exist. If you are using the C API (documented here) you have to "
534 "check for those error conditions after each call. (Other language bindings "
535 "turn these errors into exceptions)."
539 #: ../src/guestfs.pod:233
541 "File writes are affected by the per-handle umask, set by calling L</"
542 "guestfs_umask> and defaulting to 022. See L</UMASK>."
546 #: ../src/guestfs.pod:236
548 msgstr "ПОДІЛ НА РОЗДІЛИ"
551 #: ../src/guestfs.pod:238
553 "Libguestfs contains API calls to read, create and modify partition tables on "
558 #: ../src/guestfs.pod:241
560 "In the common case where you want to create a single partition covering the "
561 "whole disk, you should use the L</guestfs_part_disk> call:"
565 #: ../src/guestfs.pod:245
568 " const char *parttype = \"mbr\";\n"
569 " if (disk_is_larger_than_2TB)\n"
570 " parttype = \"gpt\";\n"
571 " guestfs_part_disk (g, \"/dev/sda\", parttype);\n"
576 #: ../src/guestfs.pod:250
578 "Obviously this effectively wipes anything that was on that disk image before."
582 #: ../src/guestfs.pod:253
587 #: ../src/guestfs.pod:255
589 "Libguestfs provides access to a large part of the LVM2 API, such as L</"
590 "guestfs_lvcreate> and L</guestfs_vgremove>. It won't make much sense unless "
591 "you familiarize yourself with the concepts of physical volumes, volume "
592 "groups and logical volumes."
596 #: ../src/guestfs.pod:260
598 "This author strongly recommends reading the LVM HOWTO, online at L<http://"
599 "tldp.org/HOWTO/LVM-HOWTO/>."
603 #: ../src/guestfs.pod:263
608 #: ../src/guestfs.pod:265
610 "Use L</guestfs_cat> to download small, text only files. This call is "
611 "limited to files which are less than 2 MB and which cannot contain any ASCII "
612 "NUL (C<\\0>) characters. However the API is very simple to use."
616 #: ../src/guestfs.pod:269
618 "L</guestfs_read_file> can be used to read files which contain arbitrary 8 "
619 "bit data, since it returns a (pointer, size) pair. However it is still "
620 "limited to \"small\" files, less than 2 MB."
624 #: ../src/guestfs.pod:273
626 "L</guestfs_download> can be used to download any file, with no limits on "
627 "content or size (even files larger than 4 GB)."
631 #: ../src/guestfs.pod:276
633 "To download multiple files, see L</guestfs_tar_out> and L</guestfs_tgz_out>."
637 #: ../src/guestfs.pod:279
639 msgstr "ВИВАНТАЖЕННЯ"
642 #: ../src/guestfs.pod:281
644 "It's often the case that you want to write a file or files to the disk image."
648 #: ../src/guestfs.pod:284
650 "To write a small file with fixed content, use L</guestfs_write>. To create "
651 "a file of all zeroes, use L</guestfs_truncate_size> (sparse) or L</"
652 "guestfs_fallocate64> (with all disk blocks allocated). There are a variety "
653 "of other functions for creating test files, for example L</guestfs_fill> and "
654 "L</guestfs_fill_pattern>."
658 #: ../src/guestfs.pod:290
660 "To upload a single file, use L</guestfs_upload>. This call has no limits on "
661 "file content or size (even files larger than 4 GB)."
665 #: ../src/guestfs.pod:293
667 "To upload multiple files, see L</guestfs_tar_in> and L</guestfs_tgz_in>."
671 #: ../src/guestfs.pod:295
673 "However the fastest way to upload I<large numbers of arbitrary files> is to "
674 "turn them into a squashfs or CD ISO (see L<mksquashfs(8)> and L<mkisofs(8)"
675 ">), then attach this using L</guestfs_add_drive_ro>. If you add the drive "
676 "in a predictable way (eg. adding it last after all other drives) then you "
677 "can get the device name from L</guestfs_list_devices> and mount it directly "
678 "using L</guestfs_mount_ro>. Note that squashfs images are sometimes non-"
679 "portable between kernel versions, and they don't support labels or UUIDs. "
680 "If you want to pre-build an image or you need to mount it using a label or "
681 "UUID, use an ISO image instead."
685 #: ../src/guestfs.pod:306
690 #: ../src/guestfs.pod:308
692 "There are various different commands for copying between files and devices "
693 "and in and out of the guest filesystem. These are summarised in the table "
698 #: ../src/guestfs.pod:314
699 msgid "B<file> to B<file>"
703 #: ../src/guestfs.pod:316
705 "Use L</guestfs_cp> to copy a single file, or L</guestfs_cp_a> to copy "
706 "directories recursively."
710 #: ../src/guestfs.pod:319
711 msgid "B<file or device> to B<file or device>"
715 #: ../src/guestfs.pod:321
717 "Use L</guestfs_dd> which efficiently uses L<dd(1)> to copy between files and "
718 "devices in the guest."
722 #: ../src/guestfs.pod:324
723 msgid "Example: duplicate the contents of an LV:"
727 #: ../src/guestfs.pod:326
730 " guestfs_dd (g, \"/dev/VG/Original\", \"/dev/VG/Copy\");\n"
735 #: ../src/guestfs.pod:328
737 "The destination (C</dev/VG/Copy>) must be at least as large as the source "
738 "(C</dev/VG/Original>). To copy less than the whole source device, use L</"
739 "guestfs_copy_size>."
743 #: ../src/guestfs.pod:332
744 msgid "B<file on the host> to B<file or device>"
748 #: ../src/guestfs.pod:334
749 msgid "Use L</guestfs_upload>. See L</UPLOADING> above."
753 #: ../src/guestfs.pod:336
754 msgid "B<file or device> to B<file on the host>"
758 #: ../src/guestfs.pod:338
759 msgid "Use L</guestfs_download>. See L</DOWNLOADING> above."
763 #: ../src/guestfs.pod:342
764 msgid "UPLOADING AND DOWNLOADING TO PIPES AND FILE DESCRIPTORS"
768 #: ../src/guestfs.pod:344
770 "Calls like L</guestfs_upload>, L</guestfs_download>, L</guestfs_tar_in>, L</"
771 "guestfs_tar_out> etc appear to only take filenames as arguments, so it "
772 "appears you can only upload and download to files. However many Un*x-like "
773 "hosts let you use the special device files C</dev/stdin>, C</dev/stdout>, C</"
774 "dev/stderr> and C</dev/fd/N> to read and write from stdin, stdout, stderr, "
775 "and arbitrary file descriptor N."
779 #: ../src/guestfs.pod:352
780 msgid "For example, L<virt-cat(1)> writes its output to stdout by doing:"
784 #: ../src/guestfs.pod:355
787 " guestfs_download (g, filename, \"/dev/stdout\");\n"
792 #: ../src/guestfs.pod:357
793 msgid "and you can write tar output to a pipe C<fd> by doing:"
797 #: ../src/guestfs.pod:359
801 " snprintf (devfd, sizeof devfd, \"/dev/fd/%d\", fd);\n"
802 " guestfs_tar_out (g, \"/\", devfd);\n"
807 #: ../src/guestfs.pod:363
808 msgid "LISTING FILES"
812 #: ../src/guestfs.pod:365
814 "L</guestfs_ll> is just designed for humans to read (mainly when using the "
815 "L<guestfish(1)>-equivalent command C<ll>)."
819 #: ../src/guestfs.pod:368
821 "L</guestfs_ls> is a quick way to get a list of files in a directory from "
822 "programs, as a flat list of strings."
826 #: ../src/guestfs.pod:371
828 "L</guestfs_readdir> is a programmatic way to get a list of files in a "
829 "directory, plus additional information about each one. It is more "
830 "equivalent to using the L<readdir(3)> call on a local filesystem."
834 #: ../src/guestfs.pod:375
836 "L</guestfs_find> and L</guestfs_find0> can be used to recursively list files."
840 #: ../src/guestfs.pod:378
841 msgid "RUNNING COMMANDS"
845 #: ../src/guestfs.pod:380
847 "Although libguestfs is primarily an API for manipulating files inside guest "
848 "images, we also provide some limited facilities for running commands inside "
853 #: ../src/guestfs.pod:384
854 msgid "There are many limitations to this:"
858 #: ../src/guestfs.pod:388 ../src/guestfs.pod:393 ../src/guestfs.pod:398
859 #: ../src/guestfs.pod:402 ../src/guestfs.pod:407 ../src/guestfs.pod:411
860 #: ../src/guestfs.pod:416 ../src/guestfs.pod:421 ../src/guestfs.pod:1088
861 #: ../src/guestfs.pod:1092 ../src/guestfs.pod:1096 ../src/guestfs.pod:1101
862 #: ../src/guestfs.pod:1109 ../src/guestfs.pod:1128 ../src/guestfs.pod:1136
863 #: ../src/guestfs.pod:1158 ../src/guestfs.pod:1162 ../src/guestfs.pod:1166
864 #: ../src/guestfs.pod:1170 ../src/guestfs.pod:1174 ../src/guestfs.pod:1178
865 #: ../src/guestfs.pod:1660 ../src/guestfs.pod:1665 ../src/guestfs.pod:1669
866 #: ../src/guestfs.pod:1770 ../src/guestfs.pod:1775 ../src/guestfs.pod:1779
867 #: ../src/guestfs.pod:1789 ../src/guestfs.pod:2023 ../src/guestfs.pod:2028
868 #: ../src/guestfs.pod:2034 ../src/guestfs.pod:2042 ../src/guestfs.pod:2396
869 #: ../src/guestfs.pod:2402 ../src/guestfs.pod:2407 ../src/guestfs.pod:2413
870 #: ../src/guestfs.pod:2878 ../src/guestfs.pod:2882 ../src/guestfs.pod:2886
871 #: ../src/guestfs.pod:2890 ../src/guestfs-actions.pod:15
872 #: ../src/guestfs-actions.pod:22 ../src/guestfs-actions.pod:577
873 #: ../src/guestfs-actions.pod:585 ../src/guestfs-actions.pod:592
874 #: ../src/guestfs-actions.pod:599 ../src/guestfs-actions.pod:1600
875 #: ../src/guestfs-actions.pod:1604 ../src/guestfs-actions.pod:1608
876 #: ../src/guestfs-actions.pod:1612 ../src/guestfs-actions.pod:1620
877 #: ../src/guestfs-actions.pod:1624 ../src/guestfs-actions.pod:1628
878 #: ../src/guestfs-actions.pod:1638 ../src/guestfs-actions.pod:1642
879 #: ../src/guestfs-actions.pod:1646 ../src/guestfs-actions.pod:1784
880 #: ../src/guestfs-actions.pod:1788 ../src/guestfs-actions.pod:1793
881 #: ../src/guestfs-actions.pod:1798 ../src/guestfs-actions.pod:1859
882 #: ../src/guestfs-actions.pod:1863 ../src/guestfs-actions.pod:1868
883 #: ../fish/guestfish.pod:443 ../fish/guestfish.pod:447
884 #: ../fish/guestfish.pod:451 ../fish/guestfish.pod:455
885 #: ../fish/guestfish-actions.pod:13 ../fish/guestfish-actions.pod:20
886 #: ../fish/guestfish-actions.pod:380 ../fish/guestfish-actions.pod:388
887 #: ../fish/guestfish-actions.pod:395 ../fish/guestfish-actions.pod:402
888 #: ../fish/guestfish-actions.pod:1072 ../fish/guestfish-actions.pod:1076
889 #: ../fish/guestfish-actions.pod:1080 ../fish/guestfish-actions.pod:1084
890 #: ../fish/guestfish-actions.pod:1092 ../fish/guestfish-actions.pod:1096
891 #: ../fish/guestfish-actions.pod:1100 ../fish/guestfish-actions.pod:1110
892 #: ../fish/guestfish-actions.pod:1114 ../fish/guestfish-actions.pod:1118
893 #: ../fish/guestfish-actions.pod:1208 ../fish/guestfish-actions.pod:1212
894 #: ../fish/guestfish-actions.pod:1217 ../fish/guestfish-actions.pod:1222
895 #: ../fish/guestfish-actions.pod:1264 ../fish/guestfish-actions.pod:1268
896 #: ../fish/guestfish-actions.pod:1273 ../tools/virt-win-reg.pl:536
897 #: ../tools/virt-win-reg.pl:542 ../tools/virt-win-reg.pl:548
898 #: ../tools/virt-resize.pl:345 ../tools/virt-resize.pl:350
899 #: ../tools/virt-resize.pl:360
904 #: ../src/guestfs.pod:390
906 "The kernel version that the command runs under will be different from what "
911 #: ../src/guestfs.pod:395
913 "If the command needs to communicate with daemons, then most likely they "
918 #: ../src/guestfs.pod:400
919 msgid "The command will be running in limited memory."
923 #: ../src/guestfs.pod:404
925 "The network may not be available unless you enable it (see L</"
926 "guestfs_set_network>)."
930 #: ../src/guestfs.pod:409
931 msgid "Only supports Linux guests (not Windows, BSD, etc)."
935 #: ../src/guestfs.pod:413
937 "Architecture limitations (eg. won't work for a PPC guest on an X86 host)."
941 #: ../src/guestfs.pod:418
943 "For SELinux guests, you may need to enable SELinux and load policy first. "
944 "See L</SELINUX> in this manpage."
948 #: ../src/guestfs.pod:423
950 "I<Security:> It is not safe to run commands from untrusted, possibly "
951 "malicious guests. These commands may attempt to exploit your program by "
952 "sending unexpected output. They could also try to exploit the Linux kernel "
953 "or qemu provided by the libguestfs appliance. They could use the network "
954 "provided by the libguestfs appliance to bypass ordinary network partitions "
955 "and firewalls. They could use the elevated privileges or different SELinux "
956 "context of your program to their advantage."
960 #: ../src/guestfs.pod:432
962 "A secure alternative is to use libguestfs to install a \"firstboot\" script "
963 "(a script which runs when the guest next boots normally), and to have this "
964 "script run the commands you want in the normal context of the running guest, "
965 "network security and so on. For information about other security issues, "
970 #: ../src/guestfs.pod:440
972 "The two main API calls to run commands are L</guestfs_command> and L</"
973 "guestfs_sh> (there are also variations)."
977 #: ../src/guestfs.pod:443
979 "The difference is that L</guestfs_sh> runs commands using the shell, so any "
980 "shell globs, redirections, etc will work."
984 #: ../src/guestfs.pod:446
985 msgid "CONFIGURATION FILES"
986 msgstr "ФАЙЛИ НАЛАШТУВАННЯ"
989 #: ../src/guestfs.pod:448
991 "To read and write configuration files in Linux guest filesystems, we "
992 "strongly recommend using Augeas. For example, Augeas understands how to "
993 "read and write, say, a Linux shadow password file or X.org configuration "
994 "file, and so avoids you having to write that code."
998 #: ../src/guestfs.pod:453
1000 "The main Augeas calls are bound through the C<guestfs_aug_*> APIs. We don't "
1001 "document Augeas itself here because there is excellent documentation on the "
1002 "L<http://augeas.net/> website."
1006 #: ../src/guestfs.pod:457
1008 "If you don't want to use Augeas (you fool!) then try calling L</"
1009 "guestfs_read_lines> to get the file as a list of lines which you can iterate "
1014 #: ../src/guestfs.pod:461
1019 #: ../src/guestfs.pod:463
1021 "We support SELinux guests. To ensure that labeling happens correctly in "
1022 "SELinux guests, you need to enable SELinux and load the guest's policy:"
1026 #: ../src/guestfs.pod:469 ../src/guestfs.pod:1281 ../src/guestfs.pod:1412
1027 #: ../src/guestfs.pod:2441
1032 #: ../src/guestfs.pod:471
1033 msgid "Before launching, do:"
1037 #: ../src/guestfs.pod:473
1040 " guestfs_set_selinux (g, 1);\n"
1045 #: ../src/guestfs.pod:475 ../src/guestfs.pod:1285 ../src/guestfs.pod:1416
1046 #: ../src/guestfs.pod:2466
1051 #: ../src/guestfs.pod:477
1053 "After mounting the guest's filesystem(s), load the policy. This is best "
1054 "done by running the L<load_policy(8)> command in the guest itself:"
1058 #: ../src/guestfs.pod:481
1061 " guestfs_sh (g, \"/usr/sbin/load_policy\");\n"
1066 #: ../src/guestfs.pod:483
1068 "(Older versions of C<load_policy> require you to specify the name of the "
1073 #: ../src/guestfs.pod:486 ../src/guestfs.pod:1422
1078 #: ../src/guestfs.pod:488
1080 "Optionally, set the security context for the API. The correct security "
1081 "context to use can only be known by inspecting the guest. As an example:"
1085 #: ../src/guestfs.pod:492
1088 " guestfs_setcon (g, \"unconfined_u:unconfined_r:unconfined_t:s0\");\n"
1093 #: ../src/guestfs.pod:496
1094 msgid "This will work for running commands and editing existing files."
1098 #: ../src/guestfs.pod:498
1100 "When new files are created, you may need to label them explicitly, for "
1101 "example by running the external command C<restorecon pathname>."
1105 #: ../src/guestfs.pod:502
1110 #: ../src/guestfs.pod:504
1112 "Certain calls are affected by the current file mode creation mask (the "
1113 "\"umask\"). In particular ones which create files or directories, such as "
1114 "L</guestfs_touch>, L</guestfs_mknod> or L</guestfs_mkdir>. This affects "
1115 "either the default mode that the file is created with or modifies the mode "
1120 #: ../src/guestfs.pod:510
1122 "The default umask is C<022>, so files are created with modes such as C<0644> "
1123 "and directories with C<0755>."
1127 #: ../src/guestfs.pod:513
1129 "There are two ways to avoid being affected by umask. Either set umask to 0 "
1130 "(call C<guestfs_umask (g, 0)> early after launching). Or call L</"
1131 "guestfs_chmod> after creating each file or directory."
1135 #: ../src/guestfs.pod:517
1136 msgid "For more information about umask, see L<umask(2)>."
1140 #: ../src/guestfs.pod:519 ../fish/guestfish.pod:765
1141 msgid "ENCRYPTED DISKS"
1145 #: ../src/guestfs.pod:521
1147 "Libguestfs allows you to access Linux guests which have been encrypted using "
1148 "whole disk encryption that conforms to the Linux Unified Key Setup (LUKS) "
1149 "standard. This includes nearly all whole disk encryption systems used by "
1150 "modern Linux guests."
1154 #: ../src/guestfs.pod:527
1156 "Use L</guestfs_vfs_type> to identify LUKS-encrypted block devices (it "
1157 "returns the string C<crypto_LUKS>)."
1161 #: ../src/guestfs.pod:530
1163 "Then open these devices by calling L</guestfs_luks_open>. Obviously you "
1164 "will require the passphrase!"
1168 #: ../src/guestfs.pod:533
1170 "Opening a LUKS device creates a new device mapper device called C</dev/"
1171 "mapper/mapname> (where C<mapname> is the string you supply to L</"
1172 "guestfs_luks_open>). Reads and writes to this mapper device are decrypted "
1173 "from and encrypted to the underlying block device respectively."
1177 #: ../src/guestfs.pod:539
1179 "LVM volume groups on the device can be made visible by calling L</"
1180 "guestfs_vgscan> followed by L</guestfs_vg_activate_all>. The logical volume"
1181 "(s) can now be mounted in the usual way."
1185 #: ../src/guestfs.pod:543
1187 "Use the reverse process to close a LUKS device. Unmount any logical volumes "
1188 "on it, deactivate the volume groups by caling C<guestfs_vg_activate (g, 0, "
1189 "[\"/dev/VG\"])>. Then close the mapper device by calling L</"
1190 "guestfs_luks_close> on the C</dev/mapper/mapname> device (I<not> the "
1191 "underlying encrypted block device)."
1195 #: ../src/guestfs.pod:550
1200 #: ../src/guestfs.pod:552
1202 "Libguestfs has APIs for inspecting an unknown disk image to find out if it "
1203 "contains operating systems, an install CD or a live CD. (These APIs used to "
1204 "be in a separate Perl-only library called L<Sys::Guestfs::Lib(3)> but since "
1205 "version 1.5.3 the most frequently used part of this library has been "
1206 "rewritten in C and moved into the core code)."
1210 #: ../src/guestfs.pod:559
1212 "Add all disks belonging to the unknown virtual machine and call L</"
1213 "guestfs_launch> in the usual way."
1217 #: ../src/guestfs.pod:562
1219 "Then call L</guestfs_inspect_os>. This function uses other libguestfs calls "
1220 "and certain heuristics, and returns a list of operating systems that were "
1221 "found. An empty list means none were found. A single element is the root "
1222 "filesystem of the operating system. For dual- or multi-boot guests, "
1223 "multiple roots can be returned, each one corresponding to a separate "
1224 "operating system. (Multi-boot virtual machines are extremely rare in the "
1225 "world of virtualization, but since this scenario can happen, we have built "
1226 "libguestfs to deal with it.)"
1230 #: ../src/guestfs.pod:571
1232 "For each root, you can then call various C<guestfs_inspect_get_*> functions "
1233 "to get additional details about that operating system. For example, call L</"
1234 "guestfs_inspect_get_type> to return the string C<windows> or C<linux> for "
1235 "Windows and Linux-based operating systems respectively."
1239 #: ../src/guestfs.pod:577
1241 "Un*x-like and Linux-based operating systems usually consist of several "
1242 "filesystems which are mounted at boot time (for example, a separate boot "
1243 "partition mounted on C</boot>). The inspection rules are able to detect how "
1244 "filesystems correspond to mount points. Call "
1245 "C<guestfs_inspect_get_mountpoints> to get this mapping. It might return a "
1246 "hash table like this example:"
1250 #: ../src/guestfs.pod:584
1253 " /boot => /dev/sda1\n"
1254 " / => /dev/vg_guest/lv_root\n"
1255 " /usr => /dev/vg_guest/lv_usr\n"
1260 #: ../src/guestfs.pod:588
1262 "The caller can then make calls to L</guestfs_mount_options> to mount the "
1263 "filesystems as suggested."
1267 #: ../src/guestfs.pod:591
1269 "Be careful to mount filesystems in the right order (eg. C</> before C</"
1270 "usr>). Sorting the keys of the hash by length, shortest first, should work."
1274 #: ../src/guestfs.pod:595
1276 "Inspection currently only works for some common operating systems. "
1277 "Contributors are welcome to send patches for other operating systems that we "
1278 "currently cannot detect."
1282 #: ../src/guestfs.pod:599
1284 "Encrypted disks must be opened before inspection. See L</ENCRYPTED DISKS> "
1285 "for more details. The L</guestfs_inspect_os> function just ignores any "
1286 "encrypted devices."
1290 #: ../src/guestfs.pod:603
1292 "A note on the implementation: The call L</guestfs_inspect_os> performs "
1293 "inspection and caches the results in the guest handle. Subsequent calls to "
1294 "C<guestfs_inspect_get_*> return this cached information, but I<do not> re-"
1295 "read the disks. If you change the content of the guest disks, you can redo "
1296 "inspection by calling L</guestfs_inspect_os> again. (L</"
1297 "guestfs_inspect_list_applications> works a little differently from the other "
1298 "calls and does read the disks. See documentation for that function for "
1303 #: ../src/guestfs.pod:612
1304 msgid "INSPECTING INSTALL DISKS"
1308 #: ../src/guestfs.pod:614
1310 "Libguestfs (since 1.9.4) can detect some install disks, install CDs, live "
1315 #: ../src/guestfs.pod:617
1317 "Call L</guestfs_inspect_get_format> to return the format of the operating "
1318 "system, which currently can be C<installed> (a regular operating system) or "
1319 "C<installer> (some sort of install disk)."
1323 #: ../src/guestfs.pod:621
1325 "Further information is available about the operating system that can be "
1326 "installed using the regular inspection APIs like L</"
1327 "guestfs_inspect_get_product_name>, L</guestfs_inspect_get_major_version> etc."
1331 #: ../src/guestfs.pod:626
1333 "Some additional information specific to installer disks is also available "
1334 "from the L</guestfs_inspect_is_live>, L</guestfs_inspect_is_netinst> and L</"
1335 "guestfs_inspect_is_multipart> calls."
1339 #: ../src/guestfs.pod:631
1340 msgid "SPECIAL CONSIDERATIONS FOR WINDOWS GUESTS"
1344 #: ../src/guestfs.pod:633
1346 "Libguestfs can mount NTFS partitions. It does this using the L<http://www."
1347 "ntfs-3g.org/> driver."
1351 #: ../src/guestfs.pod:636
1352 msgid "DRIVE LETTERS AND PATHS"
1356 #: ../src/guestfs.pod:638
1358 "DOS and Windows still use drive letters, and the filesystems are always "
1359 "treated as case insensitive by Windows itself, and therefore you might find "
1360 "a Windows configuration file referring to a path like C<c:\\windows"
1361 "\\system32>. When the filesystem is mounted in libguestfs, that directory "
1362 "might be referred to as C</WINDOWS/System32>."
1366 #: ../src/guestfs.pod:644
1368 "Drive letter mappings are outside the scope of libguestfs. You have to use "
1369 "libguestfs to read the appropriate Windows Registry and configuration files, "
1370 "to determine yourself how drives are mapped (see also L<hivex(3)> and L<virt-"
1375 #: ../src/guestfs.pod:649
1377 "Replacing backslash characters with forward slash characters is also outside "
1378 "the scope of libguestfs, but something that you can easily do."
1382 #: ../src/guestfs.pod:652
1384 "Where we can help is in resolving the case insensitivity of paths. For "
1385 "this, call L</guestfs_case_sensitive_path>."
1389 #: ../src/guestfs.pod:655
1390 msgid "ACCESSING THE WINDOWS REGISTRY"
1394 #: ../src/guestfs.pod:657
1396 "Libguestfs also provides some help for decoding Windows Registry \"hive\" "
1397 "files, through the library C<hivex> which is part of the libguestfs project "
1398 "although ships as a separate tarball. You have to locate and download the "
1399 "hive file(s) yourself, and then pass them to C<hivex> functions. See also "
1400 "the programs L<hivexml(1)>, L<hivexsh(1)>, L<hivexregedit(1)> and L<virt-win-"
1401 "reg(1)> for more help on this issue."
1405 #: ../src/guestfs.pod:665
1406 msgid "SYMLINKS ON NTFS-3G FILESYSTEMS"
1410 #: ../src/guestfs.pod:667
1412 "Ntfs-3g tries to rewrite \"Junction Points\" and NTFS \"symbolic links\" to "
1413 "provide something which looks like a Linux symlink. The way it tries to do "
1414 "the rewriting is described here:"
1418 #: ../src/guestfs.pod:671
1420 "L<http://www.tuxera.com/community/ntfs-3g-advanced/junction-points-and-"
1423 "L<http://www.tuxera.com/community/ntfs-3g-advanced/junction-points-and-"
1427 #: ../src/guestfs.pod:673
1429 "The essential problem is that ntfs-3g simply does not have enough "
1430 "information to do a correct job. NTFS links can contain drive letters and "
1431 "references to external device GUIDs that ntfs-3g has no way of resolving. "
1432 "It is almost certainly the case that libguestfs callers should ignore what "
1433 "ntfs-3g does (ie. don't use L</guestfs_readlink> on NTFS volumes)."
1437 #: ../src/guestfs.pod:680
1439 "Instead if you encounter a symbolic link on an ntfs-3g filesystem, use L</"
1440 "guestfs_lgetxattr> to read the C<system.ntfs_reparse_data> extended "
1441 "attribute, and read the raw reparse data from that (you can find the format "
1442 "documented in various places around the web)."
1446 #: ../src/guestfs.pod:685
1447 msgid "EXTENDED ATTRIBUTES ON NTFS-3G FILESYSTEMS"
1451 #: ../src/guestfs.pod:687
1453 "There are other useful extended attributes that can be read from ntfs-3g "
1454 "filesystems (using L</guestfs_getxattr>). See:"
1458 #: ../src/guestfs.pod:690
1460 "L<http://www.tuxera.com/community/ntfs-3g-advanced/extended-attributes/>"
1462 "L<http://www.tuxera.com/community/ntfs-3g-advanced/extended-attributes/>"
1465 #: ../src/guestfs.pod:692
1466 msgid "USING LIBGUESTFS WITH OTHER PROGRAMMING LANGUAGES"
1470 #: ../src/guestfs.pod:694
1472 "Although we don't want to discourage you from using the C API, we will "
1473 "mention here that the same API is also available in other languages."
1477 #: ../src/guestfs.pod:697
1479 "The API is broadly identical in all supported languages. This means that "
1480 "the C call C<guestfs_add_drive_ro(g,file)> is C<$g-E<gt>add_drive_ro($file)> "
1481 "in Perl, C<g.add_drive_ro(file)> in Python, and C<g#add_drive_ro file> in "
1482 "OCaml. In other words, a straightforward, predictable isomorphism between "
1487 #: ../src/guestfs.pod:703
1489 "Error messages are automatically transformed into exceptions if the language "
1494 #: ../src/guestfs.pod:706
1496 "We don't try to \"object orientify\" parts of the API in OO languages, "
1497 "although contributors are welcome to write higher level APIs above what we "
1498 "provide in their favourite languages if they wish."
1502 #: ../src/guestfs.pod:712
1507 #: ../src/guestfs.pod:714
1509 "You can use the I<guestfs.h> header file from C++ programs. The C++ API is "
1510 "identical to the C API. C++ classes and exceptions are not used."
1514 #: ../src/guestfs.pod:718
1519 #: ../src/guestfs.pod:720
1521 "The C# bindings are highly experimental. Please read the warnings at the "
1522 "top of C<csharp/Libguestfs.cs>."
1526 #: ../src/guestfs.pod:723
1531 #: ../src/guestfs.pod:725
1533 "This is the only language binding that is working but incomplete. Only "
1534 "calls which return simple integers have been bound in Haskell, and we are "
1535 "looking for help to complete this binding."
1539 #: ../src/guestfs.pod:729
1544 #: ../src/guestfs.pod:731
1546 "Full documentation is contained in the Javadoc which is distributed with "
1551 #: ../src/guestfs.pod:734
1556 #: ../src/guestfs.pod:736
1557 msgid "See L<guestfs-ocaml(3)>."
1558 msgstr "Див. L<guestfs-ocaml(3)>."
1561 #: ../src/guestfs.pod:738
1566 #: ../src/guestfs.pod:740
1567 msgid "See L<guestfs-perl(3)> and L<Sys::Guestfs(3)>."
1568 msgstr "Див. L<guestfs-perl(3)> та L<Sys::Guestfs(3)>."
1571 #: ../src/guestfs.pod:742
1576 #: ../src/guestfs.pod:744
1578 "For documentation see C<README-PHP> supplied with libguestfs sources or in "
1579 "the php-libguestfs package for your distribution."
1583 #: ../src/guestfs.pod:747
1584 msgid "The PHP binding only works correctly on 64 bit machines."
1588 #: ../src/guestfs.pod:749
1593 #: ../src/guestfs.pod:751
1594 msgid "See L<guestfs-python(3)>."
1595 msgstr "Див. L<guestfs-python(3)>."
1598 #: ../src/guestfs.pod:753
1603 #: ../src/guestfs.pod:755
1604 msgid "See L<guestfs-ruby(3)>."
1605 msgstr "Див. L<guestfs-ruby(3)>."
1608 #: ../src/guestfs.pod:757
1609 msgid "B<shell scripts>"
1610 msgstr "B<скрипти оболонки>"
1613 #: ../src/guestfs.pod:759
1614 msgid "See L<guestfish(1)>."
1615 msgstr "Див. L<guestfish(1)>."
1618 #: ../src/guestfs.pod:763
1619 msgid "LIBGUESTFS GOTCHAS"
1623 #: ../src/guestfs.pod:765
1625 "L<http://en.wikipedia.org/wiki/Gotcha_(programming)>: \"A feature of a "
1626 "system [...] that works in the way it is documented but is counterintuitive "
1627 "and almost invites mistakes.\""
1631 #: ../src/guestfs.pod:769
1633 "Since we developed libguestfs and the associated tools, there are several "
1634 "things we would have designed differently, but are now stuck with for "
1635 "backwards compatibility or other reasons. If there is ever a libguestfs 2.0 "
1636 "release, you can expect these to change. Beware of them."
1640 #: ../src/guestfs.pod:777
1641 msgid "Autosync / forgetting to sync."
1645 #: ../src/guestfs.pod:779
1647 "When modifying a filesystem from C or another language, you B<must> unmount "
1648 "all filesystems and call L</guestfs_sync> explicitly before you close the "
1649 "libguestfs handle. You can also call:"
1653 #: ../src/guestfs.pod:783
1656 " guestfs_set_autosync (g, 1);\n"
1661 #: ../src/guestfs.pod:785
1663 "to have the unmount/sync done automatically for you when the handle 'g' is "
1664 "closed. (This feature is called \"autosync\", L</guestfs_set_autosync> q.v.)"
1668 #: ../src/guestfs.pod:789
1670 "If you forget to do this, then it is entirely possible that your changes "
1671 "won't be written out, or will be partially written, or (very rarely) that "
1672 "you'll get disk corruption."
1676 #: ../src/guestfs.pod:793
1678 "Note that in L<guestfish(3)> autosync is the default. So quick and dirty "
1679 "guestfish scripts that forget to sync will work just fine, which can make "
1680 "this very puzzling if you are trying to debug a problem."
1684 #: ../src/guestfs.pod:797
1686 "Update: Autosync is enabled by default for all API users starting from "
1687 "libguestfs 1.5.24."
1691 #: ../src/guestfs.pod:800
1692 msgid "Mount option C<-o sync> should not be the default."
1696 #: ../src/guestfs.pod:802
1698 "If you use L</guestfs_mount>, then C<-o sync,noatime> are added implicitly. "
1699 "However C<-o sync> does not add any reliability benefit, but does have a "
1700 "very large performance impact."
1704 #: ../src/guestfs.pod:806
1706 "The work around is to use L</guestfs_mount_options> and set the mount "
1707 "options that you actually want to use."
1711 #: ../src/guestfs.pod:809
1712 msgid "Read-only should be the default."
1716 #: ../src/guestfs.pod:811
1718 "In L<guestfish(3)>, I<--ro> should be the default, and you should have to "
1719 "specify I<--rw> if you want to make changes to the image."
1723 #: ../src/guestfs.pod:814
1724 msgid "This would reduce the potential to corrupt live VM images."
1728 #: ../src/guestfs.pod:816
1730 "Note that many filesystems change the disk when you just mount and unmount, "
1731 "even if you didn't perform any writes. You need to use L</"
1732 "guestfs_add_drive_ro> to guarantee that the disk is not changed."
1736 #: ../src/guestfs.pod:820
1737 msgid "guestfish command line is hard to use."
1741 #: ../src/guestfs.pod:822
1743 "C<guestfish disk.img> doesn't do what people expect (open C<disk.img> for "
1744 "examination). It tries to run a guestfish command C<disk.img> which doesn't "
1745 "exist, so it fails. In earlier versions of guestfish the error message was "
1746 "also unintuitive, but we have corrected this since. Like the Bourne shell, "
1747 "we should have used C<guestfish -c command> to run commands."
1751 #: ../src/guestfs.pod:829
1752 msgid "guestfish megabyte modifiers don't work right on all commands"
1756 #: ../src/guestfs.pod:831
1758 "In recent guestfish you can use C<1M> to mean 1 megabyte (and similarly for "
1759 "other modifiers). What guestfish actually does is to multiply the number "
1760 "part by the modifier part and pass the result to the C API. However this "
1761 "doesn't work for a few APIs which aren't expecting bytes, but are already "
1762 "expecting some other unit (eg. megabytes)."
1766 #: ../src/guestfs.pod:838
1767 msgid "The most common is L</guestfs_lvcreate>. The guestfish command:"
1771 #: ../src/guestfs.pod:840
1774 " lvcreate LV VG 100M\n"
1779 #: ../src/guestfs.pod:842
1781 "does not do what you might expect. Instead because L</guestfs_lvcreate> is "
1782 "already expecting megabytes, this tries to create a 100 I<terabyte> (100 "
1783 "megabytes * megabytes) logical volume. The error message you get from this "
1784 "is also a little obscure."
1788 #: ../src/guestfs.pod:847
1790 "This could be fixed in the generator by specially marking parameters and "
1791 "return values which take bytes or other units."
1795 #: ../src/guestfs.pod:850
1796 msgid "Ambiguity between devices and paths"
1800 #: ../src/guestfs.pod:852
1802 "There is a subtle ambiguity in the API between a device name (eg. C</dev/"
1803 "sdb2>) and a similar pathname. A file might just happen to be called "
1804 "C<sdb2> in the directory C</dev> (consider some non-Unix VM image)."
1808 #: ../src/guestfs.pod:857
1810 "In the current API we usually resolve this ambiguity by having two separate "
1811 "calls, for example L</guestfs_checksum> and L</guestfs_checksum_device>. "
1812 "Some API calls are ambiguous and (incorrectly) resolve the problem by "
1813 "detecting if the path supplied begins with C</dev/>."
1817 #: ../src/guestfs.pod:863
1819 "To avoid both the ambiguity and the need to duplicate some calls, we could "
1820 "make paths/devices into structured names. One way to do this would be to "
1821 "use a notation like grub (C<hd(0,0)>), although nobody really likes this "
1822 "aspect of grub. Another way would be to use a structured type, equivalent "
1823 "to this OCaml type:"
1827 #: ../src/guestfs.pod:869
1830 " type path = Path of string | Device of int | Partition of int * int\n"
1835 #: ../src/guestfs.pod:871
1836 msgid "which would allow you to pass arguments like:"
1840 #: ../src/guestfs.pod:873
1843 " Path \"/foo/bar\"\n"
1844 " Device 1 (* /dev/sdb, or perhaps /dev/sda *)\n"
1845 " Partition (1, 2) (* /dev/sdb2 (or is it /dev/sda2 or /dev/sdb3?) *)\n"
1846 " Path \"/dev/sdb2\" (* not a device *)\n"
1851 #: ../src/guestfs.pod:878
1853 "As you can see there are still problems to resolve even with this "
1854 "representation. Also consider how it might work in guestfish."
1858 #: ../src/guestfs.pod:883
1859 msgid "PROTOCOL LIMITS"
1863 #: ../src/guestfs.pod:885
1865 "Internally libguestfs uses a message-based protocol to pass API calls and "
1866 "their responses to and from a small \"appliance\" (see L</INTERNALS> for "
1867 "plenty more detail about this). The maximum message size used by the "
1868 "protocol is slightly less than 4 MB. For some API calls you may need to be "
1869 "aware of this limit. The API calls which may be affected are individually "
1870 "documented, with a link back to this section of the documentation."
1874 #: ../src/guestfs.pod:893
1876 "A simple call such as L</guestfs_cat> returns its result (the file data) in "
1877 "a simple string. Because this string is at some point internally encoded as "
1878 "a message, the maximum size that it can return is slightly under 4 MB. If "
1879 "the requested file is larger than this then you will get an error."
1883 #: ../src/guestfs.pod:899
1885 "In order to transfer large files into and out of the guest filesystem, you "
1886 "need to use particular calls that support this. The sections L</UPLOADING> "
1887 "and L</DOWNLOADING> document how to do this."
1891 #: ../src/guestfs.pod:903
1893 "You might also consider mounting the disk image using our FUSE filesystem "
1894 "support (L<guestmount(1)>)."
1898 #: ../src/guestfs.pod:906
1899 msgid "KEYS AND PASSPHRASES"
1903 #: ../src/guestfs.pod:908
1905 "Certain libguestfs calls take a parameter that contains sensitive key "
1906 "material, passed in as a C string."
1910 #: ../src/guestfs.pod:911
1912 "In the future we would hope to change the libguestfs implementation so that "
1913 "keys are L<mlock(2)>-ed into physical RAM, and thus can never end up in "
1914 "swap. However this is I<not> done at the moment, because of the complexity "
1915 "of such an implementation."
1919 #: ../src/guestfs.pod:916
1921 "Therefore you should be aware that any key parameter you pass to libguestfs "
1922 "might end up being written out to the swap partition. If this is a concern, "
1923 "scrub the swap partition or don't use libguestfs on encrypted devices."
1927 #: ../src/guestfs.pod:921
1928 msgid "MULTIPLE HANDLES AND MULTIPLE THREADS"
1932 #: ../src/guestfs.pod:923
1934 "All high-level libguestfs actions are synchronous. If you want to use "
1935 "libguestfs asynchronously then you must create a thread."
1939 #: ../src/guestfs.pod:926
1941 "Only use the handle from a single thread. Either use the handle exclusively "
1942 "from one thread, or provide your own mutex so that two threads cannot issue "
1943 "calls on the same handle at the same time."
1947 #: ../src/guestfs.pod:930
1949 "See the graphical program guestfs-browser for one possible architecture for "
1950 "multithreaded programs using libvirt and libguestfs."
1954 #: ../src/guestfs.pod:933
1959 #: ../src/guestfs.pod:935
1961 "Libguestfs needs a supermin appliance, which it finds by looking along an "
1966 #: ../src/guestfs.pod:938
1968 "By default it looks for these in the directory C<$libdir/guestfs> (eg. C</"
1969 "usr/local/lib/guestfs> or C</usr/lib64/guestfs>)."
1973 #: ../src/guestfs.pod:941
1975 "Use L</guestfs_set_path> or set the environment variable L</LIBGUESTFS_PATH> "
1976 "to change the directories that libguestfs will search in. The value is a "
1977 "colon-separated list of paths. The current directory is I<not> searched "
1978 "unless the path contains an empty element or C<.>. For example "
1979 "C<LIBGUESTFS_PATH=:/usr/lib/guestfs> would search the current directory and "
1980 "then C</usr/lib/guestfs>."
1984 #: ../src/guestfs.pod:948
1985 msgid "QEMU WRAPPERS"
1989 #: ../src/guestfs.pod:950
1991 "If you want to compile your own qemu, run qemu from a non-standard location, "
1992 "or pass extra arguments to qemu, then you can write a shell-script wrapper "
1997 #: ../src/guestfs.pod:954
1999 "There is one important rule to remember: you I<must C<exec qemu>> as the "
2000 "last command in the shell script (so that qemu replaces the shell and "
2001 "becomes the direct child of the libguestfs-using program). If you don't do "
2002 "this, then the qemu process won't be cleaned up correctly."
2006 #: ../src/guestfs.pod:959
2008 "Here is an example of a wrapper, where I have built my own copy of qemu from "
2013 #: ../src/guestfs.pod:962
2017 " qemudir=/home/rjones/d/qemu\n"
2018 " exec $qemudir/x86_64-softmmu/qemu-system-x86_64 -L $qemudir/pc-bios \"$@\"\n"
2023 #: ../src/guestfs.pod:966
2025 "Save this script as C</tmp/qemu.wrapper> (or wherever), C<chmod +x>, and "
2026 "then use it by setting the LIBGUESTFS_QEMU environment variable. For "
2031 #: ../src/guestfs.pod:970
2034 " LIBGUESTFS_QEMU=/tmp/qemu.wrapper guestfish\n"
2039 #: ../src/guestfs.pod:972
2041 "Note that libguestfs also calls qemu with the -help and -version options in "
2042 "order to determine features."
2046 #: ../src/guestfs.pod:975
2047 msgid "ATTACHING TO RUNNING DAEMONS"
2051 #: ../src/guestfs.pod:977
2053 "I<Note (1):> This is B<highly experimental> and has a tendency to eat "
2054 "babies. Use with caution."
2058 #: ../src/guestfs.pod:980
2060 "I<Note (2):> This section explains how to attach to a running daemon from a "
2061 "low level perspective. For most users, simply using virt tools such as "
2062 "L<guestfish(1)> with the I<--live> option will \"just work\"."
2066 #: ../src/guestfs.pod:984
2067 msgid "Using guestfs_set_attach_method"
2071 #: ../src/guestfs.pod:986
2073 "By calling L</guestfs_set_attach_method> you can change how the library "
2074 "connects to the C<guestfsd> daemon in L</guestfs_launch> (read L</"
2075 "ARCHITECTURE> for some background)."
2079 #: ../src/guestfs.pod:990
2081 "The normal attach method is C<appliance>, where a small appliance is created "
2082 "containing the daemon, and then the library connects to this."
2086 #: ../src/guestfs.pod:993
2088 "Setting attach method to C<unix:I<path>> (where I<path> is the path of a "
2089 "Unix domain socket) causes L</guestfs_launch> to connect to an existing "
2090 "daemon over the Unix domain socket."
2094 #: ../src/guestfs.pod:997
2096 "The normal use for this is to connect to a running virtual machine that "
2097 "contains a C<guestfsd> daemon, and send commands so you can read and write "
2098 "files inside the live virtual machine."
2102 #: ../src/guestfs.pod:1001
2103 msgid "Using guestfs_add_domain with live flag"
2107 #: ../src/guestfs.pod:1003
2109 "L</guestfs_add_domain> provides some help for getting the correct attach "
2110 "method. If you pass the C<live> option to this function, then (if the "
2111 "virtual machine is running) it will examine the libvirt XML looking for a "
2112 "virtio-serial channel to connect to:"
2116 #: ../src/guestfs.pod:1009
2123 " <channel type='unix'>\n"
2124 " <source mode='bind' path='/path/to/socket'/>\n"
2125 " <target type='virtio' name='org.libguestfs.channel.0'/>\n"
2134 #: ../src/guestfs.pod:1021
2136 "L</guestfs_add_domain> extracts C</path/to/socket> and sets the attach "
2137 "method to C<unix:/path/to/socket>."
2141 #: ../src/guestfs.pod:1024
2143 "Some of the libguestfs tools (including guestfish) support a I<--live> "
2144 "option which is passed through to L</guestfs_add_domain> thus allowing you "
2145 "to attach to and modify live virtual machines."
2149 #: ../src/guestfs.pod:1028
2151 "The virtual machine needs to have been set up beforehand so that it has the "
2152 "virtio-serial channel and so that guestfsd is running inside it."
2156 #: ../src/guestfs.pod:1032
2157 msgid "ABI GUARANTEE"
2161 #: ../src/guestfs.pod:1034
2163 "We guarantee the libguestfs ABI (binary interface), for public, high-level "
2164 "actions as outlined in this section. Although we will deprecate some "
2165 "actions, for example if they get replaced by newer calls, we will keep the "
2166 "old actions forever. This allows you the developer to program in confidence "
2167 "against the libguestfs API."
2171 #: ../src/guestfs.pod:1040
2172 msgid "BLOCK DEVICE NAMING"
2176 #: ../src/guestfs.pod:1042
2178 "In the kernel there is now quite a profusion of schemata for naming block "
2179 "devices (in this context, by I<block device> I mean a physical or virtual "
2180 "hard drive). The original Linux IDE driver used names starting with C</dev/"
2181 "hd*>. SCSI devices have historically used a different naming scheme, C</dev/"
2182 "sd*>. When the Linux kernel I<libata> driver became a popular replacement "
2183 "for the old IDE driver (particularly for SATA devices) those devices also "
2184 "used the C</dev/sd*> scheme. Additionally we now have virtual machines with "
2185 "paravirtualized drivers. This has created several different naming systems, "
2186 "such as C</dev/vd*> for virtio disks and C</dev/xvd*> for Xen PV disks."
2190 #: ../src/guestfs.pod:1054
2192 "As discussed above, libguestfs uses a qemu appliance running an embedded "
2193 "Linux kernel to access block devices. We can run a variety of appliances "
2194 "based on a variety of Linux kernels."
2198 #: ../src/guestfs.pod:1058
2200 "This causes a problem for libguestfs because many API calls use device or "
2201 "partition names. Working scripts and the recipe (example) scripts that we "
2202 "make available over the internet could fail if the naming scheme changes."
2206 #: ../src/guestfs.pod:1063
2208 "Therefore libguestfs defines C</dev/sd*> as the I<standard naming scheme>. "
2209 "Internally C</dev/sd*> names are translated, if necessary, to other names as "
2210 "required. For example, under RHEL 5 which uses the C</dev/hd*> scheme, any "
2211 "device parameter C</dev/sda2> is translated to C</dev/hda2> transparently."
2215 #: ../src/guestfs.pod:1069
2217 "Note that this I<only> applies to parameters. The L</guestfs_list_devices>, "
2218 "L</guestfs_list_partitions> and similar calls return the true names of the "
2219 "devices and partitions as known to the appliance."
2223 #: ../src/guestfs.pod:1074
2224 msgid "ALGORITHM FOR BLOCK DEVICE NAME TRANSLATION"
2228 #: ../src/guestfs.pod:1076
2230 "Usually this translation is transparent. However in some (very rare) cases "
2231 "you may need to know the exact algorithm. Such cases include where you use "
2232 "L</guestfs_config> to add a mixture of virtio and IDE devices to the qemu-"
2233 "based appliance, so have a mixture of C</dev/sd*> and C</dev/vd*> devices."
2237 #: ../src/guestfs.pod:1082
2239 "The algorithm is applied only to I<parameters> which are known to be either "
2240 "device or partition names. Return values from functions such as L</"
2241 "guestfs_list_devices> are never changed."
2245 #: ../src/guestfs.pod:1090
2246 msgid "Is the string a parameter which is a device or partition name?"
2250 #: ../src/guestfs.pod:1094
2251 msgid "Does the string begin with C</dev/sd>?"
2255 #: ../src/guestfs.pod:1098
2257 "Does the named device exist? If so, we use that device. However if I<not> "
2258 "then we continue with this algorithm."
2262 #: ../src/guestfs.pod:1103
2263 msgid "Replace initial C</dev/sd> string with C</dev/hd>."
2267 #: ../src/guestfs.pod:1105
2268 msgid "For example, change C</dev/sda2> to C</dev/hda2>."
2272 #: ../src/guestfs.pod:1107
2273 msgid "If that named device exists, use it. If not, continue."
2277 #: ../src/guestfs.pod:1111
2278 msgid "Replace initial C</dev/sd> string with C</dev/vd>."
2282 #: ../src/guestfs.pod:1113
2283 msgid "If that named device exists, use it. If not, return an error."
2287 #: ../src/guestfs.pod:1117
2288 msgid "PORTABILITY CONCERNS WITH BLOCK DEVICE NAMING"
2292 #: ../src/guestfs.pod:1119
2294 "Although the standard naming scheme and automatic translation is useful for "
2295 "simple programs and guestfish scripts, for larger programs it is best not to "
2296 "rely on this mechanism."
2300 #: ../src/guestfs.pod:1123
2302 "Where possible for maximum future portability programs using libguestfs "
2303 "should use these future-proof techniques:"
2307 #: ../src/guestfs.pod:1130
2309 "Use L</guestfs_list_devices> or L</guestfs_list_partitions> to list actual "
2310 "device names, and then use those names directly."
2314 #: ../src/guestfs.pod:1133
2316 "Since those device names exist by definition, they will never be translated."
2320 #: ../src/guestfs.pod:1138
2322 "Use higher level ways to identify filesystems, such as LVM names, UUIDs and "
2323 "filesystem labels."
2327 #: ../src/guestfs.pod:1143
2332 #: ../src/guestfs.pod:1145
2334 "This section discusses security implications of using libguestfs, "
2335 "particularly with untrusted or malicious guests or disk images."
2339 #: ../src/guestfs.pod:1148
2340 msgid "GENERAL SECURITY CONSIDERATIONS"
2344 #: ../src/guestfs.pod:1150
2346 "Be careful with any files or data that you download from a guest (by "
2347 "\"download\" we mean not just the L</guestfs_download> command but any "
2348 "command that reads files, filenames, directories or anything else from a "
2349 "disk image). An attacker could manipulate the data to fool your program "
2350 "into doing the wrong thing. Consider cases such as:"
2354 #: ../src/guestfs.pod:1160
2355 msgid "the data (file etc) not being present"
2359 #: ../src/guestfs.pod:1164
2360 msgid "being present but empty"
2364 #: ../src/guestfs.pod:1168
2365 msgid "being much larger than normal"
2369 #: ../src/guestfs.pod:1172
2370 msgid "containing arbitrary 8 bit data"
2374 #: ../src/guestfs.pod:1176
2375 msgid "being in an unexpected character encoding"
2379 #: ../src/guestfs.pod:1180
2380 msgid "containing homoglyphs."
2384 #: ../src/guestfs.pod:1184
2385 msgid "SECURITY OF MOUNTING FILESYSTEMS"
2389 #: ../src/guestfs.pod:1186
2391 "When you mount a filesystem under Linux, mistakes in the kernel filesystem "
2392 "(VFS) module can sometimes be escalated into exploits by deliberately "
2393 "creating a malicious, malformed filesystem. These exploits are very severe "
2394 "for two reasons. Firstly there are very many filesystem drivers in the "
2395 "kernel, and many of them are infrequently used and not much developer "
2396 "attention has been paid to the code. Linux userspace helps potential "
2397 "crackers by detecting the filesystem type and automatically choosing the "
2398 "right VFS driver, even if that filesystem type is obscure or unexpected for "
2399 "the administrator. Secondly, a kernel-level exploit is like a local root "
2400 "exploit (worse in some ways), giving immediate and total access to the "
2401 "system right down to the hardware level."
2405 #: ../src/guestfs.pod:1199
2407 "That explains why you should never mount a filesystem from an untrusted "
2408 "guest on your host kernel. How about libguestfs? We run a Linux kernel "
2409 "inside a qemu virtual machine, usually running as a non-root user. The "
2410 "attacker would need to write a filesystem which first exploited the kernel, "
2411 "and then exploited either qemu virtualization (eg. a faulty qemu driver) or "
2412 "the libguestfs protocol, and finally to be as serious as the host kernel "
2413 "exploit it would need to escalate its privileges to root. This multi-step "
2414 "escalation, performed by a static piece of data, is thought to be extremely "
2415 "hard to do, although we never say 'never' about security issues."
2419 #: ../src/guestfs.pod:1210
2421 "In any case callers can reduce the attack surface by forcing the filesystem "
2422 "type when mounting (use L</guestfs_mount_vfs>)."
2426 #: ../src/guestfs.pod:1213
2427 msgid "PROTOCOL SECURITY"
2431 #: ../src/guestfs.pod:1215
2433 "The protocol is designed to be secure, being based on RFC 4506 (XDR) with a "
2434 "defined upper message size. However a program that uses libguestfs must "
2435 "also take care - for example you can write a program that downloads a binary "
2436 "from a disk image and executes it locally, and no amount of protocol "
2437 "security will save you from the consequences."
2441 #: ../src/guestfs.pod:1221
2442 msgid "INSPECTION SECURITY"
2446 #: ../src/guestfs.pod:1223
2448 "Parts of the inspection API (see L</INSPECTION>) return untrusted strings "
2449 "directly from the guest, and these could contain any 8 bit data. Callers "
2450 "should be careful to escape these before printing them to a structured file "
2451 "(for example, use HTML escaping if creating a web page)."
2455 #: ../src/guestfs.pod:1229
2457 "Guest configuration may be altered in unusual ways by the administrator of "
2458 "the virtual machine, and may not reflect reality (particularly for untrusted "
2459 "or actively malicious guests). For example we parse the hostname from "
2460 "configuration files like C</etc/sysconfig/network> that we find in the "
2461 "guest, but the guest administrator can easily manipulate these files to "
2462 "provide the wrong hostname."
2466 #: ../src/guestfs.pod:1237
2468 "The inspection API parses guest configuration using two external libraries: "
2469 "Augeas (Linux configuration) and hivex (Windows Registry). Both are "
2470 "designed to be robust in the face of malicious data, although denial of "
2471 "service attacks are still possible, for example with oversized configuration "
2476 #: ../src/guestfs.pod:1243
2477 msgid "RUNNING UNTRUSTED GUEST COMMANDS"
2481 #: ../src/guestfs.pod:1245
2483 "Be very cautious about running commands from the guest. By running a "
2484 "command in the guest, you are giving CPU time to a binary that you do not "
2485 "control, under the same user account as the library, albeit wrapped in qemu "
2486 "virtualization. More information and alternatives can be found in the "
2487 "section L</RUNNING COMMANDS>."
2491 #: ../src/guestfs.pod:1251
2492 msgid "CVE-2010-3851"
2493 msgstr "CVE-2010-3851"
2496 #: ../src/guestfs.pod:1253
2497 msgid "https://bugzilla.redhat.com/642934"
2498 msgstr "https://bugzilla.redhat.com/642934"
2501 #: ../src/guestfs.pod:1255
2503 "This security bug concerns the automatic disk format detection that qemu "
2504 "does on disk images."
2508 #: ../src/guestfs.pod:1258
2510 "A raw disk image is just the raw bytes, there is no header. Other disk "
2511 "images like qcow2 contain a special header. Qemu deals with this by looking "
2512 "for one of the known headers, and if none is found then assuming the disk "
2513 "image must be raw."
2517 #: ../src/guestfs.pod:1263
2519 "This allows a guest which has been given a raw disk image to write some "
2520 "other header. At next boot (or when the disk image is accessed by "
2521 "libguestfs) qemu would do autodetection and think the disk image format was, "
2522 "say, qcow2 based on the header written by the guest."
2526 #: ../src/guestfs.pod:1268
2528 "This in itself would not be a problem, but qcow2 offers many features, one "
2529 "of which is to allow a disk image to refer to another image (called the "
2530 "\"backing disk\"). It does this by placing the path to the backing disk "
2531 "into the qcow2 header. This path is not validated and could point to any "
2532 "host file (eg. \"/etc/passwd\"). The backing disk is then exposed through "
2533 "\"holes\" in the qcow2 disk image, which of course is completely under the "
2534 "control of the attacker."
2538 #: ../src/guestfs.pod:1276
2540 "In libguestfs this is rather hard to exploit except under two circumstances:"
2544 #: ../src/guestfs.pod:1283
2545 msgid "You have enabled the network or have opened the disk in write mode."
2549 #: ../src/guestfs.pod:1287
2551 "You are also running untrusted code from the guest (see L</RUNNING "
2556 #: ../src/guestfs.pod:1292
2558 "The way to avoid this is to specify the expected disk format when adding "
2559 "disks (the optional C<format> option to L</guestfs_add_drive_opts>). You "
2560 "should always do this if the disk is raw format, and it's a good idea for "
2565 #: ../src/guestfs.pod:1297
2567 "For disks added from libvirt using calls like L</guestfs_add_domain>, the "
2568 "format is fetched from libvirt and passed through."
2572 #: ../src/guestfs.pod:1300
2574 "For libguestfs tools, use the I<--format> command line parameter as "
2579 #: ../src/guestfs.pod:1303
2580 msgid "CONNECTION MANAGEMENT"
2584 #: ../src/guestfs.pod:1305
2589 #: ../src/guestfs.pod:1307
2591 "C<guestfs_h> is the opaque type representing a connection handle. Create a "
2592 "handle by calling L</guestfs_create>. Call L</guestfs_close> to free the "
2593 "handle and release all resources used."
2597 #: ../src/guestfs.pod:1311
2599 "For information on using multiple handles and threads, see the section L</"
2600 "MULTIPLE HANDLES AND MULTIPLE THREADS> below."
2604 #: ../src/guestfs.pod:1314
2605 msgid "guestfs_create"
2609 #: ../src/guestfs.pod:1316
2612 " guestfs_h *guestfs_create (void);\n"
2617 #: ../src/guestfs.pod:1318
2618 msgid "Create a connection handle."
2622 #: ../src/guestfs.pod:1320
2624 "You have to call L</guestfs_add_drive_opts> (or one of the equivalent calls) "
2625 "on the handle at least once."
2629 #: ../src/guestfs.pod:1323
2631 "This function returns a non-NULL pointer to a handle on success or NULL on "
2636 #: ../src/guestfs.pod:1326
2637 msgid "After configuring the handle, you have to call L</guestfs_launch>."
2641 #: ../src/guestfs.pod:1328
2643 "You may also want to configure error handling for the handle. See L</ERROR "
2644 "HANDLING> section below."
2648 #: ../src/guestfs.pod:1331
2649 msgid "guestfs_close"
2653 #: ../src/guestfs.pod:1333
2656 " void guestfs_close (guestfs_h *g);\n"
2661 #: ../src/guestfs.pod:1335
2662 msgid "This closes the connection handle and frees up all resources used."
2666 #: ../src/guestfs.pod:1337
2667 msgid "ERROR HANDLING"
2668 msgstr "ОБРОБКА ПОМИЛОК"
2671 #: ../src/guestfs.pod:1339
2673 "API functions can return errors. For example, almost all functions that "
2674 "return C<int> will return C<-1> to indicate an error."
2678 #: ../src/guestfs.pod:1342
2680 "Additional information is available for errors: an error message string and "
2681 "optionally an error number (errno) if the thing that failed was a system "
2686 #: ../src/guestfs.pod:1346
2688 "You can get at the additional information about the last error on the handle "
2689 "by calling L</guestfs_last_error>, L</guestfs_last_errno>, and/or by setting "
2690 "up an error handler with L</guestfs_set_error_handler>."
2694 #: ../src/guestfs.pod:1351
2696 "When the handle is created, a default error handler is installed which "
2697 "prints the error message string to C<stderr>. For small short-running "
2698 "command line programs it is sufficient to do:"
2702 #: ../src/guestfs.pod:1355
2705 " if (guestfs_launch (g) == -1)\n"
2706 " exit (EXIT_FAILURE);\n"
2711 #: ../src/guestfs.pod:1358
2713 "since the default error handler will ensure that an error message has been "
2714 "printed to C<stderr> before the program exits."
2718 #: ../src/guestfs.pod:1361
2720 "For other programs the caller will almost certainly want to install an "
2721 "alternate error handler or do error handling in-line like this:"
2725 #: ../src/guestfs.pod:1364
2728 " g = guestfs_create ();\n"
2733 #: ../src/guestfs.pod:1366
2736 " /* This disables the default behaviour of printing errors\n"
2738 " guestfs_set_error_handler (g, NULL, NULL);\n"
2743 #: ../src/guestfs.pod:1370
2746 " if (guestfs_launch (g) == -1) {\n"
2747 " /* Examine the error message and print it etc. */\n"
2748 " char *msg = guestfs_last_error (g);\n"
2749 " int errnum = guestfs_last_errno (g);\n"
2750 " fprintf (stderr, \"%s\\n\", msg);\n"
2757 #: ../src/guestfs.pod:1378
2759 "Out of memory errors are handled differently. The default action is to call "
2760 "L<abort(3)>. If this is undesirable, then you can set a handler using L</"
2761 "guestfs_set_out_of_memory_handler>."
2765 #: ../src/guestfs.pod:1382
2767 "L</guestfs_create> returns C<NULL> if the handle cannot be created, and "
2768 "because there is no handle if this happens there is no way to get additional "
2769 "error information. However L</guestfs_create> is supposed to be a "
2770 "lightweight operation which can only fail because of insufficient memory (it "
2771 "returns NULL in this case)."
2775 #: ../src/guestfs.pod:1388
2776 msgid "guestfs_last_error"
2780 #: ../src/guestfs.pod:1390
2783 " const char *guestfs_last_error (guestfs_h *g);\n"
2788 #: ../src/guestfs.pod:1392
2790 "This returns the last error message that happened on C<g>. If there has not "
2791 "been an error since the handle was created, then this returns C<NULL>."
2795 #: ../src/guestfs.pod:1396
2797 "The lifetime of the returned string is until the next error occurs, or L</"
2798 "guestfs_close> is called."
2802 #: ../src/guestfs.pod:1399
2803 msgid "guestfs_last_errno"
2807 #: ../src/guestfs.pod:1401
2810 " int guestfs_last_errno (guestfs_h *g);\n"
2815 #: ../src/guestfs.pod:1403
2816 msgid "This returns the last error number (errno) that happened on C<g>."
2820 #: ../src/guestfs.pod:1405
2821 msgid "If successful, an errno integer not equal to zero is returned."
2825 #: ../src/guestfs.pod:1407
2827 "If no error, this returns 0. This call can return 0 in three situations:"
2831 #: ../src/guestfs.pod:1414
2832 msgid "There has not been any error on the handle."
2836 #: ../src/guestfs.pod:1418
2838 "There has been an error but the errno was meaningless. This corresponds to "
2839 "the case where the error did not come from a failed system call, but for "
2840 "some other reason."
2844 #: ../src/guestfs.pod:1424
2846 "There was an error from a failed system call, but for some reason the errno "
2847 "was not captured and returned. This usually indicates a bug in libguestfs."
2851 #: ../src/guestfs.pod:1430
2853 "Libguestfs tries to convert the errno from inside the applicance into a "
2854 "corresponding errno for the caller (not entirely trivial: the appliance "
2855 "might be running a completely different operating system from the library "
2856 "and error numbers are not standardized across Un*xen). If this could not be "
2857 "done, then the error is translated to C<EINVAL>. In practice this should "
2858 "only happen in very rare circumstances."
2862 #: ../src/guestfs.pod:1438
2863 msgid "guestfs_set_error_handler"
2867 #: ../src/guestfs.pod:1440
2870 " typedef void (*guestfs_error_handler_cb) (guestfs_h *g,\n"
2872 " const char *msg);\n"
2873 " void guestfs_set_error_handler (guestfs_h *g,\n"
2874 " guestfs_error_handler_cb cb,\n"
2880 #: ../src/guestfs.pod:1447
2882 "The callback C<cb> will be called if there is an error. The parameters "
2883 "passed to the callback are an opaque data pointer and the error message "
2888 #: ../src/guestfs.pod:1451
2890 "C<errno> is not passed to the callback. To get that the callback must call "
2891 "L</guestfs_last_errno>."
2895 #: ../src/guestfs.pod:1454
2897 "Note that the message string C<msg> is freed as soon as the callback "
2898 "function returns, so if you want to stash it somewhere you must make your "
2903 #: ../src/guestfs.pod:1458
2904 msgid "The default handler prints messages on C<stderr>."
2908 #: ../src/guestfs.pod:1460
2909 msgid "If you set C<cb> to C<NULL> then I<no> handler is called."
2913 #: ../src/guestfs.pod:1462
2914 msgid "guestfs_get_error_handler"
2918 #: ../src/guestfs.pod:1464
2921 " guestfs_error_handler_cb guestfs_get_error_handler (guestfs_h *g,\n"
2922 " void **opaque_rtn);\n"
2927 #: ../src/guestfs.pod:1467
2928 msgid "Returns the current error handler callback."
2932 #: ../src/guestfs.pod:1469
2933 msgid "guestfs_set_out_of_memory_handler"
2937 #: ../src/guestfs.pod:1471
2940 " typedef void (*guestfs_abort_cb) (void);\n"
2941 " int guestfs_set_out_of_memory_handler (guestfs_h *g,\n"
2942 " guestfs_abort_cb);\n"
2947 #: ../src/guestfs.pod:1475
2949 "The callback C<cb> will be called if there is an out of memory situation. "
2950 "I<Note this callback must not return>."
2954 #: ../src/guestfs.pod:1478
2955 msgid "The default is to call L<abort(3)>."
2959 #: ../src/guestfs.pod:1480
2961 "You cannot set C<cb> to C<NULL>. You can't ignore out of memory situations."
2965 #: ../src/guestfs.pod:1483
2966 msgid "guestfs_get_out_of_memory_handler"
2970 #: ../src/guestfs.pod:1485
2973 " guestfs_abort_fn guestfs_get_out_of_memory_handler (guestfs_h *g);\n"
2978 #: ../src/guestfs.pod:1487
2979 msgid "This returns the current out of memory handler."
2983 #: ../src/guestfs.pod:1489
2988 #: ../src/guestfs.pod:1491 ../fish/guestfish.pod:1003
2993 #: ../src/guestfs.pod:1493
2998 #: ../src/guestfs.pod:1495
3003 #: ../src/guestfs.pod:1497
3004 msgid "AVAILABILITY"
3008 #: ../src/guestfs.pod:1499
3009 msgid "GROUPS OF FUNCTIONALITY IN THE APPLIANCE"
3013 #: ../src/guestfs.pod:1501
3015 "Using L</guestfs_available> you can test availability of the following "
3016 "groups of functions. This test queries the appliance to see if the "
3017 "appliance you are currently using supports the functionality."
3021 #: ../src/guestfs.pod:1506
3022 msgid "@AVAILABILITY@"
3026 #: ../src/guestfs.pod:1508
3027 msgid "GUESTFISH supported COMMAND"
3031 #: ../src/guestfs.pod:1510
3033 "In L<guestfish(3)> there is a handy interactive command C<supported> which "
3034 "prints out the available groups and whether they are supported by this build "
3035 "of libguestfs. Note however that you have to do C<run> first."
3039 #: ../src/guestfs.pod:1515
3040 msgid "SINGLE CALLS AT COMPILE TIME"
3044 #: ../src/guestfs.pod:1517
3046 "Since version 1.5.8, C<E<lt>guestfs.hE<gt>> defines symbols for each C API "
3047 "function, such as:"
3051 #: ../src/guestfs.pod:1520
3054 " #define LIBGUESTFS_HAVE_DD 1\n"
3059 #: ../src/guestfs.pod:1522
3060 msgid "if L</guestfs_dd> is available."
3064 #: ../src/guestfs.pod:1524
3066 "Before version 1.5.8, if you needed to test whether a single libguestfs "
3067 "function is available at compile time, we recommended using build tools such "
3068 "as autoconf or cmake. For example in autotools you could use:"
3072 #: ../src/guestfs.pod:1529
3075 " AC_CHECK_LIB([guestfs],[guestfs_create])\n"
3076 " AC_CHECK_FUNCS([guestfs_dd])\n"
3081 #: ../src/guestfs.pod:1532
3083 "which would result in C<HAVE_GUESTFS_DD> being either defined or not defined "
3088 #: ../src/guestfs.pod:1535
3089 msgid "SINGLE CALLS AT RUN TIME"
3093 #: ../src/guestfs.pod:1537
3095 "Testing at compile time doesn't guarantee that a function really exists in "
3096 "the library. The reason is that you might be dynamically linked against a "
3097 "previous I<libguestfs.so> (dynamic library) which doesn't have the call. "
3098 "This situation unfortunately results in a segmentation fault, which is a "
3099 "shortcoming of the C dynamic linking system itself."
3103 #: ../src/guestfs.pod:1544
3105 "You can use L<dlopen(3)> to test if a function is available at run time, as "
3106 "in this example program (note that you still need the compile time check as "
3111 #: ../src/guestfs.pod:1548
3114 " #include <stdio.h>\n"
3115 " #include <stdlib.h>\n"
3116 " #include <unistd.h>\n"
3117 " #include <dlfcn.h>\n"
3118 " #include <guestfs.h>\n"
3123 #: ../src/guestfs.pod:1554
3128 " #ifdef LIBGUESTFS_HAVE_DD\n"
3130 " int has_function;\n"
3135 #: ../src/guestfs.pod:1560
3138 " /* Test if the function guestfs_dd is really available. */\n"
3139 " dl = dlopen (NULL, RTLD_LAZY);\n"
3141 " fprintf (stderr, \"dlopen: %s\\n\", dlerror ());\n"
3142 " exit (EXIT_FAILURE);\n"
3144 " has_function = dlsym (dl, \"guestfs_dd\") != NULL;\n"
3150 #: ../src/guestfs.pod:1569
3153 " if (!has_function)\n"
3154 " printf (\"this libguestfs.so does NOT have guestfs_dd function\\n\");\n"
3156 " printf (\"this libguestfs.so has guestfs_dd function\\n\");\n"
3157 " /* Now it's safe to call\n"
3158 " guestfs_dd (g, \"foo\", \"bar\");\n"
3162 " printf (\"guestfs_dd function was not found at compile time\\n\");\n"
3169 #: ../src/guestfs.pod:1582
3171 "You may think the above is an awful lot of hassle, and it is. There are "
3172 "other ways outside of the C linking system to ensure that this kind of "
3173 "incompatibility never arises, such as using package versioning:"
3177 #: ../src/guestfs.pod:1587
3180 " Requires: libguestfs >= 1.0.80\n"
3185 #: ../src/guestfs.pod:1589
3186 msgid "CALLS WITH OPTIONAL ARGUMENTS"
3190 #: ../src/guestfs.pod:1591
3192 "A recent feature of the API is the introduction of calls which take optional "
3193 "arguments. In C these are declared 3 ways. The main way is as a call which "
3194 "takes variable arguments (ie. C<...>), as in this example:"
3198 #: ../src/guestfs.pod:1596
3201 " int guestfs_add_drive_opts (guestfs_h *g, const char *filename, ...);\n"
3206 #: ../src/guestfs.pod:1598
3208 "Call this with a list of optional arguments, terminated by C<-1>. So to "
3209 "call with no optional arguments specified:"
3213 #: ../src/guestfs.pod:1601
3216 " guestfs_add_drive_opts (g, filename, -1);\n"
3221 #: ../src/guestfs.pod:1603
3222 msgid "With a single optional argument:"
3226 #: ../src/guestfs.pod:1605
3229 " guestfs_add_drive_opts (g, filename,\n"
3230 " GUESTFS_ADD_DRIVE_OPTS_FORMAT, \"qcow2\",\n"
3236 #: ../src/guestfs.pod:1609
3241 #: ../src/guestfs.pod:1611
3244 " guestfs_add_drive_opts (g, filename,\n"
3245 " GUESTFS_ADD_DRIVE_OPTS_FORMAT, \"qcow2\",\n"
3246 " GUESTFS_ADD_DRIVE_OPTS_READONLY, 1,\n"
3252 #: ../src/guestfs.pod:1616
3254 "and so forth. Don't forget the terminating C<-1> otherwise Bad Things will "
3259 #: ../src/guestfs.pod:1619
3260 msgid "USING va_list FOR OPTIONAL ARGUMENTS"
3264 #: ../src/guestfs.pod:1621
3266 "The second variant has the same name with the suffix C<_va>, which works the "
3267 "same way but takes a C<va_list>. See the C manual for details. For the "
3268 "example function, this is declared:"
3272 #: ../src/guestfs.pod:1625
3275 " int guestfs_add_drive_opts_va (guestfs_h *g, const char *filename,\n"
3281 #: ../src/guestfs.pod:1628
3282 msgid "CONSTRUCTING OPTIONAL ARGUMENTS"
3286 #: ../src/guestfs.pod:1630
3288 "The third variant is useful where you need to construct these calls. You "
3289 "pass in a structure where you fill in the optional fields. The structure "
3290 "has a bitmask as the first element which you must set to indicate which "
3291 "fields you have filled in. For our example function the structure and call "
3296 #: ../src/guestfs.pod:1636
3299 " struct guestfs_add_drive_opts_argv {\n"
3300 " uint64_t bitmask;\n"
3302 " const char *format;\n"
3305 " int guestfs_add_drive_opts_argv (guestfs_h *g, const char *filename,\n"
3306 " const struct guestfs_add_drive_opts_argv *optargs);\n"
3311 #: ../src/guestfs.pod:1645
3312 msgid "You could call it like this:"
3316 #: ../src/guestfs.pod:1647
3319 " struct guestfs_add_drive_opts_argv optargs = {\n"
3320 " .bitmask = GUESTFS_ADD_DRIVE_OPTS_READONLY_BITMASK |\n"
3321 " GUESTFS_ADD_DRIVE_OPTS_FORMAT_BITMASK,\n"
3323 " .format = \"qcow2\"\n"
3329 #: ../src/guestfs.pod:1654
3332 " guestfs_add_drive_opts_argv (g, filename, &optargs);\n"
3337 #: ../src/guestfs.pod:1656 ../src/guestfs-actions.pod:11
3338 #: ../src/guestfs-actions.pod:1855 ../fish/guestfish-actions.pod:9
3339 #: ../fish/guestfish-actions.pod:1260 ../tools/virt-win-reg.pl:532
3344 #: ../src/guestfs.pod:1662
3345 msgid "The C<_BITMASK> suffix on each option name when specifying the bitmask."
3349 #: ../src/guestfs.pod:1667
3350 msgid "You do not need to fill in all fields of the structure."
3354 #: ../src/guestfs.pod:1671
3356 "There must be a one-to-one correspondence between fields of the structure "
3357 "that are filled in, and bits set in the bitmask."
3361 #: ../src/guestfs.pod:1676
3362 msgid "OPTIONAL ARGUMENTS IN OTHER LANGUAGES"
3366 #: ../src/guestfs.pod:1678
3368 "In other languages, optional arguments are expressed in the way that is "
3369 "natural for that language. We refer you to the language-specific "
3370 "documentation for more details on that."
3374 #: ../src/guestfs.pod:1682
3375 msgid "For guestfish, see L<guestfish(1)/OPTIONAL ARGUMENTS>."
3379 #: ../src/guestfs.pod:1684
3380 msgid "SETTING CALLBACKS TO HANDLE EVENTS"
3384 #: ../src/guestfs.pod:1686
3386 "B<Note:> This section documents the generic event mechanism introduced in "
3387 "libguestfs 1.10, which you should use in new code if possible. The old "
3388 "functions C<guestfs_set_log_message_callback>, "
3389 "C<guestfs_set_subprocess_quit_callback>, "
3390 "C<guestfs_set_launch_done_callback>, C<guestfs_set_close_callback> and "
3391 "C<guestfs_set_progress_callback> are no longer documented in this manual "
3396 #: ../src/guestfs.pod:1694
3398 "Handles generate events when certain things happen, such as log messages "
3399 "being generated, progress messages during long-running operations, or the "
3400 "handle being closed. The API calls described below let you register a "
3401 "callback to be called when events happen. You can register multiple "
3402 "callbacks (for the same, different or overlapping sets of events), and "
3403 "individually remove callbacks. If callbacks are not removed, then they "
3404 "remain in force until the handle is closed."
3408 #: ../src/guestfs.pod:1702
3410 "In the current implementation, events are only generated synchronously: that "
3411 "means that events (and hence callbacks) can only happen while you are in the "
3412 "middle of making another libguestfs call. The callback is called in the "
3417 #: ../src/guestfs.pod:1707
3419 "Events may contain a payload, usually nothing (void), an array of 64 bit "
3420 "unsigned integers, or a message buffer. Payloads are discussed later on."
3424 #: ../src/guestfs.pod:1711
3425 msgid "CLASSES OF EVENTS"
3429 #: ../src/guestfs.pod:1715
3430 msgid "GUESTFS_EVENT_CLOSE (payload type: void)"
3434 #: ../src/guestfs.pod:1718
3436 "The callback function will be called while the handle is being closed "
3437 "(synchronously from L</guestfs_close>)."
3441 #: ../src/guestfs.pod:1721
3443 "Note that libguestfs installs an L<atexit(3)> handler to try to clean up "
3444 "handles that are open when the program exits. This means that this callback "
3445 "might be called indirectly from L<exit(3)>, which can cause unexpected "
3446 "problems in higher-level languages (eg. if your HLL interpreter has already "
3447 "been cleaned up by the time this is called, and if your callback then jumps "
3448 "into some HLL function)."
3452 #: ../src/guestfs.pod:1728
3454 "If no callback is registered: the handle is closed without any callback "
3459 #: ../src/guestfs.pod:1731
3460 msgid "GUESTFS_EVENT_SUBPROCESS_QUIT (payload type: void)"
3464 #: ../src/guestfs.pod:1734
3466 "The callback function will be called when the child process quits, either "
3467 "asynchronously or if killed by L</guestfs_kill_subprocess>. (This "
3468 "corresponds to a transition from any state to the CONFIG state)."
3472 #: ../src/guestfs.pod:1738 ../src/guestfs.pod:1747
3473 msgid "If no callback is registered: the event is ignored."
3477 #: ../src/guestfs.pod:1740
3478 msgid "GUESTFS_EVENT_LAUNCH_DONE (payload type: void)"
3482 #: ../src/guestfs.pod:1743
3484 "The callback function will be called when the child process becomes ready "
3485 "first time after it has been launched. (This corresponds to a transition "
3486 "from LAUNCHING to the READY state)."
3490 #: ../src/guestfs.pod:1749
3491 msgid "GUESTFS_EVENT_PROGRESS (payload type: array of 4 x uint64_t)"
3495 #: ../src/guestfs.pod:1752
3497 "Some long-running operations can generate progress messages. If this "
3498 "callback is registered, then it will be called each time a progress message "
3499 "is generated (usually two seconds after the operation started, and three "
3500 "times per second thereafter until it completes, although the frequency may "
3501 "change in future versions)."
3505 #: ../src/guestfs.pod:1758
3507 "The callback receives in the payload four unsigned 64 bit numbers which are "
3508 "(in order): C<proc_nr>, C<serial>, C<position>, C<total>."
3512 #: ../src/guestfs.pod:1761
3514 "The units of C<total> are not defined, although for some operations C<total> "
3515 "may relate in some way to the amount of data to be transferred (eg. in bytes "
3516 "or megabytes), and C<position> may be the portion which has been transferred."
3520 #: ../src/guestfs.pod:1766
3521 msgid "The only defined and stable parts of the API are:"
3525 #: ../src/guestfs.pod:1772
3527 "The callback can display to the user some type of progress bar or indicator "
3528 "which shows the ratio of C<position>:C<total>."
3532 #: ../src/guestfs.pod:1777
3533 msgid "0 E<lt>= C<position> E<lt>= C<total>"
3537 #: ../src/guestfs.pod:1781
3539 "If any progress notification is sent during a call, then a final progress "
3540 "notification is always sent when C<position> = C<total> (I<unless> the call "
3541 "fails with an error)."
3545 #: ../src/guestfs.pod:1785
3547 "This is to simplify caller code, so callers can easily set the progress "
3548 "indicator to \"100%\" at the end of the operation, without requiring special "
3549 "code to detect this case."
3553 #: ../src/guestfs.pod:1791
3555 "For some calls we are unable to estimate the progress of the call, but we "
3556 "can still generate progress messages to indicate activity. This is known as "
3557 "\"pulse mode\", and is directly supported by certain progress bar "
3558 "implementations (eg. GtkProgressBar)."
3562 #: ../src/guestfs.pod:1796
3564 "For these calls, zero or more progress messages are generated with "
3565 "C<position = 0> and C<total = 1>, followed by a final message with "
3566 "C<position = total = 1>."
3570 #: ../src/guestfs.pod:1800
3572 "As noted above, if the call fails with an error then the final message may "
3577 #: ../src/guestfs.pod:1805
3579 "The callback also receives the procedure number (C<proc_nr>) and serial "
3580 "number (C<serial>) of the call. These are only useful for debugging "
3581 "protocol issues, and the callback can normally ignore them. The callback "
3582 "may want to print these numbers in error messages or debugging messages."
3586 #: ../src/guestfs.pod:1811
3587 msgid "If no callback is registered: progress messages are discarded."
3591 #: ../src/guestfs.pod:1813
3592 msgid "GUESTFS_EVENT_APPLIANCE (payload type: message buffer)"
3596 #: ../src/guestfs.pod:1816
3598 "The callback function is called whenever a log message is generated by qemu, "
3599 "the appliance kernel, guestfsd (daemon), or utility programs."
3603 #: ../src/guestfs.pod:1819
3605 "If the verbose flag (L</guestfs_set_verbose>) is set before launch (L</"
3606 "guestfs_launch>) then additional debug messages are generated."
3610 #: ../src/guestfs.pod:1822 ../src/guestfs.pod:1836
3612 "If no callback is registered: the messages are discarded unless the verbose "
3613 "flag is set in which case they are sent to stderr. You can override the "
3614 "printing of verbose messages to stderr by setting up a callback."
3618 #: ../src/guestfs.pod:1827
3619 msgid "GUESTFS_EVENT_LIBRARY (payload type: message buffer)"
3623 #: ../src/guestfs.pod:1830
3625 "The callback function is called whenever a log message is generated by the "
3626 "library part of libguestfs."
3630 #: ../src/guestfs.pod:1833
3632 "If the verbose flag (L</guestfs_set_verbose>) is set then additional debug "
3633 "messages are generated."
3637 #: ../src/guestfs.pod:1841
3638 msgid "GUESTFS_EVENT_TRACE (payload type: message buffer)"
3642 #: ../src/guestfs.pod:1844
3644 "The callback function is called whenever a trace message is generated. This "
3645 "only applies if the trace flag (L</guestfs_set_trace>) is set."
3649 #: ../src/guestfs.pod:1847
3651 "If no callback is registered: the messages are sent to stderr. You can "
3652 "override the printing of trace messages to stderr by setting up a callback."
3656 #: ../src/guestfs.pod:1853
3657 msgid "guestfs_set_event_callback"
3661 #: ../src/guestfs.pod:1855
3664 " int guestfs_set_event_callback (guestfs_h *g,\n"
3665 " guestfs_event_callback cb,\n"
3666 " uint64_t event_bitmask,\n"
3673 #: ../src/guestfs.pod:1861
3675 "This function registers a callback (C<cb>) for all event classes in the "
3680 #: ../src/guestfs.pod:1864
3682 "For example, to register for all log message events, you could call this "
3683 "function with the bitmask C<GUESTFS_EVENT_APPLIANCE|GUESTFS_EVENT_LIBRARY>. "
3684 "To register a single callback for all possible classes of events, use "
3685 "C<GUESTFS_EVENT_ALL>."
3689 #: ../src/guestfs.pod:1870
3690 msgid "C<flags> should always be passed as 0."
3694 #: ../src/guestfs.pod:1872
3696 "C<opaque> is an opaque pointer which is passed to the callback. You can use "
3697 "it for any purpose."
3701 #: ../src/guestfs.pod:1875
3703 "The return value is the event handle (an integer) which you can use to "
3704 "delete the callback (see below)."
3708 #: ../src/guestfs.pod:1878
3710 "If there is an error, this function returns C<-1>, and sets the error in the "
3711 "handle in the usual way (see L</guestfs_last_error> etc.)"
3715 #: ../src/guestfs.pod:1881
3717 "Callbacks remain in effect until they are deleted, or until the handle is "
3722 #: ../src/guestfs.pod:1884
3724 "In the case where multiple callbacks are registered for a particular event "
3725 "class, all of the callbacks are called. The order in which multiple "
3726 "callbacks are called is not defined."
3730 #: ../src/guestfs.pod:1888
3731 msgid "guestfs_delete_event_callback"
3735 #: ../src/guestfs.pod:1890
3738 " void guestfs_delete_event_callback (guestfs_h *g, int event_handle);\n"
3743 #: ../src/guestfs.pod:1892
3745 "Delete a callback that was previously registered. C<event_handle> should be "
3746 "the integer that was returned by a previous call to "
3747 "C<guestfs_set_event_callback> on the same handle."
3751 #: ../src/guestfs.pod:1896
3752 msgid "guestfs_event_callback"
3756 #: ../src/guestfs.pod:1898
3759 " typedef void (*guestfs_event_callback) (\n"
3762 " uint64_t event,\n"
3763 " int event_handle,\n"
3765 " const char *buf, size_t buf_len,\n"
3766 " const uint64_t *array, size_t array_len);\n"
3771 #: ../src/guestfs.pod:1907
3773 "This is the type of the event callback function that you have to provide."
3777 #: ../src/guestfs.pod:1910
3779 "The basic parameters are: the handle (C<g>), the opaque user pointer "
3780 "(C<opaque>), the event class (eg. C<GUESTFS_EVENT_PROGRESS>), the event "
3781 "handle, and C<flags> which in the current API you should ignore."
3785 #: ../src/guestfs.pod:1914
3787 "The remaining parameters contain the event payload (if any). Each event may "
3788 "contain a payload, which usually relates to the event class, but for future "
3789 "proofing your code should be written to handle any payload for any event "
3794 #: ../src/guestfs.pod:1919
3796 "C<buf> and C<buf_len> contain a message buffer (if C<buf_len == 0>, then "
3797 "there is no message buffer). Note that this message buffer can contain "
3798 "arbitrary 8 bit data, including NUL bytes."
3802 #: ../src/guestfs.pod:1923
3804 "C<array> and C<array_len> is an array of 64 bit unsigned integers. At the "
3805 "moment this is only used for progress messages."
3809 #: ../src/guestfs.pod:1926
3810 msgid "EXAMPLE: CAPTURING LOG MESSAGES"
3814 #: ../src/guestfs.pod:1928
3816 "One motivation for the generic event API was to allow GUI programs to "
3817 "capture debug and other messages. In libguestfs E<le> 1.8 these were sent "
3818 "unconditionally to C<stderr>."
3822 #: ../src/guestfs.pod:1932
3824 "Events associated with log messages are: C<GUESTFS_EVENT_LIBRARY>, "
3825 "C<GUESTFS_EVENT_APPLIANCE> and C<GUESTFS_EVENT_TRACE>. (Note that error "
3826 "messages are not events; you must capture error messages separately)."
3830 #: ../src/guestfs.pod:1937
3832 "Programs have to set up a callback to capture the classes of events of "
3837 #: ../src/guestfs.pod:1940
3841 " guestfs_set_event_callback\n"
3842 " (g, message_callback,\n"
3843 " GUESTFS_EVENT_LIBRARY|GUESTFS_EVENT_APPLIANCE|\n"
3844 " GUESTFS_EVENT_TRACE,\n"
3845 " 0, NULL) == -1)\n"
3846 " if (eh == -1) {\n"
3847 " // handle error in the usual way\n"
3853 #: ../src/guestfs.pod:1950
3855 "The callback can then direct messages to the appropriate place. In this "
3856 "example, messages are directed to syslog:"
3860 #: ../src/guestfs.pod:1953
3864 " message_callback (\n"
3867 " uint64_t event,\n"
3868 " int event_handle,\n"
3870 " const char *buf, size_t buf_len,\n"
3871 " const uint64_t *array, size_t array_len)\n"
3873 " const int priority = LOG_USER|LOG_INFO;\n"
3874 " if (buf_len > 0)\n"
3875 " syslog (priority, \"event 0x%lx: %s\", event, buf);\n"
3881 #: ../src/guestfs.pod:1968
3882 msgid "PRIVATE DATA AREA"
3886 #: ../src/guestfs.pod:1970
3888 "You can attach named pieces of private data to the libguestfs handle, fetch "
3889 "them by name, and walk over them, for the lifetime of the handle. This is "
3890 "called the private data area and is only available from the C API."
3894 #: ../src/guestfs.pod:1975
3895 msgid "To attach a named piece of data, use the following call:"
3899 #: ../src/guestfs.pod:1977
3902 " void guestfs_set_private (guestfs_h *g, const char *key, void *data);\n"
3907 #: ../src/guestfs.pod:1979
3909 "C<key> is the name to associate with this data, and C<data> is an arbitrary "
3910 "pointer (which can be C<NULL>). Any previous item with the same name is "
3915 #: ../src/guestfs.pod:1983
3917 "You can use any C<key> you want, but names beginning with an underscore "
3918 "character are reserved for internal libguestfs purposes (for implementing "
3919 "language bindings). It is recommended to prefix the name with some unique "
3920 "string to avoid collisions with other users."
3924 #: ../src/guestfs.pod:1988
3925 msgid "To retrieve the pointer, use:"
3929 #: ../src/guestfs.pod:1990
3932 " void *guestfs_get_private (guestfs_h *g, const char *key);\n"
3937 #: ../src/guestfs.pod:1992
3939 "This function returns C<NULL> if either no data is found associated with "
3940 "C<key>, or if the user previously set the C<key>'s C<data> pointer to "
3945 #: ../src/guestfs.pod:1996
3947 "Libguestfs does not try to look at or interpret the C<data> pointer in any "
3948 "way. As far as libguestfs is concerned, it need not be a valid pointer at "
3949 "all. In particular, libguestfs does I<not> try to free the data when the "
3950 "handle is closed. If the data must be freed, then the caller must either "
3951 "free it before calling L</guestfs_close> or must set up a close callback to "
3952 "do it (see L</GUESTFS_EVENT_CLOSE>)."
3956 #: ../src/guestfs.pod:2003
3957 msgid "To walk over all entries, use these two functions:"
3961 #: ../src/guestfs.pod:2005
3964 " void *guestfs_first_private (guestfs_h *g, const char **key_rtn);\n"
3969 #: ../src/guestfs.pod:2007
3972 " void *guestfs_next_private (guestfs_h *g, const char **key_rtn);\n"
3977 #: ../src/guestfs.pod:2009
3979 "C<guestfs_first_private> returns the first key, pointer pair (\"first\" does "
3980 "not have any particular meaning -- keys are not returned in any defined "
3981 "order). A pointer to the key is returned in C<*key_rtn> and the "
3982 "corresponding data pointer is returned from the function. C<NULL> is "
3983 "returned if there are no keys stored in the handle."
3987 #: ../src/guestfs.pod:2015
3989 "C<guestfs_next_private> returns the next key, pointer pair. The return "
3990 "value of this function is also C<NULL> is there are no further entries to "
3995 #: ../src/guestfs.pod:2019
3996 msgid "Notes about walking over entries:"
4000 #: ../src/guestfs.pod:2025
4002 "You must not call C<guestfs_set_private> while walking over the entries."
4006 #: ../src/guestfs.pod:2030
4008 "The handle maintains an internal iterator which is reset when you call "
4009 "C<guestfs_first_private>. This internal iterator is invalidated when you "
4010 "call C<guestfs_set_private>."
4014 #: ../src/guestfs.pod:2036
4015 msgid "If you have set the data pointer associated with a key to C<NULL>, ie:"
4019 #: ../src/guestfs.pod:2038
4022 " guestfs_set_private (g, key, NULL);\n"
4027 #: ../src/guestfs.pod:2040
4028 msgid "then that C<key> is not returned when walking."
4032 #: ../src/guestfs.pod:2044
4034 "C<*key_rtn> is only valid until the next call to C<guestfs_first_private>, "
4035 "C<guestfs_next_private> or C<guestfs_set_private>."
4039 #: ../src/guestfs.pod:2050
4041 "The following example code shows how to print all keys and data pointers "
4042 "that are associated with the handle C<g>:"
4046 #: ../src/guestfs.pod:2053
4049 " const char *key;\n"
4050 " void *data = guestfs_first_private (g, &key);\n"
4051 " while (data != NULL)\n"
4053 " printf (\"key = %s, data = %p\\n\", key, data);\n"
4054 " data = guestfs_next_private (g, &key);\n"
4060 #: ../src/guestfs.pod:2061
4062 "More commonly you are only interested in keys that begin with an application-"
4063 "specific prefix C<foo_>. Modify the loop like so:"
4067 #: ../src/guestfs.pod:2064
4070 " const char *key;\n"
4071 " void *data = guestfs_first_private (g, &key);\n"
4072 " while (data != NULL)\n"
4074 " if (strncmp (key, \"foo_\", strlen (\"foo_\")) == 0)\n"
4075 " printf (\"key = %s, data = %p\\n\", key, data);\n"
4076 " data = guestfs_next_private (g, &key);\n"
4082 #: ../src/guestfs.pod:2073
4084 "If you need to modify keys while walking, then you have to jump back to the "
4085 "beginning of the loop. For example, to delete all keys prefixed with "
4090 #: ../src/guestfs.pod:2077
4093 " const char *key;\n"
4096 " data = guestfs_first_private (g, &key);\n"
4097 " while (data != NULL)\n"
4099 " if (strncmp (key, \"foo_\", strlen (\"foo_\")) == 0)\n"
4101 " guestfs_set_private (g, key, NULL);\n"
4102 " /* note that 'key' pointer is now invalid, and so is\n"
4103 " the internal iterator */\n"
4106 " data = guestfs_next_private (g, &key);\n"
4112 #: ../src/guestfs.pod:2093
4114 "Note that the above loop is guaranteed to terminate because the keys are "
4115 "being deleted, but other manipulations of keys within the loop might not "
4116 "terminate unless you also maintain an indication of which keys have been "
4121 #: ../src/guestfs.pod:2098 ../src/guestfs.pod:2103
4126 #: ../src/guestfs.pod:2100
4128 "<!-- old anchor for the next section --> <a name="
4129 "\"state_machine_and_low_level_event_api\"/>"
4131 "<!-- old anchor for the next section --> <a name="
4132 "\"state_machine_and_low_level_event_api\"/>"
4135 #: ../src/guestfs.pod:2105
4136 msgid "ARCHITECTURE"
4137 msgstr "АРХІТЕКТУРА"
4140 #: ../src/guestfs.pod:2107
4142 "Internally, libguestfs is implemented by running an appliance (a special "
4143 "type of small virtual machine) using L<qemu(1)>. Qemu runs as a child "
4144 "process of the main program."
4148 #: ../src/guestfs.pod:2111
4151 " ___________________\n"
4153 " | main program |\n"
4155 " | | child process / appliance\n"
4156 " | | __________________________\n"
4158 " +-------------------+ RPC | +-----------------+ |\n"
4159 " | libguestfs <--------------------> guestfsd | |\n"
4160 " | | | +-----------------+ |\n"
4161 " \\___________________/ | | Linux kernel | |\n"
4162 " | +--^--------------+ |\n"
4163 " \\_________|________________/\n"
4169 " \\______________/\n"
4174 #: ../src/guestfs.pod:2131
4176 "The library, linked to the main program, creates the child process and hence "
4177 "the appliance in the L</guestfs_launch> function."
4181 #: ../src/guestfs.pod:2134
4183 "Inside the appliance is a Linux kernel and a complete stack of userspace "
4184 "tools (such as LVM and ext2 programs) and a small controlling daemon called "
4185 "L</guestfsd>. The library talks to L</guestfsd> using remote procedure "
4186 "calls (RPC). There is a mostly one-to-one correspondence between libguestfs "
4187 "API calls and RPC calls to the daemon. Lastly the disk image(s) are "
4188 "attached to the qemu process which translates device access by the "
4189 "appliance's Linux kernel into accesses to the image."
4193 #: ../src/guestfs.pod:2143
4195 "A common misunderstanding is that the appliance \"is\" the virtual machine. "
4196 "Although the disk image you are attached to might also be used by some "
4197 "virtual machine, libguestfs doesn't know or care about this. (But you will "
4198 "care if both libguestfs's qemu process and your virtual machine are trying "
4199 "to update the disk image at the same time, since these usually results in "
4200 "massive disk corruption)."
4204 #: ../src/guestfs.pod:2150
4205 msgid "STATE MACHINE"
4206 msgstr "СКІНЧЕННИЙ АВТОМАТ"
4209 #: ../src/guestfs.pod:2152
4210 msgid "libguestfs uses a state machine to model the child process:"
4214 #: ../src/guestfs.pod:2154
4226 " / | \\ \\ guestfs_launch\n"
4227 " / | _\\__V______\n"
4229 " / | | LAUNCHING |\n"
4230 " / | \\___________/\n"
4232 " / | guestfs_launch\n"
4234 " ______ / __|____V\n"
4235 " / \\ ------> / \\\n"
4236 " | BUSY | | READY |\n"
4237 " \\______/ <------ \\________/\n"
4242 #: ../src/guestfs.pod:2176
4244 "The normal transitions are (1) CONFIG (when the handle is created, but there "
4245 "is no child process), (2) LAUNCHING (when the child process is booting up), "
4246 "(3) alternating between READY and BUSY as commands are issued to, and "
4247 "carried out by, the child process."
4251 #: ../src/guestfs.pod:2181
4253 "The guest may be killed by L</guestfs_kill_subprocess>, or may die "
4254 "asynchronously at any time (eg. due to some internal error), and that causes "
4255 "the state to transition back to CONFIG."
4259 #: ../src/guestfs.pod:2185
4261 "Configuration commands for qemu such as L</guestfs_add_drive> can only be "
4262 "issued when in the CONFIG state."
4266 #: ../src/guestfs.pod:2188
4268 "The API offers one call that goes from CONFIG through LAUNCHING to READY. "
4269 "L</guestfs_launch> blocks until the child process is READY to accept "
4270 "commands (or until some failure or timeout). L</guestfs_launch> internally "
4271 "moves the state from CONFIG to LAUNCHING while it is running."
4275 #: ../src/guestfs.pod:2194
4277 "API actions such as L</guestfs_mount> can only be issued when in the READY "
4278 "state. These API calls block waiting for the command to be carried out (ie. "
4279 "the state to transition to BUSY and then back to READY). There are no non-"
4280 "blocking versions, and no way to issue more than one command per handle at "
4285 #: ../src/guestfs.pod:2200
4287 "Finally, the child process sends asynchronous messages back to the main "
4288 "program, such as kernel log messages. You can register a callback to "
4289 "receive these messages."
4293 #: ../src/guestfs.pod:2204
4298 #: ../src/guestfs.pod:2206
4299 msgid "COMMUNICATION PROTOCOL"
4303 #: ../src/guestfs.pod:2208
4305 "Don't rely on using this protocol directly. This section documents how it "
4306 "currently works, but it may change at any time."
4310 #: ../src/guestfs.pod:2211
4312 "The protocol used to talk between the library and the daemon running inside "
4313 "the qemu virtual machine is a simple RPC mechanism built on top of XDR (RFC "
4314 "1014, RFC 1832, RFC 4506)."
4318 #: ../src/guestfs.pod:2215
4320 "The detailed format of structures is in C<src/guestfs_protocol.x> (note: "
4321 "this file is automatically generated)."
4325 #: ../src/guestfs.pod:2218
4327 "There are two broad cases, ordinary functions that don't have any C<FileIn> "
4328 "and C<FileOut> parameters, which are handled with very simple request/reply "
4329 "messages. Then there are functions that have any C<FileIn> or C<FileOut> "
4330 "parameters, which use the same request and reply messages, but they may also "
4331 "be followed by files sent using a chunked encoding."
4335 #: ../src/guestfs.pod:2225
4336 msgid "ORDINARY FUNCTIONS (NO FILEIN/FILEOUT PARAMS)"
4340 #: ../src/guestfs.pod:2227
4341 msgid "For ordinary functions, the request message is:"
4345 #: ../src/guestfs.pod:2229
4348 " total length (header + arguments,\n"
4349 " but not including the length word itself)\n"
4350 " struct guestfs_message_header (encoded as XDR)\n"
4351 " struct guestfs_<foo>_args (encoded as XDR)\n"
4356 #: ../src/guestfs.pod:2234
4358 "The total length field allows the daemon to allocate a fixed size buffer "
4359 "into which it slurps the rest of the message. As a result, the total length "
4360 "is limited to C<GUESTFS_MESSAGE_MAX> bytes (currently 4MB), which means the "
4361 "effective size of any request is limited to somewhere under this size."
4365 #: ../src/guestfs.pod:2240
4367 "Note also that many functions don't take any arguments, in which case the "
4368 "C<guestfs_I<foo>_args> is completely omitted."
4372 #: ../src/guestfs.pod:2243
4374 "The header contains the procedure number (C<guestfs_proc>) which is how the "
4375 "receiver knows what type of args structure to expect, or none at all."
4379 #: ../src/guestfs.pod:2247
4381 "For functions that take optional arguments, the optional arguments are "
4382 "encoded in the C<guestfs_I<foo>_args> structure in the same way as ordinary "
4383 "arguments. A bitmask in the header indicates which optional arguments are "
4384 "meaningful. The bitmask is also checked to see if it contains bits set "
4385 "which the daemon does not know about (eg. if more optional arguments were "
4386 "added in a later version of the library), and this causes the call to be "
4391 #: ../src/guestfs.pod:2255
4392 msgid "The reply message for ordinary functions is:"
4396 #: ../src/guestfs.pod:2257
4399 " total length (header + ret,\n"
4400 " but not including the length word itself)\n"
4401 " struct guestfs_message_header (encoded as XDR)\n"
4402 " struct guestfs_<foo>_ret (encoded as XDR)\n"
4407 #: ../src/guestfs.pod:2262
4409 "As above the C<guestfs_I<foo>_ret> structure may be completely omitted for "
4410 "functions that return no formal return values."
4414 #: ../src/guestfs.pod:2265
4416 "As above the total length of the reply is limited to C<GUESTFS_MESSAGE_MAX>."
4420 #: ../src/guestfs.pod:2268
4422 "In the case of an error, a flag is set in the header, and the reply message "
4423 "is slightly changed:"
4427 #: ../src/guestfs.pod:2271
4430 " total length (header + error,\n"
4431 " but not including the length word itself)\n"
4432 " struct guestfs_message_header (encoded as XDR)\n"
4433 " struct guestfs_message_error (encoded as XDR)\n"
4438 #: ../src/guestfs.pod:2276
4440 "The C<guestfs_message_error> structure contains the error message as a "
4445 #: ../src/guestfs.pod:2279
4446 msgid "FUNCTIONS THAT HAVE FILEIN PARAMETERS"
4450 #: ../src/guestfs.pod:2281
4452 "A C<FileIn> parameter indicates that we transfer a file I<into> the guest. "
4453 "The normal request message is sent (see above). However this is followed by "
4454 "a sequence of file chunks."
4458 #: ../src/guestfs.pod:2285
4461 " total length (header + arguments,\n"
4462 " but not including the length word itself,\n"
4463 " and not including the chunks)\n"
4464 " struct guestfs_message_header (encoded as XDR)\n"
4465 " struct guestfs_<foo>_args (encoded as XDR)\n"
4466 " sequence of chunks for FileIn param #0\n"
4467 " sequence of chunks for FileIn param #1 etc.\n"
4472 #: ../src/guestfs.pod:2293
4473 msgid "The \"sequence of chunks\" is:"
4477 #: ../src/guestfs.pod:2295
4480 " length of chunk (not including length word itself)\n"
4481 " struct guestfs_chunk (encoded as XDR)\n"
4482 " length of chunk\n"
4483 " struct guestfs_chunk (encoded as XDR)\n"
4485 " length of chunk\n"
4486 " struct guestfs_chunk (with data.data_len == 0)\n"
4491 #: ../src/guestfs.pod:2303
4493 "The final chunk has the C<data_len> field set to zero. Additionally a flag "
4494 "is set in the final chunk to indicate either successful completion or early "
4499 #: ../src/guestfs.pod:2307
4501 "At time of writing there are no functions that have more than one FileIn "
4502 "parameter. However this is (theoretically) supported, by sending the "
4503 "sequence of chunks for each FileIn parameter one after another (from left to "
4508 #: ../src/guestfs.pod:2312
4510 "Both the library (sender) I<and> the daemon (receiver) may cancel the "
4511 "transfer. The library does this by sending a chunk with a special flag set "
4512 "to indicate cancellation. When the daemon sees this, it cancels the whole "
4513 "RPC, does I<not> send any reply, and goes back to reading the next request."
4517 #: ../src/guestfs.pod:2318
4519 "The daemon may also cancel. It does this by writing a special word "
4520 "C<GUESTFS_CANCEL_FLAG> to the socket. The library listens for this during "
4521 "the transfer, and if it gets it, it will cancel the transfer (it sends a "
4522 "cancel chunk). The special word is chosen so that even if cancellation "
4523 "happens right at the end of the transfer (after the library has finished "
4524 "writing and has started listening for the reply), the \"spurious\" cancel "
4525 "flag will not be confused with the reply message."
4529 #: ../src/guestfs.pod:2327
4531 "This protocol allows the transfer of arbitrary sized files (no 32 bit "
4532 "limit), and also files where the size is not known in advance (eg. from "
4533 "pipes or sockets). However the chunks are rather small "
4534 "(C<GUESTFS_MAX_CHUNK_SIZE>), so that neither the library nor the daemon need "
4535 "to keep much in memory."
4539 #: ../src/guestfs.pod:2333
4540 msgid "FUNCTIONS THAT HAVE FILEOUT PARAMETERS"
4544 #: ../src/guestfs.pod:2335
4546 "The protocol for FileOut parameters is exactly the same as for FileIn "
4547 "parameters, but with the roles of daemon and library reversed."
4551 #: ../src/guestfs.pod:2338
4554 " total length (header + ret,\n"
4555 " but not including the length word itself,\n"
4556 " and not including the chunks)\n"
4557 " struct guestfs_message_header (encoded as XDR)\n"
4558 " struct guestfs_<foo>_ret (encoded as XDR)\n"
4559 " sequence of chunks for FileOut param #0\n"
4560 " sequence of chunks for FileOut param #1 etc.\n"
4565 #: ../src/guestfs.pod:2346
4566 msgid "INITIAL MESSAGE"
4570 #: ../src/guestfs.pod:2348
4572 "When the daemon launches it sends an initial word (C<GUESTFS_LAUNCH_FLAG>) "
4573 "which indicates that the guest and daemon is alive. This is what L</"
4574 "guestfs_launch> waits for."
4578 #: ../src/guestfs.pod:2352
4579 msgid "PROGRESS NOTIFICATION MESSAGES"
4583 #: ../src/guestfs.pod:2354
4585 "The daemon may send progress notification messages at any time. These are "
4586 "distinguished by the normal length word being replaced by "
4587 "C<GUESTFS_PROGRESS_FLAG>, followed by a fixed size progress message."
4591 #: ../src/guestfs.pod:2358
4593 "The library turns them into progress callbacks (see L</"
4594 "GUESTFS_EVENT_PROGRESS>) if there is a callback registered, or discards them "
4599 #: ../src/guestfs.pod:2362
4601 "The daemon self-limits the frequency of progress messages it sends (see "
4602 "C<daemon/proto.c:notify_progress>). Not all calls generate progress "
4607 #: ../src/guestfs.pod:2366
4608 msgid "LIBGUESTFS VERSION NUMBERS"
4612 #: ../src/guestfs.pod:2368
4614 "Since April 2010, libguestfs has started to make separate development and "
4615 "stable releases, along with corresponding branches in our git repository. "
4616 "These separate releases can be identified by version number:"
4620 #: ../src/guestfs.pod:2373
4623 " even numbers for stable: 1.2.x, 1.4.x, ...\n"
4624 " .-------- odd numbers for development: 1.3.x, 1.5.x, ...\n"
4630 " | `-------- sub-version\n"
4632 " `------ always '1' because we don't change the ABI\n"
4637 #: ../src/guestfs.pod:2384
4638 msgid "Thus \"1.3.5\" is the 5th update to the development branch \"1.3\"."
4642 #: ../src/guestfs.pod:2386
4644 "As time passes we cherry pick fixes from the development branch and backport "
4645 "those into the stable branch, the effect being that the stable branch should "
4646 "get more stable and less buggy over time. So the stable releases are ideal "
4647 "for people who don't need new features but would just like the software to "
4652 #: ../src/guestfs.pod:2392
4653 msgid "Our criteria for backporting changes are:"
4657 #: ../src/guestfs.pod:2398
4659 "Documentation changes which don't affect any code are backported unless the "
4660 "documentation refers to a future feature which is not in stable."
4664 #: ../src/guestfs.pod:2404
4666 "Bug fixes which are not controversial, fix obvious problems, and have been "
4667 "well tested are backported."
4671 #: ../src/guestfs.pod:2409
4673 "Simple rearrangements of code which shouldn't affect how it works get "
4674 "backported. This is so that the code in the two branches doesn't get too "
4675 "far out of step, allowing us to backport future fixes more easily."
4679 #: ../src/guestfs.pod:2415
4681 "We I<don't> backport new features, new APIs, new tools etc, except in one "
4682 "exceptional case: the new feature is required in order to implement an "
4683 "important bug fix."
4687 #: ../src/guestfs.pod:2421
4689 "A new stable branch starts when we think the new features in development are "
4690 "substantial and compelling enough over the current stable branch to warrant "
4691 "it. When that happens we create new stable and development versions 1.N.0 "
4692 "and 1.(N+1).0 [N is even]. The new dot-oh release won't necessarily be so "
4693 "stable at this point, but by backporting fixes from development, that branch "
4694 "will stabilize over time."
4698 #: ../src/guestfs.pod:2429
4699 msgid "EXTENDING LIBGUESTFS"
4703 #: ../src/guestfs.pod:2431
4704 msgid "ADDING A NEW API ACTION"
4708 #: ../src/guestfs.pod:2433
4710 "Large amounts of boilerplate code in libguestfs (RPC, bindings, "
4711 "documentation) are generated, and this makes it easy to extend the "
4716 #: ../src/guestfs.pod:2437
4717 msgid "To add a new API action there are two changes:"
4721 #: ../src/guestfs.pod:2443
4723 "You need to add a description of the call (name, parameters, return type, "
4724 "tests, documentation) to C<generator/generator_actions.ml>."
4728 #: ../src/guestfs.pod:2446
4730 "There are two sorts of API action, depending on whether the call goes "
4731 "through to the daemon in the appliance, or is serviced entirely by the "
4732 "library (see L</ARCHITECTURE> above). L</guestfs_sync> is an example of the "
4733 "former, since the sync is done in the appliance. L</guestfs_set_trace> is "
4734 "an example of the latter, since a trace flag is maintained in the handle and "
4735 "all tracing is done on the library side."
4739 #: ../src/guestfs.pod:2454
4741 "Most new actions are of the first type, and get added to the "
4742 "C<daemon_functions> list. Each function has a unique procedure number used "
4743 "in the RPC protocol which is assigned to that action when we publish "
4744 "libguestfs and cannot be reused. Take the latest procedure number and "
4749 #: ../src/guestfs.pod:2460
4751 "For library-only actions of the second type, add to the "
4752 "C<non_daemon_functions> list. Since these functions are serviced by the "
4753 "library and do not travel over the RPC mechanism to the daemon, these "
4754 "functions do not need a procedure number, and so the procedure number is set "
4759 #: ../src/guestfs.pod:2468
4760 msgid "Implement the action (in C):"
4764 #: ../src/guestfs.pod:2470
4766 "For daemon actions, implement the function C<do_E<lt>nameE<gt>> in the "
4767 "C<daemon/> directory."
4771 #: ../src/guestfs.pod:2473
4773 "For library actions, implement the function C<guestfs__E<lt>nameE<gt>> "
4774 "(note: double underscore) in the C<src/> directory."
4778 #: ../src/guestfs.pod:2476
4779 msgid "In either case, use another function as an example of what to do."
4783 #: ../src/guestfs.pod:2480
4784 msgid "After making these changes, use C<make> to compile."
4788 #: ../src/guestfs.pod:2482
4790 "Note that you don't need to implement the RPC, language bindings, manual "
4791 "pages or anything else. It's all automatically generated from the OCaml "
4796 #: ../src/guestfs.pod:2486
4797 msgid "ADDING TESTS FOR AN API ACTION"
4801 #: ../src/guestfs.pod:2488
4803 "You can supply zero or as many tests as you want per API call. The tests "
4804 "can either be added as part of the API description (C<generator/"
4805 "generator_actions.ml>), or in some rarer cases you may want to drop a script "
4806 "into C<regressions/>. Note that adding a script to C<regressions/> is "
4807 "slower, so if possible use the first method."
4811 #: ../src/guestfs.pod:2494
4813 "The following describes the test environment used when you add an API test "
4814 "in C<generator_actions.ml>."
4818 #: ../src/guestfs.pod:2497
4819 msgid "The test environment has 4 block devices:"
4823 #: ../src/guestfs.pod:2501
4824 msgid "C</dev/sda> 500MB"
4828 #: ../src/guestfs.pod:2503
4829 msgid "General block device for testing."
4833 #: ../src/guestfs.pod:2505
4834 msgid "C</dev/sdb> 50MB"
4838 #: ../src/guestfs.pod:2507
4840 "C</dev/sdb1> is an ext2 filesystem used for testing filesystem write "
4845 #: ../src/guestfs.pod:2510
4846 msgid "C</dev/sdc> 10MB"
4850 #: ../src/guestfs.pod:2512
4851 msgid "Used in a few tests where two block devices are needed."
4855 #: ../src/guestfs.pod:2514
4857 msgstr "C</dev/sdd>"
4860 #: ../src/guestfs.pod:2516
4861 msgid "ISO with fixed content (see C<images/test.iso>)."
4865 #: ../src/guestfs.pod:2520
4867 "To be able to run the tests in a reasonable amount of time, the libguestfs "
4868 "appliance and block devices are reused between tests. So don't try testing "
4869 "L</guestfs_kill_subprocess> :-x"
4873 #: ../src/guestfs.pod:2524
4875 "Each test starts with an initial scenario, selected using one of the "
4876 "C<Init*> expressions, described in C<generator/generator_types.ml>. These "
4877 "initialize the disks mentioned above in a particular way as documented in "
4878 "C<generator_types.ml>. You should not assume anything about the previous "
4879 "contents of other disks that are not initialized."