X-Git-Url: http://git.annexia.org/?a=blobdiff_plain;f=inspector%2Fvirt-inspector.pl;h=c5c3813571ca4941b6fb0275e232d1e96c9ba88c;hb=e595146b5c742de5604a175f0d150931d9f6aa6d;hp=c8c045e12f02728fcab59259e3cb4f4597f697fb;hpb=6f2929c4635c3f2af4a9211981d9edd1f58cce69;p=libguestfs.git
diff --git a/inspector/virt-inspector.pl b/inspector/virt-inspector.pl
index c8c045e..c5c3813 100755
--- a/inspector/virt-inspector.pl
+++ b/inspector/virt-inspector.pl
@@ -566,12 +566,6 @@ if ($output !~ /.*fish$/) {
check_for_applications ($root_dev);
check_for_kernels ($root_dev);
- # umount_all in libguestfs is buggy - it doesn't unmount
- # filesystems in the correct order. So let's unmount them
- # in reverse first before calling umount_all as a last resort.
- foreach (sort { $b cmp $a } keys %$mounts) {
- eval "\$g->umount ('$_')";
- }
$g->umount_all ();
}
}
@@ -581,7 +575,40 @@ sub check_for_applications
local $_;
my $root_dev = shift;
- # XXX rpm -qa, look in Program Files, or whatever
+ my @apps;
+
+ my $os = $oses{$root_dev}->{os};
+ if ($os eq "linux") {
+ my $distro = $oses{$root_dev}->{distro};
+ if ($distro eq "redhat") {
+ my @lines = $g->command_lines
+ (["rpm", "-q", "-a", "--qf",
+ "%{name} %{epoch} %{version} %{release} %{arch}\n"]);
+ foreach (@lines) {
+ if (m/^(.*) (.*) (.*) (.*) (.*)$/) {
+ my $epoch = $2;
+ $epoch = "" if $epoch eq "(none)";
+ my $app = {
+ name => $1,
+ epoch => $epoch,
+ version => $3,
+ release => $4,
+ arch => $5
+ };
+ push @apps, $app
+ }
+ }
+ }
+ } elsif ($os eq "windows") {
+ # XXX
+ # I worked out a general plan for this, but haven't
+ # implemented it yet. We can iterate over /Program Files
+ # looking for *.EXE files, which we download, then use
+ # i686-pc-mingw32-windres on, to find the VERSIONINFO
+ # section, which has a lot of useful information.
+ }
+
+ $oses{$root_dev}->{apps} = \@apps;
}
sub check_for_kernels
@@ -625,24 +652,111 @@ elsif ($output eq "perl") {
# Plain text output (the default).
elsif ($output eq "text") {
- # XXX text output.
+ output_text ();
+}
+# XML output.
+elsif ($output eq "xml") {
+ output_xml ();
+}
+sub output_text
+{
+ output_text_os ($oses{$_}) foreach sort keys %oses;
+}
+sub output_text_os
+{
+ my $os = shift;
+ print $os->{os}, " " if exists $os->{os};
+ print $os->{distro}, " " if exists $os->{distro};
+ print $os->{version}, " " if exists $os->{version};
+ print "on ", $os->{root_device}, ":\n";
-}
+ print " Mountpoints:\n";
+ my $mounts = $os->{mounts};
+ foreach (sort keys %$mounts) {
+ printf " %-30s %s\n", $mounts->{$_}, $_
+ }
-# XML output.
-elsif ($output eq "xml") {
- # XXX XML output.
+ print " Filesystems:\n";
+ my $filesystems = $os->{filesystems};
+ foreach (sort keys %$filesystems) {
+ print " $_:\n";
+ print " label: $filesystems->{$_}{label}\n"
+ if exists $filesystems->{$_}{label};
+ print " UUID: $filesystems->{$_}{uuid}\n"
+ if exists $filesystems->{$_}{uuid};
+ print " type: $filesystems->{$_}{fstype}\n"
+ if exists $filesystems->{$_}{fstype};
+ print " content: $filesystems->{$_}{content}\n"
+ if exists $filesystems->{$_}{content};
+ }
+ print " Applications:\n";
+ my @apps = @{$os->{apps}};
+ foreach (@apps) {
+ print " $_->{name} $_->{version}\n"
+ }
+ # XXX Kernel.
+}
+sub output_xml
+{
+ print "\n";
+ output_xml_os ($oses{$_}) foreach sort keys %oses;
+ print "\n";
+}
+sub output_xml_os
+{
+ my $os = shift;
+
+ print "\n";
+ print "", $os->{os}, "\n" if exists $os->{os};
+ print "", $os->{distro}, "\n" if exists $os->{distro};
+ print "", $os->{version}, "\n" if exists $os->{version};
+ print "", $os->{root_device}, "\n";
+
+ print "\n";
+ my $mounts = $os->{mounts};
+ foreach (sort keys %$mounts) {
+ printf "%s\n",
+ $mounts->{$_}, $_
+ }
+ print "\n";
+
+ print "\n";
+ my $filesystems = $os->{filesystems};
+ foreach (sort keys %$filesystems) {
+ print "\n";
+ print "\n"
+ if exists $filesystems->{$_}{label};
+ print "$filesystems->{$_}{uuid}\n"
+ if exists $filesystems->{$_}{uuid};
+ print "$filesystems->{$_}{fstype}\n"
+ if exists $filesystems->{$_}{fstype};
+ print "$filesystems->{$_}{content}\n"
+ if exists $filesystems->{$_}{content};
+ print "\n";
+ }
+ print "\n";
+
+ print "\n";
+ my @apps = @{$os->{apps}};
+ foreach (@apps) {
+ print "\n";
+ print "$_->{name}$_->{version}\n";
+ print "\n";
+ }
+ print "\n";
+ # XXX Kernel.
+ print "\n";
}
=head1 SEE ALSO