Warn instead of dying if grub refers to non-existent kernel
authorMatthew Booth <mbooth@redhat.com>
Fri, 7 May 2010 13:58:32 +0000 (14:58 +0100)
committerRichard Jones <rjones@redhat.com>
Fri, 7 May 2010 14:23:37 +0000 (15:23 +0100)
perl/lib/Sys/Guestfs/Lib.pm

index b6c4a31..8ec487d 100644 (file)
@@ -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)) {