[Libguestfs] [PATCH v2 1/2] v2v: ova: fix checking of the manifest file
Richard W.M. Jones
rjones at redhat.com
Wed Oct 5 11:15:57 UTC 2016
On Wed, Oct 05, 2016 at 12:51:05PM +0200, Tomáš Golembiovský wrote:
> 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 | 8 +++++++-
> 1 file changed, 7 insertions(+), 1 deletion(-)
>
> diff --git a/v2v/input_ova.ml b/v2v/input_ova.ml
> index 5731a45..44e41ed 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;
Don't capitalize the message.
> let mf_folder = Filename.dirname mf in
> let chan = open_in mf in
> let rec loop () =
> @@ -149,6 +150,11 @@ 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. Line is \"%s\"")
> + (String.replace line "\r" "")
Use this instead:
warning (f_"unable to parse line from manifest file: %S") line
Note %S _is_ supposed to be a capital letter.
Rich.
--
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
Read my programming and virtualization blog: http://rwmj.wordpress.com
virt-p2v converts physical machines to virtual machines. Boot with a
live CD or over the network (PXE) and turn machines into KVM guests.
http://libguestfs.org/virt-v2v
More information about the Libguestfs
mailing list