Displaying 20 results from an estimated 54 matches for "xpath_eval_express".
2017 Oct 27
0
[PATCH v11 7/8] mllib: add XPath helper xpath_get_nodes
...ls/xpath_helpers.ml
+++ b/common/mltools/xpath_helpers.ml
@@ -40,3 +40,12 @@ let xpath_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...
2015 Jun 25
0
[PATCH v2] v2v: Free XML objects in the correct order.
...freeing up objects in the correct order,
because we didn't express the dependency between objects at the C
level into the OCaml, where the OCaml garbage collector could see
those dependencies. For example code like:
let doc = ... in
let xpathctx = xpath_new_context doc in
let xpathobj = xpath_eval_expression xpathctx "/foo" in
might end up freeing the 'doc' (xmlDocPtr) if, say, there were no
further references to it in the code, even though the 'xpathobj'
(xmlXPathObjectPtr) remains live.
To avoid this, we change the OCaml-level representation of objects
like xpathobj so...
2015 Jun 25
0
[PATCH] v2v: Free XML objects in the correct order.
...freeing up objects in the correct order,
because we didn't express the dependency between objects at the C
level into the OCaml, where the OCaml garbage collector could see
those dependencies. For example code like:
let doc = ... in
let xpathctx = xpath_new_context doc in
let xpathobj = xpath_eval_expression xpathctx "/foo" in
might end up freeing the 'doc' (xmlDocPtr) if, say, there were no
further references to it in the code, before freeing the 'xpathobj'
(xmlXPathObjectPtr).
To avoid this, we change the OCaml-level representation of objects
like xpathobj so they conta...
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()
The subject says ‘xpath_get_nodes()‘, but this function doesn'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²...
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
15
[PATCH v11 0/8] virt-builder-repository
Hi all,
Here is the latest version of the series.
Diffs to v10:
* Make Index.arch a (string, string option) maybe and use it
to guess arch at parse time
* Compute the image size at parse time when the template flag
is set and the value is missing.
* Add virt-repository_main slow test
* Other fixes from Richard's comments
Cédric Bosdonnat (7):
Ignore builder/*.out and *.img
2015 Mar 10
0
[PATCH] v2v: Add the test-harness used by external tests.
...done;
+ List.rev !nodes
+ in
+
+ let test_boot boot_disk boot_xml_doc =
+ (* Modify boot XML (in memory). *)
+ let xpathctx = Xml.xpath_new_context boot_xml_doc in
+
+ (* Change <name> to something unique. *)
+ let domname = "tmpv2v-" ^ test in
+ let xpath = Xml.xpath_eval_expression xpathctx "/domain/name" in
+ let nodes = nodes_of_xpathobj boot_xml_doc xpath in
+ List.iter (fun node -> Xml.node_set_content node domname) nodes;
+
+ (* Limit the RAM used by the guest to 2GB. *)
+ let xpath = Xml.xpath_eval_expression xpathctx "/domain/memory&quo...
2015 Mar 10
2
[PATCH 0/1] v2v: Add the test-harness used by external tests.
As I'm now working through the enormous virt-v2v/virt-p2v bug list, we
need a high quality set of tests to ensure that we don't accidentally
regress some old OS/hypervisor combination while making changes.
The test cases are going to be huge, so we cannot possibly distribute
them in libguestfs. Furthermore many of them have licensing problems
which means we cannot redistribute them at
2018 Jun 07
0
[PATCH] v2v: parse_libvirt_xml: Simplify code by using xpath_get_nodes utility fn.
...2v/parse_libvirt_xml.ml b/v2v/parse_libvirt_xml.ml
index 57e741574..03a201e77 100644
--- 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 &qu...
2019 Apr 08
1
[PATCH] v2v: start reading the new libvirt firmware autoselect
...rmware. *)
+ let firmware =
+ match xpath_string "/domain/os/@firmware" with
+ | Some "bios" -> BIOS
+ | Some "efi" -> UEFI
+ | None | Some _ -> UnknownFirmware in
+
(* Check for hostdev devices. (RHBZ#1472719) *)
let () =
let obj = Xml.xpath_eval_expression xpathctx "/domain/devices/hostdev" in
@@ -502,7 +509,7 @@ let parse_libvirt_xml ?conn xml =
s_cpu_model = cpu_model;
s_cpu_topology = cpu_topology;
s_features = features;
- s_firmware = UnknownFirmware; (* XXX until RHBZ#1217444 is fixed *)
+ s_firmware = firmware;...
2017 Aug 30
1
[PATCH] v2v: warn when the guest has hostdev devices (RHBZ#1472719)
....ml b/v2v/parse_libvirt_xml.ml
index 84c5d4fc7..c71707000 100644
--- a/v2v/parse_libvirt_xml.ml
+++ 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...
2017 Mar 13
0
[PATCH 2/2] v2v: -i ova: Factor out the OVF parsing into a separate module.
...om the ova")
- controller;
- None
- in
-
- (* 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 "...
2019 Apr 12
1
[PATCH] v2v: warn when the guest has direct network interfaces (RHBZ#1518539)
..._xml.ml
index 9cf4c496b..14cd82afd 100644
--- a/v2v/parse_libvirt_xml.ml
+++ b/v2v/parse_libvirt_xml.ml
@@ -499,6 +499,24 @@ 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...
2017 Apr 04
1
Re: [PATCH v5 09/10] mllib: add XPath helper xpath_get_nodes()
..._default parsefn xpath expr default =
> let xpath_string_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]
You can use the utilities from Common_utils for manipulating list
references, so:
push_back nodes...
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
...docv)
}
value
+v2v_xml_xpath_register_ns (value prefix, value uri, value xpathctx)
+{
+ CAMLparam3 (prefix, uri, xpathctx);
+ CAMLlocal1 (retval);
+ retval = xmlXPathRegisterNs (BAD_CAST String_val (prefix), BAD_CAST String_val (uri), xpathctx);
+
+ CAMLreturn (retval);
+}
+
+value
v2v_xml_xpath_eval_expression (value xpathctxv, value exprv)
{
CAMLparam2 (xpathctxv, exprv);
diff --git a/v2v/xml.ml b/v2v/xml.ml
index 78cb022..2e4d222 100644
--- a/v2v/xml.ml
+++ b/v2v/xml.ml
@@ -31,6 +31,7 @@ type node = doc * node_ptr
external parse_memory : string -> doc = "v2v_xml_parse_memory"
exte...
2014 Oct 31
0
[PATCH] v2v: -o libvirt: Get the <features/> right in the output XML (RHBZ#1159258).
...oc arch =
+ let xpathctx = Xml.xpath_new_context doc 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;...
2016 Feb 09
0
[PATCH 1/4] v2v: collect source network and video adapter types
...s = [];
diff --git a/v2v/input_libvirtxml.ml b/v2v/input_libvirtxml.ml
index 3537011..c6f7a1f 100644
--- a/v2v/input_libvirtxml.ml
+++ b/v2v/input_libvirtxml.ml
@@ -140,6 +140,25 @@ let parse_libvirt_xml ?conn xml =
None
) in
+ (* Video adapter. *)
+ let video =
+ let obj = Xml.xpath_eval_expression xpathctx "/domain/devices/video" in
+ let nr_nodes = Xml.xpathobj_nr_nodes obj in
+ if nr_nodes < 1 then None
+ else (
+ (* Ignore everything except the first <video> device. *)
+ let node = Xml.xpathobj_node obj 0 in
+
+ Xml.xpathctx_set_current_contex...
2016 Mar 18
0
[PATCH v4 1/5] v2v: collect source network and video adapter types
...s = [];
diff --git a/v2v/input_libvirtxml.ml b/v2v/input_libvirtxml.ml
index 3537011..9d8963d 100644
--- a/v2v/input_libvirtxml.ml
+++ b/v2v/input_libvirtxml.ml
@@ -140,6 +140,23 @@ let parse_libvirt_xml ?conn xml =
None
) in
+ (* Video adapter. *)
+ let video =
+ let obj = Xml.xpath_eval_expression xpathctx "/domain/devices/video" in
+ let nr_nodes = Xml.xpathobj_nr_nodes obj in
+ if nr_nodes < 1 then None
+ else (
+ (* Ignore everything except the first <video> device. *)
+ let node = Xml.xpathobj_node obj 0 in
+
+ Xml.xpathctx_set_current_contex...