Displaying 20 results from an estimated 52 matches for "xpathobj_nr_nod".
Did you mean:
xpathobj_nr_nodes
2015 Jun 25
0
[PATCH v2] v2v: Free XML objects in the correct order.
...s(+), 96 deletions(-)
diff --git a/v2v/input_libvirtxml.ml b/v2v/input_libvirtxml.ml
index ba00d94..646346d 100644
--- a/v2v/input_libvirtxml.ml
+++ b/v2v/input_libvirtxml.ml
@@ -44,14 +44,14 @@ let parse_libvirt_xml ?conn xml =
let obj = Xml.xpath_eval_expression xpathctx expr in
if Xml.xpathobj_nr_nodes obj < 1 then default
else (
- let node = Xml.xpathobj_node doc obj 0 in
+ let node = Xml.xpathobj_node obj 0 in
Xml.node_as_string node
)
and xpath_to_int expr default =
let obj = Xml.xpath_eval_expression xpathctx expr in
if Xml.xpathobj_nr_nodes obj &l...
2015 Jun 25
0
[PATCH] v2v: Free XML objects in the correct order.
...(+), 102 deletions(-)
diff --git a/v2v/input_libvirtxml.ml b/v2v/input_libvirtxml.ml
index ba00d94..646346d 100644
--- a/v2v/input_libvirtxml.ml
+++ b/v2v/input_libvirtxml.ml
@@ -44,14 +44,14 @@ let parse_libvirt_xml ?conn xml =
let obj = Xml.xpath_eval_expression xpathctx expr in
if Xml.xpathobj_nr_nodes obj < 1 then default
else (
- let node = Xml.xpathobj_node doc obj 0 in
+ let node = Xml.xpathobj_node obj 0 in
Xml.node_as_string node
)
and xpath_to_int expr default =
let obj = Xml.xpath_eval_expression xpathctx expr in
if Xml.xpathobj_nr_nodes obj &l...
2015 Jun 25
2
[PATCH v2] v2v: Free XML objects in the correct order.
In version 2:
- No substantial change, I just tidied up the code a bit.
- Removed one case where whitespace changes had crept in.
Rich.
2017 Oct 08
1
Re: [PATCH v11 5/6] mllib: add XPath helper xpath_get_nodes()
...;t
actually take a unit parameter, so it's better to drop ‘()’.
On Thu, Oct 05, 2017 at 04:58:29PM +0200, Cédric Bosdonnat wrote:
> +
> +let xpath_get_nodes xpathctx expr =
> + let obj = Xml.xpath_eval_expression xpathctx expr in
> + let nodes = ref [] in
> + for i = 0 to Xml.xpathobj_nr_nodes obj - 1 do
> + let node = Xml.xpathobj_node obj i in
> + push_back nodes node
> + done;
> + !nodes
‘push_back’ is unfortunately O(n) and no tail recursive, and so the
whole loop is O(n²). It's going to be much more efficient therefore
to build the list up in reverse and...
2015 Aug 28
7
v2v: -i libvirtxml: Map empty network or bridge name to a default (RHBZ#1257895).
When importing from VMware via the libvirt driver, the libvirt driver
can add an empty source bridge name:
<interface type='bridge'>
<mac address='00:01:02:03:04:05:06'/>
<source bridge=''/>
</interface>
Replicate what we do on the -i ova path, and map these to "eth0",
"eth1" etc.
This also includes a bunch
2017 Oct 27
0
[PATCH v11 7/8] mllib: add XPath helper xpath_get_nodes
...th_eval parsefn xpathctx expr =
let xpath_string = xpath_eval identity
let xpath_int = xpath_eval int_of_string
let xpath_int64 = xpath_eval Int64.of_string
+
+let xpath_get_nodes xpathctx expr =
+ let obj = Xml.xpath_eval_expression xpathctx expr in
+ let nodes = ref [] in
+ for i = 0 to Xml.xpathobj_nr_nodes obj - 1 do
+ let node = Xml.xpathobj_node obj i in
+ push_front node nodes
+ done;
+ List.rev !nodes
diff --git a/common/mltools/xpath_helpers.mli b/common/mltools/xpath_helpers.mli
index 3a8190b05..3a2607aeb 100644
--- a/common/mltools/xpath_helpers.mli
+++ b/common/mltools/xpath_helpers...
2017 Aug 30
1
[PATCH] v2v: warn when the guest has hostdev devices (RHBZ#1472719)
...l
+++ b/v2v/parse_libvirt_xml.ml
@@ -460,6 +460,22 @@ let parse_libvirt_xml ?conn xml =
done;
List.rev !nics in
+ (* Check for hostdev devices. (RHBZ#1472719) *)
+ let () =
+ let obj = Xml.xpath_eval_expression xpathctx "/domain/devices/hostdev" in
+ let nr_nodes = Xml.xpathobj_nr_nodes obj in
+ if nr_nodes > 0 then (
+ (* Sadly fn_ in ocaml-gettext seems broken, and always returns the
+ * singular string no matter what. Work around this by using a simple
+ * string with sn_ (which works), and outputting it as a whole.
+ *)
+ let msg = sn_ &quo...
2017 Mar 13
0
[PATCH 2/2] v2v: -i ova: Factor out the OVF parsing into a separate module.
...- (* Hard disks (ResourceType = 17). *)
- let disks = ref [] in
- let () =
- let expr = "/ovf:Envelope/ovf:VirtualSystem/ovf:VirtualHardwareSection/ovf:Item[rasd:ResourceType/text()=17]" in
- let obj = Xml.xpath_eval_expression xpathctx expr in
- let nr_nodes = Xml.xpathobj_nr_nodes obj in
- for i = 0 to nr_nodes-1 do
- let n = Xml.xpathobj_node obj i in
- Xml.xpathctx_set_current_context xpathctx n;
-
- (* XXX We assume the OVF lists these in order.
- let address = xpath_int "rasd:AddressOnParent/text()" in
- *)
-
- (...
2019 Apr 12
1
[PATCH] v2v: warn when the guest has direct network interfaces (RHBZ#1518539)
...4 @@ let parse_libvirt_xml ?conn xml =
)
in
+ (* Check for direct attachments to physical network interfaces.
+ * (RHBZ#1518539)
+ *)
+ let () =
+ let obj = Xml.xpath_eval_expression xpathctx "/domain/devices/interface[@type='direct']" in
+ let nr_nodes = Xml.xpathobj_nr_nodes obj in
+ if nr_nodes > 0 then (
+ (* Sadly fn_ in ocaml-gettext seems broken, and always returns the
+ * singular string no matter what. Work around this by using a simple
+ * string with sn_ (which works), and outputting it as a whole.
+ *)
+ let msg = sn_ &quo...
2017 Apr 04
1
Re: [PATCH v5 09/10] mllib: add XPath helper xpath_get_nodes()
...tity
> let xpath_int_default = xpath_eval_default int_of_string
> let xpath_int64_default = xpath_eval_default Int64.of_string
> +
> +let xpath_get_nodes xpathctx expr =
> + let obj = Xml.xpath_eval_expression xpathctx expr in
> + let nodes = ref [] in
> + for i = 0 to Xml.xpathobj_nr_nodes obj - 1 do
> + let node = Xml.xpathobj_node obj i in
> + nodes := List.append !nodes [node]
You can use the utilities from Common_utils for manipulating list
references, so:
push_back nodes node;
The other option to not use a list reference to collect the nodes would
be to use a...
2017 Mar 13
4
[PATCH 0/2] v2v: -i ova: A couple of cleanup patches.
A couple of patches cleaning up the -i ova code. These are
both just refactoring (or should be at any rate).
The second patch is best viewed with 'git show -w' to exclude
whitespace changes.
Rich.
2014 Aug 26
3
Segmentation fault when trying to add binding
...oc -> xpathctx = "v2v_xml_xpath_new_context"
external xpath_eval_expression : xpathctx -> string -> xpathobj = "v2v_xml_xpath_eval_expression"
+external xpath_register_ns : string -> string -> xpathctx -> int = "v2v_xml_xpath_register_ns"
external xpathobj_nr_nodes : xpathobj -> int = "v2v_xml_xpathobj_nr_nodes"
external xpathobj_get_node_ptr : xpathobj -> int -> node_ptr = "v2v_xml_xpathobj_get_node_ptr"
diff --git a/v2v/xml.mli b/v2v/xml.mli
index 38bb9cd..cab4395 100644
--- a/v2v/xml.mli
+++ b/v2v/xml.mli
@@ -29,6 +29,8 @@ v...
2014 Oct 31
0
[PATCH] v2v: -o libvirt: Get the <features/> right in the output XML (RHBZ#1159258).
...oc in
+ let expr =
+ (* NB: Pay attention to the square brackets. This returns the
+ * <guest> nodes!
+ *)
+ sprintf "/capabilities/guest[arch[@name='%s']/domain/@type='kvm']" arch in
+ let obj = Xml.xpath_eval_expression xpathctx expr in
+
+ if Xml.xpathobj_nr_nodes obj < 1 then (
+ (* Old virt-v2v used to die here, but that seems unfair since the
+ * user has gone through conversion before we reach here.
+ *)
+ warning (f_"the target hypervisor does not support a %s KVM guest") arch;
+ []
+ ) else (
+ let node (* first matc...
2017 Mar 23
0
[PATCH v5 09/10] mllib: add XPath helper xpath_get_nodes()
...g_default = xpath_eval_default identity
let xpath_int_default = xpath_eval_default int_of_string
let xpath_int64_default = xpath_eval_default Int64.of_string
+
+let xpath_get_nodes xpathctx expr =
+ let obj = Xml.xpath_eval_expression xpathctx expr in
+ let nodes = ref [] in
+ for i = 0 to Xml.xpathobj_nr_nodes obj - 1 do
+ let node = Xml.xpathobj_node obj i in
+ nodes := List.append !nodes [node]
+ done;
+ !nodes
diff --git a/mllib/xpath_helpers.mli b/mllib/xpath_helpers.mli
index 7434ba645..ab176351f 100644
--- a/mllib/xpath_helpers.mli
+++ b/mllib/xpath_helpers.mli
@@ -31,3 +31,7 @@ val xpath...
2017 Sep 12
0
[PATCH v8 6/7] mllib: add XPath helper xpath_get_nodes()
...g_default = xpath_eval_default identity
let xpath_int_default = xpath_eval_default int_of_string
let xpath_int64_default = xpath_eval_default Int64.of_string
+
+let xpath_get_nodes xpathctx expr =
+ let obj = Xml.xpath_eval_expression xpathctx expr in
+ let nodes = ref [] in
+ for i = 0 to Xml.xpathobj_nr_nodes obj - 1 do
+ let node = Xml.xpathobj_node obj i in
+ push_back nodes node
+ done;
+ !nodes
diff --git a/mllib/xpath_helpers.mli b/mllib/xpath_helpers.mli
index 7434ba645..83c770281 100644
--- a/mllib/xpath_helpers.mli
+++ b/mllib/xpath_helpers.mli
@@ -31,3 +31,7 @@ val xpath_int_default :...
2017 Sep 18
0
[PATCH v9 5/7] mllib: add XPath helper xpath_get_nodes()
...g_default = xpath_eval_default identity
let xpath_int_default = xpath_eval_default int_of_string
let xpath_int64_default = xpath_eval_default Int64.of_string
+
+let xpath_get_nodes xpathctx expr =
+ let obj = Xml.xpath_eval_expression xpathctx expr in
+ let nodes = ref [] in
+ for i = 0 to Xml.xpathobj_nr_nodes obj - 1 do
+ let node = Xml.xpathobj_node obj i in
+ push_back nodes node
+ done;
+ !nodes
diff --git a/mllib/xpath_helpers.mli b/mllib/xpath_helpers.mli
index 7434ba645..83c770281 100644
--- a/mllib/xpath_helpers.mli
+++ b/mllib/xpath_helpers.mli
@@ -31,3 +31,7 @@ val xpath_int_default :...
2017 Sep 20
0
[PATCH v10 5/6] mllib: add XPath helper xpath_get_nodes()
...g_default = xpath_eval_default identity
let xpath_int_default = xpath_eval_default int_of_string
let xpath_int64_default = xpath_eval_default Int64.of_string
+
+let xpath_get_nodes xpathctx expr =
+ let obj = Xml.xpath_eval_expression xpathctx expr in
+ let nodes = ref [] in
+ for i = 0 to Xml.xpathobj_nr_nodes obj - 1 do
+ let node = Xml.xpathobj_node obj i in
+ push_back nodes node
+ done;
+ !nodes
diff --git a/mllib/xpath_helpers.mli b/mllib/xpath_helpers.mli
index 7434ba645..83c770281 100644
--- a/mllib/xpath_helpers.mli
+++ b/mllib/xpath_helpers.mli
@@ -31,3 +31,7 @@ val xpath_int_default :...
2017 Oct 05
0
[PATCH v11 5/6] mllib: add XPath helper xpath_get_nodes()
...g_default = xpath_eval_default identity
let xpath_int_default = xpath_eval_default int_of_string
let xpath_int64_default = xpath_eval_default Int64.of_string
+
+let xpath_get_nodes xpathctx expr =
+ let obj = Xml.xpath_eval_expression xpathctx expr in
+ let nodes = ref [] in
+ for i = 0 to Xml.xpathobj_nr_nodes obj - 1 do
+ let node = Xml.xpathobj_node obj i in
+ push_back nodes node
+ done;
+ !nodes
diff --git a/common/mltools/xpath_helpers.mli b/common/mltools/xpath_helpers.mli
index 7434ba645..83c770281 100644
--- a/common/mltools/xpath_helpers.mli
+++ b/common/mltools/xpath_helpers.mli
@@ -3...
2018 Jun 07
0
[PATCH] v2v: parse_libvirt_xml: Simplify code by using xpath_get_nodes utility fn.
...a/v2v/parse_libvirt_xml.ml
+++ b/v2v/parse_libvirt_xml.ml
@@ -123,14 +123,8 @@ let parse_libvirt_xml ?conn xml =
| _, _, _ -> None in
let features =
- let features = ref [] in
- let obj = Xml.xpath_eval_expression xpathctx "/domain/features/*" in
- let nr_nodes = Xml.xpathobj_nr_nodes obj in
- for i = 0 to nr_nodes-1 do
- let node = Xml.xpathobj_node obj i in
- List.push_front (Xml.node_name node) features
- done;
- !features in
+ let nodes = xpath_get_nodes xpathctx "/domain/features/*" in
+ List.map Xml.node_name nodes in
let display =...
2015 Oct 08
0
[PATCH] v2v: Add xpath_int64 functions, and use them to read memory values.
...2v/utils.ml
@@ -79,6 +79,17 @@ let xpath_int xpathctx expr =
error (f_"expecting XML expression to return an integer (expression: %s, matching string: %s)")
expr str
)
+let xpath_int64 xpathctx expr =
+ let obj = Xml.xpath_eval_expression xpathctx expr in
+ if Xml.xpathobj_nr_nodes obj < 1 then None
+ else (
+ let node = Xml.xpathobj_node obj 0 in
+ let str = Xml.node_as_string node in
+ try Some (Int64.of_string str)
+ with Failure "int_of_string" ->
+ error (f_"expecting XML expression to return an integer (expression: %s, matching s...