|
|
ffd6ed |
From 124edcf9a0900dc8e721180217b550b846b7c8f9 Mon Sep 17 00:00:00 2001
|
|
|
ffd6ed |
From: Pino Toscano <ptoscano@redhat.com>
|
|
|
ffd6ed |
Date: Tue, 14 Apr 2015 16:35:51 +0200
|
|
|
ffd6ed |
Subject: [PATCH] v2v: domainxml: add vol_dumpxml
|
|
|
ffd6ed |
|
|
|
ffd6ed |
Add a new vol_dumpxml to get the XML dump of a pool's volume.
|
|
|
ffd6ed |
|
|
|
ffd6ed |
(cherry picked from commit 5da2ed95c11af6be6bee27f5b3dce8a6f3a29d74)
|
|
|
ffd6ed |
---
|
|
|
ffd6ed |
v2v/domainxml-c.c | 61 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
|
|
ffd6ed |
v2v/domainxml.ml | 1 +
|
|
|
ffd6ed |
v2v/domainxml.mli | 6 ++++++
|
|
|
ffd6ed |
3 files changed, 68 insertions(+)
|
|
|
ffd6ed |
|
|
|
ffd6ed |
diff --git a/v2v/domainxml-c.c b/v2v/domainxml-c.c
|
|
|
ffd6ed |
index ba2a5bc..60157e1 100644
|
|
|
ffd6ed |
--- a/v2v/domainxml-c.c
|
|
|
ffd6ed |
+++ b/v2v/domainxml-c.c
|
|
|
ffd6ed |
@@ -305,6 +305,61 @@ v2v_pool_dumpxml (value connv, value poolnamev)
|
|
|
ffd6ed |
CAMLreturn (retv);
|
|
|
ffd6ed |
}
|
|
|
ffd6ed |
|
|
|
ffd6ed |
+value
|
|
|
ffd6ed |
+v2v_vol_dumpxml (value connv, value poolnamev, value volnamev)
|
|
|
ffd6ed |
+{
|
|
|
ffd6ed |
+ CAMLparam3 (connv, poolnamev, volnamev);
|
|
|
ffd6ed |
+ CAMLlocal1 (retv);
|
|
|
ffd6ed |
+ const char *volname;
|
|
|
ffd6ed |
+ /* We have to assemble the error on the stack because a dynamic
|
|
|
ffd6ed |
+ * string couldn't be freed.
|
|
|
ffd6ed |
+ */
|
|
|
ffd6ed |
+ char errmsg[256];
|
|
|
ffd6ed |
+ virErrorPtr err;
|
|
|
ffd6ed |
+ virConnectPtr conn;
|
|
|
ffd6ed |
+ virStoragePoolPtr pool;
|
|
|
ffd6ed |
+ virStorageVolPtr vol;
|
|
|
ffd6ed |
+ char *xml;
|
|
|
ffd6ed |
+
|
|
|
ffd6ed |
+ /* Look up the pool. */
|
|
|
ffd6ed |
+ pool = connect_and_load_pool (connv, poolnamev);
|
|
|
ffd6ed |
+ conn = virStoragePoolGetConnect (pool);
|
|
|
ffd6ed |
+
|
|
|
ffd6ed |
+ /* Look up the volume. */
|
|
|
ffd6ed |
+ volname = String_val (volnamev);
|
|
|
ffd6ed |
+
|
|
|
ffd6ed |
+ vol = virStorageVolLookupByName (pool, volname);
|
|
|
ffd6ed |
+
|
|
|
ffd6ed |
+ if (!vol) {
|
|
|
ffd6ed |
+ err = virGetLastError ();
|
|
|
ffd6ed |
+ snprintf (errmsg, sizeof errmsg,
|
|
|
ffd6ed |
+ _("cannot find libvirt volume '%s': %s"), volname, err->message);
|
|
|
ffd6ed |
+ virStoragePoolFree (pool);
|
|
|
ffd6ed |
+ virConnectClose (conn);
|
|
|
ffd6ed |
+ caml_invalid_argument (errmsg);
|
|
|
ffd6ed |
+ }
|
|
|
ffd6ed |
+
|
|
|
ffd6ed |
+ xml = virStorageVolGetXMLDesc (vol, 0);
|
|
|
ffd6ed |
+ if (xml == NULL) {
|
|
|
ffd6ed |
+ err = virGetLastError ();
|
|
|
ffd6ed |
+ snprintf (errmsg, sizeof errmsg,
|
|
|
ffd6ed |
+ _("cannot fetch XML description of volume '%s': %s"),
|
|
|
ffd6ed |
+ volname, err->message);
|
|
|
ffd6ed |
+ virStorageVolFree (vol);
|
|
|
ffd6ed |
+ virStoragePoolFree (pool);
|
|
|
ffd6ed |
+ virConnectClose (conn);
|
|
|
ffd6ed |
+ caml_invalid_argument (errmsg);
|
|
|
ffd6ed |
+ }
|
|
|
ffd6ed |
+ virStorageVolFree (vol);
|
|
|
ffd6ed |
+ virStoragePoolFree (pool);
|
|
|
ffd6ed |
+ virConnectClose (conn);
|
|
|
ffd6ed |
+
|
|
|
ffd6ed |
+ retv = caml_copy_string (xml);
|
|
|
ffd6ed |
+ free (xml);
|
|
|
ffd6ed |
+
|
|
|
ffd6ed |
+ CAMLreturn (retv);
|
|
|
ffd6ed |
+}
|
|
|
ffd6ed |
+
|
|
|
ffd6ed |
#else /* !HAVE_LIBVIRT */
|
|
|
ffd6ed |
|
|
|
ffd6ed |
value
|
|
|
ffd6ed |
@@ -319,4 +374,10 @@ v2v_pool_dumpxml (value connv, value poolv)
|
|
|
ffd6ed |
caml_invalid_argument ("virt-v2v was compiled without libvirt support");
|
|
|
ffd6ed |
}
|
|
|
ffd6ed |
|
|
|
ffd6ed |
+value
|
|
|
ffd6ed |
+v2v_vol_dumpxml (value connv, value poolnamev, value volnamev)
|
|
|
ffd6ed |
+{
|
|
|
ffd6ed |
+ caml_invalid_argument ("virt-v2v was compiled without libvirt support");
|
|
|
ffd6ed |
+}
|
|
|
ffd6ed |
+
|
|
|
ffd6ed |
#endif /* !HAVE_LIBVIRT */
|
|
|
ffd6ed |
diff --git a/v2v/domainxml.ml b/v2v/domainxml.ml
|
|
|
ffd6ed |
index 61ed5e0..d8b9ed4 100644
|
|
|
ffd6ed |
--- a/v2v/domainxml.ml
|
|
|
ffd6ed |
+++ b/v2v/domainxml.ml
|
|
|
ffd6ed |
@@ -20,3 +20,4 @@
|
|
|
ffd6ed |
|
|
|
ffd6ed |
external dumpxml : ?password:string -> ?conn:string -> string -> string = "v2v_dumpxml"
|
|
|
ffd6ed |
external pool_dumpxml : ?conn:string -> string -> string = "v2v_pool_dumpxml"
|
|
|
ffd6ed |
+external vol_dumpxml : ?conn:string -> string -> string -> string = "v2v_vol_dumpxml"
|
|
|
ffd6ed |
diff --git a/v2v/domainxml.mli b/v2v/domainxml.mli
|
|
|
ffd6ed |
index ffb1c46..98690fe 100644
|
|
|
ffd6ed |
--- a/v2v/domainxml.mli
|
|
|
ffd6ed |
+++ b/v2v/domainxml.mli
|
|
|
ffd6ed |
@@ -32,3 +32,9 @@ val pool_dumpxml : ?conn:string -> string -> string
|
|
|
ffd6ed |
(** [pool_dumpxml ?conn pool] returns the libvirt XML of pool [pool].
|
|
|
ffd6ed |
The optional [?conn] parameter is the libvirt connection URI.
|
|
|
ffd6ed |
[pool] may be a pool name or UUID. *)
|
|
|
ffd6ed |
+
|
|
|
ffd6ed |
+val vol_dumpxml : ?conn:string -> string -> string -> string
|
|
|
ffd6ed |
+(** [vol_dumpxml ?conn pool vol] returns the libvirt XML of volume [vol],
|
|
|
ffd6ed |
+ which is part of the pool [pool].
|
|
|
ffd6ed |
+ The optional [?conn] parameter is the libvirt connection URI.
|
|
|
ffd6ed |
+ [pool] may be a pool name or UUID. *)
|
|
|
ffd6ed |
--
|
|
|
ffd6ed |
1.8.3.1
|
|
|
ffd6ed |
|