Richard W.M. Jones
2014-Nov-24 16:01 UTC
[Libguestfs] [PATCH] v2v: -i ova: Remove incorrect warning for disks that have no parent controller (RHBZ#1167302).
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 -- 2.1.0
Pino Toscano
2014-Nov-24 18:01 UTC
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 withLGTM. -- Pino Toscano
Pino Toscano
2014-Nov-24 19:21 UTC
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 >Slightly related note: parent_controller mentions "hard disk" in its error messages, while that function seems to be used also for non-hd resources. Should those be made a bit more generic, or non-hd cases shouldn't generally get into error situations? -- Pino Toscano
Richard W.M. Jones
2014-Nov-25 14:34 UTC
Re: [Libguestfs] [PATCH] v2v: -i ova: Remove incorrect warning for disks that have no parent controller (RHBZ#1167302).
On Mon, Nov 24, 2014 at 08:21:41PM +0100, Pino Toscano wrote:> Slightly related note: parent_controller mentions "hard disk" in its > error messages, while that function seems to be used also for non-hd > resources. Should those be made a bit more generic, or non-hd cases > shouldn't generally get into error situations?I pushed a small patch to fix this. Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones Read my programming and virtualization blog: http://rwmj.wordpress.com Fedora Windows cross-compiler. Compile Windows programs, test, and build Windows installers. Over 100 libraries supported. http://fedoraproject.org/wiki/MinGW
Reasonably Related Threads
- Re: [PATCH] v2v: -i ova: Remove incorrect warning for disks that have no parent controller (RHBZ#1167302).
- v2v: -i libvirtxml: Map empty network or bridge name to a default (RHBZ#1257895).
- [PATCH] virt-v2v: Support for ova exported from AWS
- [PATCH 0/2] v2v: -i ova: A couple of cleanup patches.
- [PATCH v2 0/9] v2v: -i ova: Handle OVAs containing snapshots.