X-Git-Url: http://git.annexia.org/?p=libguestfs.git;a=blobdiff_plain;f=perl%2Flib%2FSys%2FGuestfs.pm;h=ea82659256c01f5e1bba0cde3ef36afe9c1c9918;hp=36bedd5e1ffc5c57cf1a25cabe3d0c80ec1083e0;hb=79cdf81e2fb717ea4372a55170d16800cdbddf23;hpb=ad5abc8d367c9c410051062cae066b1b141b4c76 diff --git a/perl/lib/Sys/Guestfs.pm b/perl/lib/Sys/Guestfs.pm index 36bedd5..ea82659 100644 --- a/perl/lib/Sys/Guestfs.pm +++ b/perl/lib/Sys/Guestfs.pm @@ -245,19 +245,141 @@ how files are saved. Set the value associated with C to C. +=item $h->blockdev_flushbufs ($device); + +This tells the kernel to flush internal buffers associated +with C. + +This uses the L command. + +=item $blocksize = $h->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. + +=item $ro = $h->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. + +=item $sizeinbytes = $h->blockdev_getsize64 ($device); + +This returns the size of the device in bytes. + +See also C<$h-Eblockdev_getsz>. + +This uses the L command. + +=item $sectorsize = $h->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<$h-Eblockdev_getsz> +for that). + +This uses the L command. + +=item $sizeinsectors = $h->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<$h-Eblockdev_getss> for the real sector size of +the device, and C<$h-Eblockdev_getsize64> for the more +useful I. + +This uses the L command. + +=item $h->blockdev_rereadpt ($device); + +Reread the partition table on C. + +This uses the L command. + +=item $h->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. + +=item $h->blockdev_setro ($device); + +Sets the block device named C to read-only. + +This uses the L command. + +=item $h->blockdev_setrw ($device); + +Sets the block device named C to read-write. + +This uses the L command. + =item $content = $h->cat ($path); 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<$h-Eread_file> +as end of string). For those you need to use the C<$h-Edownload> 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. +=item $checksum = $h->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. + =item $h->chmod ($mode, $path); Change the mode (permissions) of C to C. Only @@ -310,6 +432,15 @@ The first character of C string must be a C<-> (dash). C can be NULL. +=item $h->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<$h-Eupload>, C<$h-Ecat>. + =item $existsflag = $h->exists ($path); This returns C if and only if there is a file, directory @@ -338,10 +469,38 @@ Return the current search path. This is always non-NULL. If it wasn't set already, then this will return the default path. +=item $qemu = $h->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. + +=item $state = $h->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. + =item $verbose = $h->get_verbose (); This returns the verbose messages flag. +=item $busy = $h->is_busy (); + +This returns true iff this handle is busy processing a command +(in the C state). + +For more information on states, see L. + +=item $config = $h->is_config (); + +This returns true iff this handle is being configured +(in the C state). + +For more information on states, see L. + =item $dirflag = $h->is_dir ($path); This returns C if and only if there is a directory @@ -358,6 +517,20 @@ other objects like directories. See also C<$h-Estat>. +=item $launching = $h->is_launching (); + +This returns true iff this handle is launching the subprocess +(in the C state). + +For more information on states, see L. + +=item $ready = $h->is_ready (); + +This returns true iff this handle is ready to accept commands +(in the C state). + +For more information on states, see L. + =item $h->kill_subprocess (); This kills the qemu subprocess. You should never need to call this. @@ -474,6 +647,23 @@ on the underlying device. The filesystem options C and C are set with this call, in order to improve reliability. +=item $h->mount_options ($options, $device, $mountpoint); + +This is the same as the C<$h-Emount> command, but it +allows you to set the mount options as for the +L I<-o> flag. + +=item $h->mount_ro ($device, $mountpoint); + +This is the same as the C<$h-Emount> command, but it +mounts the filesystem with the read-only (I<-o ro>) flag. + +=item $h->mount_vfs ($options, $vfstype, $device, $mountpoint); + +This is the same as the C<$h-Emount> command, but it +allows you to set both the mount options and the vfstype +as for the L I<-o> and I<-t> flags. + =item @devices = $h->mounts (); This returns the list of currently mounted filesystems. It returns @@ -534,6 +724,13 @@ If C is true, this enables autosync. Libguestfs will make a best effort attempt to run C<$h-Esync> when the handle is closed (also if the program exits without closing handles). +=item $h->set_busy (); + +This sets the state to C. This is only used when implementing +actions using the low-level API. + +For more information on states, see L. + =item $h->set_path ($path); Set the path that libguestfs searches for kernel and initrd.img. @@ -546,6 +743,28 @@ must make sure it remains valid for the lifetime of the handle. Setting C to C restores the default path. +=item $h->set_qemu ($qemu); + +Set the qemu binary that we will use. + +The default is chosen when the library was compiled by the +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. + +=item $h->set_ready (); + +This sets the state to C. This is only used when implementing +actions using the low-level API. + +For more information on states, see L. + =item $h->set_verbose ($verbose); If C is true, this turns on verbose messages (to C). @@ -600,6 +819,34 @@ underlying disk image. You should always call this if you have modified a disk image, before closing the handle. +=item $h->tar_in ($tarfile, $directory); + +This command uploads and unpacks local file C (an +I tar file) into C. + +To upload a compressed tarball, use C<$h-Etgz_in>. + +=item $h->tar_out ($directory, $tarfile); + +This command packs the contents of C and downloads +it to local file C. + +To download a compressed tarball, use C<$h-Etgz_out>. + +=item $h->tgz_in ($tarball, $directory); + +This command uploads and unpacks local file C (a +I tar file) into C. + +To upload an uncompressed tarball, use C<$h-Etar_in>. + +=item $h->tgz_out ($directory, $tarball); + +This command packs the contents of C and downloads +it to local file C. + +To download an uncompressed tarball, use C<$h-Etar_out>. + =item $h->touch ($path); Touch acts like the L command. It can be used to @@ -628,6 +875,15 @@ This unmounts all mounted filesystems. Some internal mounts are not unmounted by this call. +=item $h->upload ($filename, $remotefilename); + +Upload local file C to C on the +filesystem. + +C can also be a named pipe. + +See also C<$h-Edownload>. + =item $h->vgcreate ($volgroup, \@physvols); This creates an LVM volume group called C