X-Git-Url: http://git.annexia.org/?p=libguestfs.git;a=blobdiff_plain;f=guestfs-actions.pod;h=50eba95a2685306247e633e97dd00d74eabcc2de;hp=c5fadcfcc0deff331ff954b29424b4070ec84c54;hb=0884d8bbae6d76a603ec1385ada2938f88981c5c;hpb=e7eca50046e9a69dac27c0bee832af0a3014e02c diff --git a/guestfs-actions.pod b/guestfs-actions.pod index c5fadcf..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. @@ -58,8 +92,9 @@ On success this returns a pair containing the number of nodes in the nodeset, and a boolean flag if a node was created. -This function returns a C. -I after use.>. +This function returns a C, +or NULL if there was an error. +I after use>. =head2 guestfs_aug_defvar @@ -84,7 +119,7 @@ On error this function returns -1. Look up the value associated with C. If C matches exactly one node, the C is returned. -This function returns a string or NULL on error. +This function returns a string, or NULL on error. I. =head2 guestfs_aug_init @@ -109,28 +144,28 @@ integers: =over 4 -=item 1 C +=item C = 1 Keep the original file with a C<.augsave> extension. -=item 2 C +=item C = 2 Save changes into a file with extension C<.augnew>, and do not overwrite original. Overrides C. -=item 4 C +=item C = 4 Typecheck lenses (can be expensive). -=item 8 C +=item C = 8 Do not use standard load path for modules. -=item 16 C +=item C = 16 Make save a no-op, just record what would have been changed. -=item 32 C +=item C = 32 Do not load the tree in C. @@ -170,6 +205,18 @@ details. This function returns 0 on success or -1 on error. +=head2 guestfs_aug_ls + + char **guestfs_aug_ls (guestfs_h *handle, + const char *path); + +This is just a shortcut for listing C +C and sorting the resulting nodes into alphabetical order. + +This function returns a NULL-terminated array of strings +(like L), or NULL if there was an error. +I. + =head2 guestfs_aug_match char **guestfs_aug_match (guestfs_h *handle, @@ -226,320 +273,2086 @@ Set the value associated with C to C. This function returns 0 on success or -1 on error. -=head2 guestfs_cat +=head2 guestfs_blockdev_flushbufs - char *guestfs_cat (guestfs_h *handle, - const char *path); + int guestfs_blockdev_flushbufs (guestfs_h *handle, + const char *device); -Return the contents of the file named C. +This tells the kernel to flush internal buffers associated +with C. -Note that this function cannot correctly handle binary files -(specifically, files containing C<\0> character which is treated -as end of string). For those you need to use the C -function which has a more complex interface. +This uses the L command. -This function returns a string or NULL on error. -I. +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_blockdev_getbsz -=head2 guestfs_config + int guestfs_blockdev_getbsz (guestfs_h *handle, + const char *device); - int guestfs_config (guestfs_h *handle, - const char *qemuparam, - const char *qemuvalue); +This returns the block size of a device. -This can be used to add arbitrary qemu command line parameters -of the form C<-param value>. Actually it's not quite arbitrary - we -prevent you from setting some parameters which would interfere with -parameters that we use. +(Note this is different from both I and +I). -The first character of C string must be a C<-> (dash). +This uses the L command. -C can be NULL. +On error this function returns -1. -This function returns 0 on success or -1 on error. +=head2 guestfs_blockdev_getro -=head2 guestfs_get_autosync + int guestfs_blockdev_getro (guestfs_h *handle, + const char *device); - int guestfs_get_autosync (guestfs_h *handle); +Returns a boolean indicating if the block device is read-only +(true if read-only, false if not). -Get the autosync flag. +This uses the L command. This function returns a C truth value on success or -1 on error. -=head2 guestfs_get_path +=head2 guestfs_blockdev_getsize64 - const char *guestfs_get_path (guestfs_h *handle); + int64_t guestfs_blockdev_getsize64 (guestfs_h *handle, + const char *device); -Return the current search path. +This returns the size of the device in bytes. -This is always non-NULL. If it wasn't set already, then this will -return the default path. +See also C. -This function returns a string or NULL on error. -The string is owned by the guest handle and must I be freed. +This uses the L command. -=head2 guestfs_get_verbose +On error this function returns -1. - int guestfs_get_verbose (guestfs_h *handle); +=head2 guestfs_blockdev_getss -This returns the verbose messages flag. + int guestfs_blockdev_getss (guestfs_h *handle, + const char *device); -This function returns a C truth value on success or -1 on error. +This returns the size of sectors on a block device. +Usually 512, but can be larger for modern devices. -=head2 guestfs_kill_subprocess +(Note, this is not the size in sectors, use C +for that). - int guestfs_kill_subprocess (guestfs_h *handle); +This uses the L command. -This kills the qemu subprocess. You should never need to call this. +On error this function returns -1. -This function returns 0 on success or -1 on error. +=head2 guestfs_blockdev_getsz -=head2 guestfs_launch + int64_t guestfs_blockdev_getsz (guestfs_h *handle, + const char *device); - int guestfs_launch (guestfs_h *handle); +This returns the size of the device in units of 512-byte sectors +(even if the sectorsize isn't 512 bytes ... weird). -Internally libguestfs is implemented by running a virtual machine -using L. +See also C for the real sector size of +the device, and C for the more +useful I. -You should call this after configuring the handle -(eg. adding drives) but before performing any actions. +This uses the L command. + +On error this function returns -1. + +=head2 guestfs_blockdev_rereadpt + + int guestfs_blockdev_rereadpt (guestfs_h *handle, + const char *device); + +Reread the partition table on C. + +This uses the L command. This function returns 0 on success or -1 on error. -=head2 guestfs_list_devices +=head2 guestfs_blockdev_setbsz - char **guestfs_list_devices (guestfs_h *handle); + int guestfs_blockdev_setbsz (guestfs_h *handle, + const char *device, + int blocksize); -List all the block devices. +This sets the block size of a device. -The full block device names are returned, eg. C +(Note this is different from both I and +I). -This function returns a NULL-terminated array of strings -(like L), or NULL if there was an error. -I. +This uses the L command. -=head2 guestfs_list_partitions +This function returns 0 on success or -1 on error. - char **guestfs_list_partitions (guestfs_h *handle); +=head2 guestfs_blockdev_setro -List all the partitions detected on all block devices. + int guestfs_blockdev_setro (guestfs_h *handle, + const char *device); -The full partition device names are returned, eg. C +Sets the block device named C to read-only. -This does not return logical volumes. For that you will need to -call C. +This uses the L command. -This function returns a NULL-terminated array of strings -(like L), or NULL if there was an error. -I. +This function returns 0 on success or -1 on error. -=head2 guestfs_ll +=head2 guestfs_blockdev_setrw - char *guestfs_ll (guestfs_h *handle, - const char *directory); + int guestfs_blockdev_setrw (guestfs_h *handle, + const char *device); -List the files in C (relative to the root directory, -there is no cwd) in the format of 'ls -la'. +Sets the block device named C to read-write. -This command is mostly useful for interactive sessions. It -is I intended that you try to parse the output string. +This uses the L command. -This function returns a string or NULL on error. -I. +This function returns 0 on success or -1 on error. -=head2 guestfs_ls +=head2 guestfs_cat - char **guestfs_ls (guestfs_h *handle, - const char *directory); + char *guestfs_cat (guestfs_h *handle, + const char *path); -List the files in C (relative to the root directory, -there is no cwd). The '.' and '..' entries are not returned, but -hidden files are shown. +Return the contents of the file named C. -This command is mostly useful for interactive sessions. Programs -should probably use C instead. +Note that this function cannot correctly handle binary files +(specifically, files containing C<\0> character which is treated +as end of string). For those you need to use the C +function which has a more complex interface. -This function returns a NULL-terminated array of strings -(like L), or NULL if there was an error. -I. +This function returns a string, or NULL on error. +I. -=head2 guestfs_lvs +Because of the message protocol, there is a transfer limit +of somewhere between 2MB and 4MB. To transfer large files you should use +FTP. - char **guestfs_lvs (guestfs_h *handle); +=head2 guestfs_checksum -List all the logical volumes detected. This is the equivalent -of the L command. + char *guestfs_checksum (guestfs_h *handle, + const char *csumtype, + const char *path); -This returns a list of the logical volume device names -(eg. C). +This call computes the MD5, SHAx or CRC checksum of the +file named C. -See also C. +The type of checksum to compute is given by the C +parameter which must have one of the following values: -This function returns a NULL-terminated array of strings -(like L), or NULL if there was an error. -I. +=over 4 -=head2 guestfs_lvs_full +=item C - struct guestfs_lvm_lv_list *guestfs_lvs_full (guestfs_h *handle); +Compute the cyclic redundancy check (CRC) specified by POSIX +for the C command. -List all the logical volumes detected. This is the equivalent -of the L command. The "full" version includes all fields. +=item C -This function returns a C. -I after use.>. +Compute the MD5 hash (using the C program). -=head2 guestfs_mount +=item C - int guestfs_mount (guestfs_h *handle, - const char *device, - const char *mountpoint); +Compute the SHA1 hash (using the C program). -Mount a guest disk at a position in the filesystem. Block devices -are named C, C and so on, as they were added to -the guest. If those block devices contain partitions, they will have -the usual names (eg. C). Also LVM C-style -names can be used. +=item C -The rules are the same as for L: A filesystem must -first be mounted on C before others can be mounted. Other -filesystems can only be mounted on directories which already -exist. +Compute the SHA224 hash (using the C program). -The mounted filesystem is writable, if we have sufficient permissions -on the underlying device. +=item C -The filesystem options C and C are set with this -call, in order to improve reliability. +Compute the SHA256 hash (using the C program). -This function returns 0 on success or -1 on error. +=item C -=head2 guestfs_pvs +Compute the SHA384 hash (using the C program). - char **guestfs_pvs (guestfs_h *handle); +=item C -List all the physical volumes detected. This is the equivalent -of the L command. +Compute the SHA512 hash (using the C program). -This returns a list of just the device names that contain -PVs (eg. C). +=back -See also C. +The checksum is returned as a printable string. -This function returns a NULL-terminated array of strings -(like L), or NULL if there was an error. -I. +This function returns a string, or NULL on error. +I. -=head2 guestfs_pvs_full +=head2 guestfs_chmod - struct guestfs_lvm_pv_list *guestfs_pvs_full (guestfs_h *handle); + int guestfs_chmod (guestfs_h *handle, + int mode, + const char *path); -List all the physical volumes detected. This is the equivalent -of the L command. The "full" version includes all fields. +Change the mode (permissions) of C to C. Only +numeric modes are supported. -This function returns a C. -I after use.>. +This function returns 0 on success or -1 on error. -=head2 guestfs_read_lines +=head2 guestfs_chown - char **guestfs_read_lines (guestfs_h *handle, + int guestfs_chown (guestfs_h *handle, + int owner, + int group, const char *path); -Return the contents of the file named C. +Change the file owner to C and group to C. -The file contents are returned as a list of lines. Trailing -C and C character sequences are I returned. +Only numeric uid and gid are supported. If you want to use +names, you will need to locate and parse the password file +yourself (Augeas support makes this relatively easy). -Note that this function cannot correctly handle binary files -(specifically, files containing C<\0> character which is treated -as end of line). For those you need to use the C -function which has a more complex interface. +This function returns 0 on success or -1 on error. -This function returns a NULL-terminated array of strings -(like L), or NULL if there was an error. -I. +=head2 guestfs_command -=head2 guestfs_set_autosync + char *guestfs_command (guestfs_h *handle, + char * const* const arguments); - int guestfs_set_autosync (guestfs_h *handle, - int autosync); +This call runs a command from the guest filesystem. The +filesystem must be mounted, and must contain a compatible +operating system (ie. something Linux, with the same +or compatible processor architecture). -If C is true, this enables autosync. Libguestfs will make a -best effort attempt to run C when the handle is closed -(also if the program exits without closing handles). +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). Note that +the command runs directly, and is I invoked via +the shell (see C). -This function returns 0 on success or -1 on error. +The return value is anything printed to I by +the command. -=head2 guestfs_set_path +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. - int guestfs_set_path (guestfs_h *handle, - const char *path); +The C<$PATH> environment variable will contain at least +C and C. If you require a program from +another location, you should provide the full path in the +first parameter. -Set the path that libguestfs searches for kernel and initrd.img. +Shared libraries and data files required by the program +must be available on filesystems which are mounted in the +correct places. It is the caller's responsibility to ensure +all filesystems that are needed are mounted at the right +locations. -The default is C<$libdir/guestfs> unless overridden by setting -C environment variable. +This function returns a string, or NULL on error. +I. -The string C is stashed in the libguestfs handle, so the caller -must make sure it remains valid for the lifetime of the handle. +Because of the message protocol, there is a transfer limit +of somewhere between 2MB and 4MB. To transfer large files you should use +FTP. -Setting C to C restores the default path. +=head2 guestfs_command_lines -This function returns 0 on success or -1 on error. + char **guestfs_command_lines (guestfs_h *handle, + char * const* const arguments); -=head2 guestfs_set_verbose +This is the same as C, but splits the +result into a list of lines. - int guestfs_set_verbose (guestfs_h *handle, - int verbose); +See also: C -If C is true, this turns on verbose messages (to C). +This function returns a NULL-terminated array of strings +(like L), or NULL if there was an error. +I. -Verbose messages are disabled unless the environment variable -C is defined and set to C<1>. +Because of the message protocol, there is a transfer limit +of somewhere between 2MB and 4MB. To transfer large files you should use +FTP. -This function returns 0 on success or -1 on error. +=head2 guestfs_config -=head2 guestfs_sync + int guestfs_config (guestfs_h *handle, + const char *qemuparam, + const char *qemuvalue); - int guestfs_sync (guestfs_h *handle); +This can be used to add arbitrary qemu command line parameters +of the form C<-param value>. Actually it's not quite arbitrary - we +prevent you from setting some parameters which would interfere with +parameters that we use. -This syncs the disk, so that any writes are flushed through to the -underlying disk image. +The first character of C string must be a C<-> (dash). -You should always call this if you have modified a disk image, before -closing the handle. +C can be NULL. This function returns 0 on success or -1 on error. -=head2 guestfs_touch +=head2 guestfs_cp - int guestfs_touch (guestfs_h *handle, - const char *path); + int guestfs_cp (guestfs_h *handle, + const char *src, + const char *dest); -Touch acts like the L command. It can be used to -update the timestamps on a file, or, if the file does not exist, -to create a new zero-length file. +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_vgs +=head2 guestfs_cp_a - char **guestfs_vgs (guestfs_h *handle); + int guestfs_cp_a (guestfs_h *handle, + const char *src, + const char *dest); -List all the volumes groups detected. This is the equivalent -of the L command. +This copies a file or directory from C to C +recursively using the C command. -This returns a list of just the volume group names that were -detected (eg. C). +This function returns 0 on success or -1 on error. -See also C. +=head2 guestfs_debug -This function returns a NULL-terminated array of strings -(like L), or NULL if there was an error. + 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, + const char *remotefilename, + const char *filename); + +Download file C and save it as C +on the local machine. + +C can also be a named pipe. + +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, + const char *path); + +This returns C if and only if there is a file, directory +(or anything) with the given C name. + +See also C, C, C. + +This function returns a C truth value on success or -1 on error. + +=head2 guestfs_file + + char *guestfs_file (guestfs_h *handle, + const char *path); + +This call uses the standard L command to determine +the type or contents of the file. This also works on devices, +for example to find out whether a partition contains a filesystem. + +The exact command which runs is C. Note in +particular that the filename is not prepended to the output +(the C<-b> option). + +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); + +Get the autosync flag. + +This function returns a C truth value on success or -1 on error. + +=head2 guestfs_get_e2label + + char *guestfs_get_e2label (guestfs_h *handle, + const char *device); + +This returns the ext2/3/4 filesystem label of the filesystem on +C. + +This function returns a string, or NULL on error. +I. + +=head2 guestfs_get_e2uuid + + char *guestfs_get_e2uuid (guestfs_h *handle, + const char *device); + +This returns the ext2/3/4 filesystem UUID of the filesystem on +C. + +This function returns a string, or NULL on error. +I. + +=head2 guestfs_get_memsize + + int guestfs_get_memsize (guestfs_h *handle); + +This gets the memory size in megabytes allocated to the +qemu subprocess. + +If C was not called +on this handle, and if C was not set, +then this returns the compiled-in default value for memsize. + +For more information on the architecture of libguestfs, +see L. + +On error this function returns -1. + +=head2 guestfs_get_path + + const char *guestfs_get_path (guestfs_h *handle); + +Return the current search path. + +This is always non-NULL. If it wasn't set already, then this will +return the default path. + +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_qemu + + const char *guestfs_get_qemu (guestfs_h *handle); + +Return the current qemu binary. + +This is always non-NULL. If it wasn't set already, then this will +return the default qemu binary name. + +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_state + + int guestfs_get_state (guestfs_h *handle); + +This returns the current state as an opaque integer. This is +only useful for printing debug and internal error messages. + +For more information on states, see L. + +On error this function returns -1. + +=head2 guestfs_get_verbose + + int guestfs_get_verbose (guestfs_h *handle); + +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_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 +(like L), or NULL if there was an error. +I. + +=head2 guestfs_ll + + char *guestfs_ll (guestfs_h *handle, + const char *directory); + +List the files in C (relative to the root directory, +there is no cwd) in the format of 'ls -la'. + +This command is mostly useful for interactive sessions. It +is I intended that you try to parse the output string. + +This function returns a string, or NULL on error. +I. + +=head2 guestfs_ls + + char **guestfs_ls (guestfs_h *handle, + const char *directory); + +List the files in C (relative to the root directory, +there is no cwd). The '.' and '..' entries are not returned, but +hidden files are shown. + +This command is mostly useful for interactive sessions. Programs +should probably use C instead. + +This function returns a NULL-terminated array of strings +(like L), or NULL if there was an error. +I. + +=head2 guestfs_lstat + + struct guestfs_stat *guestfs_lstat (guestfs_h *handle, + const char *path); + +Returns file information for the given C. + +This is the same as C except that if C +is a symbolic link, then the link is stat-ed, not the file it +refers to. + +This is the same as the C system call. + +This function returns a C +(see L and Eguestfs-structs.hE), +or NULL if there was an error. +I after use>. + +=head2 guestfs_lvcreate + + int guestfs_lvcreate (guestfs_h *handle, + const char *logvol, + const char *volgroup, + int mbytes); + +This creates an LVM volume group called C +on the volume group C, with C megabytes. + +This function returns 0 on success or -1 on error. + +=head2 guestfs_lvm_remove_all + + int guestfs_lvm_remove_all (guestfs_h *handle); + +This command removes all LVM logical volumes, volume groups +and physical volumes. + +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); + +List all the logical volumes detected. This is the equivalent +of the L command. + +This returns a list of the logical volume device names +(eg. C). + +See also C. + +This function returns a NULL-terminated array of strings +(like L), or NULL if there was an error. +I. + +=head2 guestfs_lvs_full + + struct guestfs_lvm_lv_list *guestfs_lvs_full (guestfs_h *handle); + +List all the logical volumes detected. This is the equivalent +of the L command. The "full" version includes all fields. + +This function returns a C +(see Eguestfs-structs.hE), +or NULL if there was an error. +I after use>. + +=head2 guestfs_mkdir + + int guestfs_mkdir (guestfs_h *handle, + const char *path); + +Create a directory named C. + +This function returns 0 on success or -1 on error. + +=head2 guestfs_mkdir_p + + int guestfs_mkdir_p (guestfs_h *handle, + const char *path); + +Create a directory named C, creating any parent directories +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