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.
9 "Project-Id-Version: libguestfs 1.7.10\n"
10 "Report-Msgid-Bugs-To: libguestfs@redhat.com\n"
11 "POT-Creation-Date: 2010-11-17 20:52+0000\n"
12 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
13 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
14 "Language-Team: LANGUAGE <LL@li.org>\n"
16 "Content-Type: text/plain; charset=utf-8\n"
17 "Content-Transfer-Encoding: ENCODING"
20 #: ../src/guestfs.pod:1 ../fish/guestfish.pod:1 ../test-tool/libguestfs-test-tool.pod:1 ../fuse/guestmount.pod:1 ../inspector/virt-inspector.pl:31 ../tools/virt-edit.pl:30 ../tools/virt-win-reg.pl:33 ../tools/virt-df.pl:32 ../tools/virt-ls.pl:30 ../tools/virt-resize.pl:38 ../tools/virt-list-filesystems.pl:28 ../tools/virt-tar.pl:29 ../tools/virt-rescue.pl:29 ../tools/virt-make-fs.pl:33 ../tools/virt-list-partitions.pl:28
25 #: ../src/guestfs.pod:3 ../fish/guestfish.pod:3 ../test-tool/libguestfs-test-tool.pod:3 ../fuse/guestmount.pod:3 ../inspector/virt-inspector.pl:33 ../tools/virt-edit.pl:32 ../tools/virt-win-reg.pl:35 ../tools/virt-df.pl:34 ../tools/virt-ls.pl:32 ../tools/virt-resize.pl:40 ../tools/virt-list-filesystems.pl:30 ../tools/virt-tar.pl:31 ../tools/virt-rescue.pl:31 ../tools/virt-make-fs.pl:35 ../tools/virt-list-partitions.pl:30
30 #: ../src/guestfs.pod:5
31 msgid "guestfs - Library for accessing and modifying virtual machine images"
35 #: ../src/guestfs.pod:7 ../fish/guestfish.pod:7 ../test-tool/libguestfs-test-tool.pod:7 ../fuse/guestmount.pod:7 ../inspector/virt-inspector.pl:37 ../tools/virt-edit.pl:36 ../tools/virt-win-reg.pl:39 ../tools/virt-df.pl:38 ../tools/virt-ls.pl:36 ../tools/virt-resize.pl:44 ../tools/virt-list-filesystems.pl:34 ../tools/virt-tar.pl:35 ../tools/virt-rescue.pl:35 ../tools/virt-make-fs.pl:39 ../tools/virt-list-partitions.pl:34
40 #: ../src/guestfs.pod:9
43 " #include <guestfs.h>\n"
48 #: ../src/guestfs.pod:11
51 " guestfs_h *g = guestfs_create ();\n"
52 " guestfs_add_drive (g, \"guest.img\");\n"
53 " guestfs_launch (g);\n"
54 " guestfs_mount (g, \"/dev/sda1\", \"/\");\n"
55 " guestfs_touch (g, \"/hello\");\n"
56 " guestfs_umount (g, \"/\");\n"
57 " guestfs_sync (g);\n"
58 " guestfs_close (g);\n"
63 #: ../src/guestfs.pod:20
66 " cc prog.c -o prog -lguestfs\n"
68 " cc prog.c -o prog `pkg-config libguestfs --cflags --libs`\n"
73 #: ../src/guestfs.pod:24 ../fish/guestfish.pod:30 ../test-tool/libguestfs-test-tool.pod:11 ../fuse/guestmount.pod:20 ../inspector/virt-inspector.pl:43 ../tools/virt-edit.pl:50 ../tools/virt-win-reg.pl:63 ../tools/virt-df.pl:46 ../tools/virt-ls.pl:42 ../tools/virt-resize.pl:50 ../tools/virt-list-filesystems.pl:40 ../tools/virt-tar.pl:72 ../tools/virt-rescue.pl:51 ../tools/virt-make-fs.pl:47 ../tools/virt-list-partitions.pl:40
78 #: ../src/guestfs.pod:26
80 "Libguestfs is a library for accessing and modifying guest disk images. "
81 "Amongst the things this is good for: making batch configuration changes to "
82 "guests, getting disk used/free statistics (see also: virt-df), migrating "
83 "between virtualization systems (see also: virt-p2v), performing partial "
84 "backups, performing partial guest clones, cloning guests and changing "
85 "registry/UUID/hostname info, and much else besides."
89 #: ../src/guestfs.pod:34
91 "Libguestfs uses Linux kernel and qemu code, and can access any type of guest "
92 "filesystem that Linux and qemu can, including but not limited to: ext2/3/4, "
93 "btrfs, FAT and NTFS, LVM, many different disk partition schemes, qcow, "
98 #: ../src/guestfs.pod:39
100 "Libguestfs provides ways to enumerate guest storage (eg. partitions, LVs, "
101 "what filesystem is in each LV, etc.). It can also run commands in the "
102 "context of the guest. Also you can access filesystems over FUSE."
106 #: ../src/guestfs.pod:44
108 "Libguestfs is a library that can be linked with C and C++ management "
109 "programs (or management programs written in OCaml, Perl, Python, Ruby, Java, "
110 "PHP, Haskell or C#). You can also use it from shell scripts or the command "
115 #: ../src/guestfs.pod:49
117 "You don't need to be root to use libguestfs, although obviously you do need "
118 "enough permissions to access the disk images."
122 #: ../src/guestfs.pod:52
124 "Libguestfs is a large API because it can do many things. For a gentle "
125 "introduction, please read the L</API OVERVIEW> section next."
129 #: ../src/guestfs.pod:55
134 #: ../src/guestfs.pod:57
136 "This section provides a gentler overview of the libguestfs API. We also try "
137 "to group API calls together, where that may not be obvious from reading "
138 "about the individual calls in the main section of this manual."
142 #: ../src/guestfs.pod:62
147 #: ../src/guestfs.pod:64
149 "Before you can use libguestfs calls, you have to create a handle. Then you "
150 "must add at least one disk image to the handle, followed by launching the "
151 "handle, then performing whatever operations you want, and finally closing "
152 "the handle. By convention we use the single letter C<g> for the name of the "
153 "handle variable, although of course you can use any name you want."
157 #: ../src/guestfs.pod:71
158 msgid "The general structure of all libguestfs-using programs looks like this:"
162 #: ../src/guestfs.pod:74
165 " guestfs_h *g = guestfs_create ();\n"
170 #: ../src/guestfs.pod:76
173 " /* Call guestfs_add_drive additional times if there are\n"
174 " * multiple disk images.\n"
176 " guestfs_add_drive (g, \"guest.img\");\n"
181 #: ../src/guestfs.pod:81
184 " /* Most manipulation calls won't work until you've launched\n"
185 " * the handle 'g'. You have to do this _after_ adding drives\n"
186 " * and _before_ other commands.\n"
188 " guestfs_launch (g);\n"
193 #: ../src/guestfs.pod:87
196 " /* Now you can examine what partitions, LVs etc are available.\n"
198 " char **partitions = guestfs_list_partitions (g);\n"
199 " char **logvols = guestfs_lvs (g);\n"
204 #: ../src/guestfs.pod:92
207 " /* To access a filesystem in the image, you must mount it.\n"
209 " guestfs_mount (g, \"/dev/sda1\", \"/\");\n"
214 #: ../src/guestfs.pod:96
217 " /* Now you can perform filesystem actions on the guest\n"
220 " guestfs_touch (g, \"/hello\");\n"
225 #: ../src/guestfs.pod:101
228 " /* You only need to call guestfs_sync if you have made\n"
229 " * changes to the guest image. (But if you've made changes\n"
230 " * then you *must* sync). See also: guestfs_umount and\n"
231 " * guestfs_umount_all calls.\n"
233 " guestfs_sync (g);\n"
238 #: ../src/guestfs.pod:108
241 " /* Close the handle 'g'. */\n"
242 " guestfs_close (g);\n"
247 #: ../src/guestfs.pod:111
249 "The code above doesn't include any error checking. In real code you should "
250 "check return values carefully for errors. In general all functions that "
251 "return integers return C<-1> on error, and all functions that return "
252 "pointers return C<NULL> on error. See section L</ERROR HANDLING> below for "
253 "how to handle errors, and consult the documentation for each function call "
254 "below to see precisely how they return error indications."
258 #: ../src/guestfs.pod:119
263 #: ../src/guestfs.pod:121
265 "The image filename (C<\"guest.img\"> in the example above) could be a disk "
266 "image from a virtual machine, a L<dd(1)> copy of a physical hard disk, an "
267 "actual block device, or simply an empty file of zeroes that you have created "
268 "through L<posix_fallocate(3)>. Libguestfs lets you do useful things to all "
273 #: ../src/guestfs.pod:127
275 "The call you should use in modern code for adding drives is "
276 "L</guestfs_add_drive_opts>. To add a disk image, allowing writes, and "
277 "specifying that the format is raw, do:"
281 #: ../src/guestfs.pod:131
284 " guestfs_add_drive_opts (g, filename,\n"
285 " GUESTFS_ADD_DRIVE_OPTS_FORMAT, \"raw\",\n"
291 #: ../src/guestfs.pod:135
292 msgid "You can add a disk read-only using:"
296 #: ../src/guestfs.pod:137
299 " guestfs_add_drive_opts (g, filename,\n"
300 " GUESTFS_ADD_DRIVE_OPTS_FORMAT, \"raw\",\n"
301 " GUESTFS_ADD_DRIVE_OPTS_READONLY, 1,\n"
307 #: ../src/guestfs.pod:142
309 "or by calling the older function L</guestfs_add_drive_ro>. In either case "
310 "libguestfs won't modify the file."
314 #: ../src/guestfs.pod:145
316 "Be extremely cautious if the disk image is in use, eg. if it is being used "
317 "by a virtual machine. Adding it read-write will almost certainly cause disk "
318 "corruption, but adding it read-only is safe."
322 #: ../src/guestfs.pod:149
324 "You must add at least one disk image, and you may add multiple disk images. "
325 "In the API, the disk images are usually referred to as C</dev/sda> (for the "
326 "first one you added), C</dev/sdb> (for the second one you added), etc."
330 #: ../src/guestfs.pod:154
332 "Once L</guestfs_launch> has been called you cannot add any more images. You "
333 "can call L</guestfs_list_devices> to get a list of the device names, in the "
334 "order that you added them. See also L</BLOCK DEVICE NAMING> below."
338 #: ../src/guestfs.pod:159
343 #: ../src/guestfs.pod:161
345 "Before you can read or write files, create directories and so on in a disk "
346 "image that contains filesystems, you have to mount those filesystems using "
347 "L</guestfs_mount>. If you already know that a disk image contains (for "
348 "example) one partition with a filesystem on that partition, then you can "
353 #: ../src/guestfs.pod:167
356 " guestfs_mount (g, \"/dev/sda1\", \"/\");\n"
361 #: ../src/guestfs.pod:169
363 "where C</dev/sda1> means literally the first partition (C<1>) of the first "
364 "disk image that we added (C</dev/sda>). If the disk contains Linux LVM2 "
365 "logical volumes you could refer to those instead (eg. C</dev/VG/LV>)."
369 #: ../src/guestfs.pod:173
371 "If you are given a disk image and you don't know what it contains then you "
372 "have to find out. Libguestfs can do that too: use "
373 "L</guestfs_list_partitions> and L</guestfs_lvs> to list possible partitions "
374 "and LVs, and either try mounting each to see what is mountable, or else "
375 "examine them with L</guestfs_vfs_type> or L</guestfs_file>. Libguestfs also "
376 "has a set of APIs for inspection of disk images (see L</INSPECTION> below). "
377 "But you might find it easier to look at higher level programs built on top "
378 "of libguestfs, in particular L<virt-inspector(1)>."
382 #: ../src/guestfs.pod:183
384 "To mount a disk image read-only, use L</guestfs_mount_ro>. There are "
385 "several other variations of the C<guestfs_mount_*> call."
389 #: ../src/guestfs.pod:186
390 msgid "FILESYSTEM ACCESS AND MODIFICATION"
394 #: ../src/guestfs.pod:188
396 "The majority of the libguestfs API consists of fairly low-level calls for "
397 "accessing and modifying the files, directories, symlinks etc on mounted "
398 "filesystems. There are over a hundred such calls which you can find listed "
399 "in detail below in this man page, and we don't even pretend to cover them "
400 "all in this overview."
404 #: ../src/guestfs.pod:194
406 "Specify filenames as full paths, starting with C<\"/\"> and including the "
411 #: ../src/guestfs.pod:197
413 "For example, if you mounted a filesystem at C<\"/\"> and you want to read "
414 "the file called C<\"etc/passwd\"> then you could do:"
418 #: ../src/guestfs.pod:200
421 " char *data = guestfs_cat (g, \"/etc/passwd\");\n"
426 #: ../src/guestfs.pod:202
428 "This would return C<data> as a newly allocated buffer containing the full "
429 "content of that file (with some conditions: see also L</DOWNLOADING> below), "
430 "or C<NULL> if there was an error."
434 #: ../src/guestfs.pod:206
436 "As another example, to create a top-level directory on that filesystem "
437 "called C<\"var\"> you would do:"
441 #: ../src/guestfs.pod:209
444 " guestfs_mkdir (g, \"/var\");\n"
449 #: ../src/guestfs.pod:211
450 msgid "To create a symlink you could do:"
454 #: ../src/guestfs.pod:213
457 " guestfs_ln_s (g, \"/etc/init.d/portmap\",\n"
458 " \"/etc/rc3.d/S30portmap\");\n"
463 #: ../src/guestfs.pod:216
465 "Libguestfs will reject attempts to use relative paths and there is no "
466 "concept of a current working directory."
470 #: ../src/guestfs.pod:219
472 "Libguestfs can return errors in many situations: for example if the "
473 "filesystem isn't writable, or if a file or directory that you requested "
474 "doesn't exist. If you are using the C API (documented here) you have to "
475 "check for those error conditions after each call. (Other language bindings "
476 "turn these errors into exceptions)."
480 #: ../src/guestfs.pod:225
482 "File writes are affected by the per-handle umask, set by calling "
483 "L</guestfs_umask> and defaulting to 022. See L</UMASK>."
487 #: ../src/guestfs.pod:228
492 #: ../src/guestfs.pod:230
494 "Libguestfs contains API calls to read, create and modify partition tables on "
499 #: ../src/guestfs.pod:233
501 "In the common case where you want to create a single partition covering the "
502 "whole disk, you should use the L</guestfs_part_disk> call:"
506 #: ../src/guestfs.pod:237
509 " const char *parttype = \"mbr\";\n"
510 " if (disk_is_larger_than_2TB)\n"
511 " parttype = \"gpt\";\n"
512 " guestfs_part_disk (g, \"/dev/sda\", parttype);\n"
517 #: ../src/guestfs.pod:242
519 "Obviously this effectively wipes anything that was on that disk image "
524 #: ../src/guestfs.pod:245
529 #: ../src/guestfs.pod:247
531 "Libguestfs provides access to a large part of the LVM2 API, such as "
532 "L</guestfs_lvcreate> and L</guestfs_vgremove>. It won't make much sense "
533 "unless you familiarize yourself with the concepts of physical volumes, "
534 "volume groups and logical volumes."
538 #: ../src/guestfs.pod:252
540 "This author strongly recommends reading the LVM HOWTO, online at "
541 "L<http://tldp.org/HOWTO/LVM-HOWTO/>."
545 #: ../src/guestfs.pod:255
550 #: ../src/guestfs.pod:257
552 "Use L</guestfs_cat> to download small, text only files. This call is "
553 "limited to files which are less than 2 MB and which cannot contain any ASCII "
554 "NUL (C<\\0>) characters. However it has a very simple to use API."
558 #: ../src/guestfs.pod:262
560 "L</guestfs_read_file> can be used to read files which contain arbitrary 8 "
561 "bit data, since it returns a (pointer, size) pair. However it is still "
562 "limited to \"small\" files, less than 2 MB."
566 #: ../src/guestfs.pod:266
568 "L</guestfs_download> can be used to download any file, with no limits on "
569 "content or size (even files larger than 4 GB)."
573 #: ../src/guestfs.pod:269
574 msgid "To download multiple files, see L</guestfs_tar_out> and L</guestfs_tgz_out>."
578 #: ../src/guestfs.pod:272
583 #: ../src/guestfs.pod:274
585 "It's often the case that you want to write a file or files to the disk "
590 #: ../src/guestfs.pod:277
592 "To write a small file with fixed content, use L</guestfs_write>. To create "
593 "a file of all zeroes, use L</guestfs_truncate_size> (sparse) or "
594 "L</guestfs_fallocate64> (with all disk blocks allocated). There are a "
595 "variety of other functions for creating test files, for example "
596 "L</guestfs_fill> and L</guestfs_fill_pattern>."
600 #: ../src/guestfs.pod:283
602 "To upload a single file, use L</guestfs_upload>. This call has no limits on "
603 "file content or size (even files larger than 4 GB)."
607 #: ../src/guestfs.pod:286
608 msgid "To upload multiple files, see L</guestfs_tar_in> and L</guestfs_tgz_in>."
612 #: ../src/guestfs.pod:288
614 "However the fastest way to upload I<large numbers of arbitrary files> is to "
615 "turn them into a squashfs or CD ISO (see L<mksquashfs(8)> and "
616 "L<mkisofs(8)>), then attach this using L</guestfs_add_drive_ro>. If you add "
617 "the drive in a predictable way (eg. adding it last after all other drives) "
618 "then you can get the device name from L</guestfs_list_devices> and mount it "
619 "directly using L</guestfs_mount_ro>. Note that squashfs images are "
620 "sometimes non-portable between kernel versions, and they don't support "
621 "labels or UUIDs. If you want to pre-build an image or you need to mount it "
622 "using a label or UUID, use an ISO image instead."
626 #: ../src/guestfs.pod:299
631 #: ../src/guestfs.pod:301
633 "There are various different commands for copying between files and devices "
634 "and in and out of the guest filesystem. These are summarised in the table "
639 #: ../src/guestfs.pod:307
640 msgid "B<file> to B<file>"
644 #: ../src/guestfs.pod:309
646 "Use L</guestfs_cp> to copy a single file, or L</guestfs_cp_a> to copy "
647 "directories recursively."
651 #: ../src/guestfs.pod:312
652 msgid "B<file or device> to B<file or device>"
656 #: ../src/guestfs.pod:314
658 "Use L</guestfs_dd> which efficiently uses L<dd(1)> to copy between files and "
659 "devices in the guest."
663 #: ../src/guestfs.pod:317
664 msgid "Example: duplicate the contents of an LV:"
668 #: ../src/guestfs.pod:319
671 " guestfs_dd (g, \"/dev/VG/Original\", \"/dev/VG/Copy\");\n"
676 #: ../src/guestfs.pod:321
678 "The destination (C</dev/VG/Copy>) must be at least as large as the source "
679 "(C</dev/VG/Original>). To copy less than the whole source device, use "
680 "L</guestfs_copy_size>."
684 #: ../src/guestfs.pod:325
685 msgid "B<file on the host> to B<file or device>"
689 #: ../src/guestfs.pod:327
690 msgid "Use L</guestfs_upload>. See L</UPLOADING> above."
694 #: ../src/guestfs.pod:329
695 msgid "B<file or device> to B<file on the host>"
699 #: ../src/guestfs.pod:331
700 msgid "Use L</guestfs_download>. See L</DOWNLOADING> above."
704 #: ../src/guestfs.pod:335
705 msgid "LISTING FILES"
709 #: ../src/guestfs.pod:337
711 "L</guestfs_ll> is just designed for humans to read (mainly when using the "
712 "L<guestfish(1)>-equivalent command C<ll>)."
716 #: ../src/guestfs.pod:340
718 "L</guestfs_ls> is a quick way to get a list of files in a directory from "
719 "programs, as a flat list of strings."
723 #: ../src/guestfs.pod:343
725 "L</guestfs_readdir> is a programmatic way to get a list of files in a "
726 "directory, plus additional information about each one. It is more "
727 "equivalent to using the L<readdir(3)> call on a local filesystem."
731 #: ../src/guestfs.pod:347
733 "L</guestfs_find> and L</guestfs_find0> can be used to recursively list "
738 #: ../src/guestfs.pod:350
739 msgid "RUNNING COMMANDS"
743 #: ../src/guestfs.pod:352
745 "Although libguestfs is primarily an API for manipulating files inside guest "
746 "images, we also provide some limited facilities for running commands inside "
751 #: ../src/guestfs.pod:356
752 msgid "There are many limitations to this:"
756 #: ../src/guestfs.pod:360 ../src/guestfs.pod:365 ../src/guestfs.pod:370 ../src/guestfs.pod:374 ../src/guestfs.pod:379 ../src/guestfs.pod:383 ../src/guestfs.pod:388 ../src/guestfs.pod:393 ../src/guestfs.pod:957 ../src/guestfs.pod:961 ../src/guestfs.pod:965 ../src/guestfs.pod:970 ../src/guestfs.pod:978 ../src/guestfs.pod:997 ../src/guestfs.pod:1005 ../src/guestfs.pod:1027 ../src/guestfs.pod:1031 ../src/guestfs.pod:1035 ../src/guestfs.pod:1039 ../src/guestfs.pod:1043 ../src/guestfs.pod:1047 ../src/guestfs.pod:1529 ../src/guestfs.pod:1534 ../src/guestfs.pod:1538 ../src/guestfs.pod:1648 ../src/guestfs.pod:1653 ../src/guestfs.pod:1657 ../src/guestfs.pod:2001 ../src/guestfs.pod:2007 ../src/guestfs.pod:2012 ../src/guestfs.pod:2018 ../src/guestfs.pod:2125 ../src/guestfs.pod:2129 ../src/guestfs.pod:2133 ../src/guestfs.pod:2137 ../src/guestfs-actions.pod:15 ../src/guestfs-actions.pod:22 ../src/guestfs-actions.pod:569 ../src/guestfs-actions.pod:577 ../src/guestfs-actions.pod:584 ../src/guestfs-actions.pod:591 ../src/guestfs-actions.pod:1587 ../src/guestfs-actions.pod:1591 ../src/guestfs-actions.pod:1595 ../src/guestfs-actions.pod:1599 ../src/guestfs-actions.pod:1607 ../src/guestfs-actions.pod:1611 ../src/guestfs-actions.pod:1615 ../src/guestfs-actions.pod:1625 ../src/guestfs-actions.pod:1629 ../src/guestfs-actions.pod:1633 ../src/guestfs-actions.pod:1771 ../src/guestfs-actions.pod:1775 ../src/guestfs-actions.pod:1780 ../src/guestfs-actions.pod:1785 ../src/guestfs-actions.pod:1846 ../src/guestfs-actions.pod:1850 ../src/guestfs-actions.pod:1855 ../fish/guestfish.pod:376 ../fish/guestfish.pod:380 ../fish/guestfish.pod:384 ../fish/guestfish.pod:388 ../fish/guestfish-actions.pod:13 ../fish/guestfish-actions.pod:20 ../fish/guestfish-actions.pod:375 ../fish/guestfish-actions.pod:383 ../fish/guestfish-actions.pod:390 ../fish/guestfish-actions.pod:397 ../fish/guestfish-actions.pod:1067 ../fish/guestfish-actions.pod:1071 ../fish/guestfish-actions.pod:1075 ../fish/guestfish-actions.pod:1079 ../fish/guestfish-actions.pod:1087 ../fish/guestfish-actions.pod:1091 ../fish/guestfish-actions.pod:1095 ../fish/guestfish-actions.pod:1105 ../fish/guestfish-actions.pod:1109 ../fish/guestfish-actions.pod:1113 ../fish/guestfish-actions.pod:1203 ../fish/guestfish-actions.pod:1207 ../fish/guestfish-actions.pod:1212 ../fish/guestfish-actions.pod:1217 ../fish/guestfish-actions.pod:1259 ../fish/guestfish-actions.pod:1263 ../fish/guestfish-actions.pod:1268 ../inspector/virt-inspector.pl:466 ../inspector/virt-inspector.pl:470 ../tools/virt-df.pl:161 ../tools/virt-df.pl:167 ../tools/virt-resize.pl:348 ../tools/virt-resize.pl:353 ../tools/virt-resize.pl:363
761 #: ../src/guestfs.pod:362
763 "The kernel version that the command runs under will be different from what "
768 #: ../src/guestfs.pod:367
770 "If the command needs to communicate with daemons, then most likely they "
775 #: ../src/guestfs.pod:372
776 msgid "The command will be running in limited memory."
780 #: ../src/guestfs.pod:376
782 "The network may not be available unless you enable it (see "
783 "L</guestfs_set_network>)."
787 #: ../src/guestfs.pod:381
788 msgid "Only supports Linux guests (not Windows, BSD, etc)."
792 #: ../src/guestfs.pod:385
793 msgid "Architecture limitations (eg. won't work for a PPC guest on an X86 host)."
797 #: ../src/guestfs.pod:390
799 "For SELinux guests, you may need to enable SELinux and load policy first. "
800 "See L</SELINUX> in this manpage."
804 #: ../src/guestfs.pod:395
806 "I<Security:> It is not safe to run commands from untrusted, possibly "
807 "malicious guests. These commands may attempt to exploit your program by "
808 "sending unexpected output. They could also try to exploit the Linux kernel "
809 "or qemu provided by the libguestfs appliance. They could use the network "
810 "provided by the libguestfs appliance to bypass ordinary network partitions "
811 "and firewalls. They could use the elevated privileges or different SELinux "
812 "context of your program to their advantage."
816 #: ../src/guestfs.pod:404
818 "A secure alternative is to use libguestfs to install a \"firstboot\" script "
819 "(a script which runs when the guest next boots normally), and to have this "
820 "script run the commands you want in the normal context of the running guest, "
821 "network security and so on. For information about other security issues, "
826 #: ../src/guestfs.pod:412
828 "The two main API calls to run commands are L</guestfs_command> and "
829 "L</guestfs_sh> (there are also variations)."
833 #: ../src/guestfs.pod:415
835 "The difference is that L</guestfs_sh> runs commands using the shell, so any "
836 "shell globs, redirections, etc will work."
840 #: ../src/guestfs.pod:418
841 msgid "CONFIGURATION FILES"
845 #: ../src/guestfs.pod:420
847 "To read and write configuration files in Linux guest filesystems, we "
848 "strongly recommend using Augeas. For example, Augeas understands how to "
849 "read and write, say, a Linux shadow password file or X.org configuration "
850 "file, and so avoids you having to write that code."
854 #: ../src/guestfs.pod:425
856 "The main Augeas calls are bound through the C<guestfs_aug_*> APIs. We don't "
857 "document Augeas itself here because there is excellent documentation on the "
858 "L<http://augeas.net/> website."
862 #: ../src/guestfs.pod:429
864 "If you don't want to use Augeas (you fool!) then try calling "
865 "L</guestfs_read_lines> to get the file as a list of lines which you can "
870 #: ../src/guestfs.pod:433
875 #: ../src/guestfs.pod:435
877 "We support SELinux guests. To ensure that labeling happens correctly in "
878 "SELinux guests, you need to enable SELinux and load the guest's policy:"
882 #: ../src/guestfs.pod:441 ../src/guestfs.pod:1150 ../src/guestfs.pod:1281
887 #: ../src/guestfs.pod:443
888 msgid "Before launching, do:"
892 #: ../src/guestfs.pod:445
895 " guestfs_set_selinux (g, 1);\n"
900 #: ../src/guestfs.pod:447 ../src/guestfs.pod:1154 ../src/guestfs.pod:1285
905 #: ../src/guestfs.pod:449
907 "After mounting the guest's filesystem(s), load the policy. This is best "
908 "done by running the L<load_policy(8)> command in the guest itself:"
912 #: ../src/guestfs.pod:453
915 " guestfs_sh (g, \"/usr/sbin/load_policy\");\n"
920 #: ../src/guestfs.pod:455
922 "(Older versions of C<load_policy> require you to specify the name of the "
927 #: ../src/guestfs.pod:458 ../src/guestfs.pod:1291
932 #: ../src/guestfs.pod:460
934 "Optionally, set the security context for the API. The correct security "
935 "context to use can only be known by inspecting the guest. As an example:"
939 #: ../src/guestfs.pod:464
942 " guestfs_setcon (g, \"unconfined_u:unconfined_r:unconfined_t:s0\");\n"
947 #: ../src/guestfs.pod:468
948 msgid "This will work for running commands and editing existing files."
952 #: ../src/guestfs.pod:470
954 "When new files are created, you may need to label them explicitly, for "
955 "example by running the external command C<restorecon pathname>."
959 #: ../src/guestfs.pod:474
964 #: ../src/guestfs.pod:476
966 "Certain calls are affected by the current file mode creation mask (the "
967 "\"umask\"). In particular ones which create files or directories, such as "
968 "L</guestfs_touch>, L</guestfs_mknod> or L</guestfs_mkdir>. This affects "
969 "either the default mode that the file is created with or modifies the mode "
974 #: ../src/guestfs.pod:482
976 "The default umask is C<022>, so files are created with modes such as C<0644> "
977 "and directories with C<0755>."
981 #: ../src/guestfs.pod:485
983 "There are two ways to avoid being affected by umask. Either set umask to 0 "
984 "(call C<guestfs_umask (g, 0)> early after launching). Or call "
985 "L</guestfs_chmod> after creating each file or directory."
989 #: ../src/guestfs.pod:489
990 msgid "For more information about umask, see L<umask(2)>."
994 #: ../src/guestfs.pod:491 ../fish/guestfish.pod:669
995 msgid "ENCRYPTED DISKS"
999 #: ../src/guestfs.pod:493
1001 "Libguestfs allows you to access Linux guests which have been encrypted using "
1002 "whole disk encryption that conforms to the Linux Unified Key Setup (LUKS) "
1003 "standard. This includes nearly all whole disk encryption systems used by "
1004 "modern Linux guests."
1008 #: ../src/guestfs.pod:499
1010 "Use L</guestfs_vfs_type> to identify LUKS-encrypted block devices (it "
1011 "returns the string C<crypto_LUKS>)."
1015 #: ../src/guestfs.pod:502
1017 "Then open these devices by calling L</guestfs_luks_open>. Obviously you "
1018 "will require the passphrase!"
1022 #: ../src/guestfs.pod:505
1024 "Opening a LUKS device creates a new device mapper device called "
1025 "C</dev/mapper/mapname> (where C<mapname> is the string you supply to "
1026 "L</guestfs_luks_open>). Reads and writes to this mapper device are "
1027 "decrypted from and encrypted to the underlying block device respectively."
1031 #: ../src/guestfs.pod:511
1033 "LVM volume groups on the device can be made visible by calling "
1034 "L</guestfs_vgscan> followed by L</guestfs_vg_activate_all>. The logical "
1035 "volume(s) can now be mounted in the usual way."
1039 #: ../src/guestfs.pod:515
1041 "Use the reverse process to close a LUKS device. Unmount any logical volumes "
1042 "on it, deactivate the volume groups by caling C<guestfs_vg_activate (g, 0, "
1043 "[\"/dev/VG\"])>. Then close the mapper device by calling "
1044 "L</guestfs_luks_close> on the C</dev/mapper/mapname> device (I<not> the "
1045 "underlying encrypted block device)."
1049 #: ../src/guestfs.pod:522
1054 #: ../src/guestfs.pod:524
1056 "Libguestfs has APIs for inspecting an unknown disk image to find out if it "
1057 "contains operating systems. (These APIs used to be in a separate Perl-only "
1058 "library called L<Sys::Guestfs::Lib(3)> but since version 1.5.3 the most "
1059 "frequently used part of this library has been rewritten in C and moved into "
1064 #: ../src/guestfs.pod:530
1066 "Add all disks belonging to the unknown virtual machine and call "
1067 "L</guestfs_launch> in the usual way."
1071 #: ../src/guestfs.pod:533
1073 "Then call L</guestfs_inspect_os>. This function uses other libguestfs calls "
1074 "and certain heuristics, and returns a list of operating systems that were "
1075 "found. An empty list means none were found. A single element is the root "
1076 "filesystem of the operating system. For dual- or multi-boot guests, "
1077 "multiple roots can be returned, each one corresponding to a separate "
1078 "operating system. (Multi-boot virtual machines are extremely rare in the "
1079 "world of virtualization, but since this scenario can happen, we have built "
1080 "libguestfs to deal with it.)"
1084 #: ../src/guestfs.pod:542
1086 "For each root, you can then call various C<guestfs_inspect_get_*> functions "
1087 "to get additional details about that operating system. For example, call "
1088 "L</guestfs_inspect_get_type> to return the string C<windows> or C<linux> for "
1089 "Windows and Linux-based operating systems respectively."
1093 #: ../src/guestfs.pod:548
1095 "Un*x-like and Linux-based operating systems usually consist of several "
1096 "filesystems which are mounted at boot time (for example, a separate boot "
1097 "partition mounted on C</boot>). The inspection rules are able to detect how "
1098 "filesystems correspond to mount points. Call "
1099 "C<guestfs_inspect_get_mountpoints> to get this mapping. It might return a "
1100 "hash table like this example:"
1104 #: ../src/guestfs.pod:555
1107 " /boot => /dev/sda1\n"
1108 " / => /dev/vg_guest/lv_root\n"
1109 " /usr => /dev/vg_guest/lv_usr\n"
1114 #: ../src/guestfs.pod:559
1116 "The caller can then make calls to L</guestfs_mount_options> to mount the "
1117 "filesystems as suggested."
1121 #: ../src/guestfs.pod:562
1123 "Be careful to mount filesystems in the right order (eg. C</> before "
1124 "C</usr>). Sorting the keys of the hash by length, shortest first, should "
1129 #: ../src/guestfs.pod:566
1131 "Inspection currently only works for some common operating systems. "
1132 "Contributors are welcome to send patches for other operating systems that we "
1133 "currently cannot detect."
1137 #: ../src/guestfs.pod:570
1139 "Encrypted disks must be opened before inspection. See L</ENCRYPTED DISKS> "
1140 "for more details. The L</guestfs_inspect_os> function just ignores any "
1141 "encrypted devices."
1145 #: ../src/guestfs.pod:574
1147 "A note on the implementation: The call L</guestfs_inspect_os> performs "
1148 "inspection and caches the results in the guest handle. Subsequent calls to "
1149 "C<guestfs_inspect_get_*> return this cached information, but I<do not> "
1150 "re-read the disks. If you change the content of the guest disks, you can "
1151 "redo inspection by calling L</guestfs_inspect_os> again. "
1152 "(L</guestfs_inspect_list_applications> works a little differently from the "
1153 "other calls and does read the disks. See documentation for that function "
1158 #: ../src/guestfs.pod:583
1159 msgid "SPECIAL CONSIDERATIONS FOR WINDOWS GUESTS"
1163 #: ../src/guestfs.pod:585
1165 "Libguestfs can mount NTFS partitions. It does this using the "
1166 "L<http://www.ntfs-3g.org/> driver."
1170 #: ../src/guestfs.pod:588
1172 "DOS and Windows still use drive letters, and the filesystems are always "
1173 "treated as case insensitive by Windows itself, and therefore you might find "
1174 "a Windows configuration file referring to a path like "
1175 "C<c:\\windows\\system32>. When the filesystem is mounted in libguestfs, "
1176 "that directory might be referred to as C</WINDOWS/System32>."
1180 #: ../src/guestfs.pod:594
1182 "Drive letter mappings are outside the scope of libguestfs. You have to use "
1183 "libguestfs to read the appropriate Windows Registry and configuration files, "
1184 "to determine yourself how drives are mapped (see also L<hivex(3)> and "
1185 "L<virt-inspector(1)>)."
1189 #: ../src/guestfs.pod:599
1191 "Replacing backslash characters with forward slash characters is also outside "
1192 "the scope of libguestfs, but something that you can easily do."
1196 #: ../src/guestfs.pod:602
1198 "Where we can help is in resolving the case insensitivity of paths. For "
1199 "this, call L</guestfs_case_sensitive_path>."
1203 #: ../src/guestfs.pod:605
1205 "Libguestfs also provides some help for decoding Windows Registry \"hive\" "
1206 "files, through the library C<hivex> which is part of the libguestfs project "
1207 "although ships as a separate tarball. You have to locate and download the "
1208 "hive file(s) yourself, and then pass them to C<hivex> functions. See also "
1209 "the programs L<hivexml(1)>, L<hivexsh(1)>, L<hivexregedit(1)> and "
1210 "L<virt-win-reg(1)> for more help on this issue."
1214 #: ../src/guestfs.pod:613
1215 msgid "USING LIBGUESTFS WITH OTHER PROGRAMMING LANGUAGES"
1219 #: ../src/guestfs.pod:615
1221 "Although we don't want to discourage you from using the C API, we will "
1222 "mention here that the same API is also available in other languages."
1226 #: ../src/guestfs.pod:618
1228 "The API is broadly identical in all supported languages. This means that "
1229 "the C call C<guestfs_mount(g,path)> is C<$g-E<gt>mount($path)> in Perl, "
1230 "C<g.mount(path)> in Python, and C<Guestfs.mount g path> in OCaml. In other "
1231 "words, a straightforward, predictable isomorphism between each language."
1235 #: ../src/guestfs.pod:624
1237 "Error messages are automatically transformed into exceptions if the language "
1242 #: ../src/guestfs.pod:627
1244 "We don't try to \"object orientify\" parts of the API in OO languages, "
1245 "although contributors are welcome to write higher level APIs above what we "
1246 "provide in their favourite languages if they wish."
1250 #: ../src/guestfs.pod:633
1255 #: ../src/guestfs.pod:635
1257 "You can use the I<guestfs.h> header file from C++ programs. The C++ API is "
1258 "identical to the C API. C++ classes and exceptions are not used."
1262 #: ../src/guestfs.pod:639
1267 #: ../src/guestfs.pod:641
1269 "The C# bindings are highly experimental. Please read the warnings at the "
1270 "top of C<csharp/Libguestfs.cs>."
1274 #: ../src/guestfs.pod:644
1279 #: ../src/guestfs.pod:646
1281 "This is the only language binding that is working but incomplete. Only "
1282 "calls which return simple integers have been bound in Haskell, and we are "
1283 "looking for help to complete this binding."
1287 #: ../src/guestfs.pod:650
1292 #: ../src/guestfs.pod:652
1294 "Full documentation is contained in the Javadoc which is distributed with "
1299 #: ../src/guestfs.pod:655
1304 #: ../src/guestfs.pod:657
1305 msgid "For documentation see the file C<guestfs.mli>."
1309 #: ../src/guestfs.pod:659
1314 #: ../src/guestfs.pod:661
1315 msgid "For documentation see L<Sys::Guestfs(3)>."
1319 #: ../src/guestfs.pod:663
1324 #: ../src/guestfs.pod:665
1326 "For documentation see C<README-PHP> supplied with libguestfs sources or in "
1327 "the php-libguestfs package for your distribution."
1331 #: ../src/guestfs.pod:668
1332 msgid "The PHP binding only works correctly on 64 bit machines."
1336 #: ../src/guestfs.pod:670
1341 #: ../src/guestfs.pod:672
1342 msgid "For documentation do:"
1346 #: ../src/guestfs.pod:674
1350 " >>> import guestfs\n"
1351 " >>> help (guestfs)\n"
1356 #: ../src/guestfs.pod:678
1361 #: ../src/guestfs.pod:680
1363 "Use the Guestfs module. There is no Ruby-specific documentation, but you "
1364 "can find examples written in Ruby in the libguestfs source."
1368 #: ../src/guestfs.pod:683
1369 msgid "B<shell scripts>"
1373 #: ../src/guestfs.pod:685
1374 msgid "For documentation see L<guestfish(1)>."
1378 #: ../src/guestfs.pod:689
1379 msgid "LIBGUESTFS GOTCHAS"
1383 #: ../src/guestfs.pod:691
1385 "L<http://en.wikipedia.org/wiki/Gotcha_(programming)>: \"A feature of a "
1386 "system [...] that works in the way it is documented but is counterintuitive "
1387 "and almost invites mistakes.\""
1391 #: ../src/guestfs.pod:695
1393 "Since we developed libguestfs and the associated tools, there are several "
1394 "things we would have designed differently, but are now stuck with for "
1395 "backwards compatibility or other reasons. If there is ever a libguestfs 2.0 "
1396 "release, you can expect these to change. Beware of them."
1400 #: ../src/guestfs.pod:703
1401 msgid "Autosync / forgetting to sync."
1405 #: ../src/guestfs.pod:705
1407 "When modifying a filesystem from C or another language, you B<must> unmount "
1408 "all filesystems and call L</guestfs_sync> explicitly before you close the "
1409 "libguestfs handle. You can also call:"
1413 #: ../src/guestfs.pod:709
1416 " guestfs_set_autosync (g, 1);\n"
1421 #: ../src/guestfs.pod:711
1423 "to have the unmount/sync done automatically for you when the handle 'g' is "
1424 "closed. (This feature is called \"autosync\", L</guestfs_set_autosync> "
1429 #: ../src/guestfs.pod:715
1431 "If you forget to do this, then it is entirely possible that your changes "
1432 "won't be written out, or will be partially written, or (very rarely) that "
1433 "you'll get disk corruption."
1437 #: ../src/guestfs.pod:719
1439 "Note that in L<guestfish(3)> autosync is the default. So quick and dirty "
1440 "guestfish scripts that forget to sync will work just fine, which can make "
1441 "this very puzzling if you are trying to debug a problem."
1445 #: ../src/guestfs.pod:723
1447 "Update: Autosync is enabled by default for all API users starting from "
1448 "libguestfs 1.5.24."
1452 #: ../src/guestfs.pod:726
1453 msgid "Mount option C<-o sync> should not be the default."
1457 #: ../src/guestfs.pod:728
1459 "If you use L</guestfs_mount>, then C<-o sync,noatime> are added implicitly. "
1460 "However C<-o sync> does not add any reliability benefit, but does have a "
1461 "very large performance impact."
1465 #: ../src/guestfs.pod:732
1467 "The work around is to use L</guestfs_mount_options> and set the mount "
1468 "options that you actually want to use."
1472 #: ../src/guestfs.pod:735
1473 msgid "Read-only should be the default."
1477 #: ../src/guestfs.pod:737
1479 "In L<guestfish(3)>, I<--ro> should be the default, and you should have to "
1480 "specify I<--rw> if you want to make changes to the image."
1484 #: ../src/guestfs.pod:740
1485 msgid "This would reduce the potential to corrupt live VM images."
1489 #: ../src/guestfs.pod:742
1491 "Note that many filesystems change the disk when you just mount and unmount, "
1492 "even if you didn't perform any writes. You need to use "
1493 "L</guestfs_add_drive_ro> to guarantee that the disk is not changed."
1497 #: ../src/guestfs.pod:746
1498 msgid "guestfish command line is hard to use."
1502 #: ../src/guestfs.pod:748
1504 "C<guestfish disk.img> doesn't do what people expect (open C<disk.img> for "
1505 "examination). It tries to run a guestfish command C<disk.img> which doesn't "
1506 "exist, so it fails. In earlier versions of guestfish the error message was "
1507 "also unintuitive, but we have corrected this since. Like the Bourne shell, "
1508 "we should have used C<guestfish -c command> to run commands."
1512 #: ../src/guestfs.pod:755
1513 msgid "guestfish megabyte modifiers don't work right on all commands"
1517 #: ../src/guestfs.pod:757
1519 "In recent guestfish you can use C<1M> to mean 1 megabyte (and similarly for "
1520 "other modifiers). What guestfish actually does is to multiply the number "
1521 "part by the modifier part and pass the result to the C API. However this "
1522 "doesn't work for a few APIs which aren't expecting bytes, but are already "
1523 "expecting some other unit (eg. megabytes)."
1527 #: ../src/guestfs.pod:764
1528 msgid "The most common is L</guestfs_lvcreate>. The guestfish command:"
1532 #: ../src/guestfs.pod:766
1535 " lvcreate LV VG 100M\n"
1540 #: ../src/guestfs.pod:768
1542 "does not do what you might expect. Instead because L</guestfs_lvcreate> is "
1543 "already expecting megabytes, this tries to create a 100 I<terabyte> (100 "
1544 "megabytes * megabytes) logical volume. The error message you get from this "
1545 "is also a little obscure."
1549 #: ../src/guestfs.pod:773
1551 "This could be fixed in the generator by specially marking parameters and "
1552 "return values which take bytes or other units."
1556 #: ../src/guestfs.pod:776
1557 msgid "Ambiguity between devices and paths"
1561 #: ../src/guestfs.pod:778
1563 "There is a subtle ambiguity in the API between a device name "
1564 "(eg. C</dev/sdb2>) and a similar pathname. A file might just happen to be "
1565 "called C<sdb2> in the directory C</dev> (consider some non-Unix VM image)."
1569 #: ../src/guestfs.pod:783
1571 "In the current API we usually resolve this ambiguity by having two separate "
1572 "calls, for example L</guestfs_checksum> and L</guestfs_checksum_device>. "
1573 "Some API calls are ambiguous and (incorrectly) resolve the problem by "
1574 "detecting if the path supplied begins with C</dev/>."
1578 #: ../src/guestfs.pod:789
1580 "To avoid both the ambiguity and the need to duplicate some calls, we could "
1581 "make paths/devices into structured names. One way to do this would be to "
1582 "use a notation like grub (C<hd(0,0)>), although nobody really likes this "
1583 "aspect of grub. Another way would be to use a structured type, equivalent "
1584 "to this OCaml type:"
1588 #: ../src/guestfs.pod:795
1591 " type path = Path of string | Device of int | Partition of int * int\n"
1596 #: ../src/guestfs.pod:797
1597 msgid "which would allow you to pass arguments like:"
1601 #: ../src/guestfs.pod:799
1604 " Path \"/foo/bar\"\n"
1605 " Device 1 (* /dev/sdb, or perhaps /dev/sda *)\n"
1606 " Partition (1, 2) (* /dev/sdb2 (or is it /dev/sda2 or /dev/sdb3?) *)\n"
1607 " Path \"/dev/sdb2\" (* not a device *)\n"
1612 #: ../src/guestfs.pod:804
1614 "As you can see there are still problems to resolve even with this "
1615 "representation. Also consider how it might work in guestfish."
1619 #: ../src/guestfs.pod:809
1620 msgid "PROTOCOL LIMITS"
1624 #: ../src/guestfs.pod:811
1626 "Internally libguestfs uses a message-based protocol to pass API calls and "
1627 "their responses to and from a small \"appliance\" (see L</INTERNALS> for "
1628 "plenty more detail about this). The maximum message size used by the "
1629 "protocol is slightly less than 4 MB. For some API calls you may need to be "
1630 "aware of this limit. The API calls which may be affected are individually "
1631 "documented, with a link back to this section of the documentation."
1635 #: ../src/guestfs.pod:819
1637 "A simple call such as L</guestfs_cat> returns its result (the file data) in "
1638 "a simple string. Because this string is at some point internally encoded as "
1639 "a message, the maximum size that it can return is slightly under 4 MB. If "
1640 "the requested file is larger than this then you will get an error."
1644 #: ../src/guestfs.pod:825
1646 "In order to transfer large files into and out of the guest filesystem, you "
1647 "need to use particular calls that support this. The sections L</UPLOADING> "
1648 "and L</DOWNLOADING> document how to do this."
1652 #: ../src/guestfs.pod:829
1654 "You might also consider mounting the disk image using our FUSE filesystem "
1655 "support (L<guestmount(1)>)."
1659 #: ../src/guestfs.pod:832
1660 msgid "KEYS AND PASSPHRASES"
1664 #: ../src/guestfs.pod:834
1666 "Certain libguestfs calls take a parameter that contains sensitive key "
1667 "material, passed in as a C string."
1671 #: ../src/guestfs.pod:837
1673 "In the future we would hope to change the libguestfs implementation so that "
1674 "keys are L<mlock(2)>-ed into physical RAM, and thus can never end up in "
1675 "swap. However this is I<not> done at the moment, because of the complexity "
1676 "of such an implementation."
1680 #: ../src/guestfs.pod:842
1682 "Therefore you should be aware that any key parameter you pass to libguestfs "
1683 "might end up being written out to the swap partition. If this is a concern, "
1684 "scrub the swap partition or don't use libguestfs on encrypted devices."
1688 #: ../src/guestfs.pod:847
1689 msgid "MULTIPLE HANDLES AND MULTIPLE THREADS"
1693 #: ../src/guestfs.pod:849
1695 "All high-level libguestfs actions are synchronous. If you want to use "
1696 "libguestfs asynchronously then you must create a thread."
1700 #: ../src/guestfs.pod:852
1702 "Only use the handle from a single thread. Either use the handle exclusively "
1703 "from one thread, or provide your own mutex so that two threads cannot issue "
1704 "calls on the same handle at the same time."
1708 #: ../src/guestfs.pod:856
1710 "See the graphical program guestfs-browser for one possible architecture for "
1711 "multithreaded programs using libvirt and libguestfs."
1715 #: ../src/guestfs.pod:859
1720 #: ../src/guestfs.pod:861
1722 "Libguestfs needs a kernel and initrd.img, which it finds by looking along an "
1727 #: ../src/guestfs.pod:864
1729 "By default it looks for these in the directory C<$libdir/guestfs> "
1730 "(eg. C</usr/local/lib/guestfs> or C</usr/lib64/guestfs>)."
1734 #: ../src/guestfs.pod:867
1736 "Use L</guestfs_set_path> or set the environment variable L</LIBGUESTFS_PATH> "
1737 "to change the directories that libguestfs will search in. The value is a "
1738 "colon-separated list of paths. The current directory is I<not> searched "
1739 "unless the path contains an empty element or C<.>. For example "
1740 "C<LIBGUESTFS_PATH=:/usr/lib/guestfs> would search the current directory and "
1741 "then C</usr/lib/guestfs>."
1745 #: ../src/guestfs.pod:874
1746 msgid "QEMU WRAPPERS"
1750 #: ../src/guestfs.pod:876
1752 "If you want to compile your own qemu, run qemu from a non-standard location, "
1753 "or pass extra arguments to qemu, then you can write a shell-script wrapper "
1758 #: ../src/guestfs.pod:880
1760 "There is one important rule to remember: you I<must C<exec qemu>> as the "
1761 "last command in the shell script (so that qemu replaces the shell and "
1762 "becomes the direct child of the libguestfs-using program). If you don't do "
1763 "this, then the qemu process won't be cleaned up correctly."
1767 #: ../src/guestfs.pod:885
1769 "Here is an example of a wrapper, where I have built my own copy of qemu from "
1774 #: ../src/guestfs.pod:888
1778 " qemudir=/home/rjones/d/qemu\n"
1779 " exec $qemudir/x86_64-softmmu/qemu-system-x86_64 -L $qemudir/pc-bios "
1785 #: ../src/guestfs.pod:892
1787 "Save this script as C</tmp/qemu.wrapper> (or wherever), C<chmod +x>, and "
1788 "then use it by setting the LIBGUESTFS_QEMU environment variable. For "
1793 #: ../src/guestfs.pod:896
1796 " LIBGUESTFS_QEMU=/tmp/qemu.wrapper guestfish\n"
1801 #: ../src/guestfs.pod:898
1803 "Note that libguestfs also calls qemu with the -help and -version options in "
1804 "order to determine features."
1808 #: ../src/guestfs.pod:901
1809 msgid "ABI GUARANTEE"
1813 #: ../src/guestfs.pod:903
1815 "We guarantee the libguestfs ABI (binary interface), for public, high-level "
1816 "actions as outlined in this section. Although we will deprecate some "
1817 "actions, for example if they get replaced by newer calls, we will keep the "
1818 "old actions forever. This allows you the developer to program in confidence "
1819 "against the libguestfs API."
1823 #: ../src/guestfs.pod:909
1824 msgid "BLOCK DEVICE NAMING"
1828 #: ../src/guestfs.pod:911
1830 "In the kernel there is now quite a profusion of schemata for naming block "
1831 "devices (in this context, by I<block device> I mean a physical or virtual "
1832 "hard drive). The original Linux IDE driver used names starting with "
1833 "C</dev/hd*>. SCSI devices have historically used a different naming scheme, "
1834 "C</dev/sd*>. When the Linux kernel I<libata> driver became a popular "
1835 "replacement for the old IDE driver (particularly for SATA devices) those "
1836 "devices also used the C</dev/sd*> scheme. Additionally we now have virtual "
1837 "machines with paravirtualized drivers. This has created several different "
1838 "naming systems, such as C</dev/vd*> for virtio disks and C</dev/xvd*> for "
1843 #: ../src/guestfs.pod:923
1845 "As discussed above, libguestfs uses a qemu appliance running an embedded "
1846 "Linux kernel to access block devices. We can run a variety of appliances "
1847 "based on a variety of Linux kernels."
1851 #: ../src/guestfs.pod:927
1853 "This causes a problem for libguestfs because many API calls use device or "
1854 "partition names. Working scripts and the recipe (example) scripts that we "
1855 "make available over the internet could fail if the naming scheme changes."
1859 #: ../src/guestfs.pod:932
1861 "Therefore libguestfs defines C</dev/sd*> as the I<standard naming scheme>. "
1862 "Internally C</dev/sd*> names are translated, if necessary, to other names as "
1863 "required. For example, under RHEL 5 which uses the C</dev/hd*> scheme, any "
1864 "device parameter C</dev/sda2> is translated to C</dev/hda2> transparently."
1868 #: ../src/guestfs.pod:938
1870 "Note that this I<only> applies to parameters. The L</guestfs_list_devices>, "
1871 "L</guestfs_list_partitions> and similar calls return the true names of the "
1872 "devices and partitions as known to the appliance."
1876 #: ../src/guestfs.pod:943
1877 msgid "ALGORITHM FOR BLOCK DEVICE NAME TRANSLATION"
1881 #: ../src/guestfs.pod:945
1883 "Usually this translation is transparent. However in some (very rare) cases "
1884 "you may need to know the exact algorithm. Such cases include where you use "
1885 "L</guestfs_config> to add a mixture of virtio and IDE devices to the "
1886 "qemu-based appliance, so have a mixture of C</dev/sd*> and C</dev/vd*> "
1891 #: ../src/guestfs.pod:951
1893 "The algorithm is applied only to I<parameters> which are known to be either "
1894 "device or partition names. Return values from functions such as "
1895 "L</guestfs_list_devices> are never changed."
1899 #: ../src/guestfs.pod:959
1900 msgid "Is the string a parameter which is a device or partition name?"
1904 #: ../src/guestfs.pod:963
1905 msgid "Does the string begin with C</dev/sd>?"
1909 #: ../src/guestfs.pod:967
1911 "Does the named device exist? If so, we use that device. However if I<not> "
1912 "then we continue with this algorithm."
1916 #: ../src/guestfs.pod:972
1917 msgid "Replace initial C</dev/sd> string with C</dev/hd>."
1921 #: ../src/guestfs.pod:974
1922 msgid "For example, change C</dev/sda2> to C</dev/hda2>."
1926 #: ../src/guestfs.pod:976
1927 msgid "If that named device exists, use it. If not, continue."
1931 #: ../src/guestfs.pod:980
1932 msgid "Replace initial C</dev/sd> string with C</dev/vd>."
1936 #: ../src/guestfs.pod:982
1937 msgid "If that named device exists, use it. If not, return an error."
1941 #: ../src/guestfs.pod:986
1942 msgid "PORTABILITY CONCERNS WITH BLOCK DEVICE NAMING"
1946 #: ../src/guestfs.pod:988
1948 "Although the standard naming scheme and automatic translation is useful for "
1949 "simple programs and guestfish scripts, for larger programs it is best not to "
1950 "rely on this mechanism."
1954 #: ../src/guestfs.pod:992
1956 "Where possible for maximum future portability programs using libguestfs "
1957 "should use these future-proof techniques:"
1961 #: ../src/guestfs.pod:999
1963 "Use L</guestfs_list_devices> or L</guestfs_list_partitions> to list actual "
1964 "device names, and then use those names directly."
1968 #: ../src/guestfs.pod:1002
1969 msgid "Since those device names exist by definition, they will never be translated."
1973 #: ../src/guestfs.pod:1007
1975 "Use higher level ways to identify filesystems, such as LVM names, UUIDs and "
1976 "filesystem labels."
1980 #: ../src/guestfs.pod:1012
1985 #: ../src/guestfs.pod:1014
1987 "This section discusses security implications of using libguestfs, "
1988 "particularly with untrusted or malicious guests or disk images."
1992 #: ../src/guestfs.pod:1017
1993 msgid "GENERAL SECURITY CONSIDERATIONS"
1997 #: ../src/guestfs.pod:1019
1999 "Be careful with any files or data that you download from a guest (by "
2000 "\"download\" we mean not just the L</guestfs_download> command but any "
2001 "command that reads files, filenames, directories or anything else from a "
2002 "disk image). An attacker could manipulate the data to fool your program "
2003 "into doing the wrong thing. Consider cases such as:"
2007 #: ../src/guestfs.pod:1029
2008 msgid "the data (file etc) not being present"
2012 #: ../src/guestfs.pod:1033
2013 msgid "being present but empty"
2017 #: ../src/guestfs.pod:1037
2018 msgid "being much larger than normal"
2022 #: ../src/guestfs.pod:1041
2023 msgid "containing arbitrary 8 bit data"
2027 #: ../src/guestfs.pod:1045
2028 msgid "being in an unexpected character encoding"
2032 #: ../src/guestfs.pod:1049
2033 msgid "containing homoglyphs."
2037 #: ../src/guestfs.pod:1053
2038 msgid "SECURITY OF MOUNTING FILESYSTEMS"
2042 #: ../src/guestfs.pod:1055
2044 "When you mount a filesystem under Linux, mistakes in the kernel filesystem "
2045 "(VFS) module can sometimes be escalated into exploits by deliberately "
2046 "creating a malicious, malformed filesystem. These exploits are very severe "
2047 "for two reasons. Firstly there are very many filesystem drivers in the "
2048 "kernel, and many of them are infrequently used and not much developer "
2049 "attention has been paid to the code. Linux userspace helps potential "
2050 "crackers by detecting the filesystem type and automatically choosing the "
2051 "right VFS driver, even if that filesystem type is obscure or unexpected for "
2052 "the administrator. Secondly, a kernel-level exploit is like a local root "
2053 "exploit (worse in some ways), giving immediate and total access to the "
2054 "system right down to the hardware level."
2058 #: ../src/guestfs.pod:1068
2060 "That explains why you should never mount a filesystem from an untrusted "
2061 "guest on your host kernel. How about libguestfs? We run a Linux kernel "
2062 "inside a qemu virtual machine, usually running as a non-root user. The "
2063 "attacker would need to write a filesystem which first exploited the kernel, "
2064 "and then exploited either qemu virtualization (eg. a faulty qemu driver) or "
2065 "the libguestfs protocol, and finally to be as serious as the host kernel "
2066 "exploit it would need to escalate its privileges to root. This multi-step "
2067 "escalation, performed by a static piece of data, is thought to be extremely "
2068 "hard to do, although we never say 'never' about security issues."
2072 #: ../src/guestfs.pod:1079
2074 "In any case callers can reduce the attack surface by forcing the filesystem "
2075 "type when mounting (use L</guestfs_mount_vfs>)."
2079 #: ../src/guestfs.pod:1082
2080 msgid "PROTOCOL SECURITY"
2084 #: ../src/guestfs.pod:1084
2086 "The protocol is designed to be secure, being based on RFC 4506 (XDR) with a "
2087 "defined upper message size. However a program that uses libguestfs must "
2088 "also take care - for example you can write a program that downloads a binary "
2089 "from a disk image and executes it locally, and no amount of protocol "
2090 "security will save you from the consequences."
2094 #: ../src/guestfs.pod:1090
2095 msgid "INSPECTION SECURITY"
2099 #: ../src/guestfs.pod:1092
2101 "Parts of the inspection API (see L</INSPECTION>) return untrusted strings "
2102 "directly from the guest, and these could contain any 8 bit data. Callers "
2103 "should be careful to escape these before printing them to a structured file "
2104 "(for example, use HTML escaping if creating a web page)."
2108 #: ../src/guestfs.pod:1098
2110 "Guest configuration may be altered in unusual ways by the administrator of "
2111 "the virtual machine, and may not reflect reality (particularly for untrusted "
2112 "or actively malicious guests). For example we parse the hostname from "
2113 "configuration files like C</etc/sysconfig/network> that we find in the "
2114 "guest, but the guest administrator can easily manipulate these files to "
2115 "provide the wrong hostname."
2119 #: ../src/guestfs.pod:1106
2121 "The inspection API parses guest configuration using two external libraries: "
2122 "Augeas (Linux configuration) and hivex (Windows Registry). Both are "
2123 "designed to be robust in the face of malicious data, although denial of "
2124 "service attacks are still possible, for example with oversized configuration "
2129 #: ../src/guestfs.pod:1112
2130 msgid "RUNNING UNTRUSTED GUEST COMMANDS"
2134 #: ../src/guestfs.pod:1114
2136 "Be very cautious about running commands from the guest. By running a "
2137 "command in the guest, you are giving CPU time to a binary that you do not "
2138 "control, under the same user account as the library, albeit wrapped in qemu "
2139 "virtualization. More information and alternatives can be found in the "
2140 "section L</RUNNING COMMANDS>."
2144 #: ../src/guestfs.pod:1120
2145 msgid "CVE-2010-3851"
2149 #: ../src/guestfs.pod:1122
2150 msgid "https://bugzilla.redhat.com/642934"
2154 #: ../src/guestfs.pod:1124
2156 "This security bug concerns the automatic disk format detection that qemu "
2157 "does on disk images."
2161 #: ../src/guestfs.pod:1127
2163 "A raw disk image is just the raw bytes, there is no header. Other disk "
2164 "images like qcow2 contain a special header. Qemu deals with this by looking "
2165 "for one of the known headers, and if none is found then assuming the disk "
2166 "image must be raw."
2170 #: ../src/guestfs.pod:1132
2172 "This allows a guest which has been given a raw disk image to write some "
2173 "other header. At next boot (or when the disk image is accessed by "
2174 "libguestfs) qemu would do autodetection and think the disk image format was, "
2175 "say, qcow2 based on the header written by the guest."
2179 #: ../src/guestfs.pod:1137
2181 "This in itself would not be a problem, but qcow2 offers many features, one "
2182 "of which is to allow a disk image to refer to another image (called the "
2183 "\"backing disk\"). It does this by placing the path to the backing disk "
2184 "into the qcow2 header. This path is not validated and could point to any "
2185 "host file (eg. \"/etc/passwd\"). The backing disk is then exposed through "
2186 "\"holes\" in the qcow2 disk image, which of course is completely under the "
2187 "control of the attacker."
2191 #: ../src/guestfs.pod:1145
2192 msgid "In libguestfs this is rather hard to exploit except under two circumstances:"
2196 #: ../src/guestfs.pod:1152
2197 msgid "You have enabled the network or have opened the disk in write mode."
2201 #: ../src/guestfs.pod:1156
2203 "You are also running untrusted code from the guest (see L</RUNNING "
2208 #: ../src/guestfs.pod:1161
2210 "The way to avoid this is to specify the expected disk format when adding "
2211 "disks (the optional C<format> option to L</guestfs_add_drive_opts>). You "
2212 "should always do this if the disk is raw format, and it's a good idea for "
2217 #: ../src/guestfs.pod:1166
2219 "For disks added from libvirt using calls like L</guestfs_add_domain>, the "
2220 "format is fetched from libvirt and passed through."
2224 #: ../src/guestfs.pod:1169
2226 "For libguestfs tools, use the I<--format> command line parameter as "
2231 #: ../src/guestfs.pod:1172
2232 msgid "CONNECTION MANAGEMENT"
2236 #: ../src/guestfs.pod:1174
2241 #: ../src/guestfs.pod:1176
2243 "C<guestfs_h> is the opaque type representing a connection handle. Create a "
2244 "handle by calling L</guestfs_create>. Call L</guestfs_close> to free the "
2245 "handle and release all resources used."
2249 #: ../src/guestfs.pod:1180
2251 "For information on using multiple handles and threads, see the section "
2252 "L</MULTIPLE HANDLES AND MULTIPLE THREADS> below."
2256 #: ../src/guestfs.pod:1183
2257 msgid "guestfs_create"
2261 #: ../src/guestfs.pod:1185
2264 " guestfs_h *guestfs_create (void);\n"
2269 #: ../src/guestfs.pod:1187
2270 msgid "Create a connection handle."
2274 #: ../src/guestfs.pod:1189
2276 "You have to call L</guestfs_add_drive_opts> (or one of the equivalent calls) "
2277 "on the handle at least once."
2281 #: ../src/guestfs.pod:1192
2283 "This function returns a non-NULL pointer to a handle on success or NULL on "
2288 #: ../src/guestfs.pod:1195
2289 msgid "After configuring the handle, you have to call L</guestfs_launch>."
2293 #: ../src/guestfs.pod:1197
2295 "You may also want to configure error handling for the handle. See L</ERROR "
2296 "HANDLING> section below."
2300 #: ../src/guestfs.pod:1200
2301 msgid "guestfs_close"
2305 #: ../src/guestfs.pod:1202
2308 " void guestfs_close (guestfs_h *g);\n"
2313 #: ../src/guestfs.pod:1204
2314 msgid "This closes the connection handle and frees up all resources used."
2318 #: ../src/guestfs.pod:1206
2319 msgid "ERROR HANDLING"
2323 #: ../src/guestfs.pod:1208
2325 "API functions can return errors. For example, almost all functions that "
2326 "return C<int> will return C<-1> to indicate an error."
2330 #: ../src/guestfs.pod:1211
2332 "Additional information is available for errors: an error message string and "
2333 "optionally an error number (errno) if the thing that failed was a system "
2338 #: ../src/guestfs.pod:1215
2340 "You can get at the additional information about the last error on the handle "
2341 "by calling L</guestfs_last_error>, L</guestfs_last_errno>, and/or by setting "
2342 "up an error handler with L</guestfs_set_error_handler>."
2346 #: ../src/guestfs.pod:1220
2348 "When the handle is created, a default error handler is installed which "
2349 "prints the error message string to C<stderr>. For small short-running "
2350 "command line programs it is sufficient to do:"
2354 #: ../src/guestfs.pod:1224
2357 " if (guestfs_launch (g) == -1)\n"
2358 " exit (EXIT_FAILURE);\n"
2363 #: ../src/guestfs.pod:1227
2365 "since the default error handler will ensure that an error message has been "
2366 "printed to C<stderr> before the program exits."
2370 #: ../src/guestfs.pod:1230
2372 "For other programs the caller will almost certainly want to install an "
2373 "alternate error handler or do error handling in-line like this:"
2377 #: ../src/guestfs.pod:1233
2380 " g = guestfs_create ();\n"
2385 #: ../src/guestfs.pod:1235
2388 " /* This disables the default behaviour of printing errors\n"
2390 " guestfs_set_error_handler (g, NULL, NULL);\n"
2395 #: ../src/guestfs.pod:1239
2398 " if (guestfs_launch (g) == -1) {\n"
2399 " /* Examine the error message and print it etc. */\n"
2400 " char *msg = guestfs_last_error (g);\n"
2401 " int errnum = guestfs_last_errno (g);\n"
2402 " fprintf (stderr, \"%s\\n\", msg);\n"
2409 #: ../src/guestfs.pod:1247
2411 "Out of memory errors are handled differently. The default action is to call "
2412 "L<abort(3)>. If this is undesirable, then you can set a handler using "
2413 "L</guestfs_set_out_of_memory_handler>."
2417 #: ../src/guestfs.pod:1251
2419 "L</guestfs_create> returns C<NULL> if the handle cannot be created, and "
2420 "because there is no handle if this happens there is no way to get additional "
2421 "error information. However L</guestfs_create> is supposed to be a "
2422 "lightweight operation which can only fail because of insufficient memory (it "
2423 "returns NULL in this case)."
2427 #: ../src/guestfs.pod:1257
2428 msgid "guestfs_last_error"
2432 #: ../src/guestfs.pod:1259
2435 " const char *guestfs_last_error (guestfs_h *g);\n"
2440 #: ../src/guestfs.pod:1261
2442 "This returns the last error message that happened on C<g>. If there has not "
2443 "been an error since the handle was created, then this returns C<NULL>."
2447 #: ../src/guestfs.pod:1265
2449 "The lifetime of the returned string is until the next error occurs, or "
2450 "L</guestfs_close> is called."
2454 #: ../src/guestfs.pod:1268
2455 msgid "guestfs_last_errno"
2459 #: ../src/guestfs.pod:1270
2462 " int guestfs_last_errno (guestfs_h *g);\n"
2467 #: ../src/guestfs.pod:1272
2468 msgid "This returns the last error number (errno) that happened on C<g>."
2472 #: ../src/guestfs.pod:1274
2473 msgid "If successful, an errno integer not equal to zero is returned."
2477 #: ../src/guestfs.pod:1276
2478 msgid "If no error, this returns 0. This call can return 0 in three situations:"
2482 #: ../src/guestfs.pod:1283
2483 msgid "There has not been any error on the handle."
2487 #: ../src/guestfs.pod:1287
2489 "There has been an error but the errno was meaningless. This corresponds to "
2490 "the case where the error did not come from a failed system call, but for "
2491 "some other reason."
2495 #: ../src/guestfs.pod:1293
2497 "There was an error from a failed system call, but for some reason the errno "
2498 "was not captured and returned. This usually indicates a bug in libguestfs."
2502 #: ../src/guestfs.pod:1299
2504 "Libguestfs tries to convert the errno from inside the applicance into a "
2505 "corresponding errno for the caller (not entirely trivial: the appliance "
2506 "might be running a completely different operating system from the library "
2507 "and error numbers are not standardized across Un*xen). If this could not be "
2508 "done, then the error is translated to C<EINVAL>. In practice this should "
2509 "only happen in very rare circumstances."
2513 #: ../src/guestfs.pod:1307
2514 msgid "guestfs_set_error_handler"
2518 #: ../src/guestfs.pod:1309
2521 " typedef void (*guestfs_error_handler_cb) (guestfs_h *g,\n"
2523 " const char *msg);\n"
2524 " void guestfs_set_error_handler (guestfs_h *g,\n"
2525 " guestfs_error_handler_cb cb,\n"
2531 #: ../src/guestfs.pod:1316
2533 "The callback C<cb> will be called if there is an error. The parameters "
2534 "passed to the callback are an opaque data pointer and the error message "
2539 #: ../src/guestfs.pod:1320
2541 "C<errno> is not passed to the callback. To get that the callback must call "
2542 "L</guestfs_last_errno>."
2546 #: ../src/guestfs.pod:1323
2548 "Note that the message string C<msg> is freed as soon as the callback "
2549 "function returns, so if you want to stash it somewhere you must make your "
2554 #: ../src/guestfs.pod:1327
2555 msgid "The default handler prints messages on C<stderr>."
2559 #: ../src/guestfs.pod:1329
2560 msgid "If you set C<cb> to C<NULL> then I<no> handler is called."
2564 #: ../src/guestfs.pod:1331
2565 msgid "guestfs_get_error_handler"
2569 #: ../src/guestfs.pod:1333
2572 " guestfs_error_handler_cb guestfs_get_error_handler (guestfs_h *g,\n"
2573 " void **opaque_rtn);\n"
2578 #: ../src/guestfs.pod:1336
2579 msgid "Returns the current error handler callback."
2583 #: ../src/guestfs.pod:1338
2584 msgid "guestfs_set_out_of_memory_handler"
2588 #: ../src/guestfs.pod:1340
2591 " typedef void (*guestfs_abort_cb) (void);\n"
2592 " int guestfs_set_out_of_memory_handler (guestfs_h *g,\n"
2593 " guestfs_abort_cb);\n"
2598 #: ../src/guestfs.pod:1344
2600 "The callback C<cb> will be called if there is an out of memory situation. "
2601 "I<Note this callback must not return>."
2605 #: ../src/guestfs.pod:1347
2606 msgid "The default is to call L<abort(3)>."
2610 #: ../src/guestfs.pod:1349
2611 msgid "You cannot set C<cb> to C<NULL>. You can't ignore out of memory situations."
2615 #: ../src/guestfs.pod:1352
2616 msgid "guestfs_get_out_of_memory_handler"
2620 #: ../src/guestfs.pod:1354
2623 " guestfs_abort_fn guestfs_get_out_of_memory_handler (guestfs_h *g);\n"
2628 #: ../src/guestfs.pod:1356
2629 msgid "This returns the current out of memory handler."
2633 #: ../src/guestfs.pod:1358
2638 #: ../src/guestfs.pod:1360 ../fish/guestfish.pod:907
2643 #: ../src/guestfs.pod:1362
2648 #: ../src/guestfs.pod:1364
2653 #: ../src/guestfs.pod:1366
2654 msgid "AVAILABILITY"
2658 #: ../src/guestfs.pod:1368
2659 msgid "GROUPS OF FUNCTIONALITY IN THE APPLIANCE"
2663 #: ../src/guestfs.pod:1370
2665 "Using L</guestfs_available> you can test availability of the following "
2666 "groups of functions. This test queries the appliance to see if the "
2667 "appliance you are currently using supports the functionality."
2671 #: ../src/guestfs.pod:1375
2672 msgid "@AVAILABILITY@"
2676 #: ../src/guestfs.pod:1377
2677 msgid "GUESTFISH supported COMMAND"
2681 #: ../src/guestfs.pod:1379
2683 "In L<guestfish(3)> there is a handy interactive command C<supported> which "
2684 "prints out the available groups and whether they are supported by this build "
2685 "of libguestfs. Note however that you have to do C<run> first."
2689 #: ../src/guestfs.pod:1384
2690 msgid "SINGLE CALLS AT COMPILE TIME"
2694 #: ../src/guestfs.pod:1386
2696 "Since version 1.5.8, C<E<lt>guestfs.hE<gt>> defines symbols for each C API "
2697 "function, such as:"
2701 #: ../src/guestfs.pod:1389
2704 " #define LIBGUESTFS_HAVE_DD 1\n"
2709 #: ../src/guestfs.pod:1391
2710 msgid "if L</guestfs_dd> is available."
2714 #: ../src/guestfs.pod:1393
2716 "Before version 1.5.8, if you needed to test whether a single libguestfs "
2717 "function is available at compile time, we recommended using build tools such "
2718 "as autoconf or cmake. For example in autotools you could use:"
2722 #: ../src/guestfs.pod:1398
2725 " AC_CHECK_LIB([guestfs],[guestfs_create])\n"
2726 " AC_CHECK_FUNCS([guestfs_dd])\n"
2731 #: ../src/guestfs.pod:1401
2733 "which would result in C<HAVE_GUESTFS_DD> being either defined or not defined "
2738 #: ../src/guestfs.pod:1404
2739 msgid "SINGLE CALLS AT RUN TIME"
2743 #: ../src/guestfs.pod:1406
2745 "Testing at compile time doesn't guarantee that a function really exists in "
2746 "the library. The reason is that you might be dynamically linked against a "
2747 "previous I<libguestfs.so> (dynamic library) which doesn't have the call. "
2748 "This situation unfortunately results in a segmentation fault, which is a "
2749 "shortcoming of the C dynamic linking system itself."
2753 #: ../src/guestfs.pod:1413
2755 "You can use L<dlopen(3)> to test if a function is available at run time, as "
2756 "in this example program (note that you still need the compile time check as "
2761 #: ../src/guestfs.pod:1417
2764 " #include <stdio.h>\n"
2765 " #include <stdlib.h>\n"
2766 " #include <unistd.h>\n"
2767 " #include <dlfcn.h>\n"
2768 " #include <guestfs.h>\n"
2773 #: ../src/guestfs.pod:1423
2778 " #ifdef LIBGUESTFS_HAVE_DD\n"
2780 " int has_function;\n"
2785 #: ../src/guestfs.pod:1429
2788 " /* Test if the function guestfs_dd is really available. */\n"
2789 " dl = dlopen (NULL, RTLD_LAZY);\n"
2791 " fprintf (stderr, \"dlopen: %s\\n\", dlerror ());\n"
2792 " exit (EXIT_FAILURE);\n"
2794 " has_function = dlsym (dl, \"guestfs_dd\") != NULL;\n"
2800 #: ../src/guestfs.pod:1438
2803 " if (!has_function)\n"
2804 " printf (\"this libguestfs.so does NOT have guestfs_dd function\\n\");\n"
2806 " printf (\"this libguestfs.so has guestfs_dd function\\n\");\n"
2807 " /* Now it's safe to call\n"
2808 " guestfs_dd (g, \"foo\", \"bar\");\n"
2812 " printf (\"guestfs_dd function was not found at compile time\\n\");\n"
2819 #: ../src/guestfs.pod:1451
2821 "You may think the above is an awful lot of hassle, and it is. There are "
2822 "other ways outside of the C linking system to ensure that this kind of "
2823 "incompatibility never arises, such as using package versioning:"
2827 #: ../src/guestfs.pod:1456
2830 " Requires: libguestfs >= 1.0.80\n"
2835 #: ../src/guestfs.pod:1458
2836 msgid "CALLS WITH OPTIONAL ARGUMENTS"
2840 #: ../src/guestfs.pod:1460
2842 "A recent feature of the API is the introduction of calls which take optional "
2843 "arguments. In C these are declared 3 ways. The main way is as a call which "
2844 "takes variable arguments (ie. C<...>), as in this example:"
2848 #: ../src/guestfs.pod:1465
2851 " int guestfs_add_drive_opts (guestfs_h *g, const char *filename, ...);\n"
2856 #: ../src/guestfs.pod:1467
2858 "Call this with a list of optional arguments, terminated by C<-1>. So to "
2859 "call with no optional arguments specified:"
2863 #: ../src/guestfs.pod:1470
2866 " guestfs_add_drive_opts (g, filename, -1);\n"
2871 #: ../src/guestfs.pod:1472
2872 msgid "With a single optional argument:"
2876 #: ../src/guestfs.pod:1474
2879 " guestfs_add_drive_opts (g, filename,\n"
2880 " GUESTFS_ADD_DRIVE_OPTS_FORMAT, \"qcow2\",\n"
2886 #: ../src/guestfs.pod:1478
2891 #: ../src/guestfs.pod:1480
2894 " guestfs_add_drive_opts (g, filename,\n"
2895 " GUESTFS_ADD_DRIVE_OPTS_FORMAT, \"qcow2\",\n"
2896 " GUESTFS_ADD_DRIVE_OPTS_READONLY, 1,\n"
2902 #: ../src/guestfs.pod:1485
2904 "and so forth. Don't forget the terminating C<-1> otherwise Bad Things will "
2909 #: ../src/guestfs.pod:1488
2910 msgid "USING va_list FOR OPTIONAL ARGUMENTS"
2914 #: ../src/guestfs.pod:1490
2916 "The second variant has the same name with the suffix C<_va>, which works the "
2917 "same way but takes a C<va_list>. See the C manual for details. For the "
2918 "example function, this is declared:"
2922 #: ../src/guestfs.pod:1494
2925 " int guestfs_add_drive_opts_va (guestfs_h *g, const char *filename,\n"
2931 #: ../src/guestfs.pod:1497
2932 msgid "CONSTRUCTING OPTIONAL ARGUMENTS"
2936 #: ../src/guestfs.pod:1499
2938 "The third variant is useful where you need to construct these calls. You "
2939 "pass in a structure where you fill in the optional fields. The structure "
2940 "has a bitmask as the first element which you must set to indicate which "
2941 "fields you have filled in. For our example function the structure and call "
2946 #: ../src/guestfs.pod:1505
2949 " struct guestfs_add_drive_opts_argv {\n"
2950 " uint64_t bitmask;\n"
2952 " const char *format;\n"
2955 " int guestfs_add_drive_opts_argv (guestfs_h *g, const char *filename,\n"
2956 " const struct guestfs_add_drive_opts_argv *optargs);\n"
2961 #: ../src/guestfs.pod:1514
2962 msgid "You could call it like this:"
2966 #: ../src/guestfs.pod:1516
2969 " struct guestfs_add_drive_opts_argv optargs = {\n"
2970 " .bitmask = GUESTFS_ADD_DRIVE_OPTS_READONLY_BITMASK |\n"
2971 " GUESTFS_ADD_DRIVE_OPTS_FORMAT_BITMASK,\n"
2973 " .format = \"qcow2\"\n"
2979 #: ../src/guestfs.pod:1523
2982 " guestfs_add_drive_opts_argv (g, filename, &optargs);\n"
2987 #: ../src/guestfs.pod:1525 ../src/guestfs-actions.pod:11 ../src/guestfs-actions.pod:1842 ../fish/guestfish-actions.pod:9 ../fish/guestfish-actions.pod:1255
2992 #: ../src/guestfs.pod:1531
2993 msgid "The C<_BITMASK> suffix on each option name when specifying the bitmask."
2997 #: ../src/guestfs.pod:1536
2998 msgid "You do not need to fill in all fields of the structure."
3002 #: ../src/guestfs.pod:1540
3004 "There must be a one-to-one correspondence between fields of the structure "
3005 "that are filled in, and bits set in the bitmask."
3009 #: ../src/guestfs.pod:1545
3010 msgid "OPTIONAL ARGUMENTS IN OTHER LANGUAGES"
3014 #: ../src/guestfs.pod:1547
3016 "In other languages, optional arguments are expressed in the way that is "
3017 "natural for that language. We refer you to the language-specific "
3018 "documentation for more details on that."
3022 #: ../src/guestfs.pod:1551
3023 msgid "For guestfish, see L<guestfish(1)/OPTIONAL ARGUMENTS>."
3027 #: ../src/guestfs.pod:1553
3028 msgid "SETTING CALLBACKS TO HANDLE EVENTS"
3032 #: ../src/guestfs.pod:1555
3034 "The child process generates events in some situations. Current events "
3035 "include: receiving a log message, the child process exits."
3039 #: ../src/guestfs.pod:1558
3041 "Use the C<guestfs_set_*_callback> functions to set a callback for different "
3046 #: ../src/guestfs.pod:1561
3048 "Only I<one callback of each type> can be registered for each handle. "
3049 "Calling C<guestfs_set_*_callback> again overwrites the previous callback of "
3050 "that type. Cancel all callbacks of this type by calling this function with "
3051 "C<cb> set to C<NULL>."
3055 #: ../src/guestfs.pod:1566
3056 msgid "guestfs_set_log_message_callback"
3060 #: ../src/guestfs.pod:1568
3063 " typedef void (*guestfs_log_message_cb) (guestfs_h *g, void *opaque,\n"
3064 " char *buf, int len);\n"
3065 " void guestfs_set_log_message_callback (guestfs_h *g,\n"
3066 " guestfs_log_message_cb cb,\n"
3072 #: ../src/guestfs.pod:1574
3074 "The callback function C<cb> will be called whenever qemu or the guest writes "
3075 "anything to the console."
3079 #: ../src/guestfs.pod:1577
3080 msgid "Use this function to capture kernel messages and similar."
3084 #: ../src/guestfs.pod:1579
3086 "Normally there is no log message handler, and log messages are just "
3091 #: ../src/guestfs.pod:1582
3092 msgid "guestfs_set_subprocess_quit_callback"
3096 #: ../src/guestfs.pod:1584
3099 " typedef void (*guestfs_subprocess_quit_cb) (guestfs_h *g, void *opaque);\n"
3100 " void guestfs_set_subprocess_quit_callback (guestfs_h *g,\n"
3101 " guestfs_subprocess_quit_cb cb,\n"
3107 #: ../src/guestfs.pod:1589
3109 "The callback function C<cb> will be called when the child process quits, "
3110 "either asynchronously or if killed by L</guestfs_kill_subprocess>. (This "
3111 "corresponds to a transition from any state to the CONFIG state)."
3115 #: ../src/guestfs.pod:1594
3116 msgid "guestfs_set_launch_done_callback"
3120 #: ../src/guestfs.pod:1596
3123 " typedef void (*guestfs_launch_done_cb) (guestfs_h *g, void *opaque);\n"
3124 " void guestfs_set_launch_done_callback (guestfs_h *g,\n"
3125 " guestfs_launch_done_cb cb,\n"
3131 #: ../src/guestfs.pod:1601
3133 "The callback function C<cb> will be called when the child process becomes "
3134 "ready first time after it has been launched. (This corresponds to a "
3135 "transition from LAUNCHING to the READY state)."
3139 #: ../src/guestfs.pod:1605
3140 msgid "guestfs_set_close_callback"
3144 #: ../src/guestfs.pod:1607
3147 " typedef void (*guestfs_close_cb) (guestfs_h *g, void *opaque);\n"
3148 " void guestfs_set_close_callback (guestfs_h *g,\n"
3149 " guestfs_close_cb cb,\n"
3155 #: ../src/guestfs.pod:1612
3157 "The callback function C<cb> will be called while the handle is being closed "
3158 "(synchronously from L</guestfs_close>)."
3162 #: ../src/guestfs.pod:1615
3164 "Note that libguestfs installs an L<atexit(3)> handler to try to clean up "
3165 "handles that are open when the program exits. This means that this callback "
3166 "might be called indirectly from L<exit(3)>, which can cause unexpected "
3167 "problems in higher-level languages (eg. if your HLL interpreter has already "
3168 "been cleaned up by the time this is called, and if your callback then jumps "
3169 "into some HLL function)."
3173 #: ../src/guestfs.pod:1623
3174 msgid "guestfs_set_progress_callback"
3178 #: ../src/guestfs.pod:1625
3181 " typedef void (*guestfs_progress_cb) (guestfs_h *g, void *opaque,\n"
3182 " int proc_nr, int serial,\n"
3183 " uint64_t position, uint64_t total);\n"
3184 " void guestfs_set_progress_callback (guestfs_h *g,\n"
3185 " guestfs_progress_cb cb,\n"
3191 #: ../src/guestfs.pod:1632
3193 "Some long-running operations can generate progress messages. If this "
3194 "callback is registered, then it will be called each time a progress message "
3195 "is generated (usually two seconds after the operation started, and three "
3196 "times per second thereafter until it completes, although the frequency may "
3197 "change in future versions)."
3201 #: ../src/guestfs.pod:1638
3203 "The callback receives two numbers: C<position> and C<total>. The units of "
3204 "C<total> are not defined, although for some operations C<total> may relate "
3205 "in some way to the amount of data to be transferred (eg. in bytes or "
3206 "megabytes), and C<position> may be the portion which has been transferred."
3210 #: ../src/guestfs.pod:1644
3211 msgid "The only defined and stable parts of the API are:"
3215 #: ../src/guestfs.pod:1650
3217 "The callback can display to the user some type of progress bar or indicator "
3218 "which shows the ratio of C<position>:C<total>."
3222 #: ../src/guestfs.pod:1655
3223 msgid "0 E<lt>= C<position> E<lt>= C<total>"
3227 #: ../src/guestfs.pod:1659
3229 "If any progress notification is sent during a call, then a final progress "
3230 "notification is always sent when C<position> = C<total>."
3234 #: ../src/guestfs.pod:1662
3236 "This is to simplify caller code, so callers can easily set the progress "
3237 "indicator to \"100%\" at the end of the operation, without requiring special "
3238 "code to detect this case."
3242 #: ../src/guestfs.pod:1668
3244 "The callback also receives the procedure number and serial number of the "
3245 "call. These are only useful for debugging protocol issues, and the callback "
3246 "can normally ignore them. The callback may want to print these numbers in "
3247 "error messages or debugging messages."
3251 #: ../src/guestfs.pod:1673
3252 msgid "PRIVATE DATA AREA"
3256 #: ../src/guestfs.pod:1675
3258 "You can attach named pieces of private data to the libguestfs handle, and "
3259 "fetch them by name for the lifetime of the handle. This is called the "
3260 "private data area and is only available from the C API."
3264 #: ../src/guestfs.pod:1679
3265 msgid "To attach a named piece of data, use the following call:"
3269 #: ../src/guestfs.pod:1681
3272 " void guestfs_set_private (guestfs_h *g, const char *key, void *data);\n"
3277 #: ../src/guestfs.pod:1683
3279 "C<key> is the name to associate with this data, and C<data> is an arbitrary "
3280 "pointer (which can be C<NULL>). Any previous item with the same name is "
3285 #: ../src/guestfs.pod:1687
3287 "You can use any C<key> you want, but names beginning with an underscore "
3288 "character are reserved for internal libguestfs purposes (for implementing "
3289 "language bindings). It is recommended to prefix the name with some unique "
3290 "string to avoid collisions with other users."
3294 #: ../src/guestfs.pod:1692
3295 msgid "To retrieve the pointer, use:"
3299 #: ../src/guestfs.pod:1694
3302 " void *guestfs_get_private (guestfs_h *g, const char *key);\n"
3307 #: ../src/guestfs.pod:1696
3309 "This function returns C<NULL> if either no data is found associated with "
3310 "C<key>, or if the user previously set the C<key>'s C<data> pointer to "
3315 #: ../src/guestfs.pod:1700
3317 "Libguestfs does not try to look at or interpret the C<data> pointer in any "
3318 "way. As far as libguestfs is concerned, it need not be a valid pointer at "
3319 "all. In particular, libguestfs does I<not> try to free the data when the "
3320 "handle is closed. If the data must be freed, then the caller must either "
3321 "free it before calling L</guestfs_close> or must set up a close callback to "
3322 "do it (see L</guestfs_set_close_callback>, and note that only one callback "
3323 "can be registered for a handle)."
3327 #: ../src/guestfs.pod:1708
3329 "The private data area is implemented using a hash table, and should be "
3330 "reasonably efficient for moderate numbers of keys."
3334 #: ../src/guestfs.pod:1711 ../src/guestfs.pod:1716
3339 #: ../src/guestfs.pod:1713
3341 "<!-- old anchor for the next section --> <a "
3342 "name=\"state_machine_and_low_level_event_api\"/>"
3346 #: ../src/guestfs.pod:1718
3347 msgid "ARCHITECTURE"
3351 #: ../src/guestfs.pod:1720
3353 "Internally, libguestfs is implemented by running an appliance (a special "
3354 "type of small virtual machine) using L<qemu(1)>. Qemu runs as a child "
3355 "process of the main program."
3359 #: ../src/guestfs.pod:1724
3362 " ___________________\n"
3364 " | main program |\n"
3366 " | | child process / appliance\n"
3367 " | | __________________________\n"
3369 " +-------------------+ RPC | +-----------------+ |\n"
3370 " | libguestfs <--------------------> guestfsd | |\n"
3371 " | | | +-----------------+ |\n"
3372 " \\___________________/ | | Linux kernel | |\n"
3373 " | +--^--------------+ |\n"
3374 " \\_________|________________/\n"
3380 " \\______________/\n"
3385 #: ../src/guestfs.pod:1744
3387 "The library, linked to the main program, creates the child process and hence "
3388 "the appliance in the L</guestfs_launch> function."
3392 #: ../src/guestfs.pod:1747
3394 "Inside the appliance is a Linux kernel and a complete stack of userspace "
3395 "tools (such as LVM and ext2 programs) and a small controlling daemon called "
3396 "L</guestfsd>. The library talks to L</guestfsd> using remote procedure "
3397 "calls (RPC). There is a mostly one-to-one correspondence between libguestfs "
3398 "API calls and RPC calls to the daemon. Lastly the disk image(s) are "
3399 "attached to the qemu process which translates device access by the "
3400 "appliance's Linux kernel into accesses to the image."
3404 #: ../src/guestfs.pod:1756
3406 "A common misunderstanding is that the appliance \"is\" the virtual machine. "
3407 "Although the disk image you are attached to might also be used by some "
3408 "virtual machine, libguestfs doesn't know or care about this. (But you will "
3409 "care if both libguestfs's qemu process and your virtual machine are trying "
3410 "to update the disk image at the same time, since these usually results in "
3411 "massive disk corruption)."
3415 #: ../src/guestfs.pod:1763
3416 msgid "STATE MACHINE"
3420 #: ../src/guestfs.pod:1765
3421 msgid "libguestfs uses a state machine to model the child process:"
3425 #: ../src/guestfs.pod:1767
3437 " / | \\ \\ guestfs_launch\n"
3438 " / | _\\__V______\n"
3440 " / | | LAUNCHING |\n"
3441 " / | \\___________/\n"
3443 " / | guestfs_launch\n"
3445 " ______ / __|____V\n"
3446 " / \\ ------> / \\\n"
3447 " | BUSY | | READY |\n"
3448 " \\______/ <------ \\________/\n"
3453 #: ../src/guestfs.pod:1789
3455 "The normal transitions are (1) CONFIG (when the handle is created, but there "
3456 "is no child process), (2) LAUNCHING (when the child process is booting up), "
3457 "(3) alternating between READY and BUSY as commands are issued to, and "
3458 "carried out by, the child process."
3462 #: ../src/guestfs.pod:1794
3464 "The guest may be killed by L</guestfs_kill_subprocess>, or may die "
3465 "asynchronously at any time (eg. due to some internal error), and that causes "
3466 "the state to transition back to CONFIG."
3470 #: ../src/guestfs.pod:1798
3472 "Configuration commands for qemu such as L</guestfs_add_drive> can only be "
3473 "issued when in the CONFIG state."
3477 #: ../src/guestfs.pod:1801
3479 "The API offers one call that goes from CONFIG through LAUNCHING to READY. "
3480 "L</guestfs_launch> blocks until the child process is READY to accept "
3481 "commands (or until some failure or timeout). L</guestfs_launch> internally "
3482 "moves the state from CONFIG to LAUNCHING while it is running."
3486 #: ../src/guestfs.pod:1807
3488 "API actions such as L</guestfs_mount> can only be issued when in the READY "
3489 "state. These API calls block waiting for the command to be carried out "
3490 "(ie. the state to transition to BUSY and then back to READY). There are no "
3491 "non-blocking versions, and no way to issue more than one command per handle "
3496 #: ../src/guestfs.pod:1813
3498 "Finally, the child process sends asynchronous messages back to the main "
3499 "program, such as kernel log messages. You can register a callback to "
3500 "receive these messages."
3504 #: ../src/guestfs.pod:1817
3509 #: ../src/guestfs.pod:1819
3510 msgid "COMMUNICATION PROTOCOL"
3514 #: ../src/guestfs.pod:1821
3516 "Don't rely on using this protocol directly. This section documents how it "
3517 "currently works, but it may change at any time."
3521 #: ../src/guestfs.pod:1824
3523 "The protocol used to talk between the library and the daemon running inside "
3524 "the qemu virtual machine is a simple RPC mechanism built on top of XDR (RFC "
3525 "1014, RFC 1832, RFC 4506)."
3529 #: ../src/guestfs.pod:1828
3531 "The detailed format of structures is in C<src/guestfs_protocol.x> (note: "
3532 "this file is automatically generated)."
3536 #: ../src/guestfs.pod:1831
3538 "There are two broad cases, ordinary functions that don't have any C<FileIn> "
3539 "and C<FileOut> parameters, which are handled with very simple request/reply "
3540 "messages. Then there are functions that have any C<FileIn> or C<FileOut> "
3541 "parameters, which use the same request and reply messages, but they may also "
3542 "be followed by files sent using a chunked encoding."
3546 #: ../src/guestfs.pod:1838
3547 msgid "ORDINARY FUNCTIONS (NO FILEIN/FILEOUT PARAMS)"
3551 #: ../src/guestfs.pod:1840
3552 msgid "For ordinary functions, the request message is:"
3556 #: ../src/guestfs.pod:1842
3559 " total length (header + arguments,\n"
3560 " but not including the length word itself)\n"
3561 " struct guestfs_message_header (encoded as XDR)\n"
3562 " struct guestfs_<foo>_args (encoded as XDR)\n"
3567 #: ../src/guestfs.pod:1847
3569 "The total length field allows the daemon to allocate a fixed size buffer "
3570 "into which it slurps the rest of the message. As a result, the total length "
3571 "is limited to C<GUESTFS_MESSAGE_MAX> bytes (currently 4MB), which means the "
3572 "effective size of any request is limited to somewhere under this size."
3576 #: ../src/guestfs.pod:1853
3578 "Note also that many functions don't take any arguments, in which case the "
3579 "C<guestfs_I<foo>_args> is completely omitted."
3583 #: ../src/guestfs.pod:1856
3585 "The header contains the procedure number (C<guestfs_proc>) which is how the "
3586 "receiver knows what type of args structure to expect, or none at all."
3590 #: ../src/guestfs.pod:1860
3591 msgid "The reply message for ordinary functions is:"
3595 #: ../src/guestfs.pod:1862
3598 " total length (header + ret,\n"
3599 " but not including the length word itself)\n"
3600 " struct guestfs_message_header (encoded as XDR)\n"
3601 " struct guestfs_<foo>_ret (encoded as XDR)\n"
3606 #: ../src/guestfs.pod:1867
3608 "As above the C<guestfs_I<foo>_ret> structure may be completely omitted for "
3609 "functions that return no formal return values."
3613 #: ../src/guestfs.pod:1870
3614 msgid "As above the total length of the reply is limited to C<GUESTFS_MESSAGE_MAX>."
3618 #: ../src/guestfs.pod:1873
3620 "In the case of an error, a flag is set in the header, and the reply message "
3621 "is slightly changed:"
3625 #: ../src/guestfs.pod:1876
3628 " total length (header + error,\n"
3629 " but not including the length word itself)\n"
3630 " struct guestfs_message_header (encoded as XDR)\n"
3631 " struct guestfs_message_error (encoded as XDR)\n"
3636 #: ../src/guestfs.pod:1881
3638 "The C<guestfs_message_error> structure contains the error message as a "
3643 #: ../src/guestfs.pod:1884
3644 msgid "FUNCTIONS THAT HAVE FILEIN PARAMETERS"
3648 #: ../src/guestfs.pod:1886
3650 "A C<FileIn> parameter indicates that we transfer a file I<into> the guest. "
3651 "The normal request message is sent (see above). However this is followed by "
3652 "a sequence of file chunks."
3656 #: ../src/guestfs.pod:1890
3659 " total length (header + arguments,\n"
3660 " but not including the length word itself,\n"
3661 " and not including the chunks)\n"
3662 " struct guestfs_message_header (encoded as XDR)\n"
3663 " struct guestfs_<foo>_args (encoded as XDR)\n"
3664 " sequence of chunks for FileIn param #0\n"
3665 " sequence of chunks for FileIn param #1 etc.\n"
3670 #: ../src/guestfs.pod:1898
3671 msgid "The \"sequence of chunks\" is:"
3675 #: ../src/guestfs.pod:1900
3678 " length of chunk (not including length word itself)\n"
3679 " struct guestfs_chunk (encoded as XDR)\n"
3680 " length of chunk\n"
3681 " struct guestfs_chunk (encoded as XDR)\n"
3683 " length of chunk\n"
3684 " struct guestfs_chunk (with data.data_len == 0)\n"
3689 #: ../src/guestfs.pod:1908
3691 "The final chunk has the C<data_len> field set to zero. Additionally a flag "
3692 "is set in the final chunk to indicate either successful completion or early "
3697 #: ../src/guestfs.pod:1912
3699 "At time of writing there are no functions that have more than one FileIn "
3700 "parameter. However this is (theoretically) supported, by sending the "
3701 "sequence of chunks for each FileIn parameter one after another (from left to "
3706 #: ../src/guestfs.pod:1917
3708 "Both the library (sender) I<and> the daemon (receiver) may cancel the "
3709 "transfer. The library does this by sending a chunk with a special flag set "
3710 "to indicate cancellation. When the daemon sees this, it cancels the whole "
3711 "RPC, does I<not> send any reply, and goes back to reading the next request."
3715 #: ../src/guestfs.pod:1923
3717 "The daemon may also cancel. It does this by writing a special word "
3718 "C<GUESTFS_CANCEL_FLAG> to the socket. The library listens for this during "
3719 "the transfer, and if it gets it, it will cancel the transfer (it sends a "
3720 "cancel chunk). The special word is chosen so that even if cancellation "
3721 "happens right at the end of the transfer (after the library has finished "
3722 "writing and has started listening for the reply), the \"spurious\" cancel "
3723 "flag will not be confused with the reply message."
3727 #: ../src/guestfs.pod:1932
3729 "This protocol allows the transfer of arbitrary sized files (no 32 bit "
3730 "limit), and also files where the size is not known in advance (eg. from "
3731 "pipes or sockets). However the chunks are rather small "
3732 "(C<GUESTFS_MAX_CHUNK_SIZE>), so that neither the library nor the daemon need "
3733 "to keep much in memory."
3737 #: ../src/guestfs.pod:1938
3738 msgid "FUNCTIONS THAT HAVE FILEOUT PARAMETERS"
3742 #: ../src/guestfs.pod:1940
3744 "The protocol for FileOut parameters is exactly the same as for FileIn "
3745 "parameters, but with the roles of daemon and library reversed."
3749 #: ../src/guestfs.pod:1943
3752 " total length (header + ret,\n"
3753 " but not including the length word itself,\n"
3754 " and not including the chunks)\n"
3755 " struct guestfs_message_header (encoded as XDR)\n"
3756 " struct guestfs_<foo>_ret (encoded as XDR)\n"
3757 " sequence of chunks for FileOut param #0\n"
3758 " sequence of chunks for FileOut param #1 etc.\n"
3763 #: ../src/guestfs.pod:1951
3764 msgid "INITIAL MESSAGE"
3768 #: ../src/guestfs.pod:1953
3770 "When the daemon launches it sends an initial word (C<GUESTFS_LAUNCH_FLAG>) "
3771 "which indicates that the guest and daemon is alive. This is what "
3772 "L</guestfs_launch> waits for."
3776 #: ../src/guestfs.pod:1957
3777 msgid "PROGRESS NOTIFICATION MESSAGES"
3781 #: ../src/guestfs.pod:1959
3783 "The daemon may send progress notification messages at any time. These are "
3784 "distinguished by the normal length word being replaced by "
3785 "C<GUESTFS_PROGRESS_FLAG>, followed by a fixed size progress message."
3789 #: ../src/guestfs.pod:1963
3791 "The library turns them into progress callbacks (see "
3792 "C<guestfs_set_progress_callback>) if there is a callback registered, or "
3793 "discards them if not."
3797 #: ../src/guestfs.pod:1967
3799 "The daemon self-limits the frequency of progress messages it sends (see "
3800 "C<daemon/proto.c:notify_progress>). Not all calls generate progress "
3805 #: ../src/guestfs.pod:1971
3806 msgid "LIBGUESTFS VERSION NUMBERS"
3810 #: ../src/guestfs.pod:1973
3812 "Since April 2010, libguestfs has started to make separate development and "
3813 "stable releases, along with corresponding branches in our git repository. "
3814 "These separate releases can be identified by version number:"
3818 #: ../src/guestfs.pod:1978
3821 " even numbers for stable: 1.2.x, 1.4.x, ...\n"
3822 " .-------- odd numbers for development: 1.3.x, 1.5.x, ...\n"
3828 " | `-------- sub-version\n"
3830 " `------ always '1' because we don't change the ABI\n"
3835 #: ../src/guestfs.pod:1989
3836 msgid "Thus \"1.3.5\" is the 5th update to the development branch \"1.3\"."
3840 #: ../src/guestfs.pod:1991
3842 "As time passes we cherry pick fixes from the development branch and backport "
3843 "those into the stable branch, the effect being that the stable branch should "
3844 "get more stable and less buggy over time. So the stable releases are ideal "
3845 "for people who don't need new features but would just like the software to "
3850 #: ../src/guestfs.pod:1997
3851 msgid "Our criteria for backporting changes are:"
3855 #: ../src/guestfs.pod:2003
3857 "Documentation changes which don't affect any code are backported unless the "
3858 "documentation refers to a future feature which is not in stable."
3862 #: ../src/guestfs.pod:2009
3864 "Bug fixes which are not controversial, fix obvious problems, and have been "
3865 "well tested are backported."
3869 #: ../src/guestfs.pod:2014
3871 "Simple rearrangements of code which shouldn't affect how it works get "
3872 "backported. This is so that the code in the two branches doesn't get too "
3873 "far out of step, allowing us to backport future fixes more easily."
3877 #: ../src/guestfs.pod:2020
3879 "We I<don't> backport new features, new APIs, new tools etc, except in one "
3880 "exceptional case: the new feature is required in order to implement an "
3881 "important bug fix."
3885 #: ../src/guestfs.pod:2026
3887 "A new stable branch starts when we think the new features in development are "
3888 "substantial and compelling enough over the current stable branch to warrant "
3889 "it. When that happens we create new stable and development versions 1.N.0 "
3890 "and 1.(N+1).0 [N is even]. The new dot-oh release won't necessarily be so "
3891 "stable at this point, but by backporting fixes from development, that branch "
3892 "will stabilize over time."
3896 #: ../src/guestfs.pod:2034 ../fish/guestfish.pod:914 ../test-tool/libguestfs-test-tool.pod:104 ../tools/virt-edit.pl:330 ../tools/virt-rescue.pl:255
3897 msgid "ENVIRONMENT VARIABLES"
3901 #: ../src/guestfs.pod:2038 ../fish/guestfish.pod:940
3902 msgid "LIBGUESTFS_APPEND"
3906 #: ../src/guestfs.pod:2040 ../fish/guestfish.pod:942
3907 msgid "Pass additional options to the guest kernel."
3911 #: ../src/guestfs.pod:2042 ../fish/guestfish.pod:944
3912 msgid "LIBGUESTFS_DEBUG"
3916 #: ../src/guestfs.pod:2044
3918 "Set C<LIBGUESTFS_DEBUG=1> to enable verbose messages. This has the same "
3919 "effect as calling C<guestfs_set_verbose (g, 1)>."
3923 #: ../src/guestfs.pod:2047 ../fish/guestfish.pod:949
3924 msgid "LIBGUESTFS_MEMSIZE"
3928 #: ../src/guestfs.pod:2049 ../fish/guestfish.pod:951
3929 msgid "Set the memory allocated to the qemu process, in megabytes. For example:"
3933 #: ../src/guestfs.pod:2052 ../fish/guestfish.pod:954
3936 " LIBGUESTFS_MEMSIZE=700\n"
3941 #: ../src/guestfs.pod:2054 ../fish/guestfish.pod:956
3942 msgid "LIBGUESTFS_PATH"
3946 #: ../src/guestfs.pod:2056
3948 "Set the path that libguestfs uses to search for kernel and initrd.img. See "
3949 "the discussion of paths in section PATH above."
3953 #: ../src/guestfs.pod:2059 ../fish/guestfish.pod:961
3954 msgid "LIBGUESTFS_QEMU"
3958 #: ../src/guestfs.pod:2061 ../fish/guestfish.pod:963
3960 "Set the default qemu binary that libguestfs uses. If not set, then the qemu "
3961 "which was found at compile time by the configure script is used."
3965 #: ../src/guestfs.pod:2065
3966 msgid "See also L</QEMU WRAPPERS> above."
3970 #: ../src/guestfs.pod:2067 ../fish/guestfish.pod:967
3971 msgid "LIBGUESTFS_TRACE"
3975 #: ../src/guestfs.pod:2069
3977 "Set C<LIBGUESTFS_TRACE=1> to enable command traces. This has the same "
3978 "effect as calling C<guestfs_set_trace (g, 1)>."
3982 #: ../src/guestfs.pod:2072 ../fish/guestfish.pod:976
3987 #: ../src/guestfs.pod:2074 ../fish/guestfish.pod:978
3988 msgid "Location of temporary directory, defaults to C</tmp>."
3992 #: ../src/guestfs.pod:2076 ../fish/guestfish.pod:980
3994 "If libguestfs was compiled to use the supermin appliance then the real "
3995 "appliance is cached in this directory, shared between all handles belonging "
3996 "to the same EUID. You can use C<$TMPDIR> to configure another directory to "
3997 "use in case C</tmp> is not large enough."
4001 #: ../src/guestfs.pod:2084 ../fish/guestfish.pod:1038 ../test-tool/libguestfs-test-tool.pod:109 ../fuse/guestmount.pod:233 ../inspector/virt-inspector.pl:452 ../tools/virt-edit.pl:350 ../tools/virt-win-reg.pl:484 ../tools/virt-df.pl:640 ../tools/virt-ls.pl:232 ../tools/virt-resize.pl:1486 ../tools/virt-list-filesystems.pl:186 ../tools/virt-tar.pl:281 ../tools/virt-rescue.pl:267 ../tools/virt-make-fs.pl:534 ../tools/virt-list-partitions.pl:254
4006 #: ../src/guestfs.pod:2086
4008 "L<guestfish(1)>, L<guestmount(1)>, L<virt-cat(1)>, L<virt-df(1)>, "
4009 "L<virt-edit(1)>, L<virt-inspector(1)>, L<virt-list-filesystems(1)>, "
4010 "L<virt-list-partitions(1)>, L<virt-ls(1)>, L<virt-make-fs(1)>, "
4011 "L<virt-rescue(1)>, L<virt-tar(1)>, L<virt-win-reg(1)>, L<qemu(1)>, "
4012 "L<febootstrap(1)>, L<hivex(3)>, L<http://libguestfs.org/>."
4016 #: ../src/guestfs.pod:2104
4018 "Tools with a similar purpose: L<fdisk(8)>, L<parted(8)>, L<kpartx(8)>, "
4019 "L<lvm(8)>, L<disktype(1)>."
4023 #: ../src/guestfs.pod:2111 ../tools/virt-win-reg.pl:499 ../tools/virt-make-fs.pl:548
4028 #: ../src/guestfs.pod:2113
4029 msgid "To get a list of bugs against libguestfs use this link:"
4033 #: ../src/guestfs.pod:2115
4034 msgid "L<https://bugzilla.redhat.com/buglist.cgi?component=libguestfs&product=Virtualization+Tools>"
4038 #: ../src/guestfs.pod:2117
4039 msgid "To report a new bug against libguestfs use this link:"
4043 #: ../src/guestfs.pod:2119
4044 msgid "L<https://bugzilla.redhat.com/enter_bug.cgi?component=libguestfs&product=Virtualization+Tools>"
4048 #: ../src/guestfs.pod:2121
4049 msgid "When reporting a bug, please check:"
4053 #: ../src/guestfs.pod:2127
4054 msgid "That the bug hasn't been reported already."
4058 #: ../src/guestfs.pod:2131
4059 msgid "That you are testing a recent version."
4063 #: ../src/guestfs.pod:2135
4064 msgid "Describe the bug accurately, and give a way to reproduce it."
4068 #: ../src/guestfs.pod:2139
4070 "Run libguestfs-test-tool and paste the B<complete, unedited> output into the "
4075 #: ../src/guestfs.pod:2144 ../fish/guestfish.pod:1055 ../test-tool/libguestfs-test-tool.pod:115 ../fuse/guestmount.pod:244 ../inspector/virt-inspector.pl:462
4080 #: ../src/guestfs.pod:2146 ../fish/guestfish.pod:1057 ../test-tool/libguestfs-test-tool.pod:117 ../fuse/guestmount.pod:246
4081 msgid "Richard W.M. Jones (C<rjones at redhat dot com>)"
4085 #: ../src/guestfs.pod:2148 ../fish/guestfish.pod:1059 ../test-tool/libguestfs-test-tool.pod:119 ../fuse/guestmount.pod:248 ../inspector/virt-inspector.pl:476 ../tools/virt-edit.pl:366 ../tools/virt-win-reg.pl:514 ../tools/virt-df.pl:653 ../tools/virt-ls.pl:247 ../tools/virt-resize.pl:1512 ../tools/virt-list-filesystems.pl:202 ../tools/virt-tar.pl:296 ../tools/virt-rescue.pl:281 ../tools/virt-make-fs.pl:563 ../tools/virt-list-partitions.pl:269
4090 #: ../src/guestfs.pod:2150 ../fish/guestfish.pod:1061 ../fuse/guestmount.pod:250
4091 msgid "Copyright (C) 2009-2010 Red Hat Inc. L<http://libguestfs.org/>"
4095 #: ../src/guestfs.pod:2153
4097 "This library is free software; you can redistribute it and/or modify it "
4098 "under the terms of the GNU Lesser General Public License as published by the "
4099 "Free Software Foundation; either version 2 of the License, or (at your "
4100 "option) any later version."
4104 #: ../src/guestfs.pod:2158
4106 "This library is distributed in the hope that it will be useful, but WITHOUT "
4107 "ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or "
4108 "FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License "
4113 #: ../src/guestfs.pod:2163
4115 "You should have received a copy of the GNU Lesser General Public License "
4116 "along with this library; if not, write to the Free Software Foundation, "
4117 "Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA"
4121 #: ../src/guestfs-actions.pod:1
4122 msgid "guestfs_add_cdrom"
4126 #: ../src/guestfs-actions.pod:3
4130 " guestfs_add_cdrom (guestfs_h *g,\n"
4131 " const char *filename);\n"
4136 #: ../src/guestfs-actions.pod:7 ../fish/guestfish-actions.pod:5
4137 msgid "This function adds a virtual CD-ROM disk image to the guest."
4141 #: ../src/guestfs-actions.pod:9 ../fish/guestfish-actions.pod:7
4142 msgid "This is equivalent to the qemu parameter C<-cdrom filename>."
4146 #: ../src/guestfs-actions.pod:17
4148 "This call checks for the existence of C<filename>. This stops you from "
4149 "specifying other types of drive which are supported by qemu such as C<nbd:> "
4150 "and C<http:> URLs. To specify those, use the general C<guestfs_config> call "
4155 #: ../src/guestfs-actions.pod:24
4157 "If you just want to add an ISO file (often you use this as an efficient way "
4158 "to transfer large files into the guest), then you should probably use "
4159 "C<guestfs_add_drive_ro> instead."
4163 #: ../src/guestfs-actions.pod:30 ../src/guestfs-actions.pod:126 ../src/guestfs-actions.pod:187 ../src/guestfs-actions.pod:224 ../src/guestfs-actions.pod:238 ../src/guestfs-actions.pod:259 ../src/guestfs-actions.pod:279 ../src/guestfs-actions.pod:293 ../src/guestfs-actions.pod:408 ../src/guestfs-actions.pod:428 ../src/guestfs-actions.pod:442 ../src/guestfs-actions.pod:487 ../src/guestfs-actions.pod:515 ../src/guestfs-actions.pod:533 ../src/guestfs-actions.pod:600 ../src/guestfs-actions.pod:633 ../src/guestfs-actions.pod:647 ../src/guestfs-actions.pod:662 ../src/guestfs-actions.pod:761 ../src/guestfs-actions.pod:779 ../src/guestfs-actions.pod:793 ../src/guestfs-actions.pod:807 ../src/guestfs-actions.pod:968 ../src/guestfs-actions.pod:988 ../src/guestfs-actions.pod:1006 ../src/guestfs-actions.pod:1090 ../src/guestfs-actions.pod:1108 ../src/guestfs-actions.pod:1127 ../src/guestfs-actions.pod:1141 ../src/guestfs-actions.pod:1161 ../src/guestfs-actions.pod:1231 ../src/guestfs-actions.pod:1262 ../src/guestfs-actions.pod:1287 ../src/guestfs-actions.pod:1324 ../src/guestfs-actions.pod:1430 ../src/guestfs-actions.pod:1464 ../src/guestfs-actions.pod:1682 ../src/guestfs-actions.pod:1704 ../src/guestfs-actions.pod:1791 ../src/guestfs-actions.pod:2213 ../src/guestfs-actions.pod:2357 ../src/guestfs-actions.pod:2418 ../src/guestfs-actions.pod:2453 ../src/guestfs-actions.pod:3182 ../src/guestfs-actions.pod:3197 ../src/guestfs-actions.pod:3217 ../src/guestfs-actions.pod:3342 ../src/guestfs-actions.pod:3356 ../src/guestfs-actions.pod:3369 ../src/guestfs-actions.pod:3383 ../src/guestfs-actions.pod:3398 ../src/guestfs-actions.pod:3434 ../src/guestfs-actions.pod:3506 ../src/guestfs-actions.pod:3526 ../src/guestfs-actions.pod:3543 ../src/guestfs-actions.pod:3566 ../src/guestfs-actions.pod:3589 ../src/guestfs-actions.pod:3621 ../src/guestfs-actions.pod:3640 ../src/guestfs-actions.pod:3659 ../src/guestfs-actions.pod:3694 ../src/guestfs-actions.pod:3706 ../src/guestfs-actions.pod:3742 ../src/guestfs-actions.pod:3758 ../src/guestfs-actions.pod:3771 ../src/guestfs-actions.pod:3786 ../src/guestfs-actions.pod:3803 ../src/guestfs-actions.pod:3896 ../src/guestfs-actions.pod:3916 ../src/guestfs-actions.pod:3929 ../src/guestfs-actions.pod:3980 ../src/guestfs-actions.pod:3998 ../src/guestfs-actions.pod:4016 ../src/guestfs-actions.pod:4032 ../src/guestfs-actions.pod:4046 ../src/guestfs-actions.pod:4060 ../src/guestfs-actions.pod:4077 ../src/guestfs-actions.pod:4092 ../src/guestfs-actions.pod:4112 ../src/guestfs-actions.pod:4161 ../src/guestfs-actions.pod:4192 ../src/guestfs-actions.pod:4211 ../src/guestfs-actions.pod:4230 ../src/guestfs-actions.pod:4242 ../src/guestfs-actions.pod:4259 ../src/guestfs-actions.pod:4272 ../src/guestfs-actions.pod:4287 ../src/guestfs-actions.pod:4302 ../src/guestfs-actions.pod:4337 ../src/guestfs-actions.pod:4352 ../src/guestfs-actions.pod:4372 ../src/guestfs-actions.pod:4386 ../src/guestfs-actions.pod:4403 ../src/guestfs-actions.pod:4452 ../src/guestfs-actions.pod:4489 ../src/guestfs-actions.pod:4503 ../src/guestfs-actions.pod:4531 ../src/guestfs-actions.pod:4548 ../src/guestfs-actions.pod:4566 ../src/guestfs-actions.pod:4700 ../src/guestfs-actions.pod:4757 ../src/guestfs-actions.pod:4779 ../src/guestfs-actions.pod:4797 ../src/guestfs-actions.pod:4829 ../src/guestfs-actions.pod:4895 ../src/guestfs-actions.pod:4912 ../src/guestfs-actions.pod:4925 ../src/guestfs-actions.pod:4939 ../src/guestfs-actions.pod:5228 ../src/guestfs-actions.pod:5247 ../src/guestfs-actions.pod:5261 ../src/guestfs-actions.pod:5273 ../src/guestfs-actions.pod:5287 ../src/guestfs-actions.pod:5299 ../src/guestfs-actions.pod:5313 ../src/guestfs-actions.pod:5329 ../src/guestfs-actions.pod:5350 ../src/guestfs-actions.pod:5369 ../src/guestfs-actions.pod:5388 ../src/guestfs-actions.pod:5406 ../src/guestfs-actions.pod:5429 ../src/guestfs-actions.pod:5447 ../src/guestfs-actions.pod:5466 ../src/guestfs-actions.pod:5487 ../src/guestfs-actions.pod:5506 ../src/guestfs-actions.pod:5523 ../src/guestfs-actions.pod:5551 ../src/guestfs-actions.pod:5575 ../src/guestfs-actions.pod:5594 ../src/guestfs-actions.pod:5618 ../src/guestfs-actions.pod:5633 ../src/guestfs-actions.pod:5648 ../src/guestfs-actions.pod:5667 ../src/guestfs-actions.pod:5704 ../src/guestfs-actions.pod:5727 ../src/guestfs-actions.pod:5753 ../src/guestfs-actions.pod:5861 ../src/guestfs-actions.pod:5982 ../src/guestfs-actions.pod:5994 ../src/guestfs-actions.pod:6007 ../src/guestfs-actions.pod:6020 ../src/guestfs-actions.pod:6042 ../src/guestfs-actions.pod:6055 ../src/guestfs-actions.pod:6068 ../src/guestfs-actions.pod:6081 ../src/guestfs-actions.pod:6096 ../src/guestfs-actions.pod:6155 ../src/guestfs-actions.pod:6172 ../src/guestfs-actions.pod:6188 ../src/guestfs-actions.pod:6204 ../src/guestfs-actions.pod:6221 ../src/guestfs-actions.pod:6234 ../src/guestfs-actions.pod:6254 ../src/guestfs-actions.pod:6290 ../src/guestfs-actions.pod:6304 ../src/guestfs-actions.pod:6345 ../src/guestfs-actions.pod:6358 ../src/guestfs-actions.pod:6376 ../src/guestfs-actions.pod:6405 ../src/guestfs-actions.pod:6436 ../src/guestfs-actions.pod:6555 ../src/guestfs-actions.pod:6573 ../src/guestfs-actions.pod:6587 ../src/guestfs-actions.pod:6642 ../src/guestfs-actions.pod:6655 ../src/guestfs-actions.pod:6700 ../src/guestfs-actions.pod:6733 ../src/guestfs-actions.pod:6787 ../src/guestfs-actions.pod:6813 ../src/guestfs-actions.pod:6879 ../src/guestfs-actions.pod:6898 ../src/guestfs-actions.pod:6927
4164 msgid "This function returns 0 on success or -1 on error."
4168 #: ../src/guestfs-actions.pod:32 ../src/guestfs-actions.pod:240 ../src/guestfs-actions.pod:261 ../fish/guestfish-actions.pod:28 ../fish/guestfish-actions.pod:153 ../fish/guestfish-actions.pod:167
4170 "This function is deprecated. In new code, use the C<add_drive_opts> call "
4175 #: ../src/guestfs-actions.pod:35 ../src/guestfs-actions.pod:243 ../src/guestfs-actions.pod:264 ../src/guestfs-actions.pod:1435 ../src/guestfs-actions.pod:1921 ../src/guestfs-actions.pod:1942 ../src/guestfs-actions.pod:6821 ../src/guestfs-actions.pod:6990 ../fish/guestfish-actions.pod:31 ../fish/guestfish-actions.pod:156 ../fish/guestfish-actions.pod:170 ../fish/guestfish-actions.pod:951 ../fish/guestfish-actions.pod:1308 ../fish/guestfish-actions.pod:1322 ../fish/guestfish-actions.pod:4549 ../fish/guestfish-actions.pod:4646
4177 "Deprecated functions will not be removed from the API, but the fact that "
4178 "they are deprecated indicates that there are problems with correct use of "
4183 #: ../src/guestfs-actions.pod:39 ../src/guestfs-actions.pod:128 ../src/guestfs-actions.pod:1092 ../src/guestfs-actions.pod:1893 ../src/guestfs-actions.pod:1991 ../src/guestfs-actions.pod:2094 ../src/guestfs-actions.pod:3184 ../src/guestfs-actions.pod:3199 ../src/guestfs-actions.pod:4339 ../src/guestfs-actions.pod:5408 ../src/guestfs-actions.pod:5525 ../src/guestfs-actions.pod:5635 ../src/guestfs-actions.pod:6098 ../src/guestfs-actions.pod:6223 ../src/guestfs-actions.pod:6735
4184 msgid "(Added in 0.3)"
4188 #: ../src/guestfs-actions.pod:41
4189 msgid "guestfs_add_domain"
4193 #: ../src/guestfs-actions.pod:43
4197 " guestfs_add_domain (guestfs_h *g,\n"
4198 " const char *dom,\n"
4204 #: ../src/guestfs-actions.pod:48 ../src/guestfs-actions.pod:137
4206 "You may supply a list of optional arguments to this call. Use zero or more "
4207 "of the following pairs of parameters, and terminate the list with C<-1> on "
4208 "its own. See L</CALLS WITH OPTIONAL ARGUMENTS>."
4212 #: ../src/guestfs-actions.pod:53
4215 " GUESTFS_ADD_DOMAIN_LIBVIRTURI, const char *libvirturi,\n"
4216 " GUESTFS_ADD_DOMAIN_READONLY, int readonly,\n"
4217 " GUESTFS_ADD_DOMAIN_IFACE, const char *iface,\n"
4222 #: ../src/guestfs-actions.pod:57
4224 "This function adds the disk(s) attached to the named libvirt domain C<dom>. "
4225 "It works by connecting to libvirt, requesting the domain and domain XML from "
4226 "libvirt, parsing it for disks, and calling C<guestfs_add_drive_opts> on each "
4231 #: ../src/guestfs-actions.pod:62 ../fish/guestfish-actions.pod:46
4233 "The number of disks added is returned. This operation is atomic: if an "
4234 "error is returned, then no disks are added."
4238 #: ../src/guestfs-actions.pod:65 ../fish/guestfish-actions.pod:49
4240 "This function does some minimal checks to make sure the libvirt domain is "
4241 "not running (unless C<readonly> is true). In a future version we will try "
4242 "to acquire the libvirt lock on each disk."
4246 #: ../src/guestfs-actions.pod:69 ../fish/guestfish-actions.pod:53
4248 "Disks must be accessible locally. This often means that adding disks from a "
4249 "remote libvirt connection (see L<http://libvirt.org/remote.html>) will fail "
4250 "unless those disks are accessible via the same device path locally too."
4254 #: ../src/guestfs-actions.pod:74
4256 "The optional C<libvirturi> parameter sets the libvirt URI (see "
4257 "L<http://libvirt.org/uri.html>). If this is not set then we connect to the "
4258 "default libvirt URI (or one set through an environment variable, see the "
4259 "libvirt documentation for full details). If you are using the C API "
4260 "directly then it is more flexible to create the libvirt connection object "
4261 "yourself, get the domain object, and call C<guestfs_add_libvirt_dom>."
4265 #: ../src/guestfs-actions.pod:82
4267 "The other optional parameters are passed directly through to "
4268 "C<guestfs_add_drive_opts>."
4272 #: ../src/guestfs-actions.pod:85 ../src/guestfs-actions.pod:336 ../src/guestfs-actions.pod:501 ../src/guestfs-actions.pod:679 ../src/guestfs-actions.pod:710 ../src/guestfs-actions.pod:728 ../src/guestfs-actions.pod:747 ../src/guestfs-actions.pod:1307 ../src/guestfs-actions.pod:1661 ../src/guestfs-actions.pod:1864 ../src/guestfs-actions.pod:1963 ../src/guestfs-actions.pod:2003 ../src/guestfs-actions.pod:2058 ../src/guestfs-actions.pod:2081 ../src/guestfs-actions.pod:2344 ../src/guestfs-actions.pod:2630 ../src/guestfs-actions.pod:2651 ../src/guestfs-actions.pod:4475 ../src/guestfs-actions.pod:4603 ../src/guestfs-actions.pod:5009 ../src/guestfs-actions.pod:5035 ../src/guestfs-actions.pod:6331 ../src/guestfs-actions.pod:6746 ../src/guestfs-actions.pod:6759 ../src/guestfs-actions.pod:6772
4273 msgid "On error this function returns -1."
4277 #: ../src/guestfs-actions.pod:87
4278 msgid "guestfs_add_domain_va"
4282 #: ../src/guestfs-actions.pod:89
4286 " guestfs_add_domain_va (guestfs_h *g,\n"
4287 " const char *dom,\n"
4293 #: ../src/guestfs-actions.pod:94
4294 msgid "This is the \"va_list variant\" of L</guestfs_add_domain>."
4298 #: ../src/guestfs-actions.pod:96 ../src/guestfs-actions.pod:107 ../src/guestfs-actions.pod:200 ../src/guestfs-actions.pod:211
4299 msgid "See L</CALLS WITH OPTIONAL ARGUMENTS>."
4303 #: ../src/guestfs-actions.pod:98
4304 msgid "guestfs_add_domain_argv"
4308 #: ../src/guestfs-actions.pod:100
4312 " guestfs_add_domain_argv (guestfs_h *g,\n"
4313 " const char *dom,\n"
4314 " const struct guestfs_add_domain_argv *optargs);\n"
4319 #: ../src/guestfs-actions.pod:105
4320 msgid "This is the \"argv variant\" of L</guestfs_add_domain>."
4324 #: ../src/guestfs-actions.pod:109
4325 msgid "guestfs_add_drive"
4329 #: ../src/guestfs-actions.pod:111
4333 " guestfs_add_drive (guestfs_h *g,\n"
4334 " const char *filename);\n"
4339 #: ../src/guestfs-actions.pod:115
4341 "This function is the equivalent of calling C<guestfs_add_drive_opts> with no "
4342 "optional parameters, so the disk is added writable, with the format being "
4343 "detected automatically."
4347 #: ../src/guestfs-actions.pod:119
4349 "Automatic detection of the format opens you up to a potential security hole "
4350 "when dealing with untrusted raw-format images. See CVE-2010-3851 and "
4351 "RHBZ#642934. Specifying the format closes this security hole. Therefore "
4352 "you should think about replacing calls to this function with calls to "
4353 "C<guestfs_add_drive_opts>, and specifying the format."
4357 #: ../src/guestfs-actions.pod:130
4358 msgid "guestfs_add_drive_opts"
4362 #: ../src/guestfs-actions.pod:132
4366 " guestfs_add_drive_opts (guestfs_h *g,\n"
4367 " const char *filename,\n"
4373 #: ../src/guestfs-actions.pod:142
4376 " GUESTFS_ADD_DRIVE_OPTS_READONLY, int readonly,\n"
4377 " GUESTFS_ADD_DRIVE_OPTS_FORMAT, const char *format,\n"
4378 " GUESTFS_ADD_DRIVE_OPTS_IFACE, const char *iface,\n"
4383 #: ../src/guestfs-actions.pod:146 ../fish/guestfish-actions.pod:92
4385 "This function adds a virtual machine disk image C<filename> to libguestfs. "
4386 "The first time you call this function, the disk appears as C</dev/sda>, the "
4387 "second time as C</dev/sdb>, and so on."
4391 #: ../src/guestfs-actions.pod:151 ../fish/guestfish-actions.pod:97
4393 "You don't necessarily need to be root when using libguestfs. However you "
4394 "obviously do need sufficient permissions to access the filename for whatever "
4395 "operations you want to perform (ie. read access if you just want to read the "
4396 "image or write access if you want to modify the image)."
4400 #: ../src/guestfs-actions.pod:157 ../fish/guestfish-actions.pod:103
4401 msgid "This call checks that C<filename> exists."
4405 #: ../src/guestfs-actions.pod:159 ../fish/guestfish-actions.pod:105
4406 msgid "The optional arguments are:"
4410 #: ../src/guestfs-actions.pod:163 ../fish/guestfish-actions.pod:109
4415 #: ../src/guestfs-actions.pod:165 ../fish/guestfish-actions.pod:111
4417 "If true then the image is treated as read-only. Writes are still allowed, "
4418 "but they are stored in a temporary snapshot overlay which is discarded at "
4419 "the end. The disk that you add is not modified."
4423 #: ../src/guestfs-actions.pod:169 ../fish/guestfish-actions.pod:115
4428 #: ../src/guestfs-actions.pod:171
4430 "This forces the image format. If you omit this (or use C<guestfs_add_drive> "
4431 "or C<guestfs_add_drive_ro>) then the format is automatically detected. "
4432 "Possible formats include C<raw> and C<qcow2>."
4436 #: ../src/guestfs-actions.pod:175 ../fish/guestfish-actions.pod:121
4438 "Automatic detection of the format opens you up to a potential security hole "
4439 "when dealing with untrusted raw-format images. See CVE-2010-3851 and "
4440 "RHBZ#642934. Specifying the format closes this security hole."
4444 #: ../src/guestfs-actions.pod:180 ../fish/guestfish-actions.pod:126
4449 #: ../src/guestfs-actions.pod:182
4451 "This rarely-used option lets you emulate the behaviour of the deprecated "
4452 "C<guestfs_add_drive_with_if> call (q.v.)"
4456 #: ../src/guestfs-actions.pod:189
4457 msgid "(Added in 1.5.23)"
4461 #: ../src/guestfs-actions.pod:191
4462 msgid "guestfs_add_drive_opts_va"
4466 #: ../src/guestfs-actions.pod:193
4470 " guestfs_add_drive_opts_va (guestfs_h *g,\n"
4471 " const char *filename,\n"
4477 #: ../src/guestfs-actions.pod:198
4478 msgid "This is the \"va_list variant\" of L</guestfs_add_drive_opts>."
4482 #: ../src/guestfs-actions.pod:202
4483 msgid "guestfs_add_drive_opts_argv"
4487 #: ../src/guestfs-actions.pod:204
4491 " guestfs_add_drive_opts_argv (guestfs_h *g,\n"
4492 " const char *filename,\n"
4493 " const struct guestfs_add_drive_opts_argv "
4499 #: ../src/guestfs-actions.pod:209
4500 msgid "This is the \"argv variant\" of L</guestfs_add_drive_opts>."
4504 #: ../src/guestfs-actions.pod:213
4505 msgid "guestfs_add_drive_ro"
4509 #: ../src/guestfs-actions.pod:215
4513 " guestfs_add_drive_ro (guestfs_h *g,\n"
4514 " const char *filename);\n"
4519 #: ../src/guestfs-actions.pod:219
4521 "This function is the equivalent of calling C<guestfs_add_drive_opts> with "
4522 "the optional parameter C<GUESTFS_ADD_DRIVE_OPTS_READONLY> set to 1, so the "
4523 "disk is added read-only, with the format being detected automatically."
4527 #: ../src/guestfs-actions.pod:226
4528 msgid "(Added in 1.0.38)"
4532 #: ../src/guestfs-actions.pod:228
4533 msgid "guestfs_add_drive_ro_with_if"