Pino Toscano
2020-Jan-17 16:19 UTC
[Libguestfs] [v2v PATCH] -o libvirt: read pool name from object
Now that we have a Libvirt.Pool object for the output storage pool,
query it to get its name instead of reading it from the XML.
The result is unchanged.
---
v2v/output_libvirt.ml | 12 +++---------
1 file changed, 3 insertions(+), 9 deletions(-)
diff --git a/v2v/output_libvirt.ml b/v2v/output_libvirt.ml
index 0247e5ad..dfd5d1a3 100644
--- a/v2v/output_libvirt.ml
+++ b/v2v/output_libvirt.ml
@@ -105,9 +105,8 @@ object (self)
(* Connect to output libvirt instance and check that the pool exists
* and dump out its XML.
*)
- let xml - let pool = Libvirt_utils.get_pool self#conn output_pool in
- Libvirt.Pool.get_xml_desc (Libvirt.Pool.const pool) in
+ let pool = Libvirt_utils.get_pool self#conn output_pool in
+ let xml = Libvirt.Pool.get_xml_desc (Libvirt.Pool.const pool) in
let doc = Xml.parse_memory xml in
let xpathctx = Xml.xpath_new_context doc in
let xpath_string = xpath_string xpathctx in
@@ -125,12 +124,7 @@ object (self)
(* Get the name of the pool, since we have to use that
* (and not the UUID) in the XML of the guest.
*)
- let name - match xpath_string "/pool/name/text()" with
- | None ->
- error (f_"-o libvirt: output pool ā%sā does not have /pool/name
element. See virt-v2v-output-local(1)") output_pool
- | Some name -> name in
- pool_name <- Some name;
+ pool_name <- Some (Libvirt.Pool.get_name (Libvirt.Pool.const pool));
(* Set up the targets. *)
List.map (
--
2.24.1
Richard W.M. Jones
2020-Jan-17 21:50 UTC
Re: [Libguestfs] [v2v PATCH] -o libvirt: read pool name from object
On Fri, Jan 17, 2020 at 05:19:27PM +0100, Pino Toscano wrote:> Now that we have a Libvirt.Pool object for the output storage pool, > query it to get its name instead of reading it from the XML. > > The result is unchanged. > --- > v2v/output_libvirt.ml | 12 +++--------- > 1 file changed, 3 insertions(+), 9 deletions(-) > > diff --git a/v2v/output_libvirt.ml b/v2v/output_libvirt.ml > index 0247e5ad..dfd5d1a3 100644 > --- a/v2v/output_libvirt.ml > +++ b/v2v/output_libvirt.ml > @@ -105,9 +105,8 @@ object (self) > (* Connect to output libvirt instance and check that the pool exists > * and dump out its XML. > *) > - let xml > - let pool = Libvirt_utils.get_pool self#conn output_pool in > - Libvirt.Pool.get_xml_desc (Libvirt.Pool.const pool) in > + let pool = Libvirt_utils.get_pool self#conn output_pool in > + let xml = Libvirt.Pool.get_xml_desc (Libvirt.Pool.const pool) in > let doc = Xml.parse_memory xml in > let xpathctx = Xml.xpath_new_context doc in > let xpath_string = xpath_string xpathctx in > @@ -125,12 +124,7 @@ object (self) > (* Get the name of the pool, since we have to use that > * (and not the UUID) in the XML of the guest. > *) > - let name > - match xpath_string "/pool/name/text()" with > - | None -> > - error (f_"-o libvirt: output pool ā%sā does not have /pool/name element. See virt-v2v-output-local(1)") output_pool > - | Some name -> name in > - pool_name <- Some name; > + pool_name <- Some (Libvirt.Pool.get_name (Libvirt.Pool.const pool)); > > (* Set up the targets. *) > List.map (Looks fine, ACK. 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
Seemingly Similar Threads
- [PATCH] v2v: -o libvirt: always write pool names (RHBZ#1141631)
- [PATCH v4 4/7] v2v: -o libvirt: use a Lazy for the connection
- [PATCH v4 3/7] v2v: switch to ocaml-libvirt
- [PATCH v4 5/7] v2v: -o libvirt: switch away from virsh
- [PATCH] v2v: make virsh command quiet if v2v is quiet (RHBZ#1358142)