Merge commit 'et/master'
authorMatthew Booth <mbooth@redhat.com>
Mon, 29 Jun 2009 15:27:05 +0000 (16:27 +0100)
committerMatthew Booth <mbooth@redhat.com>
Mon, 29 Jun 2009 15:27:05 +0000 (16:27 +0100)
1  2 
inspector/virt-inspector.pl

@@@ -672,7 -672,6 +672,7 @@@ sub assign_mount_point
                } else {
                    $fs->{used} = 1
                }
 +                $fs->{spec} = $spec;
            }
        }
      }
@@@ -706,12 -705,6 +706,12 @@@ sub find_filesyste
      } else {
        return ($_, $fses{$_}) if exists $fses{$_};
  
 +        # The following is to handle the case where an fstab entry specifies a
 +        # specific device rather than its label or uuid, and the libguestfs
 +        # appliance has named the device differently due to the use of a
 +        # different driver.
 +        # This will work as long as the underlying drivers recognise devices in
 +        # the same order.
        if (m{^/dev/hd(.*)} && exists $fses{"/dev/sd$1"}) {
            return ("/dev/sd$1", $fses{"/dev/sd$1"});
        }
  # we don't need to know.
  
  if ($output !~ /.*fish$/) {
-     # Temporary directory for use by check_for_initrd.
-     my $dir = tempdir (CLEANUP => 1);
      my $root_dev;
      foreach $root_dev (sort keys %oses) {
        my $mounts = $oses{$root_dev}->{mounts};
        check_for_kernels ($root_dev);
        if ($oses{$root_dev}->{os} eq "linux") {
            check_for_modprobe_aliases ($root_dev);
-           check_for_initrd ($root_dev, $dir);
+           check_for_initrd ($root_dev);
        }
  
        $g->umount_all ();
@@@ -885,22 -875,13 +882,22 @@@ sub check_for_modprobe_aliase
          @results = $g->aug_match($pattern);
  
          for my $path ( @results ) {
 +            $path =~ m{^/files(.*)/alias(?:\[\d*\])?$}
 +                or die("$path doesn't match augeas pattern");
 +            my $file = $1;
 +
              my $alias;
              $alias = $g->aug_get($path);
  
              my $modulename;
              $modulename = $g->aug_get($path.'/modulename');
  
 -            $modprobe_aliases{$alias} = $modulename;
 +            my %aliasinfo;
 +            $aliasinfo{modulename} = $modulename;
 +            $aliasinfo{augeas} = $path;
 +            $aliasinfo{file} = $file;
 +
 +            $modprobe_aliases{$alias} = \%aliasinfo;
          }
      }
  
@@@ -914,42 -895,22 +911,22 @@@ sub check_for_initr
  {
      local $_;
      my $root_dev = shift;
-     my $dir = shift;
  
      my %initrd_modules;
  
      foreach my $initrd ($g->ls ("/boot")) {
        if ($initrd =~ m/^initrd-(.*)\.img$/ && $g->is_file ("/boot/$initrd")) {
            my $version = $1;
-           my @modules = ();
-           # We have to download these to a temporary file.
-           $g->download ("/boot/$initrd", "$dir/initrd");
-           my $cmd = "zcat $dir/initrd | file -";
-           open P, "$cmd |" or die "$cmd: $!";
-           my $lines;
-           { local $/ = undef; $lines = <P>; }
-           close P;
-           if ($lines =~ /ext\d filesystem data/) {
-               # Before initramfs came along, these were compressed
-               # ext2 filesystems.  We could run another libguestfs
-               # instance to unpack these, but punt on them for now. (XXX)
-               warn "initrd image is unsupported ext2/3/4 filesystem\n";
-           }
-           elsif ($lines =~ /cpio/) {
-               my $cmd = "zcat $dir/initrd | cpio --quiet -it";
-               open P, "$cmd |" or die "$cmd: $!";
-               while (<P>) {
-                   push @modules, $1
-                       if m,([^/]+)\.ko$, || m,([^/]+)\.o$,;
-               }
-               close P;
-               unlink "$dir/initrd";
-               $initrd_modules{$version} = \@modules;
-           }
-           else {
-               # What?
-               warn "unrecognized initrd image: $lines\n";
+           my @modules;
+           eval {
+               @modules = $g->initrd_list ("/boot/$initrd");
+           };
+           unless ($@) {
+               @modules = grep { m,([^/]+)\.ko$, || m,([^/]+)\.o$, } @modules;
+               $initrd_modules{$version} = \@modules
+           } else {
+               warn "/boot/$initrd: could not read initrd format"
            }
        }
      }
@@@ -1050,7 -1011,7 +1027,7 @@@ sub output_text_o
        if (@keys) {
            print "  Modprobe aliases:\n";
            foreach (@keys) {
 -              printf "    %-30s %s\n", $_, $aliases{$_}
 +              printf "    %-30s %s\n", $_, $aliases{$_}->{modulename}
            }
        }
      }
@@@ -1132,8 -1093,7 +1109,8 @@@ sub output_xml_o
          foreach my $field ( [ "label" => "label" ],
                              [ "uuid" => "uuid" ],
                              [ "type" => "fstype" ],
 -                            [ "content" => "content" ] ) {
 +                            [ "content" => "content" ],
 +                            [ "spec" => "spec" ] ) {
              $xml->dataElement($field->[0], $filesystems->{$_}{$field->[1]})
                  if exists $filesystems->{$_}{$field->[1]};
          }
        if (@keys) {
              $xml->startTag("modprobealiases");
            foreach (@keys) {
 -                $xml->dataElement("alias", $aliases{$_}, "device" => $_);
 +                $xml->startTag("alias", "device" => $_);
 +
 +                foreach my $field ( [ "modulename" => "modulename" ],
 +                                    [ "augeas" => "augeas" ],
 +                                    [ "file" => "file" ] ) {
 +                    $xml->dataElement($field->[0], $aliases{$_}->{$field->[1]});
 +                }
 +
 +                $xml->endTag("alias");
            }
              $xml->endTag("modprobealiases");
        }