[Libguestfs] [PATCH] v2v: bootloaders: handle no default grubby kernel (RHBZ#1519204)

Pino Toscano ptoscano at redhat.com
Fri Dec 1 13:49:30 UTC 2017


When using grubby to get the default kernel of a guest, do not fail
with a bogus error like:

virt-v2v: error: libguestfs error: statns: statns_stub: path must start
with a / character

in case there is no default kernel that can be determined (e.g. because
of a bogus configuration).
---
 v2v/linux_bootloaders.ml | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/v2v/linux_bootloaders.ml b/v2v/linux_bootloaders.ml
index 8de3f0469..b820f731f 100644
--- a/v2v/linux_bootloaders.ml
+++ b/v2v/linux_bootloaders.ml
@@ -239,7 +239,10 @@ object (self)
       let res =
         match get_default_method with
         | MethodGrubby ->
-          Some (g#command [| "grubby"; "--default-kernel" |])
+          let res = g#command [| "grubby"; "--default-kernel" |] in
+          (match res with
+           | "" -> None
+           | _ -> Some res)
         | MethodPerlBootloader ->
           let cmd =
             [| "/usr/bin/perl"; "-MBootloader::Tools"; "-e"; "
-- 
2.14.3




More information about the Libguestfs mailing list