[Pkg-libvirt-commits] [libguestfs] 64/384: v2v: linux: Fix modifications to default kernel for legacy grub.

Hilko Bengen bengen at moszumanska.debian.org
Sun Mar 29 16:55:32 UTC 2015


This is an automated email from the git hooks/post-receive script.

bengen pushed a commit to branch experimental
in repository libguestfs.

commit e1fd9615cc4a9ceb68f4a47a289712fc31a0af5e
Author: Richard W.M. Jones <rjones at redhat.com>
Date:   Wed Dec 10 13:03:55 2014 +0000

    v2v: linux: Fix modifications to default kernel for legacy grub.
    
    This didn't work at all because the regular expression did not match
    the returned Augeas path.
    
    In future if the regular expression doesn't match, this will give an
    internal error instead of continuing with a bogus value.
    
    Thanks: Junqin Zhou for providing the test case and debug information.
---
 v2v/convert_linux.ml | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/v2v/convert_linux.ml b/v2v/convert_linux.ml
index 3d6a369..ff09408 100644
--- a/v2v/convert_linux.ml
+++ b/v2v/convert_linux.ml
@@ -792,12 +792,11 @@ let rec convert ~verbose ~keep_serial_console (g : G.guestfs) inspect source =
       if paths = [] then
         error (f_"didn't find grub entry for kernel %s") kernel.ki_vmlinuz;
       let path = List.hd paths in
-      let rex = Str.regexp "/title\\[\\([1-9][0-9]*\\)\\]/kernel" in
-      let index =
-        if Str.string_match rex path 0 then
-          (int_of_string (Str.matched_group 1 path) - 1)
-        else
-          0 in
+      let rex = Str.regexp ".*/title\\[\\([1-9][0-9]*\\)\\]/kernel" in
+      if not (Str.string_match rex path 0) then
+        error (f_"internal error: regular expression did not match '%s'")
+          path;
+      let index = int_of_string (Str.matched_group 1 path) - 1 in
       g#aug_set (sprintf "/files%s/default" grub_config) (string_of_int index);
       g#aug_save ()
 

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-libvirt/libguestfs.git



More information about the Pkg-libvirt-commits mailing list