-=head1 OUTPUT FORMAT
-
- Operating system(s)
- -------------------
- Linux (distro + version)
- Windows (version)
- |
- |
- +--- Filesystems ---------- Installed apps --- Kernel & drivers
- ----------- -------------- ----------------
- mount point => device List of apps Extra information
- mount point => device and versions about kernel(s)
- ... and drivers
- swap => swap device
- (plus lots of extra information
- about each filesystem)
-
-The output of virt-inspector is a complex two-level data structure.
-
-At the top level is a list of the operating systems installed on the
-guest. (For the vast majority of guests, only a single OS is
-installed.) The data returned for the OS includes the name (Linux,
-Windows), the distribution and version.
-
-The diagram above shows what we return for each OS.
-
-With the I<--xml> option the output is mapped into an XML document.
-There is a RELAX-NG schema for this XML in the file
-I<virt-inspector.rng> which normally ships with virt-inspector, or can
-be found in the source.
-
-With the I<--fish> or I<--ro-fish> option the mount points are mapped to
-L<guestfish(1)> command line parameters, so that you can go in
-afterwards and inspect the guest with everything mounted in the
-right place. For example:
-
- guestfish $(virt-inspector --ro-fish guest.img)
- ==> guestfish --ro -a guest.img -m /dev/VG/LV:/ -m /dev/sda1:/boot
-
-=cut
-
-# List of possible filesystems.
-my @partitions = get_partitions ($g);
-
-# Now query each one to build up a picture of what's in it.
-my %fses =
- inspect_all_partitions ($g, \@partitions);
-
-#print "fses -----------\n";
-#print Dumper(\%fses);
-
-my $oses = inspect_operating_systems ($g, \%fses);
-
-#print "oses -----------\n";
-#print Dumper($oses);
-
-# Mount up the disks so we can check for applications
-# and kernels. Skip this if the output is "*fish" because
-# we don't need to know.
-
-if ($output !~ /.*fish$/) {
- my $root_dev;
- foreach $root_dev (sort keys %$oses) {
- my $os = $oses->{$root_dev};
- mount_operating_system ($g, $os);
- inspect_in_detail ($g, $os);
- $g->umount_all ();
- }
-}
-
-#----------------------------------------------------------------------
-# Output.
-
-if ($output eq "fish" || $output eq "ro-fish") {
- my @osdevs = keys %$oses;
- # This only works if there is a single OS.
- die __"--fish output is only possible with a single OS\n" if @osdevs != 1;
-
- my $root_dev = $osdevs[0];
-
- if ($output eq "ro-fish") {
- print "--ro ";
- }
-
- foreach (@images) {
- unless (defined $_->[1]) {
- printf "-a %s ", shell_quote ($_->[0]);
- } else {
- printf "--format %s -a %s ",
- shell_quote ($_->[1]), shell_quote ($_->[0]);
- }
- }
-
- my $mounts = $oses->{$root_dev}->{mounts};
- # Have to mount / first. Luckily '/' is early in the ASCII
- # character set, so this should be OK.
- foreach (sort keys %$mounts) {
- if ($_ ne "swap" && $_ ne "none") {
- printf "-m %s ", shell_quote ("$mounts->{$_}:$_");
- }
- }
- print "\n"
-}
-
-# Perl output.
-elsif ($output eq "perl") {
- print Dumper(%$oses);
-}
-
-# YAML output
-elsif ($output eq "yaml") {
- die __"virt-inspector: no YAML support, try installing perl-YAML or libyaml-perl\n"
- unless exists $INC{"YAML/Any.pm"};
-
- print Dump(%$oses);
-}
-
-# Plain text output (the default).
-elsif ($output eq "text") {
- output_text ();
-}
-
-# XML output.
-elsif ($output eq "xml") {
- output_xml ();