X-Git-Url: http://git.annexia.org/?p=libguestfs.git;a=blobdiff_plain;f=perl%2Fexamples%2Flvs.pl;fp=perl%2Fexamples%2Flvs.pl;h=152db08824698b75fe5608271286f99f74a71dea;hp=0000000000000000000000000000000000000000;hb=9908e03e922b670437bcd89b6873f9ebc914567e;hpb=00e309d3608661eaa8c9cc69ba5bf175c612698d diff --git a/perl/examples/lvs.pl b/perl/examples/lvs.pl new file mode 100755 index 0000000..152db08 --- /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";