Blame SOURCES/0083-v2v-linux-Fix-modifications-to-default-kernel-for-le.patch

0d20ef
From 574481cdd1ccef9e2cba8d8f44a26a538158803b Mon Sep 17 00:00:00 2001
0d20ef
From: "Richard W.M. Jones" <rjones@redhat.com>
0d20ef
Date: Wed, 10 Dec 2014 13:03:55 +0000
0d20ef
Subject: [PATCH] v2v: linux: Fix modifications to default kernel for legacy
0d20ef
 grub.
0d20ef
0d20ef
This didn't work at all because the regular expression did not match
0d20ef
the returned Augeas path.
0d20ef
0d20ef
In future if the regular expression doesn't match, this will give an
0d20ef
internal error instead of continuing with a bogus value.
0d20ef
0d20ef
Thanks: Junqin Zhou for providing the test case and debug information.
0d20ef
(cherry picked from commit e1fd9615cc4a9ceb68f4a47a289712fc31a0af5e)
0d20ef
---
0d20ef
 v2v/convert_linux.ml | 11 +++++------
0d20ef
 1 file changed, 5 insertions(+), 6 deletions(-)
0d20ef
0d20ef
diff --git a/v2v/convert_linux.ml b/v2v/convert_linux.ml
0d20ef
index a4897ca..709b4b9 100644
0d20ef
--- a/v2v/convert_linux.ml
0d20ef
+++ b/v2v/convert_linux.ml
0d20ef
@@ -786,12 +786,11 @@ let rec convert ~verbose ~keep_serial_console (g : G.guestfs) inspect source =
0d20ef
       if paths = [] then
0d20ef
         error (f_"didn't find grub entry for kernel %s") kernel.ki_vmlinuz;
0d20ef
       let path = List.hd paths in
0d20ef
-      let rex = Str.regexp "/title\\[\\([1-9][0-9]*\\)\\]/kernel" in
0d20ef
-      let index =
0d20ef
-        if Str.string_match rex path 0 then
0d20ef
-          (int_of_string (Str.matched_group 1 path) - 1)
0d20ef
-        else
0d20ef
-          0 in
0d20ef
+      let rex = Str.regexp ".*/title\\[\\([1-9][0-9]*\\)\\]/kernel" in
0d20ef
+      if not (Str.string_match rex path 0) then
0d20ef
+        error (f_"internal error: regular expression did not match '%s'")
0d20ef
+          path;
0d20ef
+      let index = int_of_string (Str.matched_group 1 path) - 1 in
0d20ef
       g#aug_set (sprintf "/files%s/default" grub_config) (string_of_int index);
0d20ef
       g#aug_save ()
0d20ef
 
0d20ef
-- 
0d20ef
1.8.3.1
0d20ef