X-Git-Url: http://git.annexia.org/?p=libguestfs.git;a=blobdiff_plain;f=inspector%2Fvirt-inspector.pl;h=4ee0e08a29d0d911abec84096f34b26c32ce078d;hp=a5ba00502bcf7883594370448bbcdcc12e4e58e6;hb=e02066bcb33a2aed5f23dd18c3168dc66efddb18;hpb=0faa5dde7b992ba11bb88f77b3424676c7c492e4 diff --git a/inspector/virt-inspector.pl b/inspector/virt-inspector.pl index a5ba005..4ee0e08 100755 --- a/inspector/virt-inspector.pl +++ b/inspector/virt-inspector.pl @@ -434,8 +434,7 @@ sub check_windows_root local $_; my $r = shift; - # XXX Windows version. - # List of applications. + # Windows version? } sub check_grub @@ -443,7 +442,7 @@ sub check_grub local $_; my $r = shift; - # XXX Kernel versions, grub version. + # Grub version, if we care. } #print Dumper (\%fses); @@ -586,7 +585,7 @@ sub check_for_applications "%{name} %{epoch} %{version} %{release} %{arch}\n"]); foreach (@lines) { if (m/^(.*) (.*) (.*) (.*) (.*)$/) { - $epoch = $2; + my $epoch = $2; $epoch = "" if $epoch eq "(none)"; my $app = { name => $1, @@ -600,9 +599,15 @@ sub check_for_applications } } } elsif ($os eq "windows") { - # This sucks ... XXX - XXX + # 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 @@ -610,7 +615,37 @@ sub check_for_kernels local $_; my $root_dev = shift; - # XXX + my @kernels; + + my $os = $oses{$root_dev}->{os}; + if ($os eq "linux") { + # Installed kernels will have a corresponding /lib/modules/ + # directory, which is the easiest way to find out what kernels + # are installed, and what modules are available. + foreach ($g->ls ("/lib/modules")) { + if ($g->is_dir ("/lib/modules/$_")) { + my %kernel; + $kernel{version} = $_; + + # List modules. + my @modules; + foreach ($g->find ("/lib/modules/$_")) { + if (m,/([^/]+)\.ko,) { + push @modules, $1; + } + } + + $kernel{modules} = \@modules; + + push @kernels, \%kernel; + } + } + + } elsif ($os eq "windows") { + # XXX + } + + $oses{$root_dev}->{kernels} = \@kernels; } #---------------------------------------------------------------------- @@ -688,8 +723,21 @@ sub output_text_os if exists $filesystems->{$_}{content}; } - # XXX Applications. - # XXX Kernel. + print " Applications:\n"; + my @apps = @{$os->{apps}}; + foreach (@apps) { + print " $_->{name} $_->{version}\n" + } + + print " Kernels:\n"; + my @kernels = @{$os->{kernels}}; + foreach (@kernels) { + print " $_->{version}\n"; + my @modules = @{$_->{modules}}; + foreach (@modules) { + print " $_\n"; + } + } } sub output_xml @@ -734,8 +782,30 @@ sub output_xml_os } print "\n"; - # XXX Applications. - # XXX Kernel. + print "\n"; + my @apps = @{$os->{apps}}; + foreach (@apps) { + print "\n"; + print "$_->{name}$_->{version}\n"; + print "\n"; + } + print "\n"; + + print "\n"; + my @kernels = @{$os->{kernels}}; + foreach (@kernels) { + print "\n"; + print "$_->{version}\n"; + print "\n"; + my @modules = @{$_->{modules}}; + foreach (@modules) { + print "$_\n"; + } + print "\n"; + print "\n"; + } + print "\n"; + print "\n"; }