X-Git-Url: http://git.annexia.org/?p=libguestfs.git;a=blobdiff_plain;f=guestfs-actions.pod;h=9afa5de9a6c994ab05e1e7e90e79c349e4483b39;hp=210e82518ecc3878c4ec11a4c054b40861032d53;hb=5e332cc6c06532191f793a6789bafe818f726258;hpb=f7e6ffa8a82f8a7a214a47ff32f46d9e893902d8 diff --git a/guestfs-actions.pod b/guestfs-actions.pod index 210e825..9afa5de 100644 --- a/guestfs-actions.pod +++ b/guestfs-actions.pod @@ -7,6 +7,11 @@ This function adds a virtual CD-ROM disk image to the guest. This is equivalent to the qemu parameter C<-cdrom filename>. +Note that this call checks for the existence of C. This +stops you from specifying other types of drive which are supported +by qemu such as C and C URLs. To specify those, use +the general C call instead. + This function returns 0 on success or -1 on error. =head2 guestfs_add_drive @@ -25,7 +30,36 @@ for whatever operations you want to perform (ie. read access if you just want to read the image or write access if you want to modify the image). -This is equivalent to the qemu parameter C<-drive file=filename>. +This is equivalent to the qemu parameter C<-drive file=filename,cache=off>. + +Note that this call checks for the existence of C. This +stops you from specifying other types of drive which are supported +by qemu such as C and C URLs. To specify those, use +the general C call instead. + +This function returns 0 on success or -1 on error. + +=head2 guestfs_add_drive_ro + + int guestfs_add_drive_ro (guestfs_h *handle, + const char *filename); + +This adds a drive in snapshot mode, making it effectively +read-only. + +Note that writes to the device are allowed, and will be seen for +the duration of the guestfs handle, but they are written +to a temporary file which is discarded as soon as the guestfs +handle is closed. We don't currently have any method to enable +changes to be committed, although qemu can support this. + +This is equivalent to the qemu parameter +C<-drive file=filename,snapshot=on>. + +Note that this call checks for the existence of C. This +stops you from specifying other types of drive which are supported +by qemu such as C and C URLs. To specify those, use +the general C call instead. This function returns 0 on success or -1 on error. @@ -477,7 +511,16 @@ or compatible processor architecture). The single parameter is an argv-style list of arguments. The first element is the name of the program to run. Subsequent elements are parameters. The list must be -non-empty (ie. must contain a program name). +non-empty (ie. must contain a program name). Note that +the command runs directly, and is I invoked via +the shell (see C). + +The return value is anything printed to I by +the command. + +If the command returns a non-zero exit status, then +this function returns an error message. The error message +string is the content of I from the command. The C<$PATH> environment variable will contain at least C and C. If you require a program from @@ -493,6 +536,10 @@ locations. This function returns a string, or NULL on error. I. +Because of the message protocol, there is a transfer limit +of somewhere between 2MB and 4MB. To transfer large files you should use +FTP. + =head2 guestfs_command_lines char **guestfs_command_lines (guestfs_h *handle, @@ -501,10 +548,16 @@ I. This is the same as C, but splits the result into a list of lines. +See also: C + This function returns a NULL-terminated array of strings (like L), or NULL if there was an error. I. +Because of the message protocol, there is a transfer limit +of somewhere between 2MB and 4MB. To transfer large files you should use +FTP. + =head2 guestfs_config int guestfs_config (guestfs_h *handle, @@ -522,6 +575,28 @@ C can be NULL. This function returns 0 on success or -1 on error. +=head2 guestfs_cp + + int guestfs_cp (guestfs_h *handle, + const char *src, + const char *dest); + +This copies a file from C to C where C is +either a destination filename or destination directory. + +This function returns 0 on success or -1 on error. + +=head2 guestfs_cp_a + + int guestfs_cp_a (guestfs_h *handle, + const char *src, + const char *dest); + +This copies a file or directory from C to C +recursively using the C command. + +This function returns 0 on success or -1 on error. + =head2 guestfs_debug char *guestfs_debug (guestfs_h *handle, @@ -539,6 +614,22 @@ to find out what you can do. This function returns a string, or NULL on error. I. +=head2 guestfs_dmesg + + char *guestfs_dmesg (guestfs_h *handle); + +This returns the kernel messages (C output) from +the guest kernel. This is sometimes useful for extended +debugging of problems. + +Another way to get the same information is to enable +verbose messages with C or by setting +the environment variable C before +running the program. + +This function returns a string, or NULL on error. +I. + =head2 guestfs_download int guestfs_download (guestfs_h *handle, @@ -554,6 +645,62 @@ See also C, C. This function returns 0 on success or -1 on error. +=head2 guestfs_drop_caches + + int guestfs_drop_caches (guestfs_h *handle, + int whattodrop); + +This instructs the guest kernel to drop its page cache, +and/or dentries and inode caches. The parameter C +tells the kernel what precisely to drop, see +L + +Setting C to 3 should drop everything. + +This automatically calls L before the operation, +so that the maximum guest memory is freed. + +This function returns 0 on success or -1 on error. + +=head2 guestfs_e2fsck_f + + int guestfs_e2fsck_f (guestfs_h *handle, + const char *device); + +This runs C, ie. runs the ext2/ext3 +filesystem checker on C, noninteractively (C<-p>), +even if the filesystem appears to be clean (C<-f>). + +This command is only needed because of C +(q.v.). Normally you should use C. + +This function returns 0 on success or -1 on error. + +=head2 guestfs_end_busy + + int guestfs_end_busy (guestfs_h *handle); + +This sets the state to C, or if in C then it leaves the +state as is. This is only used when implementing +actions using the low-level API. + +For more information on states, see L. + +This function returns 0 on success or -1 on error. + +=head2 guestfs_equal + + int guestfs_equal (guestfs_h *handle, + const char *file1, + const char *file2); + +This compares the two files C and C and returns +true if their content is exactly equal, or false otherwise. + +The external L program is used for the comparison. + +This function returns a C truth value on success or -1 on error. + =head2 guestfs_exists int guestfs_exists (guestfs_h *handle, @@ -582,6 +729,88 @@ particular that the filename is not prepended to the output This function returns a string, or NULL on error. I. +=head2 guestfs_find + + char **guestfs_find (guestfs_h *handle, + const char *directory); + +This command lists out all files and directories, recursively, +starting at C. It is essentially equivalent to +running the shell command C but some +post-processing happens on the output, described below. + +This returns a list of strings I. Thus +if the directory structure was: + + /tmp/a + /tmp/b + /tmp/c/d + +then the returned list from C C would be +4 elements: + + a + b + c + c/d + +If C is not a directory, then this command returns +an error. + +The returned list is sorted. + +This function returns a NULL-terminated array of strings +(like L), or NULL if there was an error. +I. + +=head2 guestfs_fsck + + int guestfs_fsck (guestfs_h *handle, + const char *fstype, + const char *device); + +This runs the filesystem checker (fsck) on C which +should have filesystem type C. + +The returned integer is the status. See L for the +list of status codes from C. + +Notes: + +=over 4 + +=item * + +Multiple status codes can be summed together. + +=item * + +A non-zero return code can mean "success", for example if +errors have been corrected on the filesystem. + +=item * + +Checking or repairing NTFS volumes is not supported +(by linux-ntfs). + +=back + +This command is entirely equivalent to running C. + +On error this function returns -1. + +=head2 guestfs_get_append + + const char *guestfs_get_append (guestfs_h *handle); + +Return the additional kernel options which are added to the +guest kernel command line. + +If C then no options are added. + +This function returns a string, or NULL on error. +The string is owned by the guest handle and must I be freed. + =head2 guestfs_get_autosync int guestfs_get_autosync (guestfs_h *handle); @@ -655,6 +884,52 @@ This returns the verbose messages flag. This function returns a C truth value on success or -1 on error. +=head2 guestfs_glob_expand + + char **guestfs_glob_expand (guestfs_h *handle, + const char *pattern); + +This command searches for all the pathnames matching +C according to the wildcard expansion rules +used by the shell. + +If no paths match, then this returns an empty list +(note: not an error). + +It is just a wrapper around the C L function +with flags C. +See that manual page for more details. + +This function returns a NULL-terminated array of strings +(like L), or NULL if there was an error. +I. + +=head2 guestfs_grub_install + + int guestfs_grub_install (guestfs_h *handle, + const char *root, + const char *device); + +This command installs GRUB (the Grand Unified Bootloader) on +C, with the root directory being C. + +This function returns 0 on success or -1 on error. + +=head2 guestfs_hexdump + + char *guestfs_hexdump (guestfs_h *handle, + const char *path); + +This runs C on the given C. The result is +the human-readable, canonical hex dump of the file. + +This function returns a string, or NULL on error. +I. + +Because of the message protocol, there is a transfer limit +of somewhere between 2MB and 4MB. To transfer large files you should use +FTP. + =head2 guestfs_is_busy int guestfs_is_busy (guestfs_h *handle); @@ -857,6 +1132,18 @@ the VG name, C. This function returns 0 on success or -1 on error. +=head2 guestfs_lvresize + + int guestfs_lvresize (guestfs_h *handle, + const char *device, + int mbytes); + +This resizes (expands or shrinks) an existing LVM logical +volume to C. When reducing, data in the reduced part +is lost. + +This function returns 0 on success or -1 on error. + =head2 guestfs_lvs char **guestfs_lvs (guestfs_h *handle); @@ -911,7 +1198,7 @@ This function returns 0 on success or -1 on error. const char *device); This creates a filesystem on C (usually a partition -of LVM logical volume). The filesystem type is C, for +or LVM logical volume). The filesystem type is C, for example C. This function returns 0 on success or -1 on error. @@ -992,6 +1279,48 @@ This function returns a NULL-terminated array of strings (like L), or NULL if there was an error. I. +=head2 guestfs_mv + + int guestfs_mv (guestfs_h *handle, + const char *src, + const char *dest); + +This moves a file from C to C where C is +either a destination filename or destination directory. + +This function returns 0 on success or -1 on error. + +=head2 guestfs_ntfs_3g_probe + + int guestfs_ntfs_3g_probe (guestfs_h *handle, + int rw, + const char *device); + +This command runs the L command which probes +an NTFS C for mountability. (Not all NTFS volumes can +be mounted read-write, and some cannot be mounted at all). + +C is a boolean flag. Set it to true if you want to test +if the volume can be mounted read-write. Set it to false if +you want to test if the volume can be mounted read-only. + +The return value is an integer which C<0> if the operation +would succeed, or some non-zero value documented in the +L manual page. + +On error this function returns -1. + +=head2 guestfs_ping_daemon + + int guestfs_ping_daemon (guestfs_h *handle); + +This is a test probe into the guestfs daemon running inside +the qemu subprocess. Calling this function checks that the +daemon responds to the ping message, without affecting the daemon +or attached block device(s) in any other way. + +This function returns 0 on success or -1 on error. + =head2 guestfs_pvcreate int guestfs_pvcreate (guestfs_h *handle, @@ -1017,6 +1346,16 @@ to remove those first. This function returns 0 on success or -1 on error. +=head2 guestfs_pvresize + + int guestfs_pvresize (guestfs_h *handle, + const char *device); + +This resizes (expands or shrinks) an existing LVM physical +volume to match the new size of the underlying device. + +This function returns 0 on success or -1 on error. + =head2 guestfs_pvs char **guestfs_pvs (guestfs_h *handle); @@ -1064,6 +1403,22 @@ This function returns a NULL-terminated array of strings (like L), or NULL if there was an error. I. +=head2 guestfs_resize2fs + + int guestfs_resize2fs (guestfs_h *handle, + const char *device); + +This resizes an ext2 or ext3 filesystem to match the size of +the underlying device. + +I It is sometimes required that you run C +on the C before calling this command. For unknown reasons +C sometimes gives an error about this and sometimes not. +In any case, it is always safe to call C before +calling this function. + +This function returns 0 on success or -1 on error. + =head2 guestfs_rm int guestfs_rm (guestfs_h *handle, @@ -1093,6 +1448,69 @@ Remove the single directory C. This function returns 0 on success or -1 on error. +=head2 guestfs_scrub_device + + int guestfs_scrub_device (guestfs_h *handle, + const char *device); + +This command writes patterns over C to make data retrieval +more difficult. + +It is an interface to the L program. See that +manual page for more details. + +This function returns 0 on success or -1 on error. + +B. + +=head2 guestfs_scrub_file + + int guestfs_scrub_file (guestfs_h *handle, + const char *file); + +This command writes patterns over a file to make data retrieval +more difficult. + +The file is I after scrubbing. + +It is an interface to the L program. See that +manual page for more details. + +This function returns 0 on success or -1 on error. + +=head2 guestfs_scrub_freespace + + int guestfs_scrub_freespace (guestfs_h *handle, + const char *dir); + +This command creates the directory C and then fills it +with files until the filesystem is full, and scrubs the files +as for C, and deletes them. +The intention is to scrub any free space on the partition +containing C. + +It is an interface to the L program. See that +manual page for more details. + +This function returns 0 on success or -1 on error. + +=head2 guestfs_set_append + + int guestfs_set_append (guestfs_h *handle, + const char *append); + +This function is used to add additional options to the +guest kernel command line. + +The default is C unless overridden by setting +C environment variable. + +Setting C to C means I additional options +are passed (libguestfs always adds a few of its own). + +This function returns 0 on success or -1 on error. + =head2 guestfs_set_autosync int guestfs_set_autosync (guestfs_h *handle, @@ -1160,9 +1578,6 @@ Set the path that libguestfs searches for kernel and initrd.img. The default is C<$libdir/guestfs> unless overridden by setting C environment variable. -The string C is stashed in the libguestfs handle, so the caller -must make sure it remains valid for the lifetime of the handle. - Setting C to C restores the default path. This function returns 0 on success or -1 on error. @@ -1180,9 +1595,6 @@ configure script. You can also override this by setting the C environment variable. -The string C is stashed in the libguestfs handle, so the caller -must make sure it remains valid for the lifetime of the handle. - Setting C to C restores the default qemu binary. This function returns 0 on success or -1 on error. @@ -1239,11 +1651,119 @@ To create a single partition occupying the whole disk, you would pass C as a single element list, when the single element being the string C<,> (comma). +See also: C, C + This function returns 0 on success or -1 on error. B. +=head2 guestfs_sfdisk_N + + int guestfs_sfdisk_N (guestfs_h *handle, + const char *device, + int n, + int cyls, + int heads, + int sectors, + const char *line); + +This runs L option to modify just the single +partition C (note: C counts from 1). + +For other parameters, see C. You should usually +pass C<0> for the cyls/heads/sectors parameters. + +This function returns 0 on success or -1 on error. + +B. + +=head2 guestfs_sfdisk_disk_geometry + + char *guestfs_sfdisk_disk_geometry (guestfs_h *handle, + const char *device); + +This displays the disk geometry of C read from the +partition table. Especially in the case where the underlying +block device has been resized, this can be different from the +kernel's idea of the geometry (see C). + +The result is in human-readable format, and not designed to +be parsed. + +This function returns a string, or NULL on error. +I. + +=head2 guestfs_sfdisk_kernel_geometry + + char *guestfs_sfdisk_kernel_geometry (guestfs_h *handle, + const char *device); + +This displays the kernel's idea of the geometry of C. + +The result is in human-readable format, and not designed to +be parsed. + +This function returns a string, or NULL on error. +I. + +=head2 guestfs_sfdisk_l + + char *guestfs_sfdisk_l (guestfs_h *handle, + const char *device); + +This displays the partition table on C, in the +human-readable output of the L command. It is +not intended to be parsed. + +This function returns a string, or NULL on error. +I. + +=head2 guestfs_sh + + char *guestfs_sh (guestfs_h *handle, + const char *command); + +This call runs a command from the guest filesystem via the +guest's C. + +This is like C, but passes the command to: + + /bin/sh -c "command" + +Depending on the guest's shell, this usually results in +wildcards being expanded, shell expressions being interpolated +and so on. + +All the provisos about C apply to this call. + +This function returns a string, or NULL on error. +I. + +=head2 guestfs_sh_lines + + char **guestfs_sh_lines (guestfs_h *handle, + const char *command); + +This is the same as C, but splits the result +into a list of lines. + +See also: C + +This function returns a NULL-terminated array of strings +(like L), or NULL if there was an error. +I. + +=head2 guestfs_sleep + + int guestfs_sleep (guestfs_h *handle, + int secs); + +Sleep for C seconds. + +This function returns 0 on success or -1 on error. + =head2 guestfs_stat struct guestfs_stat *guestfs_stat (guestfs_h *handle, @@ -1274,6 +1794,46 @@ This function returns a C or NULL if there was an error. I after use>. +=head2 guestfs_strings + + char **guestfs_strings (guestfs_h *handle, + const char *path); + +This runs the L command on a file and returns +the list of printable strings found. + +This function returns a NULL-terminated array of strings +(like L), or NULL if there was an error. +I. + +Because of the message protocol, there is a transfer limit +of somewhere between 2MB and 4MB. To transfer large files you should use +FTP. + +=head2 guestfs_strings_e + + char **guestfs_strings_e (guestfs_h *handle, + const char *encoding, + const char *path); + +This is like the C command, but allows you to +specify the encoding. + +See the L manpage for the full list of encodings. + +Commonly useful encodings are C (lower case L) which will +show strings inside Windows/x86 files. + +The returned strings are transcoded to UTF-8. + +This function returns a NULL-terminated array of strings +(like L), or NULL if there was an error. +I. + +Because of the message protocol, there is a transfer limit +of somewhere between 2MB and 4MB. To transfer large files you should use +FTP. + =head2 guestfs_sync int guestfs_sync (guestfs_h *handle); @@ -1404,6 +1964,40 @@ See also C. This function returns 0 on success or -1 on error. +=head2 guestfs_vg_activate + + int guestfs_vg_activate (guestfs_h *handle, + int activate, + char * const* const volgroups); + +This command activates or (if C is false) deactivates +all logical volumes in the listed volume groups C. +If activated, then they are made known to the +kernel, ie. they appear as C devices. If deactivated, +then those devices disappear. + +This command is the same as running C + +Note that if C is an empty list then B volume groups +are activated or deactivated. + +This function returns 0 on success or -1 on error. + +=head2 guestfs_vg_activate_all + + int guestfs_vg_activate_all (guestfs_h *handle, + int activate); + +This command activates or (if C is false) deactivates +all logical volumes in all volume groups. +If activated, then they are made known to the +kernel, ie. they appear as C devices. If deactivated, +then those devices disappear. + +This command is the same as running C + +This function returns 0 on success or -1 on error. + =head2 guestfs_vgcreate int guestfs_vgcreate (guestfs_h *handle, @@ -1482,9 +2076,47 @@ As a special case, if C is C<0> then the length is calculated using C (so in this case the content cannot contain embedded ASCII NULs). +I Owing to a bug, writing content containing ASCII NUL +characters does I work, even if the length is specified. +We hope to resolve this bug in a future version. In the meantime +use C. + This function returns 0 on success or -1 on error. Because of the message protocol, there is a transfer limit of somewhere between 2MB and 4MB. To transfer large files you should use FTP. +=head2 guestfs_zero + + int guestfs_zero (guestfs_h *handle, + const char *device); + +This command writes zeroes over the first few blocks of C. + +How many blocks are zeroed isn't specified (but it's I enough +to securely wipe the device). It should be sufficient to remove +any partition tables, filesystem superblocks and so on. + +See also: C. + +This function returns 0 on success or -1 on error. + +=head2 guestfs_zerofree + + int guestfs_zerofree (guestfs_h *handle, + const char *device); + +This runs the I program on C. This program +claims to zero unused inodes and disk blocks on an ext2/3 +filesystem, thus making it possible to compress the filesystem +more effectively. + +You should B run this program if the filesystem is +mounted. + +It is possible that using this program can damage the filesystem +or data on the filesystem. + +This function returns 0 on success or -1 on error. +