[Libguestfs] [PATCH v4 1/2] v2v: ova: fix checking of the manifest file

Tomáš Golembiovský tgolembi at redhat.com
Wed Oct 5 14:35:21 UTC 2016


The regular expression for parsing the manifest line was wrong. There is
a mandatory space between '=' and the hash.

Another problem was that only the first line of the manifest file was
actually processed.

Also added some debugging info and warning to catch problems with
parsing.

Signed-off-by: Tomáš Golembiovský <tgolembi at redhat.com>
---
 v2v/input_ova.ml | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/v2v/input_ova.ml b/v2v/input_ova.ml
index 5731a45..0d04659 100644
--- a/v2v/input_ova.ml
+++ b/v2v/input_ova.ml
@@ -133,9 +133,10 @@ object
 
     (* Read any .mf (manifest) files and verify sha1. *)
     let mf = find_files exploded ".mf" in
-    let rex = Str.regexp "SHA1(\\(.*\\))=\\([0-9a-fA-F]+\\)\r?" in
+    let rex = Str.regexp "SHA1(\\(.*\\))= \\([0-9a-fA-F]+\\)\r?" in
     List.iter (
       fun mf ->
+        debug "processing manifest %s" mf;
         let mf_folder = Filename.dirname mf in
         let chan = open_in mf in
         let rec loop () =
@@ -149,6 +150,10 @@ object
               error (f_"checksum of disk %s does not match manifest %s (actual sha1(%s) = %s, expected sha1 (%s) = %s)")
                 disk mf disk actual disk expected;
           )
+          else
+            warning (f_"unable to parse line from manifest file: %S") line
+          ;
+          loop ()
         in
         (try loop () with End_of_file -> ());
         close_in chan
-- 
2.10.0




More information about the Libguestfs mailing list