X-Git-Url: http://git.annexia.org/?p=libguestfs.git;a=blobdiff_plain;f=inspector%2Fvirt-inspector.pl;h=d2acf0620a3b0ce24ca80110d567e65f6f36e82f;hp=3754ceda1299cef25497d4f6e39287f6083126f3;hb=06df9ec2413d7f5ae366bfab1b2177d7b3929837;hpb=b3595c5553035798b7b33d05c9326f7e8dd55e69 diff --git a/inspector/virt-inspector.pl b/inspector/virt-inspector.pl index 3754ced..d2acf06 100755 --- a/inspector/virt-inspector.pl +++ b/inspector/virt-inspector.pl @@ -207,10 +207,15 @@ pod2usage (__"virt-inspector: no image or VM names given") if @ARGV == 0; my $rw = 0; $rw = 1 if $output eq "fish"; my $g; +my @images; if ($uri) { - $g = open_guest (\@ARGV, rw => $rw, address => $uri); + my ($conn, $dom); + ($g, $conn, $dom, @images) = + open_guest (\@ARGV, rw => $rw, address => $uri); } else { - $g = open_guest (\@ARGV, rw => $rw); + my ($conn, $dom); + ($g, $conn, $dom, @images) = + open_guest (\@ARGV, rw => $rw); } $g->launch (); @@ -302,7 +307,7 @@ if ($output eq "fish" || $output eq "ro-fish") { print "--ro "; } - print "-a $_ " foreach @ARGV; + print "-a $_ " foreach @images; my $mounts = $oses->{$root_dev}->{mounts}; # Have to mount / first. Luckily '/' is early in the ASCII @@ -352,7 +357,10 @@ sub output_text_os print $os->{os}, " " if exists $os->{os}; print $os->{distro}, " " if exists $os->{distro}; - print $os->{version}, " " if exists $os->{version}; + print $os->{arch}, " " if exists $os->{arch}; + print $os->{major_version} if exists $os->{major_version}; + print ".", $os->{minor_version} if exists $os->{minor_version}; + print " "; print "on ", $os->{root_device}, ":\n"; print __" Mountpoints:\n"; @@ -408,7 +416,7 @@ sub output_text_os print __" Kernels:\n"; my @kernels = @{$os->{kernels}}; foreach (@kernels) { - print " $_->{version}\n"; + print " $_->{version} ($_->{arch})\n"; my @modules = @{$_->{modules}}; foreach (@modules) { print " $_\n"; @@ -443,7 +451,11 @@ sub output_xml_os foreach ( [ "name" => "os" ], [ "distro" => "distro" ], - [ "version" => "version" ], + [ "arch" => "arch" ], + [ "major_version" => "major_version" ], + [ "minor_version" => "minor_version" ], + [ "package_format" => "package_format" ], + [ "package_management" => "package_management" ], [ "root" => "root_device" ] ) { $xml->dataElement($_->[0], $os->{$_->[1]}) if exists $os->{$_->[1]}; } @@ -521,7 +533,9 @@ sub output_xml_os $xml->startTag("kernels"); my @kernels = @{$os->{kernels}}; foreach (@kernels) { - $xml->startTag("kernel", "version" => $_->{version}); + $xml->startTag("kernel", + "version" => $_->{version}, + "arch" => $_->{arch}); $xml->startTag("modules"); my @modules = @{$_->{modules}}; foreach (@modules) { @@ -581,6 +595,8 @@ sub output_query output_query_xen_domU_kernel (); output_query_xen_pv_drivers (); output_query_virtio_drivers (); + output_query_kernel_arch (); + output_query_userspace_arch (); } =item windows=(yes|no) @@ -623,7 +639,8 @@ sub output_query_rhel { my $rhel = "no"; foreach my $os (keys %$oses) { - $rhel="yes" if $oses->{$os}->{os} eq "linux" && $oses->{$os}->{distro} eq "redhat"; + $rhel="yes" if ($oses->{$os}->{os} eq "linux" && + $oses->{$os}->{distro} eq "rhel"); } print "rhel=$rhel\n"; } @@ -752,6 +769,50 @@ sub output_query_virtio_drivers print "virtio_drivers=no\n"; } +=item userspace_arch=(x86_64|...) + +Print the architecture of userspace. + +NB. For multi-boot VMs this can print several lines. + +=cut + +sub output_query_userspace_arch +{ + my %arches; + + foreach my $os (keys %$oses) { + $arches{$oses->{$os}->{arch}} = 1 if exists $oses->{$os}->{arch}; + } + + foreach (sort keys %arches) { + print "userspace_arch=$_\n"; + } +} + +=item kernel_arch=(x86_64|...) + +Print the architecture of the kernel. + +NB. For multi-boot VMs this can print several lines. + +=cut + +sub output_query_kernel_arch +{ + my %arches; + + foreach my $os (keys %$oses) { + foreach my $kernel (@{$oses->{$os}->{kernels}}) { + $arches{$kernel->{arch}} = 1 if exists $kernel->{arch}; + } + } + + foreach (sort keys %arches) { + print "kernel_arch=$_\n"; + } +} + =back =head1 SEE ALSO