X-Git-Url: http://git.annexia.org/?p=libguestfs.git;a=blobdiff_plain;f=guestfs-actions.pod;h=50eba95a2685306247e633e97dd00d74eabcc2de;hp=d57dae3802f3acca4396b10e4d8b8a93d8a72f5a;hb=0884d8bbae6d76a603ec1385ada2938f88981c5c;hpb=170f262f0413de843af62b968f6d12c1c476ae7f diff --git a/guestfs-actions.pod b/guestfs-actions.pod index d57dae3..50eba95 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. @@ -388,6 +422,56 @@ 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_checksum + + char *guestfs_checksum (guestfs_h *handle, + const char *csumtype, + const char *path); + +This call computes the MD5, SHAx or CRC checksum of the +file named C. + +The type of checksum to compute is given by the C +parameter which must have one of the following values: + +=over 4 + +=item C + +Compute the cyclic redundancy check (CRC) specified by POSIX +for the C command. + +=item C + +Compute the MD5 hash (using the C program). + +=item C + +Compute the SHA1 hash (using the C program). + +=item C + +Compute the SHA224 hash (using the C program). + +=item C + +Compute the SHA256 hash (using the C program). + +=item C + +Compute the SHA384 hash (using the C program). + +=item C + +Compute the SHA512 hash (using the C program). + +=back + +The checksum is returned as a printable string. + +This function returns a string, or NULL on error. +I. + =head2 guestfs_chmod int guestfs_chmod (guestfs_h *handle, @@ -427,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 @@ -443,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, @@ -451,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, @@ -472,6 +575,88 @@ 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, + const char *subcmd, + char * const* const extraargs); + +The C command exposes some internals of +C (the guestfs daemon) that runs inside the +qemu subprocess. + +There is no comprehensive help for this command. You have +to look at the file C in the libguestfs source +to find out what you can do. + +This function returns a string, or NULL on error. +I. + +=head2 guestfs_df + + char *guestfs_df (guestfs_h *handle); + +This command runs the C command to report disk space used. + +This command is mostly useful for interactive sessions. It +is I intended that you try to parse the output string. +Use C from programs. + +This function returns a string, or NULL on error. +I. + +=head2 guestfs_df_h + + char *guestfs_df_h (guestfs_h *handle); + +This command runs the C command to report disk space used +in human-readable format. + +This command is mostly useful for interactive sessions. It +is I intended that you try to parse the output string. +Use C from programs. + +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, @@ -487,6 +672,79 @@ 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_du + + int64_t guestfs_du (guestfs_h *handle, + const char *path); + +This command runs the C command to estimate file space +usage for C. + +C can be a file or a directory. If C is a directory +then the estimate includes the contents of the directory and all +subdirectories (recursively). + +The result is the estimated size in I +(ie. units of 1024 bytes). + +On error this function returns -1. + +=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, @@ -515,156 +773,391 @@ particular that the filename is not prepended to the output This function returns a string, or NULL on error. I. -=head2 guestfs_get_autosync +=head2 guestfs_find - int guestfs_get_autosync (guestfs_h *handle); + char **guestfs_find (guestfs_h *handle, + const char *directory); -Get the autosync flag. +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 function returns a C truth value on success or -1 on error. +This returns a list of strings I. Thus +if the directory structure was: -=head2 guestfs_get_path + /tmp/a + /tmp/b + /tmp/c/d - const char *guestfs_get_path (guestfs_h *handle); +then the returned list from C C would be +4 elements: -Return the current search path. + a + b + c + c/d -This is always non-NULL. If it wasn't set already, then this will -return the default path. +If C is not a directory, then this command returns +an error. -This function returns a string, or NULL on error. -The string is owned by the guest handle and must I be freed. +The returned list is sorted. -=head2 guestfs_get_state +This function returns a NULL-terminated array of strings +(like L), or NULL if there was an error. +I. - int guestfs_get_state (guestfs_h *handle); +=head2 guestfs_fsck -This returns the current state as an opaque integer. This is -only useful for printing debug and internal error messages. + int guestfs_fsck (guestfs_h *handle, + const char *fstype, + const char *device); -For more information on states, see L. +This runs the filesystem checker (fsck) on C which +should have filesystem type C. -On error this function returns -1. +The returned integer is the status. See L for the +list of status codes from C. -=head2 guestfs_get_verbose +Notes: - int guestfs_get_verbose (guestfs_h *handle); +=over 4 -This returns the verbose messages flag. +=item * -This function returns a C truth value on success or -1 on error. +Multiple status codes can be summed together. -=head2 guestfs_is_busy +=item * - int guestfs_is_busy (guestfs_h *handle); +A non-zero return code can mean "success", for example if +errors have been corrected on the filesystem. -This returns true iff this handle is busy processing a command -(in the C state). +=item * -For more information on states, see L. +Checking or repairing NTFS volumes is not supported +(by linux-ntfs). -This function returns a C truth value on success or -1 on error. +=back -=head2 guestfs_is_config +This command is entirely equivalent to running C. - int guestfs_is_config (guestfs_h *handle); +On error this function returns -1. -This returns true iff this handle is being configured -(in the C state). +=head2 guestfs_get_append -For more information on states, see L. + const char *guestfs_get_append (guestfs_h *handle); -This function returns a C truth value on success or -1 on error. +Return the additional kernel options which are added to the +guest kernel command line. -=head2 guestfs_is_dir +If C then no options are added. - int guestfs_is_dir (guestfs_h *handle, - const char *path); +This function returns a string, or NULL on error. +The string is owned by the guest handle and must I be freed. -This returns C if and only if there is a directory -with the given C name. Note that it returns false for -other objects like files. +=head2 guestfs_get_autosync -See also C. + int guestfs_get_autosync (guestfs_h *handle); + +Get the autosync flag. This function returns a C truth value on success or -1 on error. -=head2 guestfs_is_file +=head2 guestfs_get_e2label - int guestfs_is_file (guestfs_h *handle, - const char *path); + char *guestfs_get_e2label (guestfs_h *handle, + const char *device); -This returns C if and only if there is a file -with the given C name. Note that it returns false for -other objects like directories. +This returns the ext2/3/4 filesystem label of the filesystem on +C. -See also C. +This function returns a string, or NULL on error. +I. -This function returns a C truth value on success or -1 on error. +=head2 guestfs_get_e2uuid -=head2 guestfs_is_launching + char *guestfs_get_e2uuid (guestfs_h *handle, + const char *device); - int guestfs_is_launching (guestfs_h *handle); +This returns the ext2/3/4 filesystem UUID of the filesystem on +C. -This returns true iff this handle is launching the subprocess -(in the C state). +This function returns a string, or NULL on error. +I. -For more information on states, see L. +=head2 guestfs_get_memsize -This function returns a C truth value on success or -1 on error. + int guestfs_get_memsize (guestfs_h *handle); -=head2 guestfs_is_ready +This gets the memory size in megabytes allocated to the +qemu subprocess. - int guestfs_is_ready (guestfs_h *handle); +If C was not called +on this handle, and if C was not set, +then this returns the compiled-in default value for memsize. -This returns true iff this handle is ready to accept commands -(in the C state). +For more information on the architecture of libguestfs, +see L. -For more information on states, see L. +On error this function returns -1. -This function returns a C truth value on success or -1 on error. +=head2 guestfs_get_path -=head2 guestfs_kill_subprocess + const char *guestfs_get_path (guestfs_h *handle); - int guestfs_kill_subprocess (guestfs_h *handle); +Return the current search path. -This kills the qemu subprocess. You should never need to call this. +This is always non-NULL. If it wasn't set already, then this will +return the default path. -This function returns 0 on success or -1 on error. +This function returns a string, or NULL on error. +The string is owned by the guest handle and must I be freed. -=head2 guestfs_launch +=head2 guestfs_get_qemu - int guestfs_launch (guestfs_h *handle); + const char *guestfs_get_qemu (guestfs_h *handle); -Internally libguestfs is implemented by running a virtual machine -using L. +Return the current qemu binary. -You should call this after configuring the handle -(eg. adding drives) but before performing any actions. +This is always non-NULL. If it wasn't set already, then this will +return the default qemu binary name. -This function returns 0 on success or -1 on error. +This function returns a string, or NULL on error. +The string is owned by the guest handle and must I be freed. -=head2 guestfs_list_devices +=head2 guestfs_get_state - char **guestfs_list_devices (guestfs_h *handle); + int guestfs_get_state (guestfs_h *handle); -List all the block devices. +This returns the current state as an opaque integer. This is +only useful for printing debug and internal error messages. -The full block device names are returned, eg. C +For more information on states, see L. -This function returns a NULL-terminated array of strings -(like L), or NULL if there was an error. -I. +On error this function returns -1. -=head2 guestfs_list_partitions +=head2 guestfs_get_verbose - char **guestfs_list_partitions (guestfs_h *handle); + int guestfs_get_verbose (guestfs_h *handle); -List all the partitions detected on all block devices. +This returns the verbose messages flag. -The full partition device names are returned, eg. C +This function returns a C truth value on success or -1 on error. -This does not return logical volumes. For that you will need to +=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_head + + char **guestfs_head (guestfs_h *handle, + const char *path); + +This command returns up to the first 10 lines of a file as +a list of strings. + +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_head_n + + char **guestfs_head_n (guestfs_h *handle, + int nrlines, + const char *path); + +If the parameter C is a positive number, this returns the first +C lines of the file C. + +If the parameter C is a negative number, this returns lines +from the file C, excluding the last C lines. + +If the parameter C is zero, this returns an empty list. + +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_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_initrd_list + + char **guestfs_initrd_list (guestfs_h *handle, + const char *path); + +This command lists out files contained in an initrd. + +The files are listed without any initial C character. The +files are listed in the order they appear (not necessarily +alphabetical). Directory names are listed as separate items. + +Old Linux kernels (2.4 and earlier) used a compressed ext2 +filesystem as initrd. We I support the newer initramfs +format (compressed cpio files). + +This function returns a NULL-terminated array of strings +(like L), or NULL if there was an error. +I. + +=head2 guestfs_is_busy + + int guestfs_is_busy (guestfs_h *handle); + +This returns true iff this handle is busy processing a command +(in the C state). + +For more information on states, see L. + +This function returns a C truth value on success or -1 on error. + +=head2 guestfs_is_config + + int guestfs_is_config (guestfs_h *handle); + +This returns true iff this handle is being configured +(in the C state). + +For more information on states, see L. + +This function returns a C truth value on success or -1 on error. + +=head2 guestfs_is_dir + + int guestfs_is_dir (guestfs_h *handle, + const char *path); + +This returns C if and only if there is a directory +with the given C name. Note that it returns false for +other objects like files. + +See also C. + +This function returns a C truth value on success or -1 on error. + +=head2 guestfs_is_file + + int guestfs_is_file (guestfs_h *handle, + const char *path); + +This returns C if and only if there is a file +with the given C name. Note that it returns false for +other objects like directories. + +See also C. + +This function returns a C truth value on success or -1 on error. + +=head2 guestfs_is_launching + + int guestfs_is_launching (guestfs_h *handle); + +This returns true iff this handle is launching the subprocess +(in the C state). + +For more information on states, see L. + +This function returns a C truth value on success or -1 on error. + +=head2 guestfs_is_ready + + int guestfs_is_ready (guestfs_h *handle); + +This returns true iff this handle is ready to accept commands +(in the C state). + +For more information on states, see L. + +This function returns a C truth value on success or -1 on error. + +=head2 guestfs_kill_subprocess + + int guestfs_kill_subprocess (guestfs_h *handle); + +This kills the qemu subprocess. You should never need to call this. + +This function returns 0 on success or -1 on error. + +=head2 guestfs_launch + + int guestfs_launch (guestfs_h *handle); + +Internally libguestfs is implemented by running a virtual machine +using L. + +You should call this after configuring the handle +(eg. adding drives) but before performing any actions. + +This function returns 0 on success or -1 on error. + +=head2 guestfs_list_devices + + char **guestfs_list_devices (guestfs_h *handle); + +List all the block devices. + +The full block device names are returned, eg. C + +This function returns a NULL-terminated array of strings +(like L), or NULL if there was an error. +I. + +=head2 guestfs_list_partitions + + char **guestfs_list_partitions (guestfs_h *handle); + +List all the partitions detected on all block devices. + +The full partition device names are returned, eg. C + +This does not return logical volumes. For that you will need to call C. This function returns a NULL-terminated array of strings @@ -743,6 +1236,31 @@ This function returns 0 on success or -1 on error. B. +=head2 guestfs_lvremove + + int guestfs_lvremove (guestfs_h *handle, + const char *device); + +Remove an LVM logical volume C, where C is +the path to the LV, such as C. + +You can also remove all LVs in a volume group by specifying +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); @@ -790,6 +1308,45 @@ as necessary. This is like the C shell command. This function returns 0 on success or -1 on error. +=head2 guestfs_mkdtemp + + char *guestfs_mkdtemp (guestfs_h *handle, + const char *template); + +This command creates a temporary directory. The +C