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.8\n"
10 "Report-Msgid-Bugs-To: libguestfs@redhat.com\n"
11 "POT-Creation-Date: 2010-11-15 23:02+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:1521 ../src/guestfs.pod:1526 ../src/guestfs.pod:1530 ../src/guestfs.pod:1640 ../src/guestfs.pod:1645 ../src/guestfs.pod:1649 ../src/guestfs.pod:1993 ../src/guestfs.pod:1999 ../src/guestfs.pod:2004 ../src/guestfs.pod:2010 ../src/guestfs.pod:2117 ../src/guestfs.pod:2121 ../src/guestfs.pod:2125 ../src/guestfs.pod:2129 ../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:1142 ../src/guestfs.pod:1273
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:1146 ../src/guestfs.pod:1277
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:1283
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 "The inspection API parses guest configuration using two external libraries: "
2111 "Augeas (Linux configuration) and hivex (Windows Registry). Both are "
2112 "designed to be robust in the face of malicious data, although denial of "
2113 "service attacks are still possible, for example with oversized configuration "
2118 #: ../src/guestfs.pod:1104
2119 msgid "RUNNING UNTRUSTED GUEST COMMANDS"
2123 #: ../src/guestfs.pod:1106
2125 "Be very cautious about running commands from the guest. By running a "
2126 "command in the guest, you are giving CPU time to a binary that you do not "
2127 "control, under the same user account as the library, albeit wrapped in qemu "
2128 "virtualization. More information and alternatives can be found in the "
2129 "section L</RUNNING COMMANDS>."
2133 #: ../src/guestfs.pod:1112
2134 msgid "CVE-2010-3851"
2138 #: ../src/guestfs.pod:1114
2139 msgid "https://bugzilla.redhat.com/642934"
2143 #: ../src/guestfs.pod:1116
2145 "This security bug concerns the automatic disk format detection that qemu "
2146 "does on disk images."
2150 #: ../src/guestfs.pod:1119
2152 "A raw disk image is just the raw bytes, there is no header. Other disk "
2153 "images like qcow2 contain a special header. Qemu deals with this by looking "
2154 "for one of the known headers, and if none is found then assuming the disk "
2155 "image must be raw."
2159 #: ../src/guestfs.pod:1124
2161 "This allows a guest which has been given a raw disk image to write some "
2162 "other header. At next boot (or when the disk image is accessed by "
2163 "libguestfs) qemu would do autodetection and think the disk image format was, "
2164 "say, qcow2 based on the header written by the guest."
2168 #: ../src/guestfs.pod:1129
2170 "This in itself would not be a problem, but qcow2 offers many features, one "
2171 "of which is to allow a disk image to refer to another image (called the "
2172 "\"backing disk\"). It does this by placing the path to the backing disk "
2173 "into the qcow2 header. This path is not validated and could point to any "
2174 "host file (eg. \"/etc/passwd\"). The backing disk is then exposed through "
2175 "\"holes\" in the qcow2 disk image, which of course is completely under the "
2176 "control of the attacker."
2180 #: ../src/guestfs.pod:1137
2181 msgid "In libguestfs this is rather hard to exploit except under two circumstances:"
2185 #: ../src/guestfs.pod:1144
2186 msgid "You have enabled the network or have opened the disk in write mode."
2190 #: ../src/guestfs.pod:1148
2192 "You are also running untrusted code from the guest (see L</RUNNING "
2197 #: ../src/guestfs.pod:1153
2199 "The way to avoid this is to specify the expected disk format when adding "
2200 "disks (the optional C<format> option to L</guestfs_add_drive_opts>). You "
2201 "should always do this if the disk is raw format, and it's a good idea for "
2206 #: ../src/guestfs.pod:1158
2208 "For disks added from libvirt using calls like L</guestfs_add_domain>, the "
2209 "format is fetched from libvirt and passed through."
2213 #: ../src/guestfs.pod:1161
2215 "For libguestfs tools, use the I<--format> command line parameter as "
2220 #: ../src/guestfs.pod:1164
2221 msgid "CONNECTION MANAGEMENT"
2225 #: ../src/guestfs.pod:1166
2230 #: ../src/guestfs.pod:1168
2232 "C<guestfs_h> is the opaque type representing a connection handle. Create a "
2233 "handle by calling L</guestfs_create>. Call L</guestfs_close> to free the "
2234 "handle and release all resources used."
2238 #: ../src/guestfs.pod:1172
2240 "For information on using multiple handles and threads, see the section "
2241 "L</MULTIPLE HANDLES AND MULTIPLE THREADS> below."
2245 #: ../src/guestfs.pod:1175
2246 msgid "guestfs_create"
2250 #: ../src/guestfs.pod:1177
2253 " guestfs_h *guestfs_create (void);\n"
2258 #: ../src/guestfs.pod:1179
2259 msgid "Create a connection handle."
2263 #: ../src/guestfs.pod:1181
2265 "You have to call L</guestfs_add_drive_opts> (or one of the equivalent calls) "
2266 "on the handle at least once."
2270 #: ../src/guestfs.pod:1184
2272 "This function returns a non-NULL pointer to a handle on success or NULL on "
2277 #: ../src/guestfs.pod:1187
2278 msgid "After configuring the handle, you have to call L</guestfs_launch>."
2282 #: ../src/guestfs.pod:1189
2284 "You may also want to configure error handling for the handle. See L</ERROR "
2285 "HANDLING> section below."
2289 #: ../src/guestfs.pod:1192
2290 msgid "guestfs_close"
2294 #: ../src/guestfs.pod:1194
2297 " void guestfs_close (guestfs_h *g);\n"
2302 #: ../src/guestfs.pod:1196
2303 msgid "This closes the connection handle and frees up all resources used."
2307 #: ../src/guestfs.pod:1198
2308 msgid "ERROR HANDLING"
2312 #: ../src/guestfs.pod:1200
2314 "API functions can return errors. For example, almost all functions that "
2315 "return C<int> will return C<-1> to indicate an error."
2319 #: ../src/guestfs.pod:1203
2321 "Additional information is available for errors: an error message string and "
2322 "optionally an error number (errno) if the thing that failed was a system "
2327 #: ../src/guestfs.pod:1207
2329 "You can get at the additional information about the last error on the handle "
2330 "by calling L</guestfs_last_error>, L</guestfs_last_errno>, and/or by setting "
2331 "up an error handler with L</guestfs_set_error_handler>."
2335 #: ../src/guestfs.pod:1212
2337 "When the handle is created, a default error handler is installed which "
2338 "prints the error message string to C<stderr>. For small short-running "
2339 "command line programs it is sufficient to do:"
2343 #: ../src/guestfs.pod:1216
2346 " if (guestfs_launch (g) == -1)\n"
2347 " exit (EXIT_FAILURE);\n"
2352 #: ../src/guestfs.pod:1219
2354 "since the default error handler will ensure that an error message has been "
2355 "printed to C<stderr> before the program exits."
2359 #: ../src/guestfs.pod:1222
2361 "For other programs the caller will almost certainly want to install an "
2362 "alternate error handler or do error handling in-line like this:"
2366 #: ../src/guestfs.pod:1225
2369 " g = guestfs_create ();\n"
2374 #: ../src/guestfs.pod:1227
2377 " /* This disables the default behaviour of printing errors\n"
2379 " guestfs_set_error_handler (g, NULL, NULL);\n"
2384 #: ../src/guestfs.pod:1231
2387 " if (guestfs_launch (g) == -1) {\n"
2388 " /* Examine the error message and print it etc. */\n"
2389 " char *msg = guestfs_last_error (g);\n"
2390 " int errnum = guestfs_last_errno (g);\n"
2391 " fprintf (stderr, \"%s\\n\", msg);\n"
2398 #: ../src/guestfs.pod:1239
2400 "Out of memory errors are handled differently. The default action is to call "
2401 "L<abort(3)>. If this is undesirable, then you can set a handler using "
2402 "L</guestfs_set_out_of_memory_handler>."
2406 #: ../src/guestfs.pod:1243
2408 "L</guestfs_create> returns C<NULL> if the handle cannot be created, and "
2409 "because there is no handle if this happens there is no way to get additional "
2410 "error information. However L</guestfs_create> is supposed to be a "
2411 "lightweight operation which can only fail because of insufficient memory (it "
2412 "returns NULL in this case)."
2416 #: ../src/guestfs.pod:1249
2417 msgid "guestfs_last_error"
2421 #: ../src/guestfs.pod:1251
2424 " const char *guestfs_last_error (guestfs_h *g);\n"
2429 #: ../src/guestfs.pod:1253
2431 "This returns the last error message that happened on C<g>. If there has not "
2432 "been an error since the handle was created, then this returns C<NULL>."
2436 #: ../src/guestfs.pod:1257
2438 "The lifetime of the returned string is until the next error occurs, or "
2439 "L</guestfs_close> is called."
2443 #: ../src/guestfs.pod:1260
2444 msgid "guestfs_last_errno"
2448 #: ../src/guestfs.pod:1262
2451 " int guestfs_last_errno (guestfs_h *g);\n"
2456 #: ../src/guestfs.pod:1264
2457 msgid "This returns the last error number (errno) that happened on C<g>."
2461 #: ../src/guestfs.pod:1266
2462 msgid "If successful, an errno integer not equal to zero is returned."
2466 #: ../src/guestfs.pod:1268
2467 msgid "If no error, this returns 0. This call can return 0 in three situations:"
2471 #: ../src/guestfs.pod:1275
2472 msgid "There has not been any error on the handle."
2476 #: ../src/guestfs.pod:1279
2478 "There has been an error but the errno was meaningless. This corresponds to "
2479 "the case where the error did not come from a failed system call, but for "
2480 "some other reason."
2484 #: ../src/guestfs.pod:1285
2486 "There was an error from a failed system call, but for some reason the errno "
2487 "was not captured and returned. This usually indicates a bug in libguestfs."
2491 #: ../src/guestfs.pod:1291
2493 "Libguestfs tries to convert the errno from inside the applicance into a "
2494 "corresponding errno for the caller (not entirely trivial: the appliance "
2495 "might be running a completely different operating system from the library "
2496 "and error numbers are not standardized across Un*xen). If this could not be "
2497 "done, then the error is translated to C<EINVAL>. In practice this should "
2498 "only happen in very rare circumstances."
2502 #: ../src/guestfs.pod:1299
2503 msgid "guestfs_set_error_handler"
2507 #: ../src/guestfs.pod:1301
2510 " typedef void (*guestfs_error_handler_cb) (guestfs_h *g,\n"
2512 " const char *msg);\n"
2513 " void guestfs_set_error_handler (guestfs_h *g,\n"
2514 " guestfs_error_handler_cb cb,\n"
2520 #: ../src/guestfs.pod:1308
2522 "The callback C<cb> will be called if there is an error. The parameters "
2523 "passed to the callback are an opaque data pointer and the error message "
2528 #: ../src/guestfs.pod:1312
2530 "C<errno> is not passed to the callback. To get that the callback must call "
2531 "L</guestfs_last_errno>."
2535 #: ../src/guestfs.pod:1315
2537 "Note that the message string C<msg> is freed as soon as the callback "
2538 "function returns, so if you want to stash it somewhere you must make your "
2543 #: ../src/guestfs.pod:1319
2544 msgid "The default handler prints messages on C<stderr>."
2548 #: ../src/guestfs.pod:1321
2549 msgid "If you set C<cb> to C<NULL> then I<no> handler is called."
2553 #: ../src/guestfs.pod:1323
2554 msgid "guestfs_get_error_handler"
2558 #: ../src/guestfs.pod:1325
2561 " guestfs_error_handler_cb guestfs_get_error_handler (guestfs_h *g,\n"
2562 " void **opaque_rtn);\n"
2567 #: ../src/guestfs.pod:1328
2568 msgid "Returns the current error handler callback."
2572 #: ../src/guestfs.pod:1330
2573 msgid "guestfs_set_out_of_memory_handler"
2577 #: ../src/guestfs.pod:1332
2580 " typedef void (*guestfs_abort_cb) (void);\n"
2581 " int guestfs_set_out_of_memory_handler (guestfs_h *g,\n"
2582 " guestfs_abort_cb);\n"
2587 #: ../src/guestfs.pod:1336
2589 "The callback C<cb> will be called if there is an out of memory situation. "
2590 "I<Note this callback must not return>."
2594 #: ../src/guestfs.pod:1339
2595 msgid "The default is to call L<abort(3)>."
2599 #: ../src/guestfs.pod:1341
2600 msgid "You cannot set C<cb> to C<NULL>. You can't ignore out of memory situations."
2604 #: ../src/guestfs.pod:1344
2605 msgid "guestfs_get_out_of_memory_handler"
2609 #: ../src/guestfs.pod:1346
2612 " guestfs_abort_fn guestfs_get_out_of_memory_handler (guestfs_h *g);\n"
2617 #: ../src/guestfs.pod:1348
2618 msgid "This returns the current out of memory handler."
2622 #: ../src/guestfs.pod:1350
2627 #: ../src/guestfs.pod:1352 ../fish/guestfish.pod:907
2632 #: ../src/guestfs.pod:1354
2637 #: ../src/guestfs.pod:1356
2642 #: ../src/guestfs.pod:1358
2643 msgid "AVAILABILITY"
2647 #: ../src/guestfs.pod:1360
2648 msgid "GROUPS OF FUNCTIONALITY IN THE APPLIANCE"
2652 #: ../src/guestfs.pod:1362
2654 "Using L</guestfs_available> you can test availability of the following "
2655 "groups of functions. This test queries the appliance to see if the "
2656 "appliance you are currently using supports the functionality."
2660 #: ../src/guestfs.pod:1367
2661 msgid "@AVAILABILITY@"
2665 #: ../src/guestfs.pod:1369
2666 msgid "GUESTFISH supported COMMAND"
2670 #: ../src/guestfs.pod:1371
2672 "In L<guestfish(3)> there is a handy interactive command C<supported> which "
2673 "prints out the available groups and whether they are supported by this build "
2674 "of libguestfs. Note however that you have to do C<run> first."
2678 #: ../src/guestfs.pod:1376
2679 msgid "SINGLE CALLS AT COMPILE TIME"
2683 #: ../src/guestfs.pod:1378
2685 "Since version 1.5.8, C<E<lt>guestfs.hE<gt>> defines symbols for each C API "
2686 "function, such as:"
2690 #: ../src/guestfs.pod:1381
2693 " #define LIBGUESTFS_HAVE_DD 1\n"
2698 #: ../src/guestfs.pod:1383
2699 msgid "if L</guestfs_dd> is available."
2703 #: ../src/guestfs.pod:1385
2705 "Before version 1.5.8, if you needed to test whether a single libguestfs "
2706 "function is available at compile time, we recommended using build tools such "
2707 "as autoconf or cmake. For example in autotools you could use:"
2711 #: ../src/guestfs.pod:1390
2714 " AC_CHECK_LIB([guestfs],[guestfs_create])\n"
2715 " AC_CHECK_FUNCS([guestfs_dd])\n"
2720 #: ../src/guestfs.pod:1393
2722 "which would result in C<HAVE_GUESTFS_DD> being either defined or not defined "
2727 #: ../src/guestfs.pod:1396
2728 msgid "SINGLE CALLS AT RUN TIME"
2732 #: ../src/guestfs.pod:1398
2734 "Testing at compile time doesn't guarantee that a function really exists in "
2735 "the library. The reason is that you might be dynamically linked against a "
2736 "previous I<libguestfs.so> (dynamic library) which doesn't have the call. "
2737 "This situation unfortunately results in a segmentation fault, which is a "
2738 "shortcoming of the C dynamic linking system itself."
2742 #: ../src/guestfs.pod:1405
2744 "You can use L<dlopen(3)> to test if a function is available at run time, as "
2745 "in this example program (note that you still need the compile time check as "
2750 #: ../src/guestfs.pod:1409
2753 " #include <stdio.h>\n"
2754 " #include <stdlib.h>\n"
2755 " #include <unistd.h>\n"
2756 " #include <dlfcn.h>\n"
2757 " #include <guestfs.h>\n"
2762 #: ../src/guestfs.pod:1415
2767 " #ifdef LIBGUESTFS_HAVE_DD\n"
2769 " int has_function;\n"
2774 #: ../src/guestfs.pod:1421
2777 " /* Test if the function guestfs_dd is really available. */\n"
2778 " dl = dlopen (NULL, RTLD_LAZY);\n"
2780 " fprintf (stderr, \"dlopen: %s\\n\", dlerror ());\n"
2781 " exit (EXIT_FAILURE);\n"
2783 " has_function = dlsym (dl, \"guestfs_dd\") != NULL;\n"
2789 #: ../src/guestfs.pod:1430
2792 " if (!has_function)\n"
2793 " printf (\"this libguestfs.so does NOT have guestfs_dd function\\n\");\n"
2795 " printf (\"this libguestfs.so has guestfs_dd function\\n\");\n"
2796 " /* Now it's safe to call\n"
2797 " guestfs_dd (g, \"foo\", \"bar\");\n"
2801 " printf (\"guestfs_dd function was not found at compile time\\n\");\n"
2808 #: ../src/guestfs.pod:1443
2810 "You may think the above is an awful lot of hassle, and it is. There are "
2811 "other ways outside of the C linking system to ensure that this kind of "
2812 "incompatibility never arises, such as using package versioning:"
2816 #: ../src/guestfs.pod:1448
2819 " Requires: libguestfs >= 1.0.80\n"
2824 #: ../src/guestfs.pod:1450
2825 msgid "CALLS WITH OPTIONAL ARGUMENTS"
2829 #: ../src/guestfs.pod:1452
2831 "A recent feature of the API is the introduction of calls which take optional "
2832 "arguments. In C these are declared 3 ways. The main way is as a call which "
2833 "takes variable arguments (ie. C<...>), as in this example:"
2837 #: ../src/guestfs.pod:1457
2840 " int guestfs_add_drive_opts (guestfs_h *g, const char *filename, ...);\n"
2845 #: ../src/guestfs.pod:1459
2847 "Call this with a list of optional arguments, terminated by C<-1>. So to "
2848 "call with no optional arguments specified:"
2852 #: ../src/guestfs.pod:1462
2855 " guestfs_add_drive_opts (g, filename, -1);\n"
2860 #: ../src/guestfs.pod:1464
2861 msgid "With a single optional argument:"
2865 #: ../src/guestfs.pod:1466
2868 " guestfs_add_drive_opts (g, filename,\n"
2869 " GUESTFS_ADD_DRIVE_OPTS_FORMAT, \"qcow2\",\n"
2875 #: ../src/guestfs.pod:1470
2880 #: ../src/guestfs.pod:1472
2883 " guestfs_add_drive_opts (g, filename,\n"
2884 " GUESTFS_ADD_DRIVE_OPTS_FORMAT, \"qcow2\",\n"
2885 " GUESTFS_ADD_DRIVE_OPTS_READONLY, 1,\n"
2891 #: ../src/guestfs.pod:1477
2893 "and so forth. Don't forget the terminating C<-1> otherwise Bad Things will "
2898 #: ../src/guestfs.pod:1480
2899 msgid "USING va_list FOR OPTIONAL ARGUMENTS"
2903 #: ../src/guestfs.pod:1482
2905 "The second variant has the same name with the suffix C<_va>, which works the "
2906 "same way but takes a C<va_list>. See the C manual for details. For the "
2907 "example function, this is declared:"
2911 #: ../src/guestfs.pod:1486
2914 " int guestfs_add_drive_opts_va (guestfs_h *g, const char *filename,\n"
2920 #: ../src/guestfs.pod:1489
2921 msgid "CONSTRUCTING OPTIONAL ARGUMENTS"
2925 #: ../src/guestfs.pod:1491
2927 "The third variant is useful where you need to construct these calls. You "
2928 "pass in a structure where you fill in the optional fields. The structure "
2929 "has a bitmask as the first element which you must set to indicate which "
2930 "fields you have filled in. For our example function the structure and call "
2935 #: ../src/guestfs.pod:1497
2938 " struct guestfs_add_drive_opts_argv {\n"
2939 " uint64_t bitmask;\n"
2941 " const char *format;\n"
2944 " int guestfs_add_drive_opts_argv (guestfs_h *g, const char *filename,\n"
2945 " const struct guestfs_add_drive_opts_argv *optargs);\n"
2950 #: ../src/guestfs.pod:1506
2951 msgid "You could call it like this:"
2955 #: ../src/guestfs.pod:1508
2958 " struct guestfs_add_drive_opts_argv optargs = {\n"
2959 " .bitmask = GUESTFS_ADD_DRIVE_OPTS_READONLY_BITMASK |\n"
2960 " GUESTFS_ADD_DRIVE_OPTS_FORMAT_BITMASK,\n"
2962 " .format = \"qcow2\"\n"
2968 #: ../src/guestfs.pod:1515
2971 " guestfs_add_drive_opts_argv (g, filename, &optargs);\n"
2976 #: ../src/guestfs.pod:1517 ../src/guestfs-actions.pod:11 ../src/guestfs-actions.pod:1842 ../fish/guestfish-actions.pod:9 ../fish/guestfish-actions.pod:1255
2981 #: ../src/guestfs.pod:1523
2982 msgid "The C<_BITMASK> suffix on each option name when specifying the bitmask."
2986 #: ../src/guestfs.pod:1528
2987 msgid "You do not need to fill in all fields of the structure."
2991 #: ../src/guestfs.pod:1532
2993 "There must be a one-to-one correspondence between fields of the structure "
2994 "that are filled in, and bits set in the bitmask."
2998 #: ../src/guestfs.pod:1537
2999 msgid "OPTIONAL ARGUMENTS IN OTHER LANGUAGES"
3003 #: ../src/guestfs.pod:1539
3005 "In other languages, optional arguments are expressed in the way that is "
3006 "natural for that language. We refer you to the language-specific "
3007 "documentation for more details on that."
3011 #: ../src/guestfs.pod:1543
3012 msgid "For guestfish, see L<guestfish(1)/OPTIONAL ARGUMENTS>."
3016 #: ../src/guestfs.pod:1545
3017 msgid "SETTING CALLBACKS TO HANDLE EVENTS"
3021 #: ../src/guestfs.pod:1547
3023 "The child process generates events in some situations. Current events "
3024 "include: receiving a log message, the child process exits."
3028 #: ../src/guestfs.pod:1550
3030 "Use the C<guestfs_set_*_callback> functions to set a callback for different "
3035 #: ../src/guestfs.pod:1553
3037 "Only I<one callback of each type> can be registered for each handle. "
3038 "Calling C<guestfs_set_*_callback> again overwrites the previous callback of "
3039 "that type. Cancel all callbacks of this type by calling this function with "
3040 "C<cb> set to C<NULL>."
3044 #: ../src/guestfs.pod:1558
3045 msgid "guestfs_set_log_message_callback"
3049 #: ../src/guestfs.pod:1560
3052 " typedef void (*guestfs_log_message_cb) (guestfs_h *g, void *opaque,\n"
3053 " char *buf, int len);\n"
3054 " void guestfs_set_log_message_callback (guestfs_h *g,\n"
3055 " guestfs_log_message_cb cb,\n"
3061 #: ../src/guestfs.pod:1566
3063 "The callback function C<cb> will be called whenever qemu or the guest writes "
3064 "anything to the console."
3068 #: ../src/guestfs.pod:1569
3069 msgid "Use this function to capture kernel messages and similar."
3073 #: ../src/guestfs.pod:1571
3075 "Normally there is no log message handler, and log messages are just "
3080 #: ../src/guestfs.pod:1574
3081 msgid "guestfs_set_subprocess_quit_callback"
3085 #: ../src/guestfs.pod:1576
3088 " typedef void (*guestfs_subprocess_quit_cb) (guestfs_h *g, void *opaque);\n"
3089 " void guestfs_set_subprocess_quit_callback (guestfs_h *g,\n"
3090 " guestfs_subprocess_quit_cb cb,\n"
3096 #: ../src/guestfs.pod:1581
3098 "The callback function C<cb> will be called when the child process quits, "
3099 "either asynchronously or if killed by L</guestfs_kill_subprocess>. (This "
3100 "corresponds to a transition from any state to the CONFIG state)."
3104 #: ../src/guestfs.pod:1586
3105 msgid "guestfs_set_launch_done_callback"
3109 #: ../src/guestfs.pod:1588
3112 " typedef void (*guestfs_launch_done_cb) (guestfs_h *g, void *opaque);\n"
3113 " void guestfs_set_launch_done_callback (guestfs_h *g,\n"
3114 " guestfs_launch_done_cb cb,\n"
3120 #: ../src/guestfs.pod:1593
3122 "The callback function C<cb> will be called when the child process becomes "
3123 "ready first time after it has been launched. (This corresponds to a "
3124 "transition from LAUNCHING to the READY state)."
3128 #: ../src/guestfs.pod:1597
3129 msgid "guestfs_set_close_callback"
3133 #: ../src/guestfs.pod:1599
3136 " typedef void (*guestfs_close_cb) (guestfs_h *g, void *opaque);\n"
3137 " void guestfs_set_close_callback (guestfs_h *g,\n"
3138 " guestfs_close_cb cb,\n"
3144 #: ../src/guestfs.pod:1604
3146 "The callback function C<cb> will be called while the handle is being closed "
3147 "(synchronously from L</guestfs_close>)."
3151 #: ../src/guestfs.pod:1607
3153 "Note that libguestfs installs an L<atexit(3)> handler to try to clean up "
3154 "handles that are open when the program exits. This means that this callback "
3155 "might be called indirectly from L<exit(3)>, which can cause unexpected "
3156 "problems in higher-level languages (eg. if your HLL interpreter has already "
3157 "been cleaned up by the time this is called, and if your callback then jumps "
3158 "into some HLL function)."
3162 #: ../src/guestfs.pod:1615
3163 msgid "guestfs_set_progress_callback"
3167 #: ../src/guestfs.pod:1617
3170 " typedef void (*guestfs_progress_cb) (guestfs_h *g, void *opaque,\n"
3171 " int proc_nr, int serial,\n"
3172 " uint64_t position, uint64_t total);\n"
3173 " void guestfs_set_progress_callback (guestfs_h *g,\n"
3174 " guestfs_progress_cb cb,\n"
3180 #: ../src/guestfs.pod:1624
3182 "Some long-running operations can generate progress messages. If this "
3183 "callback is registered, then it will be called each time a progress message "
3184 "is generated (usually two seconds after the operation started, and three "
3185 "times per second thereafter until it completes, although the frequency may "
3186 "change in future versions)."
3190 #: ../src/guestfs.pod:1630
3192 "The callback receives two numbers: C<position> and C<total>. The units of "
3193 "C<total> are not defined, although for some operations C<total> may relate "
3194 "in some way to the amount of data to be transferred (eg. in bytes or "
3195 "megabytes), and C<position> may be the portion which has been transferred."
3199 #: ../src/guestfs.pod:1636
3200 msgid "The only defined and stable parts of the API are:"
3204 #: ../src/guestfs.pod:1642
3206 "The callback can display to the user some type of progress bar or indicator "
3207 "which shows the ratio of C<position>:C<total>."
3211 #: ../src/guestfs.pod:1647
3212 msgid "0 E<lt>= C<position> E<lt>= C<total>"
3216 #: ../src/guestfs.pod:1651
3218 "If any progress notification is sent during a call, then a final progress "
3219 "notification is always sent when C<position> = C<total>."
3223 #: ../src/guestfs.pod:1654
3225 "This is to simplify caller code, so callers can easily set the progress "
3226 "indicator to \"100%\" at the end of the operation, without requiring special "
3227 "code to detect this case."
3231 #: ../src/guestfs.pod:1660
3233 "The callback also receives the procedure number and serial number of the "
3234 "call. These are only useful for debugging protocol issues, and the callback "
3235 "can normally ignore them. The callback may want to print these numbers in "
3236 "error messages or debugging messages."
3240 #: ../src/guestfs.pod:1665
3241 msgid "PRIVATE DATA AREA"
3245 #: ../src/guestfs.pod:1667
3247 "You can attach named pieces of private data to the libguestfs handle, and "
3248 "fetch them by name for the lifetime of the handle. This is called the "
3249 "private data area and is only available from the C API."
3253 #: ../src/guestfs.pod:1671
3254 msgid "To attach a named piece of data, use the following call:"
3258 #: ../src/guestfs.pod:1673
3261 " void guestfs_set_private (guestfs_h *g, const char *key, void *data);\n"
3266 #: ../src/guestfs.pod:1675
3268 "C<key> is the name to associate with this data, and C<data> is an arbitrary "
3269 "pointer (which can be C<NULL>). Any previous item with the same name is "
3274 #: ../src/guestfs.pod:1679
3276 "You can use any C<key> you want, but names beginning with an underscore "
3277 "character are reserved for internal libguestfs purposes (for implementing "
3278 "language bindings). It is recommended to prefix the name with some unique "
3279 "string to avoid collisions with other users."
3283 #: ../src/guestfs.pod:1684
3284 msgid "To retrieve the pointer, use:"
3288 #: ../src/guestfs.pod:1686
3291 " void *guestfs_get_private (guestfs_h *g, const char *key);\n"
3296 #: ../src/guestfs.pod:1688
3298 "This function returns C<NULL> if either no data is found associated with "
3299 "C<key>, or if the user previously set the C<key>'s C<data> pointer to "
3304 #: ../src/guestfs.pod:1692
3306 "Libguestfs does not try to look at or interpret the C<data> pointer in any "
3307 "way. As far as libguestfs is concerned, it need not be a valid pointer at "
3308 "all. In particular, libguestfs does I<not> try to free the data when the "
3309 "handle is closed. If the data must be freed, then the caller must either "
3310 "free it before calling L</guestfs_close> or must set up a close callback to "
3311 "do it (see L</guestfs_set_close_callback>, and note that only one callback "
3312 "can be registered for a handle)."
3316 #: ../src/guestfs.pod:1700
3318 "The private data area is implemented using a hash table, and should be "
3319 "reasonably efficient for moderate numbers of keys."
3323 #: ../src/guestfs.pod:1703 ../src/guestfs.pod:1708
3328 #: ../src/guestfs.pod:1705
3330 "<!-- old anchor for the next section --> <a "
3331 "name=\"state_machine_and_low_level_event_api\"/>"
3335 #: ../src/guestfs.pod:1710
3336 msgid "ARCHITECTURE"
3340 #: ../src/guestfs.pod:1712
3342 "Internally, libguestfs is implemented by running an appliance (a special "
3343 "type of small virtual machine) using L<qemu(1)>. Qemu runs as a child "
3344 "process of the main program."
3348 #: ../src/guestfs.pod:1716
3351 " ___________________\n"
3353 " | main program |\n"
3355 " | | child process / appliance\n"
3356 " | | __________________________\n"
3358 " +-------------------+ RPC | +-----------------+ |\n"
3359 " | libguestfs <--------------------> guestfsd | |\n"
3360 " | | | +-----------------+ |\n"
3361 " \\___________________/ | | Linux kernel | |\n"
3362 " | +--^--------------+ |\n"
3363 " \\_________|________________/\n"
3369 " \\______________/\n"
3374 #: ../src/guestfs.pod:1736
3376 "The library, linked to the main program, creates the child process and hence "
3377 "the appliance in the L</guestfs_launch> function."
3381 #: ../src/guestfs.pod:1739
3383 "Inside the appliance is a Linux kernel and a complete stack of userspace "
3384 "tools (such as LVM and ext2 programs) and a small controlling daemon called "
3385 "L</guestfsd>. The library talks to L</guestfsd> using remote procedure "
3386 "calls (RPC). There is a mostly one-to-one correspondence between libguestfs "
3387 "API calls and RPC calls to the daemon. Lastly the disk image(s) are "
3388 "attached to the qemu process which translates device access by the "
3389 "appliance's Linux kernel into accesses to the image."
3393 #: ../src/guestfs.pod:1748
3395 "A common misunderstanding is that the appliance \"is\" the virtual machine. "
3396 "Although the disk image you are attached to might also be used by some "
3397 "virtual machine, libguestfs doesn't know or care about this. (But you will "
3398 "care if both libguestfs's qemu process and your virtual machine are trying "
3399 "to update the disk image at the same time, since these usually results in "
3400 "massive disk corruption)."
3404 #: ../src/guestfs.pod:1755
3405 msgid "STATE MACHINE"
3409 #: ../src/guestfs.pod:1757
3410 msgid "libguestfs uses a state machine to model the child process:"
3414 #: ../src/guestfs.pod:1759
3426 " / | \\ \\ guestfs_launch\n"
3427 " / | _\\__V______\n"
3429 " / | | LAUNCHING |\n"
3430 " / | \\___________/\n"
3432 " / | guestfs_launch\n"
3434 " ______ / __|____V\n"
3435 " / \\ ------> / \\\n"
3436 " | BUSY | | READY |\n"
3437 " \\______/ <------ \\________/\n"
3442 #: ../src/guestfs.pod:1781
3444 "The normal transitions are (1) CONFIG (when the handle is created, but there "
3445 "is no child process), (2) LAUNCHING (when the child process is booting up), "
3446 "(3) alternating between READY and BUSY as commands are issued to, and "
3447 "carried out by, the child process."
3451 #: ../src/guestfs.pod:1786
3453 "The guest may be killed by L</guestfs_kill_subprocess>, or may die "
3454 "asynchronously at any time (eg. due to some internal error), and that causes "
3455 "the state to transition back to CONFIG."
3459 #: ../src/guestfs.pod:1790
3461 "Configuration commands for qemu such as L</guestfs_add_drive> can only be "
3462 "issued when in the CONFIG state."
3466 #: ../src/guestfs.pod:1793
3468 "The API offers one call that goes from CONFIG through LAUNCHING to READY. "
3469 "L</guestfs_launch> blocks until the child process is READY to accept "
3470 "commands (or until some failure or timeout). L</guestfs_launch> internally "
3471 "moves the state from CONFIG to LAUNCHING while it is running."
3475 #: ../src/guestfs.pod:1799
3477 "API actions such as L</guestfs_mount> can only be issued when in the READY "
3478 "state. These API calls block waiting for the command to be carried out "
3479 "(ie. the state to transition to BUSY and then back to READY). There are no "
3480 "non-blocking versions, and no way to issue more than one command per handle "
3485 #: ../src/guestfs.pod:1805
3487 "Finally, the child process sends asynchronous messages back to the main "
3488 "program, such as kernel log messages. You can register a callback to "
3489 "receive these messages."
3493 #: ../src/guestfs.pod:1809
3498 #: ../src/guestfs.pod:1811
3499 msgid "COMMUNICATION PROTOCOL"
3503 #: ../src/guestfs.pod:1813
3505 "Don't rely on using this protocol directly. This section documents how it "
3506 "currently works, but it may change at any time."
3510 #: ../src/guestfs.pod:1816
3512 "The protocol used to talk between the library and the daemon running inside "
3513 "the qemu virtual machine is a simple RPC mechanism built on top of XDR (RFC "
3514 "1014, RFC 1832, RFC 4506)."
3518 #: ../src/guestfs.pod:1820
3520 "The detailed format of structures is in C<src/guestfs_protocol.x> (note: "
3521 "this file is automatically generated)."
3525 #: ../src/guestfs.pod:1823
3527 "There are two broad cases, ordinary functions that don't have any C<FileIn> "
3528 "and C<FileOut> parameters, which are handled with very simple request/reply "
3529 "messages. Then there are functions that have any C<FileIn> or C<FileOut> "
3530 "parameters, which use the same request and reply messages, but they may also "
3531 "be followed by files sent using a chunked encoding."
3535 #: ../src/guestfs.pod:1830
3536 msgid "ORDINARY FUNCTIONS (NO FILEIN/FILEOUT PARAMS)"
3540 #: ../src/guestfs.pod:1832
3541 msgid "For ordinary functions, the request message is:"
3545 #: ../src/guestfs.pod:1834
3548 " total length (header + arguments,\n"
3549 " but not including the length word itself)\n"
3550 " struct guestfs_message_header (encoded as XDR)\n"
3551 " struct guestfs_<foo>_args (encoded as XDR)\n"
3556 #: ../src/guestfs.pod:1839
3558 "The total length field allows the daemon to allocate a fixed size buffer "
3559 "into which it slurps the rest of the message. As a result, the total length "
3560 "is limited to C<GUESTFS_MESSAGE_MAX> bytes (currently 4MB), which means the "
3561 "effective size of any request is limited to somewhere under this size."
3565 #: ../src/guestfs.pod:1845
3567 "Note also that many functions don't take any arguments, in which case the "
3568 "C<guestfs_I<foo>_args> is completely omitted."
3572 #: ../src/guestfs.pod:1848
3574 "The header contains the procedure number (C<guestfs_proc>) which is how the "
3575 "receiver knows what type of args structure to expect, or none at all."
3579 #: ../src/guestfs.pod:1852
3580 msgid "The reply message for ordinary functions is:"
3584 #: ../src/guestfs.pod:1854
3587 " total length (header + ret,\n"
3588 " but not including the length word itself)\n"
3589 " struct guestfs_message_header (encoded as XDR)\n"
3590 " struct guestfs_<foo>_ret (encoded as XDR)\n"
3595 #: ../src/guestfs.pod:1859
3597 "As above the C<guestfs_I<foo>_ret> structure may be completely omitted for "
3598 "functions that return no formal return values."
3602 #: ../src/guestfs.pod:1862
3603 msgid "As above the total length of the reply is limited to C<GUESTFS_MESSAGE_MAX>."
3607 #: ../src/guestfs.pod:1865
3609 "In the case of an error, a flag is set in the header, and the reply message "
3610 "is slightly changed:"
3614 #: ../src/guestfs.pod:1868
3617 " total length (header + error,\n"
3618 " but not including the length word itself)\n"
3619 " struct guestfs_message_header (encoded as XDR)\n"
3620 " struct guestfs_message_error (encoded as XDR)\n"
3625 #: ../src/guestfs.pod:1873
3627 "The C<guestfs_message_error> structure contains the error message as a "
3632 #: ../src/guestfs.pod:1876
3633 msgid "FUNCTIONS THAT HAVE FILEIN PARAMETERS"
3637 #: ../src/guestfs.pod:1878
3639 "A C<FileIn> parameter indicates that we transfer a file I<into> the guest. "
3640 "The normal request message is sent (see above). However this is followed by "
3641 "a sequence of file chunks."
3645 #: ../src/guestfs.pod:1882
3648 " total length (header + arguments,\n"
3649 " but not including the length word itself,\n"
3650 " and not including the chunks)\n"
3651 " struct guestfs_message_header (encoded as XDR)\n"
3652 " struct guestfs_<foo>_args (encoded as XDR)\n"
3653 " sequence of chunks for FileIn param #0\n"
3654 " sequence of chunks for FileIn param #1 etc.\n"
3659 #: ../src/guestfs.pod:1890
3660 msgid "The \"sequence of chunks\" is:"
3664 #: ../src/guestfs.pod:1892
3667 " length of chunk (not including length word itself)\n"
3668 " struct guestfs_chunk (encoded as XDR)\n"
3669 " length of chunk\n"
3670 " struct guestfs_chunk (encoded as XDR)\n"
3672 " length of chunk\n"
3673 " struct guestfs_chunk (with data.data_len == 0)\n"
3678 #: ../src/guestfs.pod:1900
3680 "The final chunk has the C<data_len> field set to zero. Additionally a flag "
3681 "is set in the final chunk to indicate either successful completion or early "
3686 #: ../src/guestfs.pod:1904
3688 "At time of writing there are no functions that have more than one FileIn "
3689 "parameter. However this is (theoretically) supported, by sending the "
3690 "sequence of chunks for each FileIn parameter one after another (from left to "
3695 #: ../src/guestfs.pod:1909
3697 "Both the library (sender) I<and> the daemon (receiver) may cancel the "
3698 "transfer. The library does this by sending a chunk with a special flag set "
3699 "to indicate cancellation. When the daemon sees this, it cancels the whole "
3700 "RPC, does I<not> send any reply, and goes back to reading the next request."
3704 #: ../src/guestfs.pod:1915
3706 "The daemon may also cancel. It does this by writing a special word "
3707 "C<GUESTFS_CANCEL_FLAG> to the socket. The library listens for this during "
3708 "the transfer, and if it gets it, it will cancel the transfer (it sends a "
3709 "cancel chunk). The special word is chosen so that even if cancellation "
3710 "happens right at the end of the transfer (after the library has finished "
3711 "writing and has started listening for the reply), the \"spurious\" cancel "
3712 "flag will not be confused with the reply message."
3716 #: ../src/guestfs.pod:1924
3718 "This protocol allows the transfer of arbitrary sized files (no 32 bit "
3719 "limit), and also files where the size is not known in advance (eg. from "
3720 "pipes or sockets). However the chunks are rather small "
3721 "(C<GUESTFS_MAX_CHUNK_SIZE>), so that neither the library nor the daemon need "
3722 "to keep much in memory."
3726 #: ../src/guestfs.pod:1930
3727 msgid "FUNCTIONS THAT HAVE FILEOUT PARAMETERS"
3731 #: ../src/guestfs.pod:1932
3733 "The protocol for FileOut parameters is exactly the same as for FileIn "
3734 "parameters, but with the roles of daemon and library reversed."
3738 #: ../src/guestfs.pod:1935
3741 " total length (header + ret,\n"
3742 " but not including the length word itself,\n"
3743 " and not including the chunks)\n"
3744 " struct guestfs_message_header (encoded as XDR)\n"
3745 " struct guestfs_<foo>_ret (encoded as XDR)\n"
3746 " sequence of chunks for FileOut param #0\n"
3747 " sequence of chunks for FileOut param #1 etc.\n"
3752 #: ../src/guestfs.pod:1943
3753 msgid "INITIAL MESSAGE"
3757 #: ../src/guestfs.pod:1945
3759 "When the daemon launches it sends an initial word (C<GUESTFS_LAUNCH_FLAG>) "
3760 "which indicates that the guest and daemon is alive. This is what "
3761 "L</guestfs_launch> waits for."
3765 #: ../src/guestfs.pod:1949
3766 msgid "PROGRESS NOTIFICATION MESSAGES"
3770 #: ../src/guestfs.pod:1951
3772 "The daemon may send progress notification messages at any time. These are "
3773 "distinguished by the normal length word being replaced by "
3774 "C<GUESTFS_PROGRESS_FLAG>, followed by a fixed size progress message."
3778 #: ../src/guestfs.pod:1955
3780 "The library turns them into progress callbacks (see "
3781 "C<guestfs_set_progress_callback>) if there is a callback registered, or "
3782 "discards them if not."
3786 #: ../src/guestfs.pod:1959
3788 "The daemon self-limits the frequency of progress messages it sends (see "
3789 "C<daemon/proto.c:notify_progress>). Not all calls generate progress "
3794 #: ../src/guestfs.pod:1963
3795 msgid "LIBGUESTFS VERSION NUMBERS"
3799 #: ../src/guestfs.pod:1965
3801 "Since April 2010, libguestfs has started to make separate development and "
3802 "stable releases, along with corresponding branches in our git repository. "
3803 "These separate releases can be identified by version number:"
3807 #: ../src/guestfs.pod:1970
3810 " even numbers for stable: 1.2.x, 1.4.x, ...\n"
3811 " .-------- odd numbers for development: 1.3.x, 1.5.x, ...\n"
3817 " | `-------- sub-version\n"
3819 " `------ always '1' because we don't change the ABI\n"
3824 #: ../src/guestfs.pod:1981
3825 msgid "Thus \"1.3.5\" is the 5th update to the development branch \"1.3\"."
3829 #: ../src/guestfs.pod:1983
3831 "As time passes we cherry pick fixes from the development branch and backport "
3832 "those into the stable branch, the effect being that the stable branch should "
3833 "get more stable and less buggy over time. So the stable releases are ideal "
3834 "for people who don't need new features but would just like the software to "
3839 #: ../src/guestfs.pod:1989
3840 msgid "Our criteria for backporting changes are:"
3844 #: ../src/guestfs.pod:1995
3846 "Documentation changes which don't affect any code are backported unless the "
3847 "documentation refers to a future feature which is not in stable."
3851 #: ../src/guestfs.pod:2001
3853 "Bug fixes which are not controversial, fix obvious problems, and have been "
3854 "well tested are backported."
3858 #: ../src/guestfs.pod:2006
3860 "Simple rearrangements of code which shouldn't affect how it works get "
3861 "backported. This is so that the code in the two branches doesn't get too "
3862 "far out of step, allowing us to backport future fixes more easily."
3866 #: ../src/guestfs.pod:2012
3868 "We I<don't> backport new features, new APIs, new tools etc, except in one "
3869 "exceptional case: the new feature is required in order to implement an "
3870 "important bug fix."
3874 #: ../src/guestfs.pod:2018
3876 "A new stable branch starts when we think the new features in development are "
3877 "substantial and compelling enough over the current stable branch to warrant "
3878 "it. When that happens we create new stable and development versions 1.N.0 "
3879 "and 1.(N+1).0 [N is even]. The new dot-oh release won't necessarily be so "
3880 "stable at this point, but by backporting fixes from development, that branch "
3881 "will stabilize over time."
3885 #: ../src/guestfs.pod:2026 ../fish/guestfish.pod:914 ../test-tool/libguestfs-test-tool.pod:104 ../tools/virt-edit.pl:330 ../tools/virt-rescue.pl:255
3886 msgid "ENVIRONMENT VARIABLES"
3890 #: ../src/guestfs.pod:2030 ../fish/guestfish.pod:940
3891 msgid "LIBGUESTFS_APPEND"
3895 #: ../src/guestfs.pod:2032 ../fish/guestfish.pod:942
3896 msgid "Pass additional options to the guest kernel."
3900 #: ../src/guestfs.pod:2034 ../fish/guestfish.pod:944
3901 msgid "LIBGUESTFS_DEBUG"
3905 #: ../src/guestfs.pod:2036
3907 "Set C<LIBGUESTFS_DEBUG=1> to enable verbose messages. This has the same "
3908 "effect as calling C<guestfs_set_verbose (g, 1)>."
3912 #: ../src/guestfs.pod:2039 ../fish/guestfish.pod:949
3913 msgid "LIBGUESTFS_MEMSIZE"
3917 #: ../src/guestfs.pod:2041 ../fish/guestfish.pod:951
3918 msgid "Set the memory allocated to the qemu process, in megabytes. For example:"
3922 #: ../src/guestfs.pod:2044 ../fish/guestfish.pod:954
3925 " LIBGUESTFS_MEMSIZE=700\n"
3930 #: ../src/guestfs.pod:2046 ../fish/guestfish.pod:956
3931 msgid "LIBGUESTFS_PATH"
3935 #: ../src/guestfs.pod:2048
3937 "Set the path that libguestfs uses to search for kernel and initrd.img. See "
3938 "the discussion of paths in section PATH above."
3942 #: ../src/guestfs.pod:2051 ../fish/guestfish.pod:961
3943 msgid "LIBGUESTFS_QEMU"
3947 #: ../src/guestfs.pod:2053 ../fish/guestfish.pod:963
3949 "Set the default qemu binary that libguestfs uses. If not set, then the qemu "
3950 "which was found at compile time by the configure script is used."
3954 #: ../src/guestfs.pod:2057
3955 msgid "See also L</QEMU WRAPPERS> above."
3959 #: ../src/guestfs.pod:2059 ../fish/guestfish.pod:967
3960 msgid "LIBGUESTFS_TRACE"
3964 #: ../src/guestfs.pod:2061
3966 "Set C<LIBGUESTFS_TRACE=1> to enable command traces. This has the same "
3967 "effect as calling C<guestfs_set_trace (g, 1)>."
3971 #: ../src/guestfs.pod:2064 ../fish/guestfish.pod:976
3976 #: ../src/guestfs.pod:2066 ../fish/guestfish.pod:978
3977 msgid "Location of temporary directory, defaults to C</tmp>."
3981 #: ../src/guestfs.pod:2068 ../fish/guestfish.pod:980
3983 "If libguestfs was compiled to use the supermin appliance then the real "
3984 "appliance is cached in this directory, shared between all handles belonging "
3985 "to the same EUID. You can use C<$TMPDIR> to configure another directory to "
3986 "use in case C</tmp> is not large enough."
3990 #: ../src/guestfs.pod:2076 ../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
3995 #: ../src/guestfs.pod:2078
3997 "L<guestfish(1)>, L<guestmount(1)>, L<virt-cat(1)>, L<virt-df(1)>, "
3998 "L<virt-edit(1)>, L<virt-inspector(1)>, L<virt-list-filesystems(1)>, "
3999 "L<virt-list-partitions(1)>, L<virt-ls(1)>, L<virt-make-fs(1)>, "
4000 "L<virt-rescue(1)>, L<virt-tar(1)>, L<virt-win-reg(1)>, L<qemu(1)>, "
4001 "L<febootstrap(1)>, L<hivex(3)>, L<http://libguestfs.org/>."
4005 #: ../src/guestfs.pod:2096
4007 "Tools with a similar purpose: L<fdisk(8)>, L<parted(8)>, L<kpartx(8)>, "
4008 "L<lvm(8)>, L<disktype(1)>."
4012 #: ../src/guestfs.pod:2103 ../tools/virt-win-reg.pl:499 ../tools/virt-make-fs.pl:548
4017 #: ../src/guestfs.pod:2105
4018 msgid "To get a list of bugs against libguestfs use this link:"
4022 #: ../src/guestfs.pod:2107
4023 msgid "L<https://bugzilla.redhat.com/buglist.cgi?component=libguestfs&product=Virtualization+Tools>"
4027 #: ../src/guestfs.pod:2109
4028 msgid "To report a new bug against libguestfs use this link:"
4032 #: ../src/guestfs.pod:2111
4033 msgid "L<https://bugzilla.redhat.com/enter_bug.cgi?component=libguestfs&product=Virtualization+Tools>"
4037 #: ../src/guestfs.pod:2113
4038 msgid "When reporting a bug, please check:"
4042 #: ../src/guestfs.pod:2119
4043 msgid "That the bug hasn't been reported already."
4047 #: ../src/guestfs.pod:2123
4048 msgid "That you are testing a recent version."
4052 #: ../src/guestfs.pod:2127
4053 msgid "Describe the bug accurately, and give a way to reproduce it."
4057 #: ../src/guestfs.pod:2131
4059 "Run libguestfs-test-tool and paste the B<complete, unedited> output into the "
4064 #: ../src/guestfs.pod:2136 ../fish/guestfish.pod:1055 ../test-tool/libguestfs-test-tool.pod:115 ../fuse/guestmount.pod:244 ../inspector/virt-inspector.pl:462
4069 #: ../src/guestfs.pod:2138 ../fish/guestfish.pod:1057 ../test-tool/libguestfs-test-tool.pod:117 ../fuse/guestmount.pod:246
4070 msgid "Richard W.M. Jones (C<rjones at redhat dot com>)"
4074 #: ../src/guestfs.pod:2140 ../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
4079 #: ../src/guestfs.pod:2142 ../fish/guestfish.pod:1061 ../fuse/guestmount.pod:250
4080 msgid "Copyright (C) 2009-2010 Red Hat Inc. L<http://libguestfs.org/>"
4084 #: ../src/guestfs.pod:2145
4086 "This library is free software; you can redistribute it and/or modify it "
4087 "under the terms of the GNU Lesser General Public License as published by the "
4088 "Free Software Foundation; either version 2 of the License, or (at your "
4089 "option) any later version."
4093 #: ../src/guestfs.pod:2150
4095 "This library is distributed in the hope that it will be useful, but WITHOUT "
4096 "ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or "
4097 "FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License "
4102 #: ../src/guestfs.pod:2155
4104 "You should have received a copy of the GNU Lesser General Public License "
4105 "along with this library; if not, write to the Free Software Foundation, "
4106 "Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA"
4110 #: ../src/guestfs-actions.pod:1
4111 msgid "guestfs_add_cdrom"
4115 #: ../src/guestfs-actions.pod:3
4119 " guestfs_add_cdrom (guestfs_h *g,\n"
4120 " const char *filename);\n"
4125 #: ../src/guestfs-actions.pod:7 ../fish/guestfish-actions.pod:5
4126 msgid "This function adds a virtual CD-ROM disk image to the guest."
4130 #: ../src/guestfs-actions.pod:9 ../fish/guestfish-actions.pod:7
4131 msgid "This is equivalent to the qemu parameter C<-cdrom filename>."
4135 #: ../src/guestfs-actions.pod:17
4137 "This call checks for the existence of C<filename>. This stops you from "
4138 "specifying other types of drive which are supported by qemu such as C<nbd:> "
4139 "and C<http:> URLs. To specify those, use the general C<guestfs_config> call "
4144 #: ../src/guestfs-actions.pod:24
4146 "If you just want to add an ISO file (often you use this as an efficient way "
4147 "to transfer large files into the guest), then you should probably use "
4148 "C<guestfs_add_drive_ro> instead."
4152 #: ../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:3162 ../src/guestfs-actions.pod:3177 ../src/guestfs-actions.pod:3197 ../src/guestfs-actions.pod:3322 ../src/guestfs-actions.pod:3336 ../src/guestfs-actions.pod:3349 ../src/guestfs-actions.pod:3363 ../src/guestfs-actions.pod:3378 ../src/guestfs-actions.pod:3414 ../src/guestfs-actions.pod:3486 ../src/guestfs-actions.pod:3506 ../src/guestfs-actions.pod:3523 ../src/guestfs-actions.pod:3546 ../src/guestfs-actions.pod:3569 ../src/guestfs-actions.pod:3601 ../src/guestfs-actions.pod:3620 ../src/guestfs-actions.pod:3639 ../src/guestfs-actions.pod:3674 ../src/guestfs-actions.pod:3686 ../src/guestfs-actions.pod:3722 ../src/guestfs-actions.pod:3738 ../src/guestfs-actions.pod:3751 ../src/guestfs-actions.pod:3766 ../src/guestfs-actions.pod:3783 ../src/guestfs-actions.pod:3876 ../src/guestfs-actions.pod:3896 ../src/guestfs-actions.pod:3909 ../src/guestfs-actions.pod:3960 ../src/guestfs-actions.pod:3978 ../src/guestfs-actions.pod:3996 ../src/guestfs-actions.pod:4012 ../src/guestfs-actions.pod:4026 ../src/guestfs-actions.pod:4040 ../src/guestfs-actions.pod:4057 ../src/guestfs-actions.pod:4072 ../src/guestfs-actions.pod:4092 ../src/guestfs-actions.pod:4141 ../src/guestfs-actions.pod:4172 ../src/guestfs-actions.pod:4191 ../src/guestfs-actions.pod:4210 ../src/guestfs-actions.pod:4222 ../src/guestfs-actions.pod:4239 ../src/guestfs-actions.pod:4252 ../src/guestfs-actions.pod:4267 ../src/guestfs-actions.pod:4282 ../src/guestfs-actions.pod:4317 ../src/guestfs-actions.pod:4332 ../src/guestfs-actions.pod:4352 ../src/guestfs-actions.pod:4366 ../src/guestfs-actions.pod:4383 ../src/guestfs-actions.pod:4432 ../src/guestfs-actions.pod:4469 ../src/guestfs-actions.pod:4483 ../src/guestfs-actions.pod:4511 ../src/guestfs-actions.pod:4528 ../src/guestfs-actions.pod:4546 ../src/guestfs-actions.pod:4680 ../src/guestfs-actions.pod:4737 ../src/guestfs-actions.pod:4759 ../src/guestfs-actions.pod:4777 ../src/guestfs-actions.pod:4809 ../src/guestfs-actions.pod:4875 ../src/guestfs-actions.pod:4892 ../src/guestfs-actions.pod:4905 ../src/guestfs-actions.pod:4919 ../src/guestfs-actions.pod:5208 ../src/guestfs-actions.pod:5227 ../src/guestfs-actions.pod:5241 ../src/guestfs-actions.pod:5253 ../src/guestfs-actions.pod:5267 ../src/guestfs-actions.pod:5279 ../src/guestfs-actions.pod:5293 ../src/guestfs-actions.pod:5309 ../src/guestfs-actions.pod:5330 ../src/guestfs-actions.pod:5349 ../src/guestfs-actions.pod:5368 ../src/guestfs-actions.pod:5386 ../src/guestfs-actions.pod:5409 ../src/guestfs-actions.pod:5427 ../src/guestfs-actions.pod:5446 ../src/guestfs-actions.pod:5467 ../src/guestfs-actions.pod:5486 ../src/guestfs-actions.pod:5503 ../src/guestfs-actions.pod:5531 ../src/guestfs-actions.pod:5555 ../src/guestfs-actions.pod:5574 ../src/guestfs-actions.pod:5598 ../src/guestfs-actions.pod:5613 ../src/guestfs-actions.pod:5628 ../src/guestfs-actions.pod:5647 ../src/guestfs-actions.pod:5684 ../src/guestfs-actions.pod:5707 ../src/guestfs-actions.pod:5733 ../src/guestfs-actions.pod:5841 ../src/guestfs-actions.pod:5962 ../src/guestfs-actions.pod:5974 ../src/guestfs-actions.pod:5987 ../src/guestfs-actions.pod:6000 ../src/guestfs-actions.pod:6022 ../src/guestfs-actions.pod:6035 ../src/guestfs-actions.pod:6048 ../src/guestfs-actions.pod:6061 ../src/guestfs-actions.pod:6076 ../src/guestfs-actions.pod:6135 ../src/guestfs-actions.pod:6152 ../src/guestfs-actions.pod:6168 ../src/guestfs-actions.pod:6184 ../src/guestfs-actions.pod:6201 ../src/guestfs-actions.pod:6214 ../src/guestfs-actions.pod:6234 ../src/guestfs-actions.pod:6270 ../src/guestfs-actions.pod:6284 ../src/guestfs-actions.pod:6325 ../src/guestfs-actions.pod:6338 ../src/guestfs-actions.pod:6356 ../src/guestfs-actions.pod:6385 ../src/guestfs-actions.pod:6416 ../src/guestfs-actions.pod:6535 ../src/guestfs-actions.pod:6553 ../src/guestfs-actions.pod:6567 ../src/guestfs-actions.pod:6622 ../src/guestfs-actions.pod:6635 ../src/guestfs-actions.pod:6680 ../src/guestfs-actions.pod:6713 ../src/guestfs-actions.pod:6767 ../src/guestfs-actions.pod:6793 ../src/guestfs-actions.pod:6859 ../src/guestfs-actions.pod:6878 ../src/guestfs-actions.pod:6907
4153 msgid "This function returns 0 on success or -1 on error."
4157 #: ../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
4159 "This function is deprecated. In new code, use the C<add_drive_opts> call "
4164 #: ../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:6801 ../src/guestfs-actions.pod:6970 ../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:4534 ../fish/guestfish-actions.pod:4631
4166 "Deprecated functions will not be removed from the API, but the fact that "
4167 "they are deprecated indicates that there are problems with correct use of "
4172 #: ../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:3164 ../src/guestfs-actions.pod:3179 ../src/guestfs-actions.pod:4319 ../src/guestfs-actions.pod:5388 ../src/guestfs-actions.pod:5505 ../src/guestfs-actions.pod:5615 ../src/guestfs-actions.pod:6078 ../src/guestfs-actions.pod:6203 ../src/guestfs-actions.pod:6715
4173 msgid "(Added in 0.3)"
4177 #: ../src/guestfs-actions.pod:41
4178 msgid "guestfs_add_domain"
4182 #: ../src/guestfs-actions.pod:43
4186 " guestfs_add_domain (guestfs_h *g,\n"
4187 " const char *dom,\n"
4193 #: ../src/guestfs-actions.pod:48 ../src/guestfs-actions.pod:137
4195 "You may supply a list of optional arguments to this call. Use zero or more "
4196 "of the following pairs of parameters, and terminate the list with C<-1> on "
4197 "its own. See L</CALLS WITH OPTIONAL ARGUMENTS>."
4201 #: ../src/guestfs-actions.pod:53
4204 " GUESTFS_ADD_DOMAIN_LIBVIRTURI, const char *libvirturi,\n"
4205 " GUESTFS_ADD_DOMAIN_READONLY, int readonly,\n"
4206 " GUESTFS_ADD_DOMAIN_IFACE, const char *iface,\n"
4211 #: ../src/guestfs-actions.pod:57
4213 "This function adds the disk(s) attached to the named libvirt domain C<dom>. "
4214 "It works by connecting to libvirt, requesting the domain and domain XML from "
4215 "libvirt, parsing it for disks, and calling C<guestfs_add_drive_opts> on each "
4220 #: ../src/guestfs-actions.pod:62 ../fish/guestfish-actions.pod:46
4222 "The number of disks added is returned. This operation is atomic: if an "
4223 "error is returned, then no disks are added."
4227 #: ../src/guestfs-actions.pod:65 ../fish/guestfish-actions.pod:49
4229 "This function does some minimal checks to make sure the libvirt domain is "
4230 "not running (unless C<readonly> is true). In a future version we will try "
4231 "to acquire the libvirt lock on each disk."
4235 #: ../src/guestfs-actions.pod:69 ../fish/guestfish-actions.pod:53
4237 "Disks must be accessible locally. This often means that adding disks from a "
4238 "remote libvirt connection (see L<http://libvirt.org/remote.html>) will fail "
4239 "unless those disks are accessible via the same device path locally too."
4243 #: ../src/guestfs-actions.pod:74
4245 "The optional C<libvirturi> parameter sets the libvirt URI (see "
4246 "L<http://libvirt.org/uri.html>). If this is not set then we connect to the "
4247 "default libvirt URI (or one set through an environment variable, see the "
4248 "libvirt documentation for full details). If you are using the C API "
4249 "directly then it is more flexible to create the libvirt connection object "
4250 "yourself, get the domain object, and call C<guestfs_add_libvirt_dom>."
4254 #: ../src/guestfs-actions.pod:82
4256 "The other optional parameters are passed directly through to "
4257 "C<guestfs_add_drive_opts>."
4261 #: ../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:2610 ../src/guestfs-actions.pod:2631 ../src/guestfs-actions.pod:4455 ../src/guestfs-actions.pod:4583 ../src/guestfs-actions.pod:4989 ../src/guestfs-actions.pod:5015 ../src/guestfs-actions.pod:6311 ../src/guestfs-actions.pod:6726 ../src/guestfs-actions.pod:6739 ../src/guestfs-actions.pod:6752
4262 msgid "On error this function returns -1."
4266 #: ../src/guestfs-actions.pod:87
4267 msgid "guestfs_add_domain_va"
4271 #: ../src/guestfs-actions.pod:89
4275 " guestfs_add_domain_va (guestfs_h *g,\n"
4276 " const char *dom,\n"
4282 #: ../src/guestfs-actions.pod:94
4283 msgid "This is the \"va_list variant\" of L</guestfs_add_domain>."
4287 #: ../src/guestfs-actions.pod:96 ../src/guestfs-actions.pod:107 ../src/guestfs-actions.pod:200 ../src/guestfs-actions.pod:211
4288 msgid "See L</CALLS WITH OPTIONAL ARGUMENTS>."
4292 #: ../src/guestfs-actions.pod:98
4293 msgid "guestfs_add_domain_argv"
4297 #: ../src/guestfs-actions.pod:100
4301 " guestfs_add_domain_argv (guestfs_h *g,\n"
4302 " const char *dom,\n"
4303 " const struct guestfs_add_domain_argv *optargs);\n"
4308 #: ../src/guestfs-actions.pod:105
4309 msgid "This is the \"argv variant\" of L</guestfs_add_domain>."
4313 #: ../src/guestfs-actions.pod:109
4314 msgid "guestfs_add_drive"
4318 #: ../src/guestfs-actions.pod:111
4322 " guestfs_add_drive (guestfs_h *g,\n"
4323 " const char *filename);\n"
4328 #: ../src/guestfs-actions.pod:115
4330 "This function is the equivalent of calling C<guestfs_add_drive_opts> with no "
4331 "optional parameters, so the disk is added writable, with the format being "
4332 "detected automatically."
4336 #: ../src/guestfs-actions.pod:119
4338 "Automatic detection of the format opens you up to a potential security hole "
4339 "when dealing with untrusted raw-format images. See CVE-2010-3851 and "
4340 "RHBZ#642934. Specifying the format closes this security hole. Therefore "
4341 "you should think about replacing calls to this function with calls to "
4342 "C<guestfs_add_drive_opts>, and specifying the format."
4346 #: ../src/guestfs-actions.pod:130
4347 msgid "guestfs_add_drive_opts"
4351 #: ../src/guestfs-actions.pod:132
4355 " guestfs_add_drive_opts (guestfs_h *g,\n"
4356 " const char *filename,\n"
4362 #: ../src/guestfs-actions.pod:142
4365 " GUESTFS_ADD_DRIVE_OPTS_READONLY, int readonly,\n"
4366 " GUESTFS_ADD_DRIVE_OPTS_FORMAT, const char *format,\n"
4367 " GUESTFS_ADD_DRIVE_OPTS_IFACE, const char *iface,\n"
4372 #: ../src/guestfs-actions.pod:146 ../fish/guestfish-actions.pod:92
4374 "This function adds a virtual machine disk image C<filename> to libguestfs. "
4375 "The first time you call this function, the disk appears as C</dev/sda>, the "
4376 "second time as C</dev/sdb>, and so on."
4380 #: ../src/guestfs-actions.pod:151 ../fish/guestfish-actions.pod:97
4382 "You don't necessarily need to be root when using libguestfs. However you "
4383 "obviously do need sufficient permissions to access the filename for whatever "
4384 "operations you want to perform (ie. read access if you just want to read the "
4385 "image or write access if you want to modify the image)."
4389 #: ../src/guestfs-actions.pod:157 ../fish/guestfish-actions.pod:103
4390 msgid "This call checks that C<filename> exists."
4394 #: ../src/guestfs-actions.pod:159 ../fish/guestfish-actions.pod:105
4395 msgid "The optional arguments are:"
4399 #: ../src/guestfs-actions.pod:163 ../fish/guestfish-actions.pod:109
4404 #: ../src/guestfs-actions.pod:165 ../fish/guestfish-actions.pod:111
4406 "If true then the image is treated as read-only. Writes are still allowed, "
4407 "but they are stored in a temporary snapshot overlay which is discarded at "
4408 "the end. The disk that you add is not modified."
4412 #: ../src/guestfs-actions.pod:169 ../fish/guestfish-actions.pod:115
4417 #: ../src/guestfs-actions.pod:171
4419 "This forces the image format. If you omit this (or use C<guestfs_add_drive> "
4420 "or C<guestfs_add_drive_ro>) then the format is automatically detected. "
4421 "Possible formats include C<raw> and C<qcow2>."
4425 #: ../src/guestfs-actions.pod:175 ../fish/guestfish-actions.pod:121
4427 "Automatic detection of the format opens you up to a potential security hole "
4428 "when dealing with untrusted raw-format images. See CVE-2010-3851 and "
4429 "RHBZ#642934. Specifying the format closes this security hole."
4433 #: ../src/guestfs-actions.pod:180 ../fish/guestfish-actions.pod:126
4438 #: ../src/guestfs-actions.pod:182
4440 "This rarely-used option lets you emulate the behaviour of the deprecated "
4441 "C<guestfs_add_drive_with_if> call (q.v.)"
4445 #: ../src/guestfs-actions.pod:189
4446 msgid "(Added in 1.5.23)"
4450 #: ../src/guestfs-actions.pod:191
4451 msgid "guestfs_add_drive_opts_va"
4455 #: ../src/guestfs-actions.pod:193
4459 " guestfs_add_drive_opts_va (guestfs_h *g,\n"
4460 " const char *filename,\n"
4466 #: ../src/guestfs-actions.pod:198
4467 msgid "This is the \"va_list variant\" of L</guestfs_add_drive_opts>."
4471 #: ../src/guestfs-actions.pod:202
4472 msgid "guestfs_add_drive_opts_argv"
4476 #: ../src/guestfs-actions.pod:204
4480 " guestfs_add_drive_opts_argv (guestfs_h *g,\n"
4481 " const char *filename,\n"
4482 " const struct guestfs_add_drive_opts_argv "
4488 #: ../src/guestfs-actions.pod:209
4489 msgid "This is the \"argv variant\" of L</guestfs_add_drive_opts>."
4493 #: ../src/guestfs-actions.pod:213
4494 msgid "guestfs_add_drive_ro"
4498 #: ../src/guestfs-actions.pod:215
4502 " guestfs_add_drive_ro (guestfs_h *g,\n"
4503 " const char *filename);\n"
4508 #: ../src/guestfs-actions.pod:219
4510 "This function is the equivalent of calling C<guestfs_add_drive_opts> with "
4511 "the optional parameter C<GUESTFS_ADD_DRIVE_OPTS_READONLY> set to 1, so the "
4512 "disk is added read-only, with the format being detected automatically."
4516 #: ../src/guestfs-actions.pod:226
4517 msgid "(Added in 1.0.38)"
4521 #: ../src/guestfs-actions.pod:228
4522 msgid "guestfs_add_drive_ro_with_if"
4526 #: ../src/guestfs-actions.pod:230
4530 " guestfs_add_drive_ro_with_if (guestfs_h *g,\n"
4531 " const char *filename,\n"
4532 " const char *iface);\n"