summaryrefslogtreecommitdiffstats
path: root/inspector
diff options
context:
space:
mode:
authorRichard W.M. Jones <rjones@redhat.com>2009-06-29 15:16:40 +0100
committerRichard W.M. Jones <rjones@redhat.com>2009-06-29 15:16:40 +0100
commit4dff42aa13dd726fb6b02843d0f4db4b4b330fe3 (patch)
treeb7d9979063d29915df9b2d09780bd2b42674562d /inspector
parente492608f2f3809a824cb70ee03ff305964b69dd7 (diff)
downloadlibguestfs-4dff42aa13dd726fb6b02843d0f4db4b4b330fe3.tar.gz
libguestfs-4dff42aa13dd726fb6b02843d0f4db4b4b330fe3.tar.xz
libguestfs-4dff42aa13dd726fb6b02843d0f4db4b4b330fe3.zip
Add 'initrd-list' command to list contents of initrd images.
Add 'initrd-list' command to list the files inside (new-style) initrd images. Update virt-inspector to use this instead of the less efficient download/unpack locally method.
Diffstat (limited to 'inspector')
-rwxr-xr-xinspector/virt-inspector.pl45
1 files changed, 11 insertions, 34 deletions
diff --git a/inspector/virt-inspector.pl b/inspector/virt-inspector.pl
index bd8de703..f12af42f 100755
--- a/inspector/virt-inspector.pl
+++ b/inspector/virt-inspector.pl
@@ -727,9 +727,6 @@ sub find_filesystem
# 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};
@@ -744,7 +741,7 @@ if ($output !~ /.*fish$/) {
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 ();
@@ -898,42 +895,22 @@ sub check_for_initrd
{
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"
}
}
}