Matthew Booth
2010-May-07 13:58 UTC
[Libguestfs] [PATCH] Warn instead of dying if grub refers to non-existent kernel
--- .gnulib | 2 +- perl/lib/Sys/Guestfs/Lib.pm | 10 ++++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/.gnulib b/.gnulib index e2843e3..6d28070 160000 --- a/.gnulib +++ b/.gnulib @@ -1 +1 @@ -Subproject commit e2843e30e8c2885eb8cbc77e20c4e0f4d562d44d +Subproject commit 6d28070c3cc7a02107bf66402983b9fe4c6f8f6f diff --git a/perl/lib/Sys/Guestfs/Lib.pm b/perl/lib/Sys/Guestfs/Lib.pm index b6c4a31..8ec487d 100644 --- a/perl/lib/Sys/Guestfs/Lib.pm +++ b/perl/lib/Sys/Guestfs/Lib.pm @@ -1643,8 +1643,14 @@ sub _check_for_kernels } $config{cmdline} = join(' ', @args) if(scalar(@args) > 0); - my $kernel - inspect_linux_kernel($g, $path, $os->{package_format}); + my $kernel; + if ($g->exists($path)) { + $kernel + inspect_linux_kernel($g, $path, $os->{package_format}); + } else { + warn __x("grub refers to {path}, which doesn't exist\n", + path => $path); + } # Check the kernel was recognised if(defined($kernel)) { -- 1.6.6.1
Richard W.M. Jones
2010-May-07 14:17 UTC
[Libguestfs] [PATCH] Warn instead of dying if grub refers to non-existent kernel
On Fri, May 07, 2010 at 02:58:32PM +0100, Matthew Booth wrote:> --- > .gnulib | 2 +- > perl/lib/Sys/Guestfs/Lib.pm | 10 ++++++++-- > 2 files changed, 9 insertions(+), 3 deletions(-) > > diff --git a/.gnulib b/.gnulib > index e2843e3..6d28070 160000 > --- a/.gnulib > +++ b/.gnulib > @@ -1 +1 @@ > -Subproject commit e2843e30e8c2885eb8cbc77e20c4e0f4d562d44d > +Subproject commit 6d28070c3cc7a02107bf66402983b9fe4c6f8f6fDon't wanna revert to the old gnulib here ...> diff --git a/perl/lib/Sys/Guestfs/Lib.pm b/perl/lib/Sys/Guestfs/Lib.pm > index b6c4a31..8ec487d 100644 > --- a/perl/lib/Sys/Guestfs/Lib.pm > +++ b/perl/lib/Sys/Guestfs/Lib.pm > @@ -1643,8 +1643,14 @@ sub _check_for_kernels > } > $config{cmdline} = join(' ', @args) if(scalar(@args) > 0); > > - my $kernel > - inspect_linux_kernel($g, $path, $os->{package_format}); > + my $kernel; > + if ($g->exists($path)) { > + $kernel > + inspect_linux_kernel($g, $path, $os->{package_format}); > + } else { > + warn __x("grub refers to {path}, which doesn't exist\n", > + path => $path); > + }ACK. Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones libguestfs lets you edit virtual machines. Supports shell scripting, bindings from many languages. http://et.redhat.com/~rjones/libguestfs/ See what it can do: http://et.redhat.com/~rjones/libguestfs/recipes.html
Maybe Matching Threads
- [PATCH] Export inspect_linux_kernel in Lib.pm
- [PATCH] Check a grub kernel exists before selecting it
- [PATCH] Remove dependency on deprecated Sys::Guestfs::Lib::inspect_linux_kernel.
- Create new Sys::VirtV2V::Util
- [PATCH 1/2] Don't die during inspection if initrd doesn't exist