Tomáš Golembiovský
2016-Sep-29 12:59 UTC
[Libguestfs] [PATCH 1/2] v2v: ova: fix checking of the manifest file
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@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 4f848e2..513fe30 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 () @@ -156,6 +157,11 @@ object debug "sha1 of %s matches expected checksum %s" disk expected | _::_ -> error (f_"cannot parse output of sha1sum command") ) + else + warning (f_"Unable to parse line from manifest file. Line is \"%s\"") + (String.replace line "\r" "") + ; + loop () in (try loop () with End_of_file -> ()); close_in chan -- 2.10.0
Pino Toscano
2016-Sep-29 13:53 UTC
Re: [Libguestfs] [PATCH 1/2] v2v: ova: fix checking of the manifest file
On Thursday, 29 September 2016 14:59:14 CEST 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.Can you please provide an example of manifest file with more than one line? A real-life example, I mean.> Also added some debugging info and warning to catch problems with > parsing. > > Signed-off-by: Tomáš Golembiovský <tgolembi@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 4f848e2..513fe30 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 () > @@ -156,6 +157,11 @@ object > debug "sha1 of %s matches expected checksum %s" disk expected > | _::_ -> error (f_"cannot parse output of sha1sum command") > ) > + else > + warning (f_"Unable to parse line from manifest file. Line is \"%s\"") > + (String.replace line "\r" "") > + ; > + loop () > in > (try loop () with End_of_file -> ()); > close_in chan >Thanks, -- Pino Toscano
Richard W.M. Jones
2016-Sep-29 15:44 UTC
Re: [Libguestfs] [PATCH 1/2] v2v: ova: fix checking of the manifest file
On Thu, Sep 29, 2016 at 02:59:14PM +0200, Tomáš Golembiovský wrote:> + debug "Processing manifest %s" mf;Don't capitalize this debug message. Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones Read my programming and virtualization blog: http://rwmj.wordpress.com virt-top is 'top' for virtual machines. Tiny program with many powerful monitoring features, net stats, disk stats, logging, etc. http://people.redhat.com/~rjones/virt-top
Tomáš Golembiovský
2016-Sep-30 10:55 UTC
Re: [Libguestfs] [PATCH 1/2] v2v: ova: fix checking of the manifest file
On Thu, 29 Sep 2016 15:53:18 +0200 Pino Toscano <ptoscano@redhat.com> wrote:> On Thursday, 29 September 2016 14:59:14 CEST 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. > > Can you please provide an example of manifest file with more than one > line? A real-life example, I mean. >Sure, this is from OVA created by VMware: $ cat 2003-32b.mf SHA1(2003-32b.ovf)= 7c8e2cfebb540c4fa86df8413604408359b35cd9 SHA1(2003-32b-disk1.vmdk)= fef670f077ba7df83d35d8849f666d399f355bb5 If there are multiple disks in the VM there will be one line for each disk. Tomas -- Tomáš Golembiovský <tgolembi@redhat.com>