summaryrefslogtreecommitdiffstats
path: root/perl/examples
diff options
context:
space:
mode:
authorRichard Jones <rjones@redhat.com>2009-04-08 15:02:39 +0100
committerRichard Jones <rjones@redhat.com>2009-04-08 15:02:39 +0100
commit9908e03e922b670437bcd89b6873f9ebc914567e (patch)
tree30d8b8adfb5cfbd864f7e91cf8268a29344366d0 /perl/examples
parent00e309d3608661eaa8c9cc69ba5bf175c612698d (diff)
downloadlibguestfs-9908e03e922b670437bcd89b6873f9ebc914567e.tar.gz
libguestfs-9908e03e922b670437bcd89b6873f9ebc914567e.tar.xz
libguestfs-9908e03e922b670437bcd89b6873f9ebc914567e.zip
Fixed Perl bindings, they now work properly.
Diffstat (limited to 'perl/examples')
-rw-r--r--perl/examples/LICENSE2
-rw-r--r--perl/examples/README17
-rwxr-xr-xperl/examples/lvs.pl29
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";