From: Richard Jones Date: Mon, 13 Jul 2009 17:06:10 +0000 (+0100) Subject: Ignore old-style initrd which is a compressed ext2 filesystem. X-Git-Tag: 1.0.59~10 X-Git-Url: http://git.annexia.org/?p=libguestfs.git;a=commitdiff_plain;h=4e444d5c09d78b0d292d95d1f97de12f26cc139d Ignore old-style initrd which is a compressed ext2 filesystem. 'cpio' chokes on these, taking ages to decide that they are not cpio files, and producing masses of messages. This was causing virt-inspector to be very slow (many minutes) on RHEL 3 guests. With this fix, speed is back to normal. --- diff --git a/perl/lib/Sys/Guestfs/Lib.pm b/perl/lib/Sys/Guestfs/Lib.pm index 27a7b9e..d5dfb4e 100644 --- a/perl/lib/Sys/Guestfs/Lib.pm +++ b/perl/lib/Sys/Guestfs/Lib.pm @@ -1208,14 +1208,20 @@ sub _check_for_initrd my $version = $1; 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" + # Disregard old-style compressed ext2 files, since cpio + # takes ages to (fail to) process these. + if ($g->file ("/boot/$initrd") !~ /gzip compressed/ || + $g->zfile ("gzip", "/boot/$initrd") !~ /ext2 filesystem/) { + 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"; + } } } }