diff options
author | Richard Jones <rjones@redhat.com> | 2010-05-07 23:15:40 +0100 |
---|---|---|
committer | Richard Jones <rjones@redhat.com> | 2010-05-07 23:15:40 +0100 |
commit | 94775c53f163926ef99e6c6b8ab67b402935301d (patch) | |
tree | 1cda59abbab08e8f1aded2a9a1ad064290d58eb2 /perl | |
parent | f606a79ed7a20ee59bc0755b1030c6d29e503724 (diff) | |
download | libguestfs-94775c53f163926ef99e6c6b8ab67b402935301d.tar.gz libguestfs-94775c53f163926ef99e6c6b8ab67b402935301d.tar.xz libguestfs-94775c53f163926ef99e6c6b8ab67b402935301d.zip |
inspector: Support filesystem-on-image VMs (RHBZ#590167).
$ virt-df /tmp/dbroot.img
Filesystem 1K-blocks Used Available Use%
/tmp/dbroot.img:/dev/vda 3096336 593628 2345424 20%
Diffstat (limited to 'perl')
-rw-r--r-- | perl/lib/Sys/Guestfs/Lib.pm | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/perl/lib/Sys/Guestfs/Lib.pm b/perl/lib/Sys/Guestfs/Lib.pm index 8ec487dc..d3d652eb 100644 --- a/perl/lib/Sys/Guestfs/Lib.pm +++ b/perl/lib/Sys/Guestfs/Lib.pm @@ -260,16 +260,27 @@ This function takes an open libguestfs handle C<$g> and returns all partitions and logical volumes found on it. What is returned is everything that could contain a filesystem (or -swap). Physical volumes are excluded from the list, and so are any -devices which are partitioned (eg. C</dev/sda> would not be returned -if C</dev/sda1> exists). +swap). Physical volumes are not normally included from the list +except if they contain a filesystem directly. Nor are devices which +are partitioned (eg. C</dev/sda> would not be returned if C</dev/sda1> +exists). =cut sub get_partitions { + local $_; my $g = shift; + # Look to see if any devices directly contain filesystems (RHBZ#590167). + my @devices = $g->list_devices (); + my @fses_on_device = (); + foreach (@devices) { + eval { $g->mount_ro ($_, "/"); }; + push @fses_on_device, $_ unless $@; + $g->umount_all (); + } + my @partitions = $g->list_partitions (); my @pvs = $g->pvs (); @partitions = grep { ! _is_pv ($_, @pvs) } @partitions; @@ -277,7 +288,7 @@ sub get_partitions my @lvs; @lvs = $g->lvs () if feature_available ($g, "lvm2"); - return sort (@lvs, @partitions); + return sort (@fses_on_device, @lvs, @partitions); } sub _is_pv { |