[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: [Libguestfs] [PATCH] v2v: -i ova: Remove incorrect warning for disks that have no parent controller (RHBZ#1167302).



On Monday 24 November 2014 16:01:36 Richard W.M. Jones wrote:
> Don't assume every disk <Item> has a <Parent> field.  For floppy disks
> this is not the case.
> 
> Thanks: Junqin Zhou
> ---
>  v2v/input_ova.ml | 14 ++++++++++----
>  1 file changed, 10 insertions(+), 4 deletions(-)
> 
> diff --git a/v2v/input_ova.ml b/v2v/input_ova.ml
> index 95af2e5..9a9c10a 100644
> --- a/v2v/input_ova.ml
> +++ b/v2v/input_ova.ml
> @@ -187,14 +187,17 @@ object
>        for i = 0 to nr_nodes-1 do
>          let n = Xml.xpathobj_node doc obj i in
>          Xml.xpathctx_set_current_context xpathctx n;
> -        let parent_id = xpath_to_int "rasd:Parent/text()" 0 in
> 
>          (* XXX We assume the OVF lists these in order.
>          let address = xpath_to_int "rasd:AddressOnParent/text()" 0 in
>          *)
> 
>          (* Find the parent controller. *)
> -        let controller = parent_controller parent_id in
> +        let parent_id = xpath_to_int "rasd:Parent/text()" 0 in
> +        let controller =
> +          match parent_id with
> +          | 0 -> None
> +          | id -> parent_controller id in
> 
>          Xml.xpathctx_set_current_context xpathctx n;
>          let file_id = xpath_to_string "rasd:HostResource/text()" ""
> in @@ -255,14 +258,17 @@ object
>          Xml.xpathctx_set_current_context xpathctx n;
>          let id = xpath_to_int "rasd:ResourceType/text()" 0 in
>          assert (id = 14 || id = 15 || id = 16);
> -        let parent_id = xpath_to_int "rasd:Parent/text()" 0 in
> 
>          (* XXX We assume the OVF lists these in order.
>          let address = xpath_to_int "rasd:AddressOnParent/text()" 0 in
>          *)
> 
>          (* Find the parent controller. *)
> -        let controller = parent_controller parent_id in
> +        let parent_id = xpath_to_int "rasd:Parent/text()" 0 in
> +        let controller =
> +          match parent_id with
> +          | 0 -> None
> +          | id -> parent_controller id in
> 
>          let typ =
>            match id with

LGTM.

-- 
Pino Toscano


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]