|
|
ffd6ed |
From d4713b68fb4c09b4004460ad1840d75e6a3ba86c Mon Sep 17 00:00:00 2001
|
|
|
ffd6ed |
From: "Richard W.M. Jones" <rjones@redhat.com>
|
|
|
ffd6ed |
Date: Mon, 6 Jul 2015 10:47:45 +0100
|
|
|
ffd6ed |
Subject: [PATCH] v2v: Catch real exception thrown by failing aug_get
|
|
|
ffd6ed |
(RHBZ#1239053).
|
|
|
ffd6ed |
|
|
|
ffd6ed |
When converting the old Perl virt-v2v code, I made a silly mistake
|
|
|
ffd6ed |
with the exception that aug_get throws when it doesn't find any node.
|
|
|
ffd6ed |
It throws a 'Guestfs.Error' exception, not 'Not_found'.
|
|
|
ffd6ed |
|
|
|
ffd6ed |
As a result of this, the exception was escaping and the proper error
|
|
|
ffd6ed |
message was not displayed. With a malformed grub configuration you
|
|
|
ffd6ed |
would see this error:
|
|
|
ffd6ed |
|
|
|
ffd6ed |
$ virt-v2v -i disk centos-6.img -o null
|
|
|
ffd6ed |
[...]
|
|
|
ffd6ed |
virt-v2v: error: libguestfs error: aug_get: no matching node
|
|
|
ffd6ed |
|
|
|
ffd6ed |
After applying this patch:
|
|
|
ffd6ed |
|
|
|
ffd6ed |
$ virt-v2v -i disk centos-6.img -o null
|
|
|
ffd6ed |
[...]
|
|
|
ffd6ed |
virt-v2v: error: no kernels were found in the grub configuration.
|
|
|
ffd6ed |
|
|
|
ffd6ed |
This probably indicates that virt-v2v was unable to parse the grub
|
|
|
ffd6ed |
configuration of this guest.
|
|
|
ffd6ed |
|
|
|
ffd6ed |
which is the correct error message.
|
|
|
ffd6ed |
|
|
|
ffd6ed |
(cherry picked from commit 659d56db3cc4333e7410cac6720c20b3b7fa66ad)
|
|
|
ffd6ed |
---
|
|
|
ffd6ed |
v2v/convert_linux.ml | 4 +++-
|
|
|
ffd6ed |
1 file changed, 3 insertions(+), 1 deletion(-)
|
|
|
ffd6ed |
|
|
|
ffd6ed |
diff --git a/v2v/convert_linux.ml b/v2v/convert_linux.ml
|
|
|
ffd6ed |
index 8264e80..c110825 100644
|
|
|
ffd6ed |
--- a/v2v/convert_linux.ml
|
|
|
ffd6ed |
+++ b/v2v/convert_linux.ml
|
|
|
ffd6ed |
@@ -290,7 +290,9 @@ let rec convert ~verbose ~keep_serial_console (g : G.guestfs) inspect source =
|
|
|
ffd6ed |
let expr =
|
|
|
ffd6ed |
sprintf "/files%s/title[%d]/kernel" grub_config (idx+1) in
|
|
|
ffd6ed |
Some expr
|
|
|
ffd6ed |
- with Not_found -> None in
|
|
|
ffd6ed |
+ with G.Error msg
|
|
|
ffd6ed |
+ when string_find msg "aug_get: no matching node" >= 0 ->
|
|
|
ffd6ed |
+ None in
|
|
|
ffd6ed |
|
|
|
ffd6ed |
(* If a default kernel was set, put it at the beginning of the paths
|
|
|
ffd6ed |
* list. If not set, assume the first kernel always boots (?)
|
|
|
ffd6ed |
--
|
|
|
ffd6ed |
1.8.3.1
|
|
|
ffd6ed |
|