Matthew Booth
2010-Apr-21 14:39 UTC
[Libguestfs] [PATCH 1/2] Don't die during inspection if initrd doesn't exist
This fixes a problem where inspection would die if grub.conf referenced a
non-existent initrd. Just return an empty initrd instead.
---
perl/lib/Sys/Guestfs/Lib.pm | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/perl/lib/Sys/Guestfs/Lib.pm b/perl/lib/Sys/Guestfs/Lib.pm
index 5428b10..b5b3906 100644
--- a/perl/lib/Sys/Guestfs/Lib.pm
+++ b/perl/lib/Sys/Guestfs/Lib.pm
@@ -1825,7 +1825,7 @@ sub _inspect_initrd
# Disregard old-style compressed ext2 files and only work with real
# compressed cpio files, since cpio takes ages to (fail to) process
anything
# else.
- if ($g->file ($path) =~ /cpio/) {
+ if ($g->exists($path) && $g->file($path) =~ /cpio/) {
eval {
@modules = $g->initrd_list ($path);
};
--
1.6.6.1
Matthew Booth
2010-Apr-21 14:39 UTC
[Libguestfs] [PATCH 2/2] Don't die during inspection if rpm -qa or dpkg-query fails
If a problem in the package database prevented package enumeration from working,
inspection would die. This change makes it emit a warning and continue.
---
perl/lib/Sys/Guestfs/Lib.pm | 28 ++++++++++++++++++++--------
1 files changed, 20 insertions(+), 8 deletions(-)
diff --git a/perl/lib/Sys/Guestfs/Lib.pm b/perl/lib/Sys/Guestfs/Lib.pm
index b5b3906..b6c4a31 100644
--- a/perl/lib/Sys/Guestfs/Lib.pm
+++ b/perl/lib/Sys/Guestfs/Lib.pm
@@ -1463,10 +1463,16 @@ sub _check_for_applications
if ($osn eq "linux") {
my $package_format = $os->{package_format};
if (defined $package_format && $package_format eq
"rpm") {
- my @lines = $g->command_lines
- (["rpm",
- "-q", "-a",
- "--qf", "%{name} %{epoch} %{version}
%{release} %{arch}\n"]);
+ my @lines = ();
+ eval {
+ @lines = $g->command_lines
+ (["rpm",
+ "-q", "-a", "--qf",
+ "%{name} %{epoch} %{version} %{release}
%{arch}\n"]);
+ };
+
+ warn(__x("Error running rpm -qa: {error}", error =>
$@)) if ($@);
+
@lines = sort @lines;
foreach (@lines) {
if (m/^(.*) (.*) (.*) (.*) (.*)$/) {
@@ -1483,10 +1489,16 @@ sub _check_for_applications
}
}
} elsif (defined $package_format && $package_format eq
"deb") {
- my @lines = $g->command_lines
- (["dpkg-query",
- "-f", '${Package} ${Version} ${Architecture}
${Status}\n',
- "-W"]);
+ my @lines = ();
+ eval {
+ @lines = $g->command_lines
+ (["dpkg-query",
+ "-f", '${Package} ${Version}
${Architecture} ${Status}\n',
+ "-W"]);
+ };
+
+ warn(__x("Error running dpkg-query: {error}", error =>
$@)) if ($@);
+
@lines = sort @lines;
foreach (@lines) {
if (m/^(.*) (.*) (.*) (.*) (.*) (.*)$/) {
--
1.6.6.1
Richard W.M. Jones
2010-Apr-21 15:50 UTC
[Libguestfs] [PATCH 1/2] Don't die during inspection if initrd doesn't exist
On Wed, Apr 21, 2010 at 03:39:48PM +0100, Matthew Booth wrote:> This fixes a problem where inspection would die if grub.conf referenced a > non-existent initrd. Just return an empty initrd instead. > --- > perl/lib/Sys/Guestfs/Lib.pm | 2 +- > 1 files changed, 1 insertions(+), 1 deletions(-) > > diff --git a/perl/lib/Sys/Guestfs/Lib.pm b/perl/lib/Sys/Guestfs/Lib.pm > index 5428b10..b5b3906 100644 > --- a/perl/lib/Sys/Guestfs/Lib.pm > +++ b/perl/lib/Sys/Guestfs/Lib.pm > @@ -1825,7 +1825,7 @@ sub _inspect_initrd > # Disregard old-style compressed ext2 files and only work with real > # compressed cpio files, since cpio takes ages to (fail to) process anything > # else. > - if ($g->file ($path) =~ /cpio/) { > + if ($g->exists($path) && $g->file($path) =~ /cpio/) { > eval { > @modules = $g->initrd_list ($path); > }; > -- > 1.6.6.1ACK. Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones virt-top is 'top' for virtual machines. Tiny program with many powerful monitoring features, net stats, disk stats, logging, etc. http://et.redhat.com/~rjones/virt-top
Possibly Parallel Threads
- [PATCH] Warn instead of dying if grub refers to non-existent kernel
- Re: [PATCH 2/8] v2v: add basic support for the "deb" package manager
- [PATCH 0/8] v2v: first bits of Debian/Ubuntu guests supports
- [PATCH 2/7] v2v: add basic support for the "deb" package manager
- Re: [PATCH 2/8] v2v: add basic support for the "deb" package manager