X-Git-Url: http://git.annexia.org/?p=libguestfs.git;a=blobdiff_plain;f=guestfish-actions.pod;h=e21dc7b728b22d9dc25d5832155a19f750b0f064;hp=fbf2f97c678b261522e5a180bbb978c5ec852edd;hb=215041c7178922341ecbfdb23eb203f2bb8c29c4;hpb=5a563bbd9b2779640e3358f4bf1eaac622b58cae diff --git a/guestfish-actions.pod b/guestfish-actions.pod index fbf2f97..e21dc7b 100644 --- a/guestfish-actions.pod +++ b/guestfish-actions.pod @@ -6,6 +6,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. + =head2 add-drive | add add-drive filename @@ -21,7 +26,33 @@ 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. + +=head2 add-drive-ro | add-ro + + add-drive-ro 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. =head2 aug-close @@ -29,7 +60,7 @@ This is equivalent to the qemu parameter C<-drive file=filename>. Close the current Augeas handle and free up any resources used by it. After calling this, you have to call -C again before you can use any other +C again before you can use any other Augeas functions. =head2 aug-defnode @@ -40,7 +71,7 @@ Defines a variable C whose value is the result of evaluating C. If C evaluates to an empty nodeset, a node is created, -equivalent to calling C C, C. +equivalent to calling C C, C. C will be the nodeset containing that single node. On success this returns a pair containing the @@ -73,7 +104,7 @@ Create a new Augeas handle for editing configuration files. If there was any previous Augeas handle associated with this guestfs session, then it is closed. -You must call this before using any other C +You must call this before using any other C commands. C is the filesystem root. C must not be NULL, @@ -108,11 +139,11 @@ Make save a no-op, just record what would have been changed. =item C = 32 -Do not load the tree in C. +Do not load the tree in C. =back -To close the handle, you can call C. +To close the handle, you can call C. To find out more about Augeas, see L. @@ -141,7 +172,7 @@ details. aug-ls path -This is just a shortcut for listing C +This is just a shortcut for listing C C and sorting the resulting nodes into alphabetical order. =head2 aug-match @@ -173,7 +204,7 @@ On success this returns the number of entries which were removed. This writes all pending changes to disk. -The flags which were passed to C affect exactly +The flags which were passed to C affect exactly how files are saved. =head2 aug-set @@ -182,6 +213,105 @@ how files are saved. Set the value associated with C to C. +=head2 blockdev-flushbufs + + blockdev-flushbufs device + +This tells the kernel to flush internal buffers associated +with C. + +This uses the L command. + +=head2 blockdev-getbsz + + blockdev-getbsz device + +This returns the block size of a device. + +(Note this is different from both I and +I). + +This uses the L command. + +=head2 blockdev-getro + + blockdev-getro device + +Returns a boolean indicating if the block device is read-only +(true if read-only, false if not). + +This uses the L command. + +=head2 blockdev-getsize64 + + blockdev-getsize64 device + +This returns the size of the device in bytes. + +See also C. + +This uses the L command. + +=head2 blockdev-getss + + blockdev-getss device + +This returns the size of sectors on a block device. +Usually 512, but can be larger for modern devices. + +(Note, this is not the size in sectors, use C +for that). + +This uses the L command. + +=head2 blockdev-getsz + + blockdev-getsz device + +This returns the size of the device in units of 512-byte sectors +(even if the sectorsize isn't 512 bytes ... weird). + +See also C for the real sector size of +the device, and C for the more +useful I. + +This uses the L command. + +=head2 blockdev-rereadpt + + blockdev-rereadpt device + +Reread the partition table on C. + +This uses the L command. + +=head2 blockdev-setbsz + + blockdev-setbsz device blocksize + +This sets the block size of a device. + +(Note this is different from both I and +I). + +This uses the L command. + +=head2 blockdev-setro + + blockdev-setro device + +Sets the block device named C to read-only. + +This uses the L command. + +=head2 blockdev-setrw + + blockdev-setrw device + +Sets the block device named C to read-write. + +This uses the L command. + =head2 cat cat path @@ -190,13 +320,58 @@ Return the contents of the file named 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 +as end of string). For those you need to use the C function which has a more complex interface. 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 checksum + + checksum csumtype 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. + =head2 chmod chmod mode path @@ -216,7 +391,7 @@ yourself (Augeas support makes this relatively easy). =head2 command - command arguments,... + command 'arguments ...' This call runs a command from the guest filesystem. The filesystem must be mounted, and must contain a compatible @@ -226,7 +401,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 @@ -239,13 +423,23 @@ correct places. It is the caller's responsibility to ensure all filesystems that are needed are mounted at the right locations. +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 command-lines - command-lines arguments,... + command-lines 'arguments ...' This is the same as C, but splits the result into a list of lines. +See also: C + +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 config config qemuparam qemuvalue @@ -259,6 +453,92 @@ The first character of C string must be a C<-> (dash). C can be NULL. +=head2 cp + + cp src dest + +This copies a file from C to C where C is +either a destination filename or destination directory. + +=head2 cp-a + + cp-a src dest + +This copies a file or directory from C to C +recursively using the C command. + +=head2 debug + + debug subcmd '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. + +=head2 dmesg + + dmesg + +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. + +=head2 download + + download remotefilename (filename|-) + +Download file C and save it as C +on the local machine. + +C can also be a named pipe. + +See also C, C. + +Use C<-> instead of a filename to read/write from stdin/stdout. + +=head2 drop-caches + + drop-caches 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. + +=head2 e2fsck-f + + e2fsck-f 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. + +=head2 equal + + equal file1 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. + =head2 exists exists path @@ -266,7 +546,7 @@ C can be NULL. This returns C if and only if there is a file, directory (or anything) with the given C name. -See also C, C, C. +See also C, C, C. =head2 file @@ -280,12 +560,96 @@ The exact command which runs is C. Note in particular that the filename is not prepended to the output (the C<-b> option). +=head2 find + + find 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. + +=head2 fsck + + fsck fstype 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. + +=head2 get-append + + get-append + +Return the additional kernel options which are added to the +guest kernel command line. + +If C then no options are added. + =head2 get-autosync get-autosync Get the autosync flag. +=head2 get-e2label + + get-e2label device + +This returns the ext2/3/4 filesystem label of the filesystem on +C. + +=head2 get-e2uuid + + get-e2uuid device + +This returns the ext2/3/4 filesystem UUID of the filesystem on +C. + =head2 get-path get-path @@ -295,12 +659,81 @@ Return the current search path. This is always non-NULL. If it wasn't set already, then this will return the default path. +=head2 get-qemu + + get-qemu + +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. + +=head2 get-state + + get-state + +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. + =head2 get-verbose get-verbose This returns the verbose messages flag. +=head2 glob-expand + + glob-expand 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. + +=head2 grub-install + + grub-install root device + +This command installs GRUB (the Grand Unified Bootloader) on +C, with the root directory being C. + +=head2 hexdump + + hexdump path + +This runs C on the given C. The result is +the human-readable, canonical hex dump of the file. + +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 is-busy + + is-busy + +This returns true iff this handle is busy processing a command +(in the C state). + +For more information on states, see L. + +=head2 is-config + + is-config + +This returns true iff this handle is being configured +(in the C state). + +For more information on states, see L. + =head2 is-dir is-dir path @@ -321,6 +754,24 @@ other objects like directories. See also C. +=head2 is-launching + + is-launching + +This returns true iff this handle is launching the subprocess +(in the C state). + +For more information on states, see L. + +=head2 is-ready + + is-ready + +This returns true iff this handle is ready to accept commands +(in the C state). + +For more information on states, see L. + =head2 kill-subprocess kill-subprocess @@ -377,6 +828,18 @@ hidden files are shown. This command is mostly useful for interactive sessions. Programs should probably use C instead. +=head2 lstat + + lstat 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. + =head2 lvcreate lvcreate logvol volgroup mbytes @@ -394,6 +857,24 @@ and physical volumes. B. +=head2 lvremove + + lvremove 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. + +=head2 lvresize + + lvresize device mbytes + +This resizes (expands or shrinks) an existing LVM logical +volume to C. When reducing, data in the reduced part +is lost. + =head2 lvs lvs @@ -404,7 +885,7 @@ of the L command. This returns a list of the logical volume device names (eg. C). -See also C. +See also C. =head2 lvs-full @@ -426,12 +907,35 @@ Create a directory named C. Create a directory named C, creating any parent directories as necessary. This is like the C shell command. +=head2 mkdtemp + + mkdtemp template + +This command creates a temporary directory. The +C