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.23\n"
10 "Report-Msgid-Bugs-To: libguestfs@redhat.com\n"
11 "POT-Creation-Date: 2010-12-12 21:33+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 ../tools/virt-edit.pl:30 ../tools/virt-win-reg.pl:33 ../tools/virt-resize.pl:38 ../tools/virt-list-filesystems.pl:28 ../tools/virt-tar.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 ../tools/virt-edit.pl:32 ../tools/virt-win-reg.pl:35 ../tools/virt-resize.pl:40 ../tools/virt-list-filesystems.pl:30 ../tools/virt-tar.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 ../tools/virt-edit.pl:36 ../tools/virt-win-reg.pl:39 ../tools/virt-resize.pl:44 ../tools/virt-list-filesystems.pl:34 ../tools/virt-tar.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_close (g);\n"
62 #: ../src/guestfs.pod:19
65 " cc prog.c -o prog -lguestfs\n"
67 " cc prog.c -o prog `pkg-config libguestfs --cflags --libs`\n"
72 #: ../src/guestfs.pod:23 ../fish/guestfish.pod:30 ../test-tool/libguestfs-test-tool.pod:11 ../fuse/guestmount.pod:20 ../tools/virt-edit.pl:50 ../tools/virt-win-reg.pl:63 ../tools/virt-resize.pl:50 ../tools/virt-list-filesystems.pl:40 ../tools/virt-tar.pl:72 ../tools/virt-make-fs.pl:47 ../tools/virt-list-partitions.pl:40
77 #: ../src/guestfs.pod:25
79 "Libguestfs is a library for accessing and modifying guest disk images. "
80 "Amongst the things this is good for: making batch configuration changes to "
81 "guests, getting disk used/free statistics (see also: virt-df), migrating "
82 "between virtualization systems (see also: virt-p2v), performing partial "
83 "backups, performing partial guest clones, cloning guests and changing "
84 "registry/UUID/hostname info, and much else besides."
88 #: ../src/guestfs.pod:33
90 "Libguestfs uses Linux kernel and qemu code, and can access any type of guest "
91 "filesystem that Linux and qemu can, including but not limited to: ext2/3/4, "
92 "btrfs, FAT and NTFS, LVM, many different disk partition schemes, qcow, "
97 #: ../src/guestfs.pod:38
99 "Libguestfs provides ways to enumerate guest storage (eg. partitions, LVs, "
100 "what filesystem is in each LV, etc.). It can also run commands in the "
101 "context of the guest. Also you can access filesystems over FUSE."
105 #: ../src/guestfs.pod:43
107 "Libguestfs is a library that can be linked with C and C++ management "
108 "programs (or management programs written in OCaml, Perl, Python, Ruby, Java, "
109 "PHP, Haskell or C#). You can also use it from shell scripts or the command "
114 #: ../src/guestfs.pod:48
116 "You don't need to be root to use libguestfs, although obviously you do need "
117 "enough permissions to access the disk images."
121 #: ../src/guestfs.pod:51
123 "Libguestfs is a large API because it can do many things. For a gentle "
124 "introduction, please read the L</API OVERVIEW> section next."
128 #: ../src/guestfs.pod:54
130 "There are also some example programs in the L<guestfs-examples(3)> manual "
135 #: ../src/guestfs.pod:57
140 #: ../src/guestfs.pod:59
142 "This section provides a gentler overview of the libguestfs API. We also try "
143 "to group API calls together, where that may not be obvious from reading "
144 "about the individual calls in the main section of this manual."
148 #: ../src/guestfs.pod:64
153 #: ../src/guestfs.pod:66
155 "Before you can use libguestfs calls, you have to create a handle. Then you "
156 "must add at least one disk image to the handle, followed by launching the "
157 "handle, then performing whatever operations you want, and finally closing "
158 "the handle. By convention we use the single letter C<g> for the name of the "
159 "handle variable, although of course you can use any name you want."
163 #: ../src/guestfs.pod:73
164 msgid "The general structure of all libguestfs-using programs looks like this:"
168 #: ../src/guestfs.pod:76
171 " guestfs_h *g = guestfs_create ();\n"
176 #: ../src/guestfs.pod:78
179 " /* Call guestfs_add_drive additional times if there are\n"
180 " * multiple disk images.\n"
182 " guestfs_add_drive (g, \"guest.img\");\n"
187 #: ../src/guestfs.pod:83
190 " /* Most manipulation calls won't work until you've launched\n"
191 " * the handle 'g'. You have to do this _after_ adding drives\n"
192 " * and _before_ other commands.\n"
194 " guestfs_launch (g);\n"
199 #: ../src/guestfs.pod:89
202 " /* Now you can examine what partitions, LVs etc are available.\n"
204 " char **partitions = guestfs_list_partitions (g);\n"
205 " char **logvols = guestfs_lvs (g);\n"
210 #: ../src/guestfs.pod:94
213 " /* To access a filesystem in the image, you must mount it.\n"
215 " guestfs_mount (g, \"/dev/sda1\", \"/\");\n"
220 #: ../src/guestfs.pod:98
223 " /* Now you can perform filesystem actions on the guest\n"
226 " guestfs_touch (g, \"/hello\");\n"
231 #: ../src/guestfs.pod:103
234 " /* This is only needed for libguestfs < 1.5.24. Since then\n"
235 " * it is done automatically when you close the handle. See\n"
236 " * discussion of autosync in this page.\n"
238 " guestfs_sync (g);\n"
243 #: ../src/guestfs.pod:109
246 " /* Close the handle 'g'. */\n"
247 " guestfs_close (g);\n"
252 #: ../src/guestfs.pod:112
254 "The code above doesn't include any error checking. In real code you should "
255 "check return values carefully for errors. In general all functions that "
256 "return integers return C<-1> on error, and all functions that return "
257 "pointers return C<NULL> on error. See section L</ERROR HANDLING> below for "
258 "how to handle errors, and consult the documentation for each function call "
259 "below to see precisely how they return error indications. See "
260 "L<guestfs-examples(3)> for fully worked examples."
264 #: ../src/guestfs.pod:121
269 #: ../src/guestfs.pod:123
271 "The image filename (C<\"guest.img\"> in the example above) could be a disk "
272 "image from a virtual machine, a L<dd(1)> copy of a physical hard disk, an "
273 "actual block device, or simply an empty file of zeroes that you have created "
274 "through L<posix_fallocate(3)>. Libguestfs lets you do useful things to all "
279 #: ../src/guestfs.pod:129
281 "The call you should use in modern code for adding drives is "
282 "L</guestfs_add_drive_opts>. To add a disk image, allowing writes, and "
283 "specifying that the format is raw, do:"
287 #: ../src/guestfs.pod:133
290 " guestfs_add_drive_opts (g, filename,\n"
291 " GUESTFS_ADD_DRIVE_OPTS_FORMAT, \"raw\",\n"
297 #: ../src/guestfs.pod:137
298 msgid "You can add a disk read-only using:"
302 #: ../src/guestfs.pod:139
305 " guestfs_add_drive_opts (g, filename,\n"
306 " GUESTFS_ADD_DRIVE_OPTS_FORMAT, \"raw\",\n"
307 " GUESTFS_ADD_DRIVE_OPTS_READONLY, 1,\n"
313 #: ../src/guestfs.pod:144
315 "or by calling the older function L</guestfs_add_drive_ro>. In either case "
316 "libguestfs won't modify the file."
320 #: ../src/guestfs.pod:147
322 "Be extremely cautious if the disk image is in use, eg. if it is being used "
323 "by a virtual machine. Adding it read-write will almost certainly cause disk "
324 "corruption, but adding it read-only is safe."
328 #: ../src/guestfs.pod:151
330 "You must add at least one disk image, and you may add multiple disk images. "
331 "In the API, the disk images are usually referred to as C</dev/sda> (for the "
332 "first one you added), C</dev/sdb> (for the second one you added), etc."
336 #: ../src/guestfs.pod:156
338 "Once L</guestfs_launch> has been called you cannot add any more images. You "
339 "can call L</guestfs_list_devices> to get a list of the device names, in the "
340 "order that you added them. See also L</BLOCK DEVICE NAMING> below."
344 #: ../src/guestfs.pod:161
349 #: ../src/guestfs.pod:163
351 "Before you can read or write files, create directories and so on in a disk "
352 "image that contains filesystems, you have to mount those filesystems using "
353 "L</guestfs_mount>. If you already know that a disk image contains (for "
354 "example) one partition with a filesystem on that partition, then you can "
359 #: ../src/guestfs.pod:169
362 " guestfs_mount (g, \"/dev/sda1\", \"/\");\n"
367 #: ../src/guestfs.pod:171
369 "where C</dev/sda1> means literally the first partition (C<1>) of the first "
370 "disk image that we added (C</dev/sda>). If the disk contains Linux LVM2 "
371 "logical volumes you could refer to those instead (eg. C</dev/VG/LV>)."
375 #: ../src/guestfs.pod:175
377 "If you are given a disk image and you don't know what it contains then you "
378 "have to find out. Libguestfs can do that too: use "
379 "L</guestfs_list_partitions> and L</guestfs_lvs> to list possible partitions "
380 "and LVs, and either try mounting each to see what is mountable, or else "
381 "examine them with L</guestfs_vfs_type> or L</guestfs_file>. Libguestfs also "
382 "has a set of APIs for inspection of disk images (see L</INSPECTION> below). "
383 "But you might find it easier to look at higher level programs built on top "
384 "of libguestfs, in particular L<virt-inspector(1)>."
388 #: ../src/guestfs.pod:185
390 "To mount a disk image read-only, use L</guestfs_mount_ro>. There are "
391 "several other variations of the C<guestfs_mount_*> call."
395 #: ../src/guestfs.pod:188
396 msgid "FILESYSTEM ACCESS AND MODIFICATION"
400 #: ../src/guestfs.pod:190
402 "The majority of the libguestfs API consists of fairly low-level calls for "
403 "accessing and modifying the files, directories, symlinks etc on mounted "
404 "filesystems. There are over a hundred such calls which you can find listed "
405 "in detail below in this man page, and we don't even pretend to cover them "
406 "all in this overview."
410 #: ../src/guestfs.pod:196
412 "Specify filenames as full paths, starting with C<\"/\"> and including the "
417 #: ../src/guestfs.pod:199
419 "For example, if you mounted a filesystem at C<\"/\"> and you want to read "
420 "the file called C<\"etc/passwd\"> then you could do:"
424 #: ../src/guestfs.pod:202
427 " char *data = guestfs_cat (g, \"/etc/passwd\");\n"
432 #: ../src/guestfs.pod:204
434 "This would return C<data> as a newly allocated buffer containing the full "
435 "content of that file (with some conditions: see also L</DOWNLOADING> below), "
436 "or C<NULL> if there was an error."
440 #: ../src/guestfs.pod:208
442 "As another example, to create a top-level directory on that filesystem "
443 "called C<\"var\"> you would do:"
447 #: ../src/guestfs.pod:211
450 " guestfs_mkdir (g, \"/var\");\n"
455 #: ../src/guestfs.pod:213
456 msgid "To create a symlink you could do:"
460 #: ../src/guestfs.pod:215
463 " guestfs_ln_s (g, \"/etc/init.d/portmap\",\n"
464 " \"/etc/rc3.d/S30portmap\");\n"
469 #: ../src/guestfs.pod:218
471 "Libguestfs will reject attempts to use relative paths and there is no "
472 "concept of a current working directory."
476 #: ../src/guestfs.pod:221
478 "Libguestfs can return errors in many situations: for example if the "
479 "filesystem isn't writable, or if a file or directory that you requested "
480 "doesn't exist. If you are using the C API (documented here) you have to "
481 "check for those error conditions after each call. (Other language bindings "
482 "turn these errors into exceptions)."
486 #: ../src/guestfs.pod:227
488 "File writes are affected by the per-handle umask, set by calling "
489 "L</guestfs_umask> and defaulting to 022. See L</UMASK>."
493 #: ../src/guestfs.pod:230
498 #: ../src/guestfs.pod:232
500 "Libguestfs contains API calls to read, create and modify partition tables on "
505 #: ../src/guestfs.pod:235
507 "In the common case where you want to create a single partition covering the "
508 "whole disk, you should use the L</guestfs_part_disk> call:"
512 #: ../src/guestfs.pod:239
515 " const char *parttype = \"mbr\";\n"
516 " if (disk_is_larger_than_2TB)\n"
517 " parttype = \"gpt\";\n"
518 " guestfs_part_disk (g, \"/dev/sda\", parttype);\n"
523 #: ../src/guestfs.pod:244
525 "Obviously this effectively wipes anything that was on that disk image "
530 #: ../src/guestfs.pod:247
535 #: ../src/guestfs.pod:249
537 "Libguestfs provides access to a large part of the LVM2 API, such as "
538 "L</guestfs_lvcreate> and L</guestfs_vgremove>. It won't make much sense "
539 "unless you familiarize yourself with the concepts of physical volumes, "
540 "volume groups and logical volumes."
544 #: ../src/guestfs.pod:254
546 "This author strongly recommends reading the LVM HOWTO, online at "
547 "L<http://tldp.org/HOWTO/LVM-HOWTO/>."
551 #: ../src/guestfs.pod:257
556 #: ../src/guestfs.pod:259
558 "Use L</guestfs_cat> to download small, text only files. This call is "
559 "limited to files which are less than 2 MB and which cannot contain any ASCII "
560 "NUL (C<\\0>) characters. However it has a very simple to use API."
564 #: ../src/guestfs.pod:264
566 "L</guestfs_read_file> can be used to read files which contain arbitrary 8 "
567 "bit data, since it returns a (pointer, size) pair. However it is still "
568 "limited to \"small\" files, less than 2 MB."
572 #: ../src/guestfs.pod:268
574 "L</guestfs_download> can be used to download any file, with no limits on "
575 "content or size (even files larger than 4 GB)."
579 #: ../src/guestfs.pod:271
580 msgid "To download multiple files, see L</guestfs_tar_out> and L</guestfs_tgz_out>."
584 #: ../src/guestfs.pod:274
589 #: ../src/guestfs.pod:276
591 "It's often the case that you want to write a file or files to the disk "
596 #: ../src/guestfs.pod:279
598 "To write a small file with fixed content, use L</guestfs_write>. To create "
599 "a file of all zeroes, use L</guestfs_truncate_size> (sparse) or "
600 "L</guestfs_fallocate64> (with all disk blocks allocated). There are a "
601 "variety of other functions for creating test files, for example "
602 "L</guestfs_fill> and L</guestfs_fill_pattern>."
606 #: ../src/guestfs.pod:285
608 "To upload a single file, use L</guestfs_upload>. This call has no limits on "
609 "file content or size (even files larger than 4 GB)."
613 #: ../src/guestfs.pod:288
614 msgid "To upload multiple files, see L</guestfs_tar_in> and L</guestfs_tgz_in>."
618 #: ../src/guestfs.pod:290
620 "However the fastest way to upload I<large numbers of arbitrary files> is to "
621 "turn them into a squashfs or CD ISO (see L<mksquashfs(8)> and "
622 "L<mkisofs(8)>), then attach this using L</guestfs_add_drive_ro>. If you add "
623 "the drive in a predictable way (eg. adding it last after all other drives) "
624 "then you can get the device name from L</guestfs_list_devices> and mount it "
625 "directly using L</guestfs_mount_ro>. Note that squashfs images are "
626 "sometimes non-portable between kernel versions, and they don't support "
627 "labels or UUIDs. If you want to pre-build an image or you need to mount it "
628 "using a label or UUID, use an ISO image instead."
632 #: ../src/guestfs.pod:301
637 #: ../src/guestfs.pod:303
639 "There are various different commands for copying between files and devices "
640 "and in and out of the guest filesystem. These are summarised in the table "
645 #: ../src/guestfs.pod:309
646 msgid "B<file> to B<file>"
650 #: ../src/guestfs.pod:311
652 "Use L</guestfs_cp> to copy a single file, or L</guestfs_cp_a> to copy "
653 "directories recursively."
657 #: ../src/guestfs.pod:314
658 msgid "B<file or device> to B<file or device>"
662 #: ../src/guestfs.pod:316
664 "Use L</guestfs_dd> which efficiently uses L<dd(1)> to copy between files and "
665 "devices in the guest."
669 #: ../src/guestfs.pod:319
670 msgid "Example: duplicate the contents of an LV:"
674 #: ../src/guestfs.pod:321
677 " guestfs_dd (g, \"/dev/VG/Original\", \"/dev/VG/Copy\");\n"
682 #: ../src/guestfs.pod:323
684 "The destination (C</dev/VG/Copy>) must be at least as large as the source "
685 "(C</dev/VG/Original>). To copy less than the whole source device, use "
686 "L</guestfs_copy_size>."
690 #: ../src/guestfs.pod:327
691 msgid "B<file on the host> to B<file or device>"
695 #: ../src/guestfs.pod:329
696 msgid "Use L</guestfs_upload>. See L</UPLOADING> above."
700 #: ../src/guestfs.pod:331
701 msgid "B<file or device> to B<file on the host>"
705 #: ../src/guestfs.pod:333
706 msgid "Use L</guestfs_download>. See L</DOWNLOADING> above."
710 #: ../src/guestfs.pod:337
711 msgid "LISTING FILES"
715 #: ../src/guestfs.pod:339
717 "L</guestfs_ll> is just designed for humans to read (mainly when using the "
718 "L<guestfish(1)>-equivalent command C<ll>)."
722 #: ../src/guestfs.pod:342
724 "L</guestfs_ls> is a quick way to get a list of files in a directory from "
725 "programs, as a flat list of strings."
729 #: ../src/guestfs.pod:345
731 "L</guestfs_readdir> is a programmatic way to get a list of files in a "
732 "directory, plus additional information about each one. It is more "
733 "equivalent to using the L<readdir(3)> call on a local filesystem."
737 #: ../src/guestfs.pod:349
739 "L</guestfs_find> and L</guestfs_find0> can be used to recursively list "
744 #: ../src/guestfs.pod:352
745 msgid "RUNNING COMMANDS"
749 #: ../src/guestfs.pod:354
751 "Although libguestfs is primarily an API for manipulating files inside guest "
752 "images, we also provide some limited facilities for running commands inside "
757 #: ../src/guestfs.pod:358
758 msgid "There are many limitations to this:"
762 #: ../src/guestfs.pod:362 ../src/guestfs.pod:367 ../src/guestfs.pod:372 ../src/guestfs.pod:376 ../src/guestfs.pod:381 ../src/guestfs.pod:385 ../src/guestfs.pod:390 ../src/guestfs.pod:395 ../src/guestfs.pod:954 ../src/guestfs.pod:958 ../src/guestfs.pod:962 ../src/guestfs.pod:967 ../src/guestfs.pod:975 ../src/guestfs.pod:994 ../src/guestfs.pod:1002 ../src/guestfs.pod:1024 ../src/guestfs.pod:1028 ../src/guestfs.pod:1032 ../src/guestfs.pod:1036 ../src/guestfs.pod:1040 ../src/guestfs.pod:1044 ../src/guestfs.pod:1526 ../src/guestfs.pod:1531 ../src/guestfs.pod:1535 ../src/guestfs.pod:1645 ../src/guestfs.pod:1650 ../src/guestfs.pod:1654 ../src/guestfs.pod:2006 ../src/guestfs.pod:2012 ../src/guestfs.pod:2017 ../src/guestfs.pod:2023 ../src/guestfs.pod:2135 ../src/guestfs.pod:2139 ../src/guestfs.pod:2143 ../src/guestfs.pod:2147 ../src/guestfs-actions.pod:15 ../src/guestfs-actions.pod:22 ../src/guestfs-actions.pod:571 ../src/guestfs-actions.pod:579 ../src/guestfs-actions.pod:586 ../src/guestfs-actions.pod:593 ../src/guestfs-actions.pod:1589 ../src/guestfs-actions.pod:1593 ../src/guestfs-actions.pod:1597 ../src/guestfs-actions.pod:1601 ../src/guestfs-actions.pod:1609 ../src/guestfs-actions.pod:1613 ../src/guestfs-actions.pod:1617 ../src/guestfs-actions.pod:1627 ../src/guestfs-actions.pod:1631 ../src/guestfs-actions.pod:1635 ../src/guestfs-actions.pod:1773 ../src/guestfs-actions.pod:1777 ../src/guestfs-actions.pod:1782 ../src/guestfs-actions.pod:1787 ../src/guestfs-actions.pod:1848 ../src/guestfs-actions.pod:1852 ../src/guestfs-actions.pod:1857 ../fish/guestfish.pod:427 ../fish/guestfish.pod:431 ../fish/guestfish.pod:435 ../fish/guestfish.pod:439 ../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 ../tools/virt-win-reg.pl:536 ../tools/virt-win-reg.pl:542 ../tools/virt-win-reg.pl:548 ../tools/virt-resize.pl:345 ../tools/virt-resize.pl:350 ../tools/virt-resize.pl:360
767 #: ../src/guestfs.pod:364
769 "The kernel version that the command runs under will be different from what "
774 #: ../src/guestfs.pod:369
776 "If the command needs to communicate with daemons, then most likely they "
781 #: ../src/guestfs.pod:374
782 msgid "The command will be running in limited memory."
786 #: ../src/guestfs.pod:378
788 "The network may not be available unless you enable it (see "
789 "L</guestfs_set_network>)."
793 #: ../src/guestfs.pod:383
794 msgid "Only supports Linux guests (not Windows, BSD, etc)."
798 #: ../src/guestfs.pod:387
799 msgid "Architecture limitations (eg. won't work for a PPC guest on an X86 host)."
803 #: ../src/guestfs.pod:392
805 "For SELinux guests, you may need to enable SELinux and load policy first. "
806 "See L</SELINUX> in this manpage."
810 #: ../src/guestfs.pod:397
812 "I<Security:> It is not safe to run commands from untrusted, possibly "
813 "malicious guests. These commands may attempt to exploit your program by "
814 "sending unexpected output. They could also try to exploit the Linux kernel "
815 "or qemu provided by the libguestfs appliance. They could use the network "
816 "provided by the libguestfs appliance to bypass ordinary network partitions "
817 "and firewalls. They could use the elevated privileges or different SELinux "
818 "context of your program to their advantage."
822 #: ../src/guestfs.pod:406
824 "A secure alternative is to use libguestfs to install a \"firstboot\" script "
825 "(a script which runs when the guest next boots normally), and to have this "
826 "script run the commands you want in the normal context of the running guest, "
827 "network security and so on. For information about other security issues, "
832 #: ../src/guestfs.pod:414
834 "The two main API calls to run commands are L</guestfs_command> and "
835 "L</guestfs_sh> (there are also variations)."
839 #: ../src/guestfs.pod:417
841 "The difference is that L</guestfs_sh> runs commands using the shell, so any "
842 "shell globs, redirections, etc will work."
846 #: ../src/guestfs.pod:420
847 msgid "CONFIGURATION FILES"
851 #: ../src/guestfs.pod:422
853 "To read and write configuration files in Linux guest filesystems, we "
854 "strongly recommend using Augeas. For example, Augeas understands how to "
855 "read and write, say, a Linux shadow password file or X.org configuration "
856 "file, and so avoids you having to write that code."
860 #: ../src/guestfs.pod:427
862 "The main Augeas calls are bound through the C<guestfs_aug_*> APIs. We don't "
863 "document Augeas itself here because there is excellent documentation on the "
864 "L<http://augeas.net/> website."
868 #: ../src/guestfs.pod:431
870 "If you don't want to use Augeas (you fool!) then try calling "
871 "L</guestfs_read_lines> to get the file as a list of lines which you can "
876 #: ../src/guestfs.pod:435
881 #: ../src/guestfs.pod:437
883 "We support SELinux guests. To ensure that labeling happens correctly in "
884 "SELinux guests, you need to enable SELinux and load the guest's policy:"
888 #: ../src/guestfs.pod:443 ../src/guestfs.pod:1147 ../src/guestfs.pod:1278
893 #: ../src/guestfs.pod:445
894 msgid "Before launching, do:"
898 #: ../src/guestfs.pod:447
901 " guestfs_set_selinux (g, 1);\n"
906 #: ../src/guestfs.pod:449 ../src/guestfs.pod:1151 ../src/guestfs.pod:1282
911 #: ../src/guestfs.pod:451
913 "After mounting the guest's filesystem(s), load the policy. This is best "
914 "done by running the L<load_policy(8)> command in the guest itself:"
918 #: ../src/guestfs.pod:455
921 " guestfs_sh (g, \"/usr/sbin/load_policy\");\n"
926 #: ../src/guestfs.pod:457
928 "(Older versions of C<load_policy> require you to specify the name of the "
933 #: ../src/guestfs.pod:460 ../src/guestfs.pod:1288
938 #: ../src/guestfs.pod:462
940 "Optionally, set the security context for the API. The correct security "
941 "context to use can only be known by inspecting the guest. As an example:"
945 #: ../src/guestfs.pod:466
948 " guestfs_setcon (g, \"unconfined_u:unconfined_r:unconfined_t:s0\");\n"
953 #: ../src/guestfs.pod:470
954 msgid "This will work for running commands and editing existing files."
958 #: ../src/guestfs.pod:472
960 "When new files are created, you may need to label them explicitly, for "
961 "example by running the external command C<restorecon pathname>."
965 #: ../src/guestfs.pod:476
970 #: ../src/guestfs.pod:478
972 "Certain calls are affected by the current file mode creation mask (the "
973 "\"umask\"). In particular ones which create files or directories, such as "
974 "L</guestfs_touch>, L</guestfs_mknod> or L</guestfs_mkdir>. This affects "
975 "either the default mode that the file is created with or modifies the mode "
980 #: ../src/guestfs.pod:484
982 "The default umask is C<022>, so files are created with modes such as C<0644> "
983 "and directories with C<0755>."
987 #: ../src/guestfs.pod:487
989 "There are two ways to avoid being affected by umask. Either set umask to 0 "
990 "(call C<guestfs_umask (g, 0)> early after launching). Or call "
991 "L</guestfs_chmod> after creating each file or directory."
995 #: ../src/guestfs.pod:491
996 msgid "For more information about umask, see L<umask(2)>."
1000 #: ../src/guestfs.pod:493 ../fish/guestfish.pod:720
1001 msgid "ENCRYPTED DISKS"
1005 #: ../src/guestfs.pod:495
1007 "Libguestfs allows you to access Linux guests which have been encrypted using "
1008 "whole disk encryption that conforms to the Linux Unified Key Setup (LUKS) "
1009 "standard. This includes nearly all whole disk encryption systems used by "
1010 "modern Linux guests."
1014 #: ../src/guestfs.pod:501
1016 "Use L</guestfs_vfs_type> to identify LUKS-encrypted block devices (it "
1017 "returns the string C<crypto_LUKS>)."
1021 #: ../src/guestfs.pod:504
1023 "Then open these devices by calling L</guestfs_luks_open>. Obviously you "
1024 "will require the passphrase!"
1028 #: ../src/guestfs.pod:507
1030 "Opening a LUKS device creates a new device mapper device called "
1031 "C</dev/mapper/mapname> (where C<mapname> is the string you supply to "
1032 "L</guestfs_luks_open>). Reads and writes to this mapper device are "
1033 "decrypted from and encrypted to the underlying block device respectively."
1037 #: ../src/guestfs.pod:513
1039 "LVM volume groups on the device can be made visible by calling "
1040 "L</guestfs_vgscan> followed by L</guestfs_vg_activate_all>. The logical "
1041 "volume(s) can now be mounted in the usual way."
1045 #: ../src/guestfs.pod:517
1047 "Use the reverse process to close a LUKS device. Unmount any logical volumes "
1048 "on it, deactivate the volume groups by caling C<guestfs_vg_activate (g, 0, "
1049 "[\"/dev/VG\"])>. Then close the mapper device by calling "
1050 "L</guestfs_luks_close> on the C</dev/mapper/mapname> device (I<not> the "
1051 "underlying encrypted block device)."
1055 #: ../src/guestfs.pod:524
1060 #: ../src/guestfs.pod:526
1062 "Libguestfs has APIs for inspecting an unknown disk image to find out if it "
1063 "contains operating systems. (These APIs used to be in a separate Perl-only "
1064 "library called L<Sys::Guestfs::Lib(3)> but since version 1.5.3 the most "
1065 "frequently used part of this library has been rewritten in C and moved into "
1070 #: ../src/guestfs.pod:532
1072 "Add all disks belonging to the unknown virtual machine and call "
1073 "L</guestfs_launch> in the usual way."
1077 #: ../src/guestfs.pod:535
1079 "Then call L</guestfs_inspect_os>. This function uses other libguestfs calls "
1080 "and certain heuristics, and returns a list of operating systems that were "
1081 "found. An empty list means none were found. A single element is the root "
1082 "filesystem of the operating system. For dual- or multi-boot guests, "
1083 "multiple roots can be returned, each one corresponding to a separate "
1084 "operating system. (Multi-boot virtual machines are extremely rare in the "
1085 "world of virtualization, but since this scenario can happen, we have built "
1086 "libguestfs to deal with it.)"
1090 #: ../src/guestfs.pod:544
1092 "For each root, you can then call various C<guestfs_inspect_get_*> functions "
1093 "to get additional details about that operating system. For example, call "
1094 "L</guestfs_inspect_get_type> to return the string C<windows> or C<linux> for "
1095 "Windows and Linux-based operating systems respectively."
1099 #: ../src/guestfs.pod:550
1101 "Un*x-like and Linux-based operating systems usually consist of several "
1102 "filesystems which are mounted at boot time (for example, a separate boot "
1103 "partition mounted on C</boot>). The inspection rules are able to detect how "
1104 "filesystems correspond to mount points. Call "
1105 "C<guestfs_inspect_get_mountpoints> to get this mapping. It might return a "
1106 "hash table like this example:"
1110 #: ../src/guestfs.pod:557
1113 " /boot => /dev/sda1\n"
1114 " / => /dev/vg_guest/lv_root\n"
1115 " /usr => /dev/vg_guest/lv_usr\n"
1120 #: ../src/guestfs.pod:561
1122 "The caller can then make calls to L</guestfs_mount_options> to mount the "
1123 "filesystems as suggested."
1127 #: ../src/guestfs.pod:564
1129 "Be careful to mount filesystems in the right order (eg. C</> before "
1130 "C</usr>). Sorting the keys of the hash by length, shortest first, should "
1135 #: ../src/guestfs.pod:568
1137 "Inspection currently only works for some common operating systems. "
1138 "Contributors are welcome to send patches for other operating systems that we "
1139 "currently cannot detect."
1143 #: ../src/guestfs.pod:572
1145 "Encrypted disks must be opened before inspection. See L</ENCRYPTED DISKS> "
1146 "for more details. The L</guestfs_inspect_os> function just ignores any "
1147 "encrypted devices."
1151 #: ../src/guestfs.pod:576
1153 "A note on the implementation: The call L</guestfs_inspect_os> performs "
1154 "inspection and caches the results in the guest handle. Subsequent calls to "
1155 "C<guestfs_inspect_get_*> return this cached information, but I<do not> "
1156 "re-read the disks. If you change the content of the guest disks, you can "
1157 "redo inspection by calling L</guestfs_inspect_os> again. "
1158 "(L</guestfs_inspect_list_applications> works a little differently from the "
1159 "other calls and does read the disks. See documentation for that function "
1164 #: ../src/guestfs.pod:585
1165 msgid "SPECIAL CONSIDERATIONS FOR WINDOWS GUESTS"
1169 #: ../src/guestfs.pod:587
1171 "Libguestfs can mount NTFS partitions. It does this using the "
1172 "L<http://www.ntfs-3g.org/> driver."
1176 #: ../src/guestfs.pod:590
1178 "DOS and Windows still use drive letters, and the filesystems are always "
1179 "treated as case insensitive by Windows itself, and therefore you might find "
1180 "a Windows configuration file referring to a path like "
1181 "C<c:\\windows\\system32>. When the filesystem is mounted in libguestfs, "
1182 "that directory might be referred to as C</WINDOWS/System32>."
1186 #: ../src/guestfs.pod:596
1188 "Drive letter mappings are outside the scope of libguestfs. You have to use "
1189 "libguestfs to read the appropriate Windows Registry and configuration files, "
1190 "to determine yourself how drives are mapped (see also L<hivex(3)> and "
1191 "L<virt-inspector(1)>)."
1195 #: ../src/guestfs.pod:601
1197 "Replacing backslash characters with forward slash characters is also outside "
1198 "the scope of libguestfs, but something that you can easily do."
1202 #: ../src/guestfs.pod:604
1204 "Where we can help is in resolving the case insensitivity of paths. For "
1205 "this, call L</guestfs_case_sensitive_path>."
1209 #: ../src/guestfs.pod:607
1211 "Libguestfs also provides some help for decoding Windows Registry \"hive\" "
1212 "files, through the library C<hivex> which is part of the libguestfs project "
1213 "although ships as a separate tarball. You have to locate and download the "
1214 "hive file(s) yourself, and then pass them to C<hivex> functions. See also "
1215 "the programs L<hivexml(1)>, L<hivexsh(1)>, L<hivexregedit(1)> and "
1216 "L<virt-win-reg(1)> for more help on this issue."
1220 #: ../src/guestfs.pod:615
1221 msgid "USING LIBGUESTFS WITH OTHER PROGRAMMING LANGUAGES"
1225 #: ../src/guestfs.pod:617
1227 "Although we don't want to discourage you from using the C API, we will "
1228 "mention here that the same API is also available in other languages."
1232 #: ../src/guestfs.pod:620
1234 "The API is broadly identical in all supported languages. This means that "
1235 "the C call C<guestfs_mount(g,path)> is C<$g-E<gt>mount($path)> in Perl, "
1236 "C<g.mount(path)> in Python, and C<Guestfs.mount g path> in OCaml. In other "
1237 "words, a straightforward, predictable isomorphism between each language."
1241 #: ../src/guestfs.pod:626
1243 "Error messages are automatically transformed into exceptions if the language "
1248 #: ../src/guestfs.pod:629
1250 "We don't try to \"object orientify\" parts of the API in OO languages, "
1251 "although contributors are welcome to write higher level APIs above what we "
1252 "provide in their favourite languages if they wish."
1256 #: ../src/guestfs.pod:635
1261 #: ../src/guestfs.pod:637
1263 "You can use the I<guestfs.h> header file from C++ programs. The C++ API is "
1264 "identical to the C API. C++ classes and exceptions are not used."
1268 #: ../src/guestfs.pod:641
1273 #: ../src/guestfs.pod:643
1275 "The C# bindings are highly experimental. Please read the warnings at the "
1276 "top of C<csharp/Libguestfs.cs>."
1280 #: ../src/guestfs.pod:646
1285 #: ../src/guestfs.pod:648
1287 "This is the only language binding that is working but incomplete. Only "
1288 "calls which return simple integers have been bound in Haskell, and we are "
1289 "looking for help to complete this binding."
1293 #: ../src/guestfs.pod:652
1298 #: ../src/guestfs.pod:654
1300 "Full documentation is contained in the Javadoc which is distributed with "
1305 #: ../src/guestfs.pod:657
1310 #: ../src/guestfs.pod:659
1311 msgid "For documentation see L<guestfs-ocaml(3)>."
1315 #: ../src/guestfs.pod:661
1320 #: ../src/guestfs.pod:663
1321 msgid "For documentation see L<Sys::Guestfs(3)>."
1325 #: ../src/guestfs.pod:665
1330 #: ../src/guestfs.pod:667
1332 "For documentation see C<README-PHP> supplied with libguestfs sources or in "
1333 "the php-libguestfs package for your distribution."
1337 #: ../src/guestfs.pod:670
1338 msgid "The PHP binding only works correctly on 64 bit machines."
1342 #: ../src/guestfs.pod:672
1347 #: ../src/guestfs.pod:674
1348 msgid "For documentation see L<guestfs-python(3)>."
1352 #: ../src/guestfs.pod:676
1357 #: ../src/guestfs.pod:678
1358 msgid "For documentation see L<guestfs-ruby(3)>."
1362 #: ../src/guestfs.pod:680
1363 msgid "B<shell scripts>"
1367 #: ../src/guestfs.pod:682
1368 msgid "For documentation see L<guestfish(1)>."
1372 #: ../src/guestfs.pod:686
1373 msgid "LIBGUESTFS GOTCHAS"
1377 #: ../src/guestfs.pod:688
1379 "L<http://en.wikipedia.org/wiki/Gotcha_(programming)>: \"A feature of a "
1380 "system [...] that works in the way it is documented but is counterintuitive "
1381 "and almost invites mistakes.\""
1385 #: ../src/guestfs.pod:692
1387 "Since we developed libguestfs and the associated tools, there are several "
1388 "things we would have designed differently, but are now stuck with for "
1389 "backwards compatibility or other reasons. If there is ever a libguestfs 2.0 "
1390 "release, you can expect these to change. Beware of them."
1394 #: ../src/guestfs.pod:700
1395 msgid "Autosync / forgetting to sync."
1399 #: ../src/guestfs.pod:702
1401 "When modifying a filesystem from C or another language, you B<must> unmount "
1402 "all filesystems and call L</guestfs_sync> explicitly before you close the "
1403 "libguestfs handle. You can also call:"
1407 #: ../src/guestfs.pod:706
1410 " guestfs_set_autosync (g, 1);\n"
1415 #: ../src/guestfs.pod:708
1417 "to have the unmount/sync done automatically for you when the handle 'g' is "
1418 "closed. (This feature is called \"autosync\", L</guestfs_set_autosync> "
1423 #: ../src/guestfs.pod:712
1425 "If you forget to do this, then it is entirely possible that your changes "
1426 "won't be written out, or will be partially written, or (very rarely) that "
1427 "you'll get disk corruption."
1431 #: ../src/guestfs.pod:716
1433 "Note that in L<guestfish(3)> autosync is the default. So quick and dirty "
1434 "guestfish scripts that forget to sync will work just fine, which can make "
1435 "this very puzzling if you are trying to debug a problem."
1439 #: ../src/guestfs.pod:720
1441 "Update: Autosync is enabled by default for all API users starting from "
1442 "libguestfs 1.5.24."
1446 #: ../src/guestfs.pod:723
1447 msgid "Mount option C<-o sync> should not be the default."
1451 #: ../src/guestfs.pod:725
1453 "If you use L</guestfs_mount>, then C<-o sync,noatime> are added implicitly. "
1454 "However C<-o sync> does not add any reliability benefit, but does have a "
1455 "very large performance impact."
1459 #: ../src/guestfs.pod:729
1461 "The work around is to use L</guestfs_mount_options> and set the mount "
1462 "options that you actually want to use."
1466 #: ../src/guestfs.pod:732
1467 msgid "Read-only should be the default."
1471 #: ../src/guestfs.pod:734
1473 "In L<guestfish(3)>, I<--ro> should be the default, and you should have to "
1474 "specify I<--rw> if you want to make changes to the image."
1478 #: ../src/guestfs.pod:737
1479 msgid "This would reduce the potential to corrupt live VM images."
1483 #: ../src/guestfs.pod:739
1485 "Note that many filesystems change the disk when you just mount and unmount, "
1486 "even if you didn't perform any writes. You need to use "
1487 "L</guestfs_add_drive_ro> to guarantee that the disk is not changed."
1491 #: ../src/guestfs.pod:743
1492 msgid "guestfish command line is hard to use."
1496 #: ../src/guestfs.pod:745
1498 "C<guestfish disk.img> doesn't do what people expect (open C<disk.img> for "
1499 "examination). It tries to run a guestfish command C<disk.img> which doesn't "
1500 "exist, so it fails. In earlier versions of guestfish the error message was "
1501 "also unintuitive, but we have corrected this since. Like the Bourne shell, "
1502 "we should have used C<guestfish -c command> to run commands."
1506 #: ../src/guestfs.pod:752
1507 msgid "guestfish megabyte modifiers don't work right on all commands"
1511 #: ../src/guestfs.pod:754
1513 "In recent guestfish you can use C<1M> to mean 1 megabyte (and similarly for "
1514 "other modifiers). What guestfish actually does is to multiply the number "
1515 "part by the modifier part and pass the result to the C API. However this "
1516 "doesn't work for a few APIs which aren't expecting bytes, but are already "
1517 "expecting some other unit (eg. megabytes)."
1521 #: ../src/guestfs.pod:761
1522 msgid "The most common is L</guestfs_lvcreate>. The guestfish command:"
1526 #: ../src/guestfs.pod:763
1529 " lvcreate LV VG 100M\n"
1534 #: ../src/guestfs.pod:765
1536 "does not do what you might expect. Instead because L</guestfs_lvcreate> is "
1537 "already expecting megabytes, this tries to create a 100 I<terabyte> (100 "
1538 "megabytes * megabytes) logical volume. The error message you get from this "
1539 "is also a little obscure."
1543 #: ../src/guestfs.pod:770
1545 "This could be fixed in the generator by specially marking parameters and "
1546 "return values which take bytes or other units."
1550 #: ../src/guestfs.pod:773
1551 msgid "Ambiguity between devices and paths"
1555 #: ../src/guestfs.pod:775
1557 "There is a subtle ambiguity in the API between a device name "
1558 "(eg. C</dev/sdb2>) and a similar pathname. A file might just happen to be "
1559 "called C<sdb2> in the directory C</dev> (consider some non-Unix VM image)."
1563 #: ../src/guestfs.pod:780
1565 "In the current API we usually resolve this ambiguity by having two separate "
1566 "calls, for example L</guestfs_checksum> and L</guestfs_checksum_device>. "
1567 "Some API calls are ambiguous and (incorrectly) resolve the problem by "
1568 "detecting if the path supplied begins with C</dev/>."
1572 #: ../src/guestfs.pod:786
1574 "To avoid both the ambiguity and the need to duplicate some calls, we could "
1575 "make paths/devices into structured names. One way to do this would be to "
1576 "use a notation like grub (C<hd(0,0)>), although nobody really likes this "
1577 "aspect of grub. Another way would be to use a structured type, equivalent "
1578 "to this OCaml type:"
1582 #: ../src/guestfs.pod:792
1585 " type path = Path of string | Device of int | Partition of int * int\n"
1590 #: ../src/guestfs.pod:794
1591 msgid "which would allow you to pass arguments like:"
1595 #: ../src/guestfs.pod:796
1598 " Path \"/foo/bar\"\n"
1599 " Device 1 (* /dev/sdb, or perhaps /dev/sda *)\n"
1600 " Partition (1, 2) (* /dev/sdb2 (or is it /dev/sda2 or /dev/sdb3?) *)\n"
1601 " Path \"/dev/sdb2\" (* not a device *)\n"
1606 #: ../src/guestfs.pod:801
1608 "As you can see there are still problems to resolve even with this "
1609 "representation. Also consider how it might work in guestfish."
1613 #: ../src/guestfs.pod:806
1614 msgid "PROTOCOL LIMITS"
1618 #: ../src/guestfs.pod:808
1620 "Internally libguestfs uses a message-based protocol to pass API calls and "
1621 "their responses to and from a small \"appliance\" (see L</INTERNALS> for "
1622 "plenty more detail about this). The maximum message size used by the "
1623 "protocol is slightly less than 4 MB. For some API calls you may need to be "
1624 "aware of this limit. The API calls which may be affected are individually "
1625 "documented, with a link back to this section of the documentation."
1629 #: ../src/guestfs.pod:816
1631 "A simple call such as L</guestfs_cat> returns its result (the file data) in "
1632 "a simple string. Because this string is at some point internally encoded as "
1633 "a message, the maximum size that it can return is slightly under 4 MB. If "
1634 "the requested file is larger than this then you will get an error."
1638 #: ../src/guestfs.pod:822
1640 "In order to transfer large files into and out of the guest filesystem, you "
1641 "need to use particular calls that support this. The sections L</UPLOADING> "
1642 "and L</DOWNLOADING> document how to do this."
1646 #: ../src/guestfs.pod:826
1648 "You might also consider mounting the disk image using our FUSE filesystem "
1649 "support (L<guestmount(1)>)."
1653 #: ../src/guestfs.pod:829
1654 msgid "KEYS AND PASSPHRASES"
1658 #: ../src/guestfs.pod:831
1660 "Certain libguestfs calls take a parameter that contains sensitive key "
1661 "material, passed in as a C string."
1665 #: ../src/guestfs.pod:834
1667 "In the future we would hope to change the libguestfs implementation so that "
1668 "keys are L<mlock(2)>-ed into physical RAM, and thus can never end up in "
1669 "swap. However this is I<not> done at the moment, because of the complexity "
1670 "of such an implementation."
1674 #: ../src/guestfs.pod:839
1676 "Therefore you should be aware that any key parameter you pass to libguestfs "
1677 "might end up being written out to the swap partition. If this is a concern, "
1678 "scrub the swap partition or don't use libguestfs on encrypted devices."
1682 #: ../src/guestfs.pod:844
1683 msgid "MULTIPLE HANDLES AND MULTIPLE THREADS"
1687 #: ../src/guestfs.pod:846
1689 "All high-level libguestfs actions are synchronous. If you want to use "
1690 "libguestfs asynchronously then you must create a thread."
1694 #: ../src/guestfs.pod:849
1696 "Only use the handle from a single thread. Either use the handle exclusively "
1697 "from one thread, or provide your own mutex so that two threads cannot issue "
1698 "calls on the same handle at the same time."
1702 #: ../src/guestfs.pod:853
1704 "See the graphical program guestfs-browser for one possible architecture for "
1705 "multithreaded programs using libvirt and libguestfs."
1709 #: ../src/guestfs.pod:856
1714 #: ../src/guestfs.pod:858
1716 "Libguestfs needs a kernel and initrd.img, which it finds by looking along an "
1721 #: ../src/guestfs.pod:861
1723 "By default it looks for these in the directory C<$libdir/guestfs> "
1724 "(eg. C</usr/local/lib/guestfs> or C</usr/lib64/guestfs>)."
1728 #: ../src/guestfs.pod:864
1730 "Use L</guestfs_set_path> or set the environment variable L</LIBGUESTFS_PATH> "
1731 "to change the directories that libguestfs will search in. The value is a "
1732 "colon-separated list of paths. The current directory is I<not> searched "
1733 "unless the path contains an empty element or C<.>. For example "
1734 "C<LIBGUESTFS_PATH=:/usr/lib/guestfs> would search the current directory and "
1735 "then C</usr/lib/guestfs>."
1739 #: ../src/guestfs.pod:871
1740 msgid "QEMU WRAPPERS"
1744 #: ../src/guestfs.pod:873
1746 "If you want to compile your own qemu, run qemu from a non-standard location, "
1747 "or pass extra arguments to qemu, then you can write a shell-script wrapper "
1752 #: ../src/guestfs.pod:877
1754 "There is one important rule to remember: you I<must C<exec qemu>> as the "
1755 "last command in the shell script (so that qemu replaces the shell and "
1756 "becomes the direct child of the libguestfs-using program). If you don't do "
1757 "this, then the qemu process won't be cleaned up correctly."
1761 #: ../src/guestfs.pod:882
1763 "Here is an example of a wrapper, where I have built my own copy of qemu from "
1768 #: ../src/guestfs.pod:885
1772 " qemudir=/home/rjones/d/qemu\n"
1773 " exec $qemudir/x86_64-softmmu/qemu-system-x86_64 -L $qemudir/pc-bios "
1779 #: ../src/guestfs.pod:889
1781 "Save this script as C</tmp/qemu.wrapper> (or wherever), C<chmod +x>, and "
1782 "then use it by setting the LIBGUESTFS_QEMU environment variable. For "
1787 #: ../src/guestfs.pod:893
1790 " LIBGUESTFS_QEMU=/tmp/qemu.wrapper guestfish\n"
1795 #: ../src/guestfs.pod:895
1797 "Note that libguestfs also calls qemu with the -help and -version options in "
1798 "order to determine features."
1802 #: ../src/guestfs.pod:898
1803 msgid "ABI GUARANTEE"
1807 #: ../src/guestfs.pod:900
1809 "We guarantee the libguestfs ABI (binary interface), for public, high-level "
1810 "actions as outlined in this section. Although we will deprecate some "
1811 "actions, for example if they get replaced by newer calls, we will keep the "
1812 "old actions forever. This allows you the developer to program in confidence "
1813 "against the libguestfs API."
1817 #: ../src/guestfs.pod:906
1818 msgid "BLOCK DEVICE NAMING"
1822 #: ../src/guestfs.pod:908
1824 "In the kernel there is now quite a profusion of schemata for naming block "
1825 "devices (in this context, by I<block device> I mean a physical or virtual "
1826 "hard drive). The original Linux IDE driver used names starting with "
1827 "C</dev/hd*>. SCSI devices have historically used a different naming scheme, "
1828 "C</dev/sd*>. When the Linux kernel I<libata> driver became a popular "
1829 "replacement for the old IDE driver (particularly for SATA devices) those "
1830 "devices also used the C</dev/sd*> scheme. Additionally we now have virtual "
1831 "machines with paravirtualized drivers. This has created several different "
1832 "naming systems, such as C</dev/vd*> for virtio disks and C</dev/xvd*> for "
1837 #: ../src/guestfs.pod:920
1839 "As discussed above, libguestfs uses a qemu appliance running an embedded "
1840 "Linux kernel to access block devices. We can run a variety of appliances "
1841 "based on a variety of Linux kernels."
1845 #: ../src/guestfs.pod:924
1847 "This causes a problem for libguestfs because many API calls use device or "
1848 "partition names. Working scripts and the recipe (example) scripts that we "
1849 "make available over the internet could fail if the naming scheme changes."
1853 #: ../src/guestfs.pod:929
1855 "Therefore libguestfs defines C</dev/sd*> as the I<standard naming scheme>. "
1856 "Internally C</dev/sd*> names are translated, if necessary, to other names as "
1857 "required. For example, under RHEL 5 which uses the C</dev/hd*> scheme, any "
1858 "device parameter C</dev/sda2> is translated to C</dev/hda2> transparently."
1862 #: ../src/guestfs.pod:935
1864 "Note that this I<only> applies to parameters. The L</guestfs_list_devices>, "
1865 "L</guestfs_list_partitions> and similar calls return the true names of the "
1866 "devices and partitions as known to the appliance."
1870 #: ../src/guestfs.pod:940
1871 msgid "ALGORITHM FOR BLOCK DEVICE NAME TRANSLATION"
1875 #: ../src/guestfs.pod:942
1877 "Usually this translation is transparent. However in some (very rare) cases "
1878 "you may need to know the exact algorithm. Such cases include where you use "
1879 "L</guestfs_config> to add a mixture of virtio and IDE devices to the "
1880 "qemu-based appliance, so have a mixture of C</dev/sd*> and C</dev/vd*> "
1885 #: ../src/guestfs.pod:948
1887 "The algorithm is applied only to I<parameters> which are known to be either "
1888 "device or partition names. Return values from functions such as "
1889 "L</guestfs_list_devices> are never changed."
1893 #: ../src/guestfs.pod:956
1894 msgid "Is the string a parameter which is a device or partition name?"
1898 #: ../src/guestfs.pod:960
1899 msgid "Does the string begin with C</dev/sd>?"
1903 #: ../src/guestfs.pod:964
1905 "Does the named device exist? If so, we use that device. However if I<not> "
1906 "then we continue with this algorithm."
1910 #: ../src/guestfs.pod:969
1911 msgid "Replace initial C</dev/sd> string with C</dev/hd>."
1915 #: ../src/guestfs.pod:971
1916 msgid "For example, change C</dev/sda2> to C</dev/hda2>."
1920 #: ../src/guestfs.pod:973
1921 msgid "If that named device exists, use it. If not, continue."
1925 #: ../src/guestfs.pod:977
1926 msgid "Replace initial C</dev/sd> string with C</dev/vd>."
1930 #: ../src/guestfs.pod:979
1931 msgid "If that named device exists, use it. If not, return an error."
1935 #: ../src/guestfs.pod:983
1936 msgid "PORTABILITY CONCERNS WITH BLOCK DEVICE NAMING"
1940 #: ../src/guestfs.pod:985
1942 "Although the standard naming scheme and automatic translation is useful for "
1943 "simple programs and guestfish scripts, for larger programs it is best not to "
1944 "rely on this mechanism."
1948 #: ../src/guestfs.pod:989
1950 "Where possible for maximum future portability programs using libguestfs "
1951 "should use these future-proof techniques:"
1955 #: ../src/guestfs.pod:996
1957 "Use L</guestfs_list_devices> or L</guestfs_list_partitions> to list actual "
1958 "device names, and then use those names directly."
1962 #: ../src/guestfs.pod:999
1963 msgid "Since those device names exist by definition, they will never be translated."
1967 #: ../src/guestfs.pod:1004
1969 "Use higher level ways to identify filesystems, such as LVM names, UUIDs and "
1970 "filesystem labels."
1974 #: ../src/guestfs.pod:1009
1979 #: ../src/guestfs.pod:1011
1981 "This section discusses security implications of using libguestfs, "
1982 "particularly with untrusted or malicious guests or disk images."
1986 #: ../src/guestfs.pod:1014
1987 msgid "GENERAL SECURITY CONSIDERATIONS"
1991 #: ../src/guestfs.pod:1016
1993 "Be careful with any files or data that you download from a guest (by "
1994 "\"download\" we mean not just the L</guestfs_download> command but any "
1995 "command that reads files, filenames, directories or anything else from a "
1996 "disk image). An attacker could manipulate the data to fool your program "
1997 "into doing the wrong thing. Consider cases such as:"
2001 #: ../src/guestfs.pod:1026
2002 msgid "the data (file etc) not being present"
2006 #: ../src/guestfs.pod:1030
2007 msgid "being present but empty"
2011 #: ../src/guestfs.pod:1034
2012 msgid "being much larger than normal"
2016 #: ../src/guestfs.pod:1038
2017 msgid "containing arbitrary 8 bit data"
2021 #: ../src/guestfs.pod:1042
2022 msgid "being in an unexpected character encoding"
2026 #: ../src/guestfs.pod:1046
2027 msgid "containing homoglyphs."
2031 #: ../src/guestfs.pod:1050
2032 msgid "SECURITY OF MOUNTING FILESYSTEMS"
2036 #: ../src/guestfs.pod:1052
2038 "When you mount a filesystem under Linux, mistakes in the kernel filesystem "
2039 "(VFS) module can sometimes be escalated into exploits by deliberately "
2040 "creating a malicious, malformed filesystem. These exploits are very severe "
2041 "for two reasons. Firstly there are very many filesystem drivers in the "
2042 "kernel, and many of them are infrequently used and not much developer "
2043 "attention has been paid to the code. Linux userspace helps potential "
2044 "crackers by detecting the filesystem type and automatically choosing the "
2045 "right VFS driver, even if that filesystem type is obscure or unexpected for "
2046 "the administrator. Secondly, a kernel-level exploit is like a local root "
2047 "exploit (worse in some ways), giving immediate and total access to the "
2048 "system right down to the hardware level."
2052 #: ../src/guestfs.pod:1065
2054 "That explains why you should never mount a filesystem from an untrusted "
2055 "guest on your host kernel. How about libguestfs? We run a Linux kernel "
2056 "inside a qemu virtual machine, usually running as a non-root user. The "
2057 "attacker would need to write a filesystem which first exploited the kernel, "
2058 "and then exploited either qemu virtualization (eg. a faulty qemu driver) or "
2059 "the libguestfs protocol, and finally to be as serious as the host kernel "
2060 "exploit it would need to escalate its privileges to root. This multi-step "
2061 "escalation, performed by a static piece of data, is thought to be extremely "
2062 "hard to do, although we never say 'never' about security issues."
2066 #: ../src/guestfs.pod:1076
2068 "In any case callers can reduce the attack surface by forcing the filesystem "
2069 "type when mounting (use L</guestfs_mount_vfs>)."
2073 #: ../src/guestfs.pod:1079
2074 msgid "PROTOCOL SECURITY"
2078 #: ../src/guestfs.pod:1081
2080 "The protocol is designed to be secure, being based on RFC 4506 (XDR) with a "
2081 "defined upper message size. However a program that uses libguestfs must "
2082 "also take care - for example you can write a program that downloads a binary "
2083 "from a disk image and executes it locally, and no amount of protocol "
2084 "security will save you from the consequences."
2088 #: ../src/guestfs.pod:1087
2089 msgid "INSPECTION SECURITY"
2093 #: ../src/guestfs.pod:1089
2095 "Parts of the inspection API (see L</INSPECTION>) return untrusted strings "
2096 "directly from the guest, and these could contain any 8 bit data. Callers "
2097 "should be careful to escape these before printing them to a structured file "
2098 "(for example, use HTML escaping if creating a web page)."
2102 #: ../src/guestfs.pod:1095
2104 "Guest configuration may be altered in unusual ways by the administrator of "
2105 "the virtual machine, and may not reflect reality (particularly for untrusted "
2106 "or actively malicious guests). For example we parse the hostname from "
2107 "configuration files like C</etc/sysconfig/network> that we find in the "
2108 "guest, but the guest administrator can easily manipulate these files to "
2109 "provide the wrong hostname."
2113 #: ../src/guestfs.pod:1103
2115 "The inspection API parses guest configuration using two external libraries: "
2116 "Augeas (Linux configuration) and hivex (Windows Registry). Both are "
2117 "designed to be robust in the face of malicious data, although denial of "
2118 "service attacks are still possible, for example with oversized configuration "
2123 #: ../src/guestfs.pod:1109
2124 msgid "RUNNING UNTRUSTED GUEST COMMANDS"
2128 #: ../src/guestfs.pod:1111
2130 "Be very cautious about running commands from the guest. By running a "
2131 "command in the guest, you are giving CPU time to a binary that you do not "
2132 "control, under the same user account as the library, albeit wrapped in qemu "
2133 "virtualization. More information and alternatives can be found in the "
2134 "section L</RUNNING COMMANDS>."
2138 #: ../src/guestfs.pod:1117
2139 msgid "CVE-2010-3851"
2143 #: ../src/guestfs.pod:1119
2144 msgid "https://bugzilla.redhat.com/642934"
2148 #: ../src/guestfs.pod:1121
2150 "This security bug concerns the automatic disk format detection that qemu "
2151 "does on disk images."
2155 #: ../src/guestfs.pod:1124
2157 "A raw disk image is just the raw bytes, there is no header. Other disk "
2158 "images like qcow2 contain a special header. Qemu deals with this by looking "
2159 "for one of the known headers, and if none is found then assuming the disk "
2160 "image must be raw."
2164 #: ../src/guestfs.pod:1129
2166 "This allows a guest which has been given a raw disk image to write some "
2167 "other header. At next boot (or when the disk image is accessed by "
2168 "libguestfs) qemu would do autodetection and think the disk image format was, "
2169 "say, qcow2 based on the header written by the guest."
2173 #: ../src/guestfs.pod:1134
2175 "This in itself would not be a problem, but qcow2 offers many features, one "
2176 "of which is to allow a disk image to refer to another image (called the "
2177 "\"backing disk\"). It does this by placing the path to the backing disk "
2178 "into the qcow2 header. This path is not validated and could point to any "
2179 "host file (eg. \"/etc/passwd\"). The backing disk is then exposed through "
2180 "\"holes\" in the qcow2 disk image, which of course is completely under the "
2181 "control of the attacker."
2185 #: ../src/guestfs.pod:1142
2186 msgid "In libguestfs this is rather hard to exploit except under two circumstances:"
2190 #: ../src/guestfs.pod:1149
2191 msgid "You have enabled the network or have opened the disk in write mode."
2195 #: ../src/guestfs.pod:1153
2197 "You are also running untrusted code from the guest (see L</RUNNING "
2202 #: ../src/guestfs.pod:1158
2204 "The way to avoid this is to specify the expected disk format when adding "
2205 "disks (the optional C<format> option to L</guestfs_add_drive_opts>). You "
2206 "should always do this if the disk is raw format, and it's a good idea for "
2211 #: ../src/guestfs.pod:1163
2213 "For disks added from libvirt using calls like L</guestfs_add_domain>, the "
2214 "format is fetched from libvirt and passed through."
2218 #: ../src/guestfs.pod:1166
2220 "For libguestfs tools, use the I<--format> command line parameter as "
2225 #: ../src/guestfs.pod:1169
2226 msgid "CONNECTION MANAGEMENT"
2230 #: ../src/guestfs.pod:1171
2235 #: ../src/guestfs.pod:1173
2237 "C<guestfs_h> is the opaque type representing a connection handle. Create a "
2238 "handle by calling L</guestfs_create>. Call L</guestfs_close> to free the "
2239 "handle and release all resources used."
2243 #: ../src/guestfs.pod:1177
2245 "For information on using multiple handles and threads, see the section "
2246 "L</MULTIPLE HANDLES AND MULTIPLE THREADS> below."
2250 #: ../src/guestfs.pod:1180
2251 msgid "guestfs_create"
2255 #: ../src/guestfs.pod:1182
2258 " guestfs_h *guestfs_create (void);\n"
2263 #: ../src/guestfs.pod:1184
2264 msgid "Create a connection handle."
2268 #: ../src/guestfs.pod:1186
2270 "You have to call L</guestfs_add_drive_opts> (or one of the equivalent calls) "
2271 "on the handle at least once."
2275 #: ../src/guestfs.pod:1189
2277 "This function returns a non-NULL pointer to a handle on success or NULL on "
2282 #: ../src/guestfs.pod:1192
2283 msgid "After configuring the handle, you have to call L</guestfs_launch>."
2287 #: ../src/guestfs.pod:1194
2289 "You may also want to configure error handling for the handle. See L</ERROR "
2290 "HANDLING> section below."
2294 #: ../src/guestfs.pod:1197
2295 msgid "guestfs_close"
2299 #: ../src/guestfs.pod:1199
2302 " void guestfs_close (guestfs_h *g);\n"
2307 #: ../src/guestfs.pod:1201
2308 msgid "This closes the connection handle and frees up all resources used."
2312 #: ../src/guestfs.pod:1203
2313 msgid "ERROR HANDLING"
2317 #: ../src/guestfs.pod:1205
2319 "API functions can return errors. For example, almost all functions that "
2320 "return C<int> will return C<-1> to indicate an error."
2324 #: ../src/guestfs.pod:1208
2326 "Additional information is available for errors: an error message string and "
2327 "optionally an error number (errno) if the thing that failed was a system "
2332 #: ../src/guestfs.pod:1212
2334 "You can get at the additional information about the last error on the handle "
2335 "by calling L</guestfs_last_error>, L</guestfs_last_errno>, and/or by setting "
2336 "up an error handler with L</guestfs_set_error_handler>."
2340 #: ../src/guestfs.pod:1217
2342 "When the handle is created, a default error handler is installed which "
2343 "prints the error message string to C<stderr>. For small short-running "
2344 "command line programs it is sufficient to do:"
2348 #: ../src/guestfs.pod:1221
2351 " if (guestfs_launch (g) == -1)\n"
2352 " exit (EXIT_FAILURE);\n"
2357 #: ../src/guestfs.pod:1224
2359 "since the default error handler will ensure that an error message has been "
2360 "printed to C<stderr> before the program exits."
2364 #: ../src/guestfs.pod:1227
2366 "For other programs the caller will almost certainly want to install an "
2367 "alternate error handler or do error handling in-line like this:"
2371 #: ../src/guestfs.pod:1230
2374 " g = guestfs_create ();\n"
2379 #: ../src/guestfs.pod:1232
2382 " /* This disables the default behaviour of printing errors\n"
2384 " guestfs_set_error_handler (g, NULL, NULL);\n"
2389 #: ../src/guestfs.pod:1236
2392 " if (guestfs_launch (g) == -1) {\n"
2393 " /* Examine the error message and print it etc. */\n"
2394 " char *msg = guestfs_last_error (g);\n"
2395 " int errnum = guestfs_last_errno (g);\n"
2396 " fprintf (stderr, \"%s\\n\", msg);\n"
2403 #: ../src/guestfs.pod:1244
2405 "Out of memory errors are handled differently. The default action is to call "
2406 "L<abort(3)>. If this is undesirable, then you can set a handler using "
2407 "L</guestfs_set_out_of_memory_handler>."
2411 #: ../src/guestfs.pod:1248
2413 "L</guestfs_create> returns C<NULL> if the handle cannot be created, and "
2414 "because there is no handle if this happens there is no way to get additional "
2415 "error information. However L</guestfs_create> is supposed to be a "
2416 "lightweight operation which can only fail because of insufficient memory (it "
2417 "returns NULL in this case)."
2421 #: ../src/guestfs.pod:1254
2422 msgid "guestfs_last_error"
2426 #: ../src/guestfs.pod:1256
2429 " const char *guestfs_last_error (guestfs_h *g);\n"
2434 #: ../src/guestfs.pod:1258
2436 "This returns the last error message that happened on C<g>. If there has not "
2437 "been an error since the handle was created, then this returns C<NULL>."
2441 #: ../src/guestfs.pod:1262
2443 "The lifetime of the returned string is until the next error occurs, or "
2444 "L</guestfs_close> is called."
2448 #: ../src/guestfs.pod:1265
2449 msgid "guestfs_last_errno"
2453 #: ../src/guestfs.pod:1267
2456 " int guestfs_last_errno (guestfs_h *g);\n"
2461 #: ../src/guestfs.pod:1269
2462 msgid "This returns the last error number (errno) that happened on C<g>."
2466 #: ../src/guestfs.pod:1271
2467 msgid "If successful, an errno integer not equal to zero is returned."
2471 #: ../src/guestfs.pod:1273
2472 msgid "If no error, this returns 0. This call can return 0 in three situations:"
2476 #: ../src/guestfs.pod:1280
2477 msgid "There has not been any error on the handle."
2481 #: ../src/guestfs.pod:1284
2483 "There has been an error but the errno was meaningless. This corresponds to "
2484 "the case where the error did not come from a failed system call, but for "
2485 "some other reason."
2489 #: ../src/guestfs.pod:1290
2491 "There was an error from a failed system call, but for some reason the errno "
2492 "was not captured and returned. This usually indicates a bug in libguestfs."
2496 #: ../src/guestfs.pod:1296
2498 "Libguestfs tries to convert the errno from inside the applicance into a "
2499 "corresponding errno for the caller (not entirely trivial: the appliance "
2500 "might be running a completely different operating system from the library "
2501 "and error numbers are not standardized across Un*xen). If this could not be "
2502 "done, then the error is translated to C<EINVAL>. In practice this should "
2503 "only happen in very rare circumstances."
2507 #: ../src/guestfs.pod:1304
2508 msgid "guestfs_set_error_handler"
2512 #: ../src/guestfs.pod:1306
2515 " typedef void (*guestfs_error_handler_cb) (guestfs_h *g,\n"
2517 " const char *msg);\n"
2518 " void guestfs_set_error_handler (guestfs_h *g,\n"
2519 " guestfs_error_handler_cb cb,\n"
2525 #: ../src/guestfs.pod:1313
2527 "The callback C<cb> will be called if there is an error. The parameters "
2528 "passed to the callback are an opaque data pointer and the error message "
2533 #: ../src/guestfs.pod:1317
2535 "C<errno> is not passed to the callback. To get that the callback must call "
2536 "L</guestfs_last_errno>."
2540 #: ../src/guestfs.pod:1320
2542 "Note that the message string C<msg> is freed as soon as the callback "
2543 "function returns, so if you want to stash it somewhere you must make your "
2548 #: ../src/guestfs.pod:1324
2549 msgid "The default handler prints messages on C<stderr>."
2553 #: ../src/guestfs.pod:1326
2554 msgid "If you set C<cb> to C<NULL> then I<no> handler is called."
2558 #: ../src/guestfs.pod:1328
2559 msgid "guestfs_get_error_handler"
2563 #: ../src/guestfs.pod:1330
2566 " guestfs_error_handler_cb guestfs_get_error_handler (guestfs_h *g,\n"
2567 " void **opaque_rtn);\n"
2572 #: ../src/guestfs.pod:1333
2573 msgid "Returns the current error handler callback."
2577 #: ../src/guestfs.pod:1335
2578 msgid "guestfs_set_out_of_memory_handler"
2582 #: ../src/guestfs.pod:1337
2585 " typedef void (*guestfs_abort_cb) (void);\n"
2586 " int guestfs_set_out_of_memory_handler (guestfs_h *g,\n"
2587 " guestfs_abort_cb);\n"
2592 #: ../src/guestfs.pod:1341
2594 "The callback C<cb> will be called if there is an out of memory situation. "
2595 "I<Note this callback must not return>."
2599 #: ../src/guestfs.pod:1344
2600 msgid "The default is to call L<abort(3)>."
2604 #: ../src/guestfs.pod:1346
2605 msgid "You cannot set C<cb> to C<NULL>. You can't ignore out of memory situations."
2609 #: ../src/guestfs.pod:1349
2610 msgid "guestfs_get_out_of_memory_handler"
2614 #: ../src/guestfs.pod:1351
2617 " guestfs_abort_fn guestfs_get_out_of_memory_handler (guestfs_h *g);\n"
2622 #: ../src/guestfs.pod:1353
2623 msgid "This returns the current out of memory handler."
2627 #: ../src/guestfs.pod:1355
2632 #: ../src/guestfs.pod:1357 ../fish/guestfish.pod:958
2637 #: ../src/guestfs.pod:1359
2642 #: ../src/guestfs.pod:1361
2647 #: ../src/guestfs.pod:1363
2648 msgid "AVAILABILITY"
2652 #: ../src/guestfs.pod:1365
2653 msgid "GROUPS OF FUNCTIONALITY IN THE APPLIANCE"
2657 #: ../src/guestfs.pod:1367
2659 "Using L</guestfs_available> you can test availability of the following "
2660 "groups of functions. This test queries the appliance to see if the "
2661 "appliance you are currently using supports the functionality."
2665 #: ../src/guestfs.pod:1372
2666 msgid "@AVAILABILITY@"
2670 #: ../src/guestfs.pod:1374
2671 msgid "GUESTFISH supported COMMAND"
2675 #: ../src/guestfs.pod:1376
2677 "In L<guestfish(3)> there is a handy interactive command C<supported> which "
2678 "prints out the available groups and whether they are supported by this build "
2679 "of libguestfs. Note however that you have to do C<run> first."
2683 #: ../src/guestfs.pod:1381
2684 msgid "SINGLE CALLS AT COMPILE TIME"
2688 #: ../src/guestfs.pod:1383
2690 "Since version 1.5.8, C<E<lt>guestfs.hE<gt>> defines symbols for each C API "
2691 "function, such as:"
2695 #: ../src/guestfs.pod:1386
2698 " #define LIBGUESTFS_HAVE_DD 1\n"
2703 #: ../src/guestfs.pod:1388
2704 msgid "if L</guestfs_dd> is available."
2708 #: ../src/guestfs.pod:1390
2710 "Before version 1.5.8, if you needed to test whether a single libguestfs "
2711 "function is available at compile time, we recommended using build tools such "
2712 "as autoconf or cmake. For example in autotools you could use:"
2716 #: ../src/guestfs.pod:1395
2719 " AC_CHECK_LIB([guestfs],[guestfs_create])\n"
2720 " AC_CHECK_FUNCS([guestfs_dd])\n"
2725 #: ../src/guestfs.pod:1398
2727 "which would result in C<HAVE_GUESTFS_DD> being either defined or not defined "
2732 #: ../src/guestfs.pod:1401
2733 msgid "SINGLE CALLS AT RUN TIME"
2737 #: ../src/guestfs.pod:1403
2739 "Testing at compile time doesn't guarantee that a function really exists in "
2740 "the library. The reason is that you might be dynamically linked against a "
2741 "previous I<libguestfs.so> (dynamic library) which doesn't have the call. "
2742 "This situation unfortunately results in a segmentation fault, which is a "
2743 "shortcoming of the C dynamic linking system itself."
2747 #: ../src/guestfs.pod:1410
2749 "You can use L<dlopen(3)> to test if a function is available at run time, as "
2750 "in this example program (note that you still need the compile time check as "
2755 #: ../src/guestfs.pod:1414
2758 " #include <stdio.h>\n"
2759 " #include <stdlib.h>\n"
2760 " #include <unistd.h>\n"
2761 " #include <dlfcn.h>\n"
2762 " #include <guestfs.h>\n"
2767 #: ../src/guestfs.pod:1420
2772 " #ifdef LIBGUESTFS_HAVE_DD\n"
2774 " int has_function;\n"
2779 #: ../src/guestfs.pod:1426
2782 " /* Test if the function guestfs_dd is really available. */\n"
2783 " dl = dlopen (NULL, RTLD_LAZY);\n"
2785 " fprintf (stderr, \"dlopen: %s\\n\", dlerror ());\n"
2786 " exit (EXIT_FAILURE);\n"
2788 " has_function = dlsym (dl, \"guestfs_dd\") != NULL;\n"
2794 #: ../src/guestfs.pod:1435
2797 " if (!has_function)\n"
2798 " printf (\"this libguestfs.so does NOT have guestfs_dd function\\n\");\n"
2800 " printf (\"this libguestfs.so has guestfs_dd function\\n\");\n"
2801 " /* Now it's safe to call\n"
2802 " guestfs_dd (g, \"foo\", \"bar\");\n"
2806 " printf (\"guestfs_dd function was not found at compile time\\n\");\n"
2813 #: ../src/guestfs.pod:1448
2815 "You may think the above is an awful lot of hassle, and it is. There are "
2816 "other ways outside of the C linking system to ensure that this kind of "
2817 "incompatibility never arises, such as using package versioning:"
2821 #: ../src/guestfs.pod:1453
2824 " Requires: libguestfs >= 1.0.80\n"
2829 #: ../src/guestfs.pod:1455
2830 msgid "CALLS WITH OPTIONAL ARGUMENTS"
2834 #: ../src/guestfs.pod:1457
2836 "A recent feature of the API is the introduction of calls which take optional "
2837 "arguments. In C these are declared 3 ways. The main way is as a call which "
2838 "takes variable arguments (ie. C<...>), as in this example:"
2842 #: ../src/guestfs.pod:1462
2845 " int guestfs_add_drive_opts (guestfs_h *g, const char *filename, ...);\n"
2850 #: ../src/guestfs.pod:1464
2852 "Call this with a list of optional arguments, terminated by C<-1>. So to "
2853 "call with no optional arguments specified:"
2857 #: ../src/guestfs.pod:1467
2860 " guestfs_add_drive_opts (g, filename, -1);\n"
2865 #: ../src/guestfs.pod:1469
2866 msgid "With a single optional argument:"
2870 #: ../src/guestfs.pod:1471
2873 " guestfs_add_drive_opts (g, filename,\n"
2874 " GUESTFS_ADD_DRIVE_OPTS_FORMAT, \"qcow2\",\n"
2880 #: ../src/guestfs.pod:1475
2885 #: ../src/guestfs.pod:1477
2888 " guestfs_add_drive_opts (g, filename,\n"
2889 " GUESTFS_ADD_DRIVE_OPTS_FORMAT, \"qcow2\",\n"
2890 " GUESTFS_ADD_DRIVE_OPTS_READONLY, 1,\n"
2896 #: ../src/guestfs.pod:1482
2898 "and so forth. Don't forget the terminating C<-1> otherwise Bad Things will "
2903 #: ../src/guestfs.pod:1485
2904 msgid "USING va_list FOR OPTIONAL ARGUMENTS"
2908 #: ../src/guestfs.pod:1487
2910 "The second variant has the same name with the suffix C<_va>, which works the "
2911 "same way but takes a C<va_list>. See the C manual for details. For the "
2912 "example function, this is declared:"
2916 #: ../src/guestfs.pod:1491
2919 " int guestfs_add_drive_opts_va (guestfs_h *g, const char *filename,\n"
2925 #: ../src/guestfs.pod:1494
2926 msgid "CONSTRUCTING OPTIONAL ARGUMENTS"
2930 #: ../src/guestfs.pod:1496
2932 "The third variant is useful where you need to construct these calls. You "
2933 "pass in a structure where you fill in the optional fields. The structure "
2934 "has a bitmask as the first element which you must set to indicate which "
2935 "fields you have filled in. For our example function the structure and call "
2940 #: ../src/guestfs.pod:1502
2943 " struct guestfs_add_drive_opts_argv {\n"
2944 " uint64_t bitmask;\n"
2946 " const char *format;\n"
2949 " int guestfs_add_drive_opts_argv (guestfs_h *g, const char *filename,\n"
2950 " const struct guestfs_add_drive_opts_argv *optargs);\n"
2955 #: ../src/guestfs.pod:1511
2956 msgid "You could call it like this:"
2960 #: ../src/guestfs.pod:1513
2963 " struct guestfs_add_drive_opts_argv optargs = {\n"
2964 " .bitmask = GUESTFS_ADD_DRIVE_OPTS_READONLY_BITMASK |\n"
2965 " GUESTFS_ADD_DRIVE_OPTS_FORMAT_BITMASK,\n"
2967 " .format = \"qcow2\"\n"
2973 #: ../src/guestfs.pod:1520
2976 " guestfs_add_drive_opts_argv (g, filename, &optargs);\n"
2981 #: ../src/guestfs.pod:1522 ../src/guestfs-actions.pod:11 ../src/guestfs-actions.pod:1844 ../fish/guestfish-actions.pod:9 ../fish/guestfish-actions.pod:1255 ../tools/virt-win-reg.pl:532
2986 #: ../src/guestfs.pod:1528
2987 msgid "The C<_BITMASK> suffix on each option name when specifying the bitmask."
2991 #: ../src/guestfs.pod:1533
2992 msgid "You do not need to fill in all fields of the structure."
2996 #: ../src/guestfs.pod:1537
2998 "There must be a one-to-one correspondence between fields of the structure "
2999 "that are filled in, and bits set in the bitmask."
3003 #: ../src/guestfs.pod:1542
3004 msgid "OPTIONAL ARGUMENTS IN OTHER LANGUAGES"
3008 #: ../src/guestfs.pod:1544
3010 "In other languages, optional arguments are expressed in the way that is "
3011 "natural for that language. We refer you to the language-specific "
3012 "documentation for more details on that."
3016 #: ../src/guestfs.pod:1548
3017 msgid "For guestfish, see L<guestfish(1)/OPTIONAL ARGUMENTS>."
3021 #: ../src/guestfs.pod:1550
3022 msgid "SETTING CALLBACKS TO HANDLE EVENTS"
3026 #: ../src/guestfs.pod:1552
3028 "The child process generates events in some situations. Current events "
3029 "include: receiving a log message, the child process exits."
3033 #: ../src/guestfs.pod:1555
3035 "Use the C<guestfs_set_*_callback> functions to set a callback for different "
3040 #: ../src/guestfs.pod:1558
3042 "Only I<one callback of each type> can be registered for each handle. "
3043 "Calling C<guestfs_set_*_callback> again overwrites the previous callback of "
3044 "that type. Cancel all callbacks of this type by calling this function with "
3045 "C<cb> set to C<NULL>."
3049 #: ../src/guestfs.pod:1563
3050 msgid "guestfs_set_log_message_callback"
3054 #: ../src/guestfs.pod:1565
3057 " typedef void (*guestfs_log_message_cb) (guestfs_h *g, void *opaque,\n"
3058 " char *buf, int len);\n"
3059 " void guestfs_set_log_message_callback (guestfs_h *g,\n"
3060 " guestfs_log_message_cb cb,\n"
3066 #: ../src/guestfs.pod:1571
3068 "The callback function C<cb> will be called whenever qemu or the guest writes "
3069 "anything to the console."
3073 #: ../src/guestfs.pod:1574
3074 msgid "Use this function to capture kernel messages and similar."
3078 #: ../src/guestfs.pod:1576
3080 "Normally there is no log message handler, and log messages are just "
3085 #: ../src/guestfs.pod:1579
3086 msgid "guestfs_set_subprocess_quit_callback"
3090 #: ../src/guestfs.pod:1581
3093 " typedef void (*guestfs_subprocess_quit_cb) (guestfs_h *g, void *opaque);\n"
3094 " void guestfs_set_subprocess_quit_callback (guestfs_h *g,\n"
3095 " guestfs_subprocess_quit_cb cb,\n"
3101 #: ../src/guestfs.pod:1586
3103 "The callback function C<cb> will be called when the child process quits, "
3104 "either asynchronously or if killed by L</guestfs_kill_subprocess>. (This "
3105 "corresponds to a transition from any state to the CONFIG state)."
3109 #: ../src/guestfs.pod:1591
3110 msgid "guestfs_set_launch_done_callback"
3114 #: ../src/guestfs.pod:1593
3117 " typedef void (*guestfs_launch_done_cb) (guestfs_h *g, void *opaque);\n"
3118 " void guestfs_set_launch_done_callback (guestfs_h *g,\n"
3119 " guestfs_launch_done_cb cb,\n"
3125 #: ../src/guestfs.pod:1598
3127 "The callback function C<cb> will be called when the child process becomes "
3128 "ready first time after it has been launched. (This corresponds to a "
3129 "transition from LAUNCHING to the READY state)."
3133 #: ../src/guestfs.pod:1602
3134 msgid "guestfs_set_close_callback"
3138 #: ../src/guestfs.pod:1604
3141 " typedef void (*guestfs_close_cb) (guestfs_h *g, void *opaque);\n"
3142 " void guestfs_set_close_callback (guestfs_h *g,\n"
3143 " guestfs_close_cb cb,\n"
3149 #: ../src/guestfs.pod:1609
3151 "The callback function C<cb> will be called while the handle is being closed "
3152 "(synchronously from L</guestfs_close>)."
3156 #: ../src/guestfs.pod:1612
3158 "Note that libguestfs installs an L<atexit(3)> handler to try to clean up "
3159 "handles that are open when the program exits. This means that this callback "
3160 "might be called indirectly from L<exit(3)>, which can cause unexpected "
3161 "problems in higher-level languages (eg. if your HLL interpreter has already "
3162 "been cleaned up by the time this is called, and if your callback then jumps "
3163 "into some HLL function)."
3167 #: ../src/guestfs.pod:1620
3168 msgid "guestfs_set_progress_callback"
3172 #: ../src/guestfs.pod:1622
3175 " typedef void (*guestfs_progress_cb) (guestfs_h *g, void *opaque,\n"
3176 " int proc_nr, int serial,\n"
3177 " uint64_t position, uint64_t total);\n"
3178 " void guestfs_set_progress_callback (guestfs_h *g,\n"
3179 " guestfs_progress_cb cb,\n"
3185 #: ../src/guestfs.pod:1629
3187 "Some long-running operations can generate progress messages. If this "
3188 "callback is registered, then it will be called each time a progress message "
3189 "is generated (usually two seconds after the operation started, and three "
3190 "times per second thereafter until it completes, although the frequency may "
3191 "change in future versions)."
3195 #: ../src/guestfs.pod:1635
3197 "The callback receives two numbers: C<position> and C<total>. The units of "
3198 "C<total> are not defined, although for some operations C<total> may relate "
3199 "in some way to the amount of data to be transferred (eg. in bytes or "
3200 "megabytes), and C<position> may be the portion which has been transferred."
3204 #: ../src/guestfs.pod:1641
3205 msgid "The only defined and stable parts of the API are:"
3209 #: ../src/guestfs.pod:1647
3211 "The callback can display to the user some type of progress bar or indicator "
3212 "which shows the ratio of C<position>:C<total>."
3216 #: ../src/guestfs.pod:1652
3217 msgid "0 E<lt>= C<position> E<lt>= C<total>"
3221 #: ../src/guestfs.pod:1656
3223 "If any progress notification is sent during a call, then a final progress "
3224 "notification is always sent when C<position> = C<total>."
3228 #: ../src/guestfs.pod:1659
3230 "This is to simplify caller code, so callers can easily set the progress "
3231 "indicator to \"100%\" at the end of the operation, without requiring special "
3232 "code to detect this case."
3236 #: ../src/guestfs.pod:1665
3238 "The callback also receives the procedure number and serial number of the "
3239 "call. These are only useful for debugging protocol issues, and the callback "
3240 "can normally ignore them. The callback may want to print these numbers in "
3241 "error messages or debugging messages."
3245 #: ../src/guestfs.pod:1670
3246 msgid "PRIVATE DATA AREA"
3250 #: ../src/guestfs.pod:1672
3252 "You can attach named pieces of private data to the libguestfs handle, and "
3253 "fetch them by name for the lifetime of the handle. This is called the "
3254 "private data area and is only available from the C API."
3258 #: ../src/guestfs.pod:1676
3259 msgid "To attach a named piece of data, use the following call:"
3263 #: ../src/guestfs.pod:1678
3266 " void guestfs_set_private (guestfs_h *g, const char *key, void *data);\n"
3271 #: ../src/guestfs.pod:1680
3273 "C<key> is the name to associate with this data, and C<data> is an arbitrary "
3274 "pointer (which can be C<NULL>). Any previous item with the same name is "
3279 #: ../src/guestfs.pod:1684
3281 "You can use any C<key> you want, but names beginning with an underscore "
3282 "character are reserved for internal libguestfs purposes (for implementing "
3283 "language bindings). It is recommended to prefix the name with some unique "
3284 "string to avoid collisions with other users."
3288 #: ../src/guestfs.pod:1689
3289 msgid "To retrieve the pointer, use:"
3293 #: ../src/guestfs.pod:1691
3296 " void *guestfs_get_private (guestfs_h *g, const char *key);\n"
3301 #: ../src/guestfs.pod:1693
3303 "This function returns C<NULL> if either no data is found associated with "
3304 "C<key>, or if the user previously set the C<key>'s C<data> pointer to "
3309 #: ../src/guestfs.pod:1697
3311 "Libguestfs does not try to look at or interpret the C<data> pointer in any "
3312 "way. As far as libguestfs is concerned, it need not be a valid pointer at "
3313 "all. In particular, libguestfs does I<not> try to free the data when the "
3314 "handle is closed. If the data must be freed, then the caller must either "
3315 "free it before calling L</guestfs_close> or must set up a close callback to "
3316 "do it (see L</guestfs_set_close_callback>, and note that only one callback "
3317 "can be registered for a handle)."
3321 #: ../src/guestfs.pod:1705
3323 "The private data area is implemented using a hash table, and should be "
3324 "reasonably efficient for moderate numbers of keys."
3328 #: ../src/guestfs.pod:1708 ../src/guestfs.pod:1713
3333 #: ../src/guestfs.pod:1710
3335 "<!-- old anchor for the next section --> <a "
3336 "name=\"state_machine_and_low_level_event_api\"/>"
3340 #: ../src/guestfs.pod:1715
3341 msgid "ARCHITECTURE"
3345 #: ../src/guestfs.pod:1717
3347 "Internally, libguestfs is implemented by running an appliance (a special "
3348 "type of small virtual machine) using L<qemu(1)>. Qemu runs as a child "
3349 "process of the main program."
3353 #: ../src/guestfs.pod:1721
3356 " ___________________\n"
3358 " | main program |\n"
3360 " | | child process / appliance\n"
3361 " | | __________________________\n"
3363 " +-------------------+ RPC | +-----------------+ |\n"
3364 " | libguestfs <--------------------> guestfsd | |\n"
3365 " | | | +-----------------+ |\n"
3366 " \\___________________/ | | Linux kernel | |\n"
3367 " | +--^--------------+ |\n"
3368 " \\_________|________________/\n"
3374 " \\______________/\n"
3379 #: ../src/guestfs.pod:1741
3381 "The library, linked to the main program, creates the child process and hence "
3382 "the appliance in the L</guestfs_launch> function."
3386 #: ../src/guestfs.pod:1744
3388 "Inside the appliance is a Linux kernel and a complete stack of userspace "
3389 "tools (such as LVM and ext2 programs) and a small controlling daemon called "
3390 "L</guestfsd>. The library talks to L</guestfsd> using remote procedure "
3391 "calls (RPC). There is a mostly one-to-one correspondence between libguestfs "
3392 "API calls and RPC calls to the daemon. Lastly the disk image(s) are "
3393 "attached to the qemu process which translates device access by the "
3394 "appliance's Linux kernel into accesses to the image."
3398 #: ../src/guestfs.pod:1753
3400 "A common misunderstanding is that the appliance \"is\" the virtual machine. "
3401 "Although the disk image you are attached to might also be used by some "
3402 "virtual machine, libguestfs doesn't know or care about this. (But you will "
3403 "care if both libguestfs's qemu process and your virtual machine are trying "
3404 "to update the disk image at the same time, since these usually results in "
3405 "massive disk corruption)."
3409 #: ../src/guestfs.pod:1760
3410 msgid "STATE MACHINE"
3414 #: ../src/guestfs.pod:1762
3415 msgid "libguestfs uses a state machine to model the child process:"
3419 #: ../src/guestfs.pod:1764
3431 " / | \\ \\ guestfs_launch\n"
3432 " / | _\\__V______\n"
3434 " / | | LAUNCHING |\n"
3435 " / | \\___________/\n"
3437 " / | guestfs_launch\n"
3439 " ______ / __|____V\n"
3440 " / \\ ------> / \\\n"
3441 " | BUSY | | READY |\n"
3442 " \\______/ <------ \\________/\n"
3447 #: ../src/guestfs.pod:1786
3449 "The normal transitions are (1) CONFIG (when the handle is created, but there "
3450 "is no child process), (2) LAUNCHING (when the child process is booting up), "
3451 "(3) alternating between READY and BUSY as commands are issued to, and "
3452 "carried out by, the child process."
3456 #: ../src/guestfs.pod:1791
3458 "The guest may be killed by L</guestfs_kill_subprocess>, or may die "
3459 "asynchronously at any time (eg. due to some internal error), and that causes "
3460 "the state to transition back to CONFIG."
3464 #: ../src/guestfs.pod:1795
3466 "Configuration commands for qemu such as L</guestfs_add_drive> can only be "
3467 "issued when in the CONFIG state."
3471 #: ../src/guestfs.pod:1798
3473 "The API offers one call that goes from CONFIG through LAUNCHING to READY. "
3474 "L</guestfs_launch> blocks until the child process is READY to accept "
3475 "commands (or until some failure or timeout). L</guestfs_launch> internally "
3476 "moves the state from CONFIG to LAUNCHING while it is running."
3480 #: ../src/guestfs.pod:1804
3482 "API actions such as L</guestfs_mount> can only be issued when in the READY "
3483 "state. These API calls block waiting for the command to be carried out "
3484 "(ie. the state to transition to BUSY and then back to READY). There are no "
3485 "non-blocking versions, and no way to issue more than one command per handle "
3490 #: ../src/guestfs.pod:1810
3492 "Finally, the child process sends asynchronous messages back to the main "
3493 "program, such as kernel log messages. You can register a callback to "
3494 "receive these messages."
3498 #: ../src/guestfs.pod:1814
3503 #: ../src/guestfs.pod:1816
3504 msgid "COMMUNICATION PROTOCOL"
3508 #: ../src/guestfs.pod:1818
3510 "Don't rely on using this protocol directly. This section documents how it "
3511 "currently works, but it may change at any time."
3515 #: ../src/guestfs.pod:1821
3517 "The protocol used to talk between the library and the daemon running inside "
3518 "the qemu virtual machine is a simple RPC mechanism built on top of XDR (RFC "
3519 "1014, RFC 1832, RFC 4506)."
3523 #: ../src/guestfs.pod:1825
3525 "The detailed format of structures is in C<src/guestfs_protocol.x> (note: "
3526 "this file is automatically generated)."
3530 #: ../src/guestfs.pod:1828
3532 "There are two broad cases, ordinary functions that don't have any C<FileIn> "
3533 "and C<FileOut> parameters, which are handled with very simple request/reply "
3534 "messages. Then there are functions that have any C<FileIn> or C<FileOut> "
3535 "parameters, which use the same request and reply messages, but they may also "
3536 "be followed by files sent using a chunked encoding."
3540 #: ../src/guestfs.pod:1835
3541 msgid "ORDINARY FUNCTIONS (NO FILEIN/FILEOUT PARAMS)"
3545 #: ../src/guestfs.pod:1837
3546 msgid "For ordinary functions, the request message is:"
3550 #: ../src/guestfs.pod:1839
3553 " total length (header + arguments,\n"
3554 " but not including the length word itself)\n"
3555 " struct guestfs_message_header (encoded as XDR)\n"
3556 " struct guestfs_<foo>_args (encoded as XDR)\n"
3561 #: ../src/guestfs.pod:1844
3563 "The total length field allows the daemon to allocate a fixed size buffer "
3564 "into which it slurps the rest of the message. As a result, the total length "
3565 "is limited to C<GUESTFS_MESSAGE_MAX> bytes (currently 4MB), which means the "
3566 "effective size of any request is limited to somewhere under this size."
3570 #: ../src/guestfs.pod:1850
3572 "Note also that many functions don't take any arguments, in which case the "
3573 "C<guestfs_I<foo>_args> is completely omitted."
3577 #: ../src/guestfs.pod:1853
3579 "The header contains the procedure number (C<guestfs_proc>) which is how the "
3580 "receiver knows what type of args structure to expect, or none at all."
3584 #: ../src/guestfs.pod:1857
3586 "For functions that take optional arguments, the optional arguments are "
3587 "encoded in the C<guestfs_I<foo>_args> structure in the same way as ordinary "
3588 "arguments. A bitmask in the header indicates which optional arguments are "
3589 "meaningful. The bitmask is also checked to see if it contains bits set "
3590 "which the daemon does not know about (eg. if more optional arguments were "
3591 "added in a later version of the library), and this causes the call to be "
3596 #: ../src/guestfs.pod:1865
3597 msgid "The reply message for ordinary functions is:"
3601 #: ../src/guestfs.pod:1867
3604 " total length (header + ret,\n"
3605 " but not including the length word itself)\n"
3606 " struct guestfs_message_header (encoded as XDR)\n"
3607 " struct guestfs_<foo>_ret (encoded as XDR)\n"
3612 #: ../src/guestfs.pod:1872
3614 "As above the C<guestfs_I<foo>_ret> structure may be completely omitted for "
3615 "functions that return no formal return values."
3619 #: ../src/guestfs.pod:1875
3620 msgid "As above the total length of the reply is limited to C<GUESTFS_MESSAGE_MAX>."
3624 #: ../src/guestfs.pod:1878
3626 "In the case of an error, a flag is set in the header, and the reply message "
3627 "is slightly changed:"
3631 #: ../src/guestfs.pod:1881
3634 " total length (header + error,\n"
3635 " but not including the length word itself)\n"
3636 " struct guestfs_message_header (encoded as XDR)\n"
3637 " struct guestfs_message_error (encoded as XDR)\n"
3642 #: ../src/guestfs.pod:1886
3644 "The C<guestfs_message_error> structure contains the error message as a "
3649 #: ../src/guestfs.pod:1889
3650 msgid "FUNCTIONS THAT HAVE FILEIN PARAMETERS"
3654 #: ../src/guestfs.pod:1891
3656 "A C<FileIn> parameter indicates that we transfer a file I<into> the guest. "
3657 "The normal request message is sent (see above). However this is followed by "
3658 "a sequence of file chunks."
3662 #: ../src/guestfs.pod:1895
3665 " total length (header + arguments,\n"
3666 " but not including the length word itself,\n"
3667 " and not including the chunks)\n"
3668 " struct guestfs_message_header (encoded as XDR)\n"
3669 " struct guestfs_<foo>_args (encoded as XDR)\n"
3670 " sequence of chunks for FileIn param #0\n"
3671 " sequence of chunks for FileIn param #1 etc.\n"
3676 #: ../src/guestfs.pod:1903
3677 msgid "The \"sequence of chunks\" is:"
3681 #: ../src/guestfs.pod:1905
3684 " length of chunk (not including length word itself)\n"
3685 " struct guestfs_chunk (encoded as XDR)\n"
3686 " length of chunk\n"
3687 " struct guestfs_chunk (encoded as XDR)\n"
3689 " length of chunk\n"
3690 " struct guestfs_chunk (with data.data_len == 0)\n"
3695 #: ../src/guestfs.pod:1913
3697 "The final chunk has the C<data_len> field set to zero. Additionally a flag "
3698 "is set in the final chunk to indicate either successful completion or early "
3703 #: ../src/guestfs.pod:1917
3705 "At time of writing there are no functions that have more than one FileIn "
3706 "parameter. However this is (theoretically) supported, by sending the "
3707 "sequence of chunks for each FileIn parameter one after another (from left to "
3712 #: ../src/guestfs.pod:1922
3714 "Both the library (sender) I<and> the daemon (receiver) may cancel the "
3715 "transfer. The library does this by sending a chunk with a special flag set "
3716 "to indicate cancellation. When the daemon sees this, it cancels the whole "
3717 "RPC, does I<not> send any reply, and goes back to reading the next request."
3721 #: ../src/guestfs.pod:1928
3723 "The daemon may also cancel. It does this by writing a special word "
3724 "C<GUESTFS_CANCEL_FLAG> to the socket. The library listens for this during "
3725 "the transfer, and if it gets it, it will cancel the transfer (it sends a "
3726 "cancel chunk). The special word is chosen so that even if cancellation "
3727 "happens right at the end of the transfer (after the library has finished "
3728 "writing and has started listening for the reply), the \"spurious\" cancel "
3729 "flag will not be confused with the reply message."
3733 #: ../src/guestfs.pod:1937
3735 "This protocol allows the transfer of arbitrary sized files (no 32 bit "
3736 "limit), and also files where the size is not known in advance (eg. from "
3737 "pipes or sockets). However the chunks are rather small "
3738 "(C<GUESTFS_MAX_CHUNK_SIZE>), so that neither the library nor the daemon need "
3739 "to keep much in memory."
3743 #: ../src/guestfs.pod:1943
3744 msgid "FUNCTIONS THAT HAVE FILEOUT PARAMETERS"
3748 #: ../src/guestfs.pod:1945
3750 "The protocol for FileOut parameters is exactly the same as for FileIn "
3751 "parameters, but with the roles of daemon and library reversed."
3755 #: ../src/guestfs.pod:1948
3758 " total length (header + ret,\n"
3759 " but not including the length word itself,\n"
3760 " and not including the chunks)\n"
3761 " struct guestfs_message_header (encoded as XDR)\n"
3762 " struct guestfs_<foo>_ret (encoded as XDR)\n"
3763 " sequence of chunks for FileOut param #0\n"
3764 " sequence of chunks for FileOut param #1 etc.\n"
3769 #: ../src/guestfs.pod:1956
3770 msgid "INITIAL MESSAGE"
3774 #: ../src/guestfs.pod:1958
3776 "When the daemon launches it sends an initial word (C<GUESTFS_LAUNCH_FLAG>) "
3777 "which indicates that the guest and daemon is alive. This is what "
3778 "L</guestfs_launch> waits for."
3782 #: ../src/guestfs.pod:1962
3783 msgid "PROGRESS NOTIFICATION MESSAGES"
3787 #: ../src/guestfs.pod:1964
3789 "The daemon may send progress notification messages at any time. These are "
3790 "distinguished by the normal length word being replaced by "
3791 "C<GUESTFS_PROGRESS_FLAG>, followed by a fixed size progress message."
3795 #: ../src/guestfs.pod:1968
3797 "The library turns them into progress callbacks (see "
3798 "C<guestfs_set_progress_callback>) if there is a callback registered, or "
3799 "discards them if not."
3803 #: ../src/guestfs.pod:1972
3805 "The daemon self-limits the frequency of progress messages it sends (see "
3806 "C<daemon/proto.c:notify_progress>). Not all calls generate progress "
3811 #: ../src/guestfs.pod:1976
3812 msgid "LIBGUESTFS VERSION NUMBERS"
3816 #: ../src/guestfs.pod:1978
3818 "Since April 2010, libguestfs has started to make separate development and "
3819 "stable releases, along with corresponding branches in our git repository. "
3820 "These separate releases can be identified by version number:"
3824 #: ../src/guestfs.pod:1983
3827 " even numbers for stable: 1.2.x, 1.4.x, ...\n"
3828 " .-------- odd numbers for development: 1.3.x, 1.5.x, ...\n"
3834 " | `-------- sub-version\n"
3836 " `------ always '1' because we don't change the ABI\n"
3841 #: ../src/guestfs.pod:1994
3842 msgid "Thus \"1.3.5\" is the 5th update to the development branch \"1.3\"."
3846 #: ../src/guestfs.pod:1996
3848 "As time passes we cherry pick fixes from the development branch and backport "
3849 "those into the stable branch, the effect being that the stable branch should "
3850 "get more stable and less buggy over time. So the stable releases are ideal "
3851 "for people who don't need new features but would just like the software to "
3856 #: ../src/guestfs.pod:2002
3857 msgid "Our criteria for backporting changes are:"
3861 #: ../src/guestfs.pod:2008
3863 "Documentation changes which don't affect any code are backported unless the "
3864 "documentation refers to a future feature which is not in stable."
3868 #: ../src/guestfs.pod:2014
3870 "Bug fixes which are not controversial, fix obvious problems, and have been "
3871 "well tested are backported."
3875 #: ../src/guestfs.pod:2019
3877 "Simple rearrangements of code which shouldn't affect how it works get "
3878 "backported. This is so that the code in the two branches doesn't get too "
3879 "far out of step, allowing us to backport future fixes more easily."
3883 #: ../src/guestfs.pod:2025
3885 "We I<don't> backport new features, new APIs, new tools etc, except in one "
3886 "exceptional case: the new feature is required in order to implement an "
3887 "important bug fix."
3891 #: ../src/guestfs.pod:2031
3893 "A new stable branch starts when we think the new features in development are "
3894 "substantial and compelling enough over the current stable branch to warrant "
3895 "it. When that happens we create new stable and development versions 1.N.0 "
3896 "and 1.(N+1).0 [N is even]. The new dot-oh release won't necessarily be so "
3897 "stable at this point, but by backporting fixes from development, that branch "
3898 "will stabilize over time."
3902 #: ../src/guestfs.pod:2039 ../fish/guestfish.pod:965 ../test-tool/libguestfs-test-tool.pod:104 ../tools/virt-edit.pl:330
3903 msgid "ENVIRONMENT VARIABLES"
3907 #: ../src/guestfs.pod:2043 ../fish/guestfish.pod:991
3908 msgid "LIBGUESTFS_APPEND"
3912 #: ../src/guestfs.pod:2045 ../fish/guestfish.pod:993
3913 msgid "Pass additional options to the guest kernel."
3917 #: ../src/guestfs.pod:2047 ../fish/guestfish.pod:995
3918 msgid "LIBGUESTFS_DEBUG"
3922 #: ../src/guestfs.pod:2049
3924 "Set C<LIBGUESTFS_DEBUG=1> to enable verbose messages. This has the same "
3925 "effect as calling C<guestfs_set_verbose (g, 1)>."
3929 #: ../src/guestfs.pod:2052 ../fish/guestfish.pod:1000
3930 msgid "LIBGUESTFS_MEMSIZE"
3934 #: ../src/guestfs.pod:2054 ../fish/guestfish.pod:1002
3935 msgid "Set the memory allocated to the qemu process, in megabytes. For example:"
3939 #: ../src/guestfs.pod:2057 ../fish/guestfish.pod:1005
3942 " LIBGUESTFS_MEMSIZE=700\n"
3947 #: ../src/guestfs.pod:2059 ../fish/guestfish.pod:1007
3948 msgid "LIBGUESTFS_PATH"
3952 #: ../src/guestfs.pod:2061
3954 "Set the path that libguestfs uses to search for kernel and initrd.img. See "
3955 "the discussion of paths in section PATH above."
3959 #: ../src/guestfs.pod:2064 ../fish/guestfish.pod:1012
3960 msgid "LIBGUESTFS_QEMU"
3964 #: ../src/guestfs.pod:2066 ../fish/guestfish.pod:1014
3966 "Set the default qemu binary that libguestfs uses. If not set, then the qemu "
3967 "which was found at compile time by the configure script is used."
3971 #: ../src/guestfs.pod:2070
3972 msgid "See also L</QEMU WRAPPERS> above."
3976 #: ../src/guestfs.pod:2072 ../fish/guestfish.pod:1018
3977 msgid "LIBGUESTFS_TRACE"
3981 #: ../src/guestfs.pod:2074
3983 "Set C<LIBGUESTFS_TRACE=1> to enable command traces. This has the same "
3984 "effect as calling C<guestfs_set_trace (g, 1)>."
3988 #: ../src/guestfs.pod:2077 ../fish/guestfish.pod:1027
3993 #: ../src/guestfs.pod:2079 ../fish/guestfish.pod:1029
3994 msgid "Location of temporary directory, defaults to C</tmp>."
3998 #: ../src/guestfs.pod:2081 ../fish/guestfish.pod:1031
4000 "If libguestfs was compiled to use the supermin appliance then the real "
4001 "appliance is cached in this directory, shared between all handles belonging "
4002 "to the same EUID. You can use C<$TMPDIR> to configure another directory to "
4003 "use in case C</tmp> is not large enough."
4007 #: ../src/guestfs.pod:2089 ../fish/guestfish.pod:1089 ../test-tool/libguestfs-test-tool.pod:109 ../fuse/guestmount.pod:233 ../tools/virt-edit.pl:350 ../tools/virt-win-reg.pl:572 ../tools/virt-resize.pl:1483 ../tools/virt-list-filesystems.pl:189 ../tools/virt-tar.pl:281 ../tools/virt-make-fs.pl:534 ../tools/virt-list-partitions.pl:257
4012 #: ../src/guestfs.pod:2091
4014 "L<guestfs-examples(3)>, L<guestfs-ocaml(3)>, L<guestfs-python(3)>, "
4015 "L<guestfs-ruby(3)>, L<guestfish(1)>, L<guestmount(1)>, L<virt-cat(1)>, "
4016 "L<virt-df(1)>, L<virt-edit(1)>, L<virt-filesystems(1)>, "
4017 "L<virt-inspector(1)>, L<virt-list-filesystems(1)>, "
4018 "L<virt-list-partitions(1)>, L<virt-ls(1)>, L<virt-make-fs(1)>, "
4019 "L<virt-rescue(1)>, L<virt-tar(1)>, L<virt-win-reg(1)>, L<qemu(1)>, "
4020 "L<febootstrap(1)>, L<hivex(3)>, L<http://libguestfs.org/>."
4024 #: ../src/guestfs.pod:2114
4026 "Tools with a similar purpose: L<fdisk(8)>, L<parted(8)>, L<kpartx(8)>, "
4027 "L<lvm(8)>, L<disktype(1)>."
4031 #: ../src/guestfs.pod:2121 ../tools/virt-win-reg.pl:587 ../tools/virt-make-fs.pl:548
4036 #: ../src/guestfs.pod:2123
4037 msgid "To get a list of bugs against libguestfs use this link:"
4041 #: ../src/guestfs.pod:2125
4042 msgid "L<https://bugzilla.redhat.com/buglist.cgi?component=libguestfs&product=Virtualization+Tools>"
4046 #: ../src/guestfs.pod:2127
4047 msgid "To report a new bug against libguestfs use this link:"
4051 #: ../src/guestfs.pod:2129
4052 msgid "L<https://bugzilla.redhat.com/enter_bug.cgi?component=libguestfs&product=Virtualization+Tools>"
4056 #: ../src/guestfs.pod:2131
4057 msgid "When reporting a bug, please check:"
4061 #: ../src/guestfs.pod:2137
4062 msgid "That the bug hasn't been reported already."
4066 #: ../src/guestfs.pod:2141
4067 msgid "That you are testing a recent version."
4071 #: ../src/guestfs.pod:2145
4072 msgid "Describe the bug accurately, and give a way to reproduce it."
4076 #: ../src/guestfs.pod:2149
4078 "Run libguestfs-test-tool and paste the B<complete, unedited> output into the "
4083 #: ../src/guestfs.pod:2154 ../fish/guestfish.pod:1108 ../test-tool/libguestfs-test-tool.pod:115 ../fuse/guestmount.pod:244
4088 #: ../src/guestfs.pod:2156 ../fish/guestfish.pod:1110 ../test-tool/libguestfs-test-tool.pod:117 ../fuse/guestmount.pod:246
4089 msgid "Richard W.M. Jones (C<rjones at redhat dot com>)"
4093 #: ../src/guestfs.pod:2158 ../fish/guestfish.pod:1112 ../test-tool/libguestfs-test-tool.pod:119 ../fuse/guestmount.pod:248 ../tools/virt-edit.pl:366 ../tools/virt-win-reg.pl:602 ../tools/virt-resize.pl:1508 ../tools/virt-list-filesystems.pl:206 ../tools/virt-tar.pl:296 ../tools/virt-make-fs.pl:563 ../tools/virt-list-partitions.pl:273
4098 #: ../src/guestfs.pod:2160 ../fish/guestfish.pod:1114 ../fuse/guestmount.pod:250
4099 msgid "Copyright (C) 2009-2010 Red Hat Inc. L<http://libguestfs.org/>"
4103 #: ../src/guestfs.pod:2163
4105 "This library is free software; you can redistribute it and/or modify it "
4106 "under the terms of the GNU Lesser General Public License as published by the "
4107 "Free Software Foundation; either version 2 of the License, or (at your "
4108 "option) any later version."
4112 #: ../src/guestfs.pod:2168
4114 "This library is distributed in the hope that it will be useful, but WITHOUT "
4115 "ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or "
4116 "FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License "
4121 #: ../src/guestfs.pod:2173
4123 "You should have received a copy of the GNU Lesser General Public License "
4124 "along with this library; if not, write to the Free Software Foundation, "
4125 "Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA"
4129 #: ../src/guestfs-actions.pod:1
4130 msgid "guestfs_add_cdrom"
4134 #: ../src/guestfs-actions.pod:3
4138 " guestfs_add_cdrom (guestfs_h *g,\n"
4139 " const char *filename);\n"
4144 #: ../src/guestfs-actions.pod:7 ../fish/guestfish-actions.pod:5
4145 msgid "This function adds a virtual CD-ROM disk image to the guest."
4149 #: ../src/guestfs-actions.pod:9 ../fish/guestfish-actions.pod:7
4150 msgid "This is equivalent to the qemu parameter C<-cdrom filename>."
4154 #: ../src/guestfs-actions.pod:17
4156 "This call checks for the existence of C<filename>. This stops you from "
4157 "specifying other types of drive which are supported by qemu such as C<nbd:> "
4158 "and C<http:> URLs. To specify those, use the general C<guestfs_config> call "
4163 #: ../src/guestfs-actions.pod:24
4165 "If you just want to add an ISO file (often you use this as an efficient way "
4166 "to transfer large files into the guest), then you should probably use "
4167 "C<guestfs_add_drive_ro> instead."
4171 #: ../src/guestfs-actions.pod:30 ../src/guestfs-actions.pod:128 ../src/guestfs-actions.pod:189 ../src/guestfs-actions.pod:226 ../src/guestfs-actions.pod:240 ../src/guestfs-actions.pod:261 ../src/guestfs-actions.pod:281 ../src/guestfs-actions.pod:295 ../src/guestfs-actions.pod:410 ../src/guestfs-actions.pod:430 ../src/guestfs-actions.pod:444 ../src/guestfs-actions.pod:489 ../src/guestfs-actions.pod:517 ../src/guestfs-actions.pod:535 ../src/guestfs-actions.pod:602 ../src/guestfs-actions.pod:635 ../src/guestfs-actions.pod:649 ../src/guestfs-actions.pod:664 ../src/guestfs-actions.pod:763 ../src/guestfs-actions.pod:781 ../src/guestfs-actions.pod:795 ../src/guestfs-actions.pod:809 ../src/guestfs-actions.pod:970 ../src/guestfs-actions.pod:990 ../src/guestfs-actions.pod:1008 ../src/guestfs-actions.pod:1092 ../src/guestfs-actions.pod:1110 ../src/guestfs-actions.pod:1129 ../src/guestfs-actions.pod:1143 ../src/guestfs-actions.pod:1163 ../src/guestfs-actions.pod:1233 ../src/guestfs-actions.pod:1264 ../src/guestfs-actions.pod:1289 ../src/guestfs-actions.pod:1326 ../src/guestfs-actions.pod:1432 ../src/guestfs-actions.pod:1466 ../src/guestfs-actions.pod:1684 ../src/guestfs-actions.pod:1706 ../src/guestfs-actions.pod:1793 ../src/guestfs-actions.pod:2215 ../src/guestfs-actions.pod:2359 ../src/guestfs-actions.pod:2420 ../src/guestfs-actions.pod:2455 ../src/guestfs-actions.pod:3194 ../src/guestfs-actions.pod:3209 ../src/guestfs-actions.pod:3229 ../src/guestfs-actions.pod:3354 ../src/guestfs-actions.pod:3368 ../src/guestfs-actions.pod:3381 ../src/guestfs-actions.pod:3395 ../src/guestfs-actions.pod:3410 ../src/guestfs-actions.pod:3446 ../src/guestfs-actions.pod:3518 ../src/guestfs-actions.pod:3538 ../src/guestfs-actions.pod:3555 ../src/guestfs-actions.pod:3578 ../src/guestfs-actions.pod:3601 ../src/guestfs-actions.pod:3633 ../src/guestfs-actions.pod:3652 ../src/guestfs-actions.pod:3671 ../src/guestfs-actions.pod:3706 ../src/guestfs-actions.pod:3718 ../src/guestfs-actions.pod:3754 ../src/guestfs-actions.pod:3770 ../src/guestfs-actions.pod:3783 ../src/guestfs-actions.pod:3798 ../src/guestfs-actions.pod:3815 ../src/guestfs-actions.pod:3908 ../src/guestfs-actions.pod:3928 ../src/guestfs-actions.pod:3941 ../src/guestfs-actions.pod:3992 ../src/guestfs-actions.pod:4010 ../src/guestfs-actions.pod:4028 ../src/guestfs-actions.pod:4044 ../src/guestfs-actions.pod:4058 ../src/guestfs-actions.pod:4072 ../src/guestfs-actions.pod:4089 ../src/guestfs-actions.pod:4104 ../src/guestfs-actions.pod:4124 ../src/guestfs-actions.pod:4168 ../src/guestfs-actions.pod:4239 ../src/guestfs-actions.pod:4270 ../src/guestfs-actions.pod:4289 ../src/guestfs-actions.pod:4308 ../src/guestfs-actions.pod:4320 ../src/guestfs-actions.pod:4337 ../src/guestfs-actions.pod:4350 ../src/guestfs-actions.pod:4365 ../src/guestfs-actions.pod:4380 ../src/guestfs-actions.pod:4415 ../src/guestfs-actions.pod:4430 ../src/guestfs-actions.pod:4450 ../src/guestfs-actions.pod:4464 ../src/guestfs-actions.pod:4481 ../src/guestfs-actions.pod:4530 ../src/guestfs-actions.pod:4567 ../src/guestfs-actions.pod:4581 ../src/guestfs-actions.pod:4609 ../src/guestfs-actions.pod:4626 ../src/guestfs-actions.pod:4644 ../src/guestfs-actions.pod:4778 ../src/guestfs-actions.pod:4835 ../src/guestfs-actions.pod:4857 ../src/guestfs-actions.pod:4875 ../src/guestfs-actions.pod:4907 ../src/guestfs-actions.pod:4973 ../src/guestfs-actions.pod:4990 ../src/guestfs-actions.pod:5003 ../src/guestfs-actions.pod:5017 ../src/guestfs-actions.pod:5306 ../src/guestfs-actions.pod:5325 ../src/guestfs-actions.pod:5339 ../src/guestfs-actions.pod:5351 ../src/guestfs-actions.pod:5365 ../src/guestfs-actions.pod:5377 ../src/guestfs-actions.pod:5391 ../src/guestfs-actions.pod:5407 ../src/guestfs-actions.pod:5428 ../src/guestfs-actions.pod:5447 ../src/guestfs-actions.pod:5466 ../src/guestfs-actions.pod:5484 ../src/guestfs-actions.pod:5507 ../src/guestfs-actions.pod:5525 ../src/guestfs-actions.pod:5544 ../src/guestfs-actions.pod:5565 ../src/guestfs-actions.pod:5584 ../src/guestfs-actions.pod:5601 ../src/guestfs-actions.pod:5629 ../src/guestfs-actions.pod:5653 ../src/guestfs-actions.pod:5672 ../src/guestfs-actions.pod:5696 ../src/guestfs-actions.pod:5711 ../src/guestfs-actions.pod:5726 ../src/guestfs-actions.pod:5745 ../src/guestfs-actions.pod:5782 ../src/guestfs-actions.pod:5805 ../src/guestfs-actions.pod:5831 ../src/guestfs-actions.pod:5939 ../src/guestfs-actions.pod:6060 ../src/guestfs-actions.pod:6072 ../src/guestfs-actions.pod:6085 ../src/guestfs-actions.pod:6098 ../src/guestfs-actions.pod:6120 ../src/guestfs-actions.pod:6133 ../src/guestfs-actions.pod:6146 ../src/guestfs-actions.pod:6159 ../src/guestfs-actions.pod:6174 ../src/guestfs-actions.pod:6233 ../src/guestfs-actions.pod:6250 ../src/guestfs-actions.pod:6266 ../src/guestfs-actions.pod:6282 ../src/guestfs-actions.pod:6299 ../src/guestfs-actions.pod:6312 ../src/guestfs-actions.pod:6332 ../src/guestfs-actions.pod:6368 ../src/guestfs-actions.pod:6382 ../src/guestfs-actions.pod:6423 ../src/guestfs-actions.pod:6436 ../src/guestfs-actions.pod:6454 ../src/guestfs-actions.pod:6488 ../src/guestfs-actions.pod:6524 ../src/guestfs-actions.pod:6643 ../src/guestfs-actions.pod:6661 ../src/guestfs-actions.pod:6675 ../src/guestfs-actions.pod:6730 ../src/guestfs-actions.pod:6743 ../src/guestfs-actions.pod:6788 ../src/guestfs-actions.pod:6821 ../src/guestfs-actions.pod:6875 ../src/guestfs-actions.pod:6901 ../src/guestfs-actions.pod:6967 ../src/guestfs-actions.pod:6986 ../src/guestfs-actions.pod:7015
4172 msgid "This function returns 0 on success or -1 on error."
4176 #: ../src/guestfs-actions.pod:32 ../src/guestfs-actions.pod:242 ../src/guestfs-actions.pod:263 ../fish/guestfish-actions.pod:28 ../fish/guestfish-actions.pod:153 ../fish/guestfish-actions.pod:167
4178 "This function is deprecated. In new code, use the C<add_drive_opts> call "
4183 #: ../src/guestfs-actions.pod:35 ../src/guestfs-actions.pod:245 ../src/guestfs-actions.pod:266 ../src/guestfs-actions.pod:1437 ../src/guestfs-actions.pod:1923 ../src/guestfs-actions.pod:1944 ../src/guestfs-actions.pod:4129 ../src/guestfs-actions.pod:6909 ../src/guestfs-actions.pod:7078 ../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:2778 ../fish/guestfish-actions.pod:4580 ../fish/guestfish-actions.pod:4677
4185 "Deprecated functions will not be removed from the API, but the fact that "
4186 "they are deprecated indicates that there are problems with correct use of "
4191 #: ../src/guestfs-actions.pod:39 ../src/guestfs-actions.pod:130 ../src/guestfs-actions.pod:1094 ../src/guestfs-actions.pod:1895 ../src/guestfs-actions.pod:1993 ../src/guestfs-actions.pod:2096 ../src/guestfs-actions.pod:3196 ../src/guestfs-actions.pod:3211 ../src/guestfs-actions.pod:4417 ../src/guestfs-actions.pod:5486 ../src/guestfs-actions.pod:5603 ../src/guestfs-actions.pod:5713 ../src/guestfs-actions.pod:6176 ../src/guestfs-actions.pod:6301 ../src/guestfs-actions.pod:6823
4192 msgid "(Added in 0.3)"
4196 #: ../src/guestfs-actions.pod:41
4197 msgid "guestfs_add_domain"
4201 #: ../src/guestfs-actions.pod:43
4205 " guestfs_add_domain (guestfs_h *g,\n"
4206 " const char *dom,\n"
4212 #: ../src/guestfs-actions.pod:48 ../src/guestfs-actions.pod:139 ../src/guestfs-actions.pod:4143
4214 "You may supply a list of optional arguments to this call. Use zero or more "
4215 "of the following pairs of parameters, and terminate the list with C<-1> on "
4216 "its own. See L</CALLS WITH OPTIONAL ARGUMENTS>."
4220 #: ../src/guestfs-actions.pod:53
4223 " GUESTFS_ADD_DOMAIN_LIBVIRTURI, const char *libvirturi,\n"
4224 " GUESTFS_ADD_DOMAIN_READONLY, int readonly,\n"
4225 " GUESTFS_ADD_DOMAIN_IFACE, const char *iface,\n"
4230 #: ../src/guestfs-actions.pod:57
4232 "This function adds the disk(s) attached to the named libvirt domain C<dom>. "
4233 "It works by connecting to libvirt, requesting the domain and domain XML from "
4234 "libvirt, parsing it for disks, and calling C<guestfs_add_drive_opts> on each "
4239 #: ../src/guestfs-actions.pod:62 ../fish/guestfish-actions.pod:46
4241 "The number of disks added is returned. This operation is atomic: if an "
4242 "error is returned, then no disks are added."
4246 #: ../src/guestfs-actions.pod:65 ../fish/guestfish-actions.pod:49
4248 "This function does some minimal checks to make sure the libvirt domain is "
4249 "not running (unless C<readonly> is true). In a future version we will try "
4250 "to acquire the libvirt lock on each disk."
4254 #: ../src/guestfs-actions.pod:69 ../fish/guestfish-actions.pod:53
4256 "Disks must be accessible locally. This often means that adding disks from a "
4257 "remote libvirt connection (see L<http://libvirt.org/remote.html>) will fail "
4258 "unless those disks are accessible via the same device path locally too."
4262 #: ../src/guestfs-actions.pod:74
4264 "The optional C<libvirturi> parameter sets the libvirt URI (see "
4265 "L<http://libvirt.org/uri.html>). If this is not set then we connect to the "
4266 "default libvirt URI (or one set through an environment variable, see the "
4267 "libvirt documentation for full details). If you are using the C API "
4268 "directly then it is more flexible to create the libvirt connection object "
4269 "yourself, get the domain object, and call C<guestfs_add_libvirt_dom>."
4273 #: ../src/guestfs-actions.pod:82
4275 "The other optional parameters are passed directly through to "
4276 "C<guestfs_add_drive_opts>."
4280 #: ../src/guestfs-actions.pod:85 ../src/guestfs-actions.pod:338 ../src/guestfs-actions.pod:503 ../src/guestfs-actions.pod:681 ../src/guestfs-actions.pod:712 ../src/guestfs-actions.pod:730 ../src/guestfs-actions.pod:749 ../src/guestfs-actions.pod:1309 ../src/guestfs-actions.pod:1663 ../src/guestfs-actions.pod:1866 ../src/guestfs-actions.pod:1965 ../src/guestfs-actions.pod:2005 ../src/guestfs-actions.pod:2060 ../src/guestfs-actions.pod:2083 ../src/guestfs-actions.pod:2346 ../src/guestfs-actions.pod:2634 ../src/guestfs-actions.pod:2655 ../src/guestfs-actions.pod:4553 ../src/guestfs-actions.pod:4681 ../src/guestfs-actions.pod:5087 ../src/guestfs-actions.pod:5113 ../src/guestfs-actions.pod:6409 ../src/guestfs-actions.pod:6834 ../src/guestfs-actions.pod:6847 ../src/guestfs-actions.pod:6860
4281 msgid "On error this function returns -1."
4285 #: ../src/guestfs-actions.pod:87
4286 msgid "(Added in 1.7.4)"
4290 #: ../src/guestfs-actions.pod:89
4291 msgid "guestfs_add_domain_va"
4295 #: ../src/guestfs-actions.pod:91
4299 " guestfs_add_domain_va (guestfs_h *g,\n"
4300 " const char *dom,\n"
4306 #: ../src/guestfs-actions.pod:96
4307 msgid "This is the \"va_list variant\" of L</guestfs_add_domain>."
4311 #: ../src/guestfs-actions.pod:98 ../src/guestfs-actions.pod:109 ../src/guestfs-actions.pod:202 ../src/guestfs-actions.pod:213 ../src/guestfs-actions.pod:4180 ../src/guestfs-actions.pod:4192
4312 msgid "See L</CALLS WITH OPTIONAL ARGUMENTS>."
4316 #: ../src/guestfs-actions.pod:100
4317 msgid "guestfs_add_domain_argv"
4321 #: ../src/guestfs-actions.pod:102
4325 " guestfs_add_domain_argv (guestfs_h *g,\n"
4326 " const char *dom,\n"
4327 " const struct guestfs_add_domain_argv *optargs);\n"
4332 #: ../src/guestfs-actions.pod:107
4333 msgid "This is the \"argv variant\" of L</guestfs_add_domain>."
4337 #: ../src/guestfs-actions.pod:111
4338 msgid "guestfs_add_drive"
4342 #: ../src/guestfs-actions.pod:113
4346 " guestfs_add_drive (guestfs_h *g,\n"
4347 " const char *filename);\n"
4352 #: ../src/guestfs-actions.pod:117
4354 "This function is the equivalent of calling C<guestfs_add_drive_opts> with no "
4355 "optional parameters, so the disk is added writable, with the format being "
4356 "detected automatically."
4360 #: ../src/guestfs-actions.pod:121
4362 "Automatic detection of the format opens you up to a potential security hole "
4363 "when dealing with untrusted raw-format images. See CVE-2010-3851 and "
4364 "RHBZ#642934. Specifying the format closes this security hole. Therefore "
4365 "you should think about replacing calls to this function with calls to "
4366 "C<guestfs_add_drive_opts>, and specifying the format."
4370 #: ../src/guestfs-actions.pod:132
4371 msgid "guestfs_add_drive_opts"
4375 #: ../src/guestfs-actions.pod:134
4379 " guestfs_add_drive_opts (guestfs_h *g,\n"
4380 " const char *filename,\n"
4386 #: ../src/guestfs-actions.pod:144
4389 " GUESTFS_ADD_DRIVE_OPTS_READONLY, int readonly,\n"
4390 " GUESTFS_ADD_DRIVE_OPTS_FORMAT, const char *format,\n"
4391 " GUESTFS_ADD_DRIVE_OPTS_IFACE, const char *iface,\n"
4396 #: ../src/guestfs-actions.pod:148 ../fish/guestfish-actions.pod:92
4398 "This function adds a virtual machine disk image C<filename> to libguestfs. "
4399 "The first time you call this function, the disk appears as C</dev/sda>, the "
4400 "second time as C</dev/sdb>, and so on."
4404 #: ../src/guestfs-actions.pod:153 ../fish/guestfish-actions.pod:97
4406 "You don't necessarily need to be root when using libguestfs. However you "
4407 "obviously do need sufficient permissions to access the filename for whatever "
4408 "operations you want to perform (ie. read access if you just want to read the "
4409 "image or write access if you want to modify the image)."
4413 #: ../src/guestfs-actions.pod:159 ../fish/guestfish-actions.pod:103
4414 msgid "This call checks that C<filename> exists."
4418 #: ../src/guestfs-actions.pod:161 ../src/guestfs-actions.pod:4153 ../fish/guestfish-actions.pod:105 ../fish/guestfish-actions.pod:2789
4419 msgid "The optional arguments are:"
4423 #: ../src/guestfs-actions.pod:165 ../fish/guestfish-actions.pod:109
4428 #: ../src/guestfs-actions.pod:167 ../fish/guestfish-actions.pod:111
4430 "If true then the image is treated as read-only. Writes are still allowed, "
4431 "but they are stored in a temporary snapshot overlay which is discarded at "
4432 "the end. The disk that you add is not modified."
4436 #: ../src/guestfs-actions.pod:171 ../fish/guestfish-actions.pod:115
4441 #: ../src/guestfs-actions.pod:173
4443 "This forces the image format. If you omit this (or use C<guestfs_add_drive> "
4444 "or C<guestfs_add_drive_ro>) then the format is automatically detected. "
4445 "Possible formats include C<raw> and C<qcow2>."
4449 #: ../src/guestfs-actions.pod:177 ../fish/guestfish-actions.pod:121
4451 "Automatic detection of the format opens you up to a potential security hole "
4452 "when dealing with untrusted raw-format images. See CVE-2010-3851 and "
4453 "RHBZ#642934. Specifying the format closes this security hole."
4457 #: ../src/guestfs-actions.pod:182 ../fish/guestfish-actions.pod:126
4462 #: ../src/guestfs-actions.pod:184
4464 "This rarely-used option lets you emulate the behaviour of the deprecated "
4465 "C<guestfs_add_drive_with_if> call (q.v.)"
4469 #: ../src/guestfs-actions.pod:191
4470 msgid "(Added in 1.5.23)"
4474 #: ../src/guestfs-actions.pod:193
4475 msgid "guestfs_add_drive_opts_va"
4479 #: ../src/guestfs-actions.pod:195
4483 " guestfs_add_drive_opts_va (guestfs_h *g,\n"
4484 " const char *filename,\n"
4490 #: ../src/guestfs-actions.pod:200
4491 msgid "This is the \"va_list variant\" of L</guestfs_add_drive_opts>."
4495 #: ../src/guestfs-actions.pod:204
4496 msgid "guestfs_add_drive_opts_argv"
4500 #: ../src/guestfs-actions.pod:206
4504 " guestfs_add_drive_opts_argv (guestfs_h *g,\n"
4505 " const char *filename,\n"
4506 " const struct guestfs_add_drive_opts_argv "
4512 #: ../src/guestfs-actions.pod:211
4513 msgid "This is the \"argv variant\" of L</guestfs_add_drive_opts>."
4517 #: ../src/guestfs-actions.pod:215
4518 msgid "guestfs_add_drive_ro"
4522 #: ../src/guestfs-actions.pod:217
4526 " guestfs_add_drive_ro (guestfs_h *g,\n"
4527 " const char *filename);\n"
4532 #: ../src/guestfs-actions.pod:221
4534 "This function is the equivalent of calling C<guestfs_add_drive_opts> with "