[Libguestfs] [PATCH] Warn instead of dying if grub refers to non-existent kernel

Richard W.M. Jones rjones at redhat.com
Fri May 7 14:17:08 UTC 2010


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 6d28070c3cc7a02107bf66402983b9fe4c6f8f6f

Don'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




More information about the Libguestfs mailing list