[Libguestfs] [PATCH 3/3] v2v: ignore missing kernels from grub (RHBZ#1230412)

Pino Toscano ptoscano at redhat.com
Mon Aug 24 16:28:30 UTC 2015


Raise a warning for each kernel specified in grub which does not
actually exist, keep going on with the conversion using the remaining
(existing) kernels.
---
 v2v/convert_linux.ml | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/v2v/convert_linux.ml b/v2v/convert_linux.ml
index 986af54..adbcaa2 100644
--- a/v2v/convert_linux.ml
+++ b/v2v/convert_linux.ml
@@ -364,7 +364,14 @@ let rec convert ~keep_serial_console (g : G.guestfs) inspect source =
                 statbuf.G.st_dev = s.G.st_dev && statbuf.G.st_ino = s.G.st_ino
             ) installed_kernels in
           Some kernel
-        with Not_found -> None
+        with
+        | Not_found -> None
+        | G.Error msg as exn ->
+          (* If it isn't "no such file or directory", then re-raise it. *)
+          if g#last_errno () <> G.Errno.errno_ENOENT then raise exn;
+          warning (f_"ignoring kernel %s in grub, as it does not exist.")
+            vmlinuz;
+          None
     ) vmlinuzes in
 
   if verbose () then (
-- 
2.1.0




More information about the Libguestfs mailing list