# libguestfs generated file # WARNING: THIS FILE IS GENERATED BY 'src/generator.ml'. # ANY CHANGES YOU MAKE TO THIS FILE WILL BE LOST. # # Copyright (C) 2009 Red Hat Inc. # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public # License as published by the Free Software Foundation; either # version 2 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public # License along with this library; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA =pod =head1 NAME Sys::Guestfs - Perl bindings for libguestfs =head1 SYNOPSIS use Sys::Guestfs; my $h = Sys::Guestfs->new (); $h->add_drive ('guest.img'); $h->launch (); $h->wait_ready (); $h->mount ('/dev/sda1', '/'); $h->touch ('/hello'); $h->sync (); =head1 DESCRIPTION The C module provides a Perl XS binding to the libguestfs API for examining and modifying virtual machine disk images. Amongst the things this is good for: making batch configuration changes to guests, getting disk used/free statistics (see also: virt-df), migrating between virtualization systems (see also: virt-p2v), performing partial backups, performing partial guest clones, cloning guests and changing registry/UUID/hostname info, and much else besides. Libguestfs uses Linux kernel and qemu code, and can access any type of guest filesystem that Linux and qemu can, including but not limited to: ext2/3/4, btrfs, FAT and NTFS, LVM, many different disk partition schemes, qcow, qcow2, vmdk. Libguestfs provides ways to enumerate guest storage (eg. partitions, LVs, what filesystem is in each LV, etc.). It can also run commands in the context of the guest. Also you can access filesystems over FTP. =head1 ERRORS All errors turn into calls to C (see L). =head1 METHODS =over 4 =cut package Sys::Guestfs; use strict; use warnings; require XSLoader; XSLoader::load ('Sys::Guestfs'); =item $h = Sys::Guestfs->new (); Create a new guestfs handle. =cut sub new { my $proto = shift; my $class = ref ($proto) || $proto; my $self = Sys::Guestfs::_create (); bless $self, $class; return $self; } =item $h->add_cdrom ($filename); 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<$h-Econfig> call instead. =item $h->add_drive ($filename); This function adds a virtual machine disk image C to the guest. The first time you call this function, the disk appears as IDE disk 0 (C) in the guest, the second time as C, and so on. You don't necessarily need to be root when using libguestfs. However you obviously do need sufficient permissions to access the filename 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>. 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<$h-Econfig> call instead. =item $h->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<$h-Econfig> call instead. =item $h->aug_close (); Close the current Augeas handle and free up any resources used by it. After calling this, you have to call C<$h-Eaug_init> again before you can use any other Augeas functions. =item ($nrnodes, $created) = $h->aug_defnode ($name, $expr, $val); 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<$h-Eaug_set> C, C. C will be the nodeset containing that single node. On success this returns a pair containing the number of nodes in the nodeset, and a boolean flag if a node was created. =item $nrnodes = $h->aug_defvar ($name, $expr); Defines an Augeas variable C whose value is the result of evaluating C. If C is NULL, then C is undefined. On success this returns the number of nodes in C, or C<0> if C evaluates to something which is not a nodeset. =item $val = $h->aug_get ($path); Look up the value associated with C. If C matches exactly one node, the C is returned. =item $h->aug_init ($root, $flags); 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<$h-Eaug_*> commands. C is the filesystem root. C must not be NULL, use C instead. The flags are the same as the flags defined in Eaugeas.hE, the logical I of the following integers: =over 4 =item C = 1 Keep the original file with a C<.augsave> extension. =item C = 2 Save changes into a file with extension C<.augnew>, and do not overwrite original. Overrides C. =item C = 4 Typecheck lenses (can be expensive). =item C = 8 Do not use standard load path for modules. =item C = 16 Make save a no-op, just record what would have been changed. =item C = 32 Do not load the tree in C<$h-Eaug_init>. =back To close the handle, you can call C<$h-Eaug_close>. To find out more about Augeas, see L. =item $h->aug_insert ($path, $label, $before); Create a new sibling C