diff options
Diffstat (limited to 'perl/examples')
-rw-r--r-- | perl/examples/LICENSE | 2 | ||||
-rw-r--r-- | perl/examples/README | 17 | ||||
-rwxr-xr-x | perl/examples/lvs.pl | 29 |
3 files changed, 48 insertions, 0 deletions
diff --git a/perl/examples/LICENSE b/perl/examples/LICENSE new file mode 100644 index 00000000..ff237009 --- /dev/null +++ b/perl/examples/LICENSE @@ -0,0 +1,2 @@ +All the examples in the perl/examples/ subdirectory may be freely +copied without any restrictions. diff --git a/perl/examples/README b/perl/examples/README new file mode 100644 index 00000000..a7c654f7 --- /dev/null +++ b/perl/examples/README @@ -0,0 +1,17 @@ +This directory contains various example programs which use the perl +Sys::Guestfs bindings to the libguestfs API. + +As they are examples, these are licensed so they can be freely copied +and used without any restrictions. + +Tips: + +(1) To enable verbose messages, set environment variable LIBGUESTFS_DEBUG=1 + +(2) To run a program without installing the library, set PERL5LIB and +LIBGUESTFS_PATH as in this example (if run from the root directory of +the source distribution): + + LIBGUESTFS_PATH=$(pwd) \ + PERL5LIB=$(pwd)/perl/blib/lib:$(pwd)/perl/blib/arch/auto/Sys/Guestfs \ + perl/examples/foo diff --git a/perl/examples/lvs.pl b/perl/examples/lvs.pl new file mode 100755 index 00000000..152db088 --- /dev/null +++ b/perl/examples/lvs.pl @@ -0,0 +1,29 @@ +#!/usr/bin/perl -w + +use strict; + +use Sys::Guestfs; + +# Look for LVM LVs, VGs and PVs in a guest image. + +die "Usage: lvs.pl guest.img\n" if @ARGV != 1 || ! -f $ARGV[0]; + +print "Creating the libguestfs handle\n"; +my $h = Sys::Guestfs->new (); +$h->add_drive ($ARGV[0]); + +print "Launching, this can take a few seconds\n"; +$h->launch (); +$h->wait_ready (); + +print "Looking for PVs on the disk image\n"; +my @pvs = $h->pvs (); +print "PVs found: (", join (", ", @pvs), ")\n"; + +print "Looking for VGs on the disk image\n"; +my @vgs = $h->vgs (); +print "VGs found: (", join (", ", @vgs), ")\n"; + +print "Looking for LVs on the disk image\n"; +my @lvs = $h->lvs (); +print "LVs found: (", join (", ", @lvs), ")\n"; |