[PATCH] lib: command: Print command before running it with guestfs_int_cmd_pipe_run.
by Richard W.M. Jones
Unlike ordinary guestfs_int_cmd_run, the pipe version did not print
the command it was about to run when debugging was enabled.
Fixes commit e98bb8692929a037f3452686719504aea31f311d.
---
lib/command.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/lib/command.c b/lib/command.c
index 970acf6e5..bc469de59 100644
--- a/lib/command.c
+++ b/lib/command.c
@@ -791,6 +791,9 @@ guestfs_int_cmd_pipe_run (struct command *cmd, const char *mode)
finish_command (cmd);
+ if (cmd->g->verbose)
+ debug_command (cmd);
+
/* Various options cannot be used here. */
assert (!cmd->capture_errors);
assert (!cmd->stdout_callback);
--
2.13.2
7 years, 3 months
[PATCH] RFC: v2v: add and use libvirt connection objects
by Pino Toscano
Enhance the Libvirt_utils module with libvirt connection objects,
and read-only and read-writen open functions for them; adapt the rest of
the mini-binding to use these objects, instead of opening + closing
libvirt connections every time. This has different improvements:
a) a libvirt connection is reused for different API calls, improving
the communication with remote (input) servers
b) because of (a), there is way less need to pass libvirt_uri and
password variables all around
The hierarchy of input_libvirt* classes is changed to take a Lazy object
with the libvirt connection, accessing it through a "proctected" method:
this way, the connection is opened only at the first access.
---
v2v/copy_to_local.ml | 3 +-
v2v/input_libvirt.ml | 13 +-
v2v/input_libvirt_other.ml | 24 ++--
v2v/input_libvirt_other.mli | 5 +-
v2v/input_libvirt_vcenter_https.ml | 10 +-
v2v/input_libvirt_vcenter_https.mli | 2 +-
v2v/input_libvirt_vddk.ml | 18 +--
v2v/input_libvirt_vddk.mli | 4 +-
v2v/input_libvirt_xen_ssh.ml | 10 +-
v2v/input_libvirt_xen_ssh.mli | 2 +-
v2v/input_libvirtxml.ml | 3 +-
v2v/libvirt_utils-c.c | 259 +++++++++++++++++++-----------------
v2v/libvirt_utils.ml | 16 ++-
v2v/libvirt_utils.mli | 44 +++---
v2v/output_libvirt.ml | 8 +-
v2v/parse_libvirt_xml.ml | 4 +-
v2v/parse_libvirt_xml.mli | 2 +-
17 files changed, 233 insertions(+), 194 deletions(-)
diff --git a/v2v/copy_to_local.ml b/v2v/copy_to_local.ml
index 0a2b7ed75..828b5b490 100644
--- a/v2v/copy_to_local.ml
+++ b/v2v/copy_to_local.ml
@@ -131,7 +131,8 @@ read the man page virt-v2v-copy-to-local(1).
(* Get the remote libvirt XML. *)
message (f_"Fetching the remote libvirt XML metadata ...");
- let xml = Libvirt_utils.dumpxml ?password ~conn:input_conn guest_name in
+ let conn = Libvirt_utils.connect_rw ?password ~conn:input_conn () in
+ let xml = Libvirt_utils.dumpxml conn guest_name in
debug "libvirt XML from remote server:\n%s" xml;
diff --git a/v2v/input_libvirt.ml b/v2v/input_libvirt.ml
index e8143b6ad..6baac7d5f 100644
--- a/v2v/input_libvirt.ml
+++ b/v2v/input_libvirt.ml
@@ -28,9 +28,10 @@ open Utils
(* Choose the right subclass based on the URI. *)
let input_libvirt dcpath vddk_options password libvirt_uri guest =
+ let conn = lazy (Libvirt_utils.connect_rw ?password ?conn:libvirt_uri ()) in
match libvirt_uri with
| None ->
- Input_libvirt_other.input_libvirt_other password libvirt_uri guest
+ Input_libvirt_other.input_libvirt_other conn guest
| Some orig_uri ->
let { Xml.uri_server = server; uri_scheme = scheme } as parsed_uri =
@@ -45,7 +46,7 @@ let input_libvirt dcpath vddk_options password libvirt_uri guest =
| Some _, None (* No scheme? *)
| Some _, Some "" ->
- Input_libvirt_other.input_libvirt_other password libvirt_uri guest
+ Input_libvirt_other.input_libvirt_other conn guest
(* vCenter over https, or
* vCenter or ESXi using nbdkit vddk plugin
@@ -54,16 +55,16 @@ let input_libvirt dcpath vddk_options password libvirt_uri guest =
(match vddk_options with
| None ->
Input_libvirt_vcenter_https.input_libvirt_vcenter_https
- dcpath password libvirt_uri parsed_uri scheme server guest
+ dcpath conn password parsed_uri scheme server guest
| Some vddk_options ->
Input_libvirt_vddk.input_libvirt_vddk vddk_options password
- libvirt_uri parsed_uri guest
+ conn parsed_uri guest
)
(* Xen over SSH *)
| Some server, Some ("xen+ssh" as scheme) ->
Input_libvirt_xen_ssh.input_libvirt_xen_ssh
- password libvirt_uri parsed_uri scheme server guest
+ conn parsed_uri scheme server guest
(* Old virt-v2v also supported qemu+ssh://. However I am
* deliberately not supporting this in new virt-v2v. Don't
@@ -74,6 +75,6 @@ let input_libvirt dcpath vddk_options password libvirt_uri guest =
| Some _, Some _ ->
warning (f_"no support for remote libvirt connections to '-ic %s'. The conversion may fail when it tries to read the source disks.")
orig_uri;
- Input_libvirt_other.input_libvirt_other password libvirt_uri guest
+ Input_libvirt_other.input_libvirt_other conn guest
let () = Modules_list.register_input_module "libvirt"
diff --git a/v2v/input_libvirt_other.ml b/v2v/input_libvirt_other.ml
index 05923e952..cd466a2c5 100644
--- a/v2v/input_libvirt_other.ml
+++ b/v2v/input_libvirt_other.ml
@@ -49,24 +49,24 @@ let error_if_no_ssh_agent () =
error (f_"ssh-agent authentication has not been set up ($SSH_AUTH_SOCK is not set). Please read \"INPUT FROM RHEL 5 XEN\" in the virt-v2v(1) man page.")
(* Superclass. *)
-class virtual input_libvirt (password : string option) libvirt_uri guest =
-object
+class virtual input_libvirt lazy_conn guest =
+ let conn_obj = lazy_conn in
+object (self)
inherit input
method as_options =
- sprintf "-i libvirt%s %s"
- (match libvirt_uri with
- | None -> ""
- | Some uri -> " -ic " ^ uri)
- guest
+ sprintf "-i libvirt -ic %s %s" (Libvirt_utils.get_uri self#conn) guest
+
+ method private conn =
+ Lazy.force conn_obj
end
(* Subclass specialized for handling anything that's *not* VMware vCenter
* or Xen.
*)
-class input_libvirt_other password libvirt_uri guest =
-object
- inherit input_libvirt password libvirt_uri guest
+class input_libvirt_other lazy_conn guest =
+object (self)
+ inherit input_libvirt lazy_conn guest
method source () =
debug "input_libvirt_other: source()";
@@ -74,9 +74,9 @@ object
(* Get the libvirt XML. This also checks (as a side-effect)
* that the domain is not running. (RHBZ#1138586)
*)
- let xml = Libvirt_utils.dumpxml ?password ?conn:libvirt_uri guest in
+ let xml = Libvirt_utils.dumpxml self#conn guest in
- let source, disks = parse_libvirt_xml ?conn:libvirt_uri xml in
+ let source, disks = parse_libvirt_xml self#conn xml in
let disks = List.map (fun { p_source_disk = disk } -> disk) disks in
{ source with s_disks = disks }
end
diff --git a/v2v/input_libvirt_other.mli b/v2v/input_libvirt_other.mli
index 603fd3dd2..9645aa5af 100644
--- a/v2v/input_libvirt_other.mli
+++ b/v2v/input_libvirt_other.mli
@@ -21,10 +21,11 @@
val error_if_libvirt_does_not_support_json_backingfile : unit -> unit
val error_if_no_ssh_agent : unit -> unit
-class virtual input_libvirt : string option -> string option -> string -> object
+class virtual input_libvirt : Libvirt_utils.conn Lazy.t -> string -> object
method as_options : string
method virtual source : unit -> Types.source
method adjust_overlay_parameters : Types.overlay -> unit
+ method private conn : Libvirt_utils.conn
end
-val input_libvirt_other : string option -> string option -> string -> Types.input
+val input_libvirt_other : Libvirt_utils.conn Lazy.t -> string -> Types.input
diff --git a/v2v/input_libvirt_vcenter_https.ml b/v2v/input_libvirt_vcenter_https.ml
index 8b6856c7e..54370b954 100644
--- a/v2v/input_libvirt_vcenter_https.ml
+++ b/v2v/input_libvirt_vcenter_https.ml
@@ -36,9 +36,9 @@ let readahead_for_copying = Some (64 * 1024 * 1024)
(* Subclass specialized for handling VMware vCenter over https. *)
class input_libvirt_vcenter_https
- cmdline_dcPath password libvirt_uri parsed_uri scheme server guest =
-object
- inherit input_libvirt password libvirt_uri guest
+ cmdline_dcPath lazy_conn password parsed_uri scheme server guest =
+object (self)
+ inherit input_libvirt lazy_conn guest
val saved_source_paths = Hashtbl.create 13
val mutable dcPath = ""
@@ -64,8 +64,8 @@ object
(* Get the libvirt XML. This also checks (as a side-effect)
* that the domain is not running. (RHBZ#1138586)
*)
- let xml = Libvirt_utils.dumpxml ?password ?conn:libvirt_uri guest in
- let source, disks = parse_libvirt_xml ?conn:libvirt_uri xml in
+ let xml = Libvirt_utils.dumpxml self#conn guest in
+ let source, disks = parse_libvirt_xml self#conn xml in
(* Find the <vmware:datacenterpath> element from the XML, if it
* exists. This was added in libvirt >= 1.2.20.
diff --git a/v2v/input_libvirt_vcenter_https.mli b/v2v/input_libvirt_vcenter_https.mli
index 840b5a90f..6f848f2f0 100644
--- a/v2v/input_libvirt_vcenter_https.mli
+++ b/v2v/input_libvirt_vcenter_https.mli
@@ -18,4 +18,4 @@
(** [-i libvirt] when the source is VMware vCenter *)
-val input_libvirt_vcenter_https : string option -> string option -> string option -> Xml.uri -> string -> string -> string -> Types.input
+val input_libvirt_vcenter_https : string option -> Libvirt_utils.conn Lazy.t -> string option -> Xml.uri -> string -> string -> string -> Types.input
diff --git a/v2v/input_libvirt_vddk.ml b/v2v/input_libvirt_vddk.ml
index b6a57d374..a09c0b55b 100644
--- a/v2v/input_libvirt_vddk.ml
+++ b/v2v/input_libvirt_vddk.ml
@@ -34,7 +34,7 @@ open Xpath_helpers
open Printf
(* Subclass specialized for handling VMware via nbdkit vddk plugin. *)
-class input_libvirt_vddk vddk_options password libvirt_uri parsed_uri guest =
+class input_libvirt_vddk vddk_options password lazy_conn parsed_uri guest =
(* The VDDK path. *)
let libdir = vddk_options.vddk_libdir in
@@ -102,8 +102,8 @@ See also \"INPUT FROM VDDK\" in the virt-v2v(1) manual.") library_path
error (f_"You must pass the ‘--vddk-thumbprint’ option with the SSL thumbprint of the VMware server. To find the thumbprint, see the nbdkit-vddk-plugin(1) manual. See also \"INPUT FROM VDDK\" in the virt-v2v(1) manual.")
in
-object
- inherit input_libvirt password libvirt_uri guest
+object (self)
+ inherit input_libvirt lazy_conn guest
method source () =
error_unless_vddk_libdir ();
@@ -114,8 +114,8 @@ object
(* Get the libvirt XML. This also checks (as a side-effect)
* that the domain is not running. (RHBZ#1138586)
*)
- let xml = Libvirt_utils.dumpxml ?password ?conn:libvirt_uri guest in
- let source, disks = parse_libvirt_xml ?conn:libvirt_uri xml in
+ let xml = Libvirt_utils.dumpxml self#conn guest in
+ let source, disks = parse_libvirt_xml self#conn xml in
(* Find the <vmware:moref> element from the XML. This was added
* in libvirt >= 3.7 and is required.
@@ -163,12 +163,8 @@ object
match parsed_uri.Xml.uri_server with
| Some server -> server
| None ->
- match libvirt_uri with
- | Some libvirt_uri ->
- error (f_"‘-ic %s’ URL does not contain a host name field")
- libvirt_uri
- | None ->
- error (f_"you must use the ‘-ic’ parameter. See \"INPUT FROM VDDK\" in the virt-v2v(1) manual.") in
+ (* XXX *)
+ error (f_"you must use the ‘-ic’ parameter. See \"INPUT FROM VDDK\" in the virt-v2v(1) manual.") in
(* Similar to above, we also need a username to pass. *)
let user =
diff --git a/v2v/input_libvirt_vddk.mli b/v2v/input_libvirt_vddk.mli
index 19a34c202..3017488b5 100644
--- a/v2v/input_libvirt_vddk.mli
+++ b/v2v/input_libvirt_vddk.mli
@@ -18,7 +18,7 @@
(** [-i libvirt] when the source is VMware via nbdkit vddk plugin *)
-val input_libvirt_vddk : Types.vddk_options -> string option -> string option -> Xml.uri -> string -> Types.input
-(** [input_libvirt_vddk vddk_options password libvirt_uri parsed_uri guest]
+val input_libvirt_vddk : Types.vddk_options -> string option -> Libvirt_utils.conn Lazy.t -> Xml.uri -> string -> Types.input
+(** [input_libvirt_vddk vddk_options password conn parsed_uri guest]
creates and returns a {!Types.input} object specialized for reading
the guest disks using the nbdkit vddk plugin. *)
diff --git a/v2v/input_libvirt_xen_ssh.ml b/v2v/input_libvirt_xen_ssh.ml
index fd3da2c44..9d3005855 100644
--- a/v2v/input_libvirt_xen_ssh.ml
+++ b/v2v/input_libvirt_xen_ssh.ml
@@ -30,9 +30,9 @@ open Input_libvirt_other
open Printf
(* Subclass specialized for handling Xen over SSH. *)
-class input_libvirt_xen_ssh password libvirt_uri parsed_uri scheme server guest =
-object
- inherit input_libvirt password libvirt_uri guest
+class input_libvirt_xen_ssh lazy_conn parsed_uri scheme server guest =
+object (self)
+ inherit input_libvirt lazy_conn guest
method source () =
debug "input_libvirt_xen_ssh: source: scheme %s server %s"
@@ -47,8 +47,8 @@ object
(* Get the libvirt XML. This also checks (as a side-effect)
* that the domain is not running. (RHBZ#1138586)
*)
- let xml = Libvirt_utils.dumpxml ?password ?conn:libvirt_uri guest in
- let source, disks = parse_libvirt_xml ?conn:libvirt_uri xml in
+ let xml = Libvirt_utils.dumpxml self#conn guest in
+ let source, disks = parse_libvirt_xml self#conn xml in
(* Map the <source/> filename (which is relative to the remote
* Xen server) to an ssh URI. This is a JSON URI looking something
diff --git a/v2v/input_libvirt_xen_ssh.mli b/v2v/input_libvirt_xen_ssh.mli
index 85213241a..bde0ff65a 100644
--- a/v2v/input_libvirt_xen_ssh.mli
+++ b/v2v/input_libvirt_xen_ssh.mli
@@ -18,4 +18,4 @@
(** [-i libvirt] when the source is Xen *)
-val input_libvirt_xen_ssh : string option -> string option -> Xml.uri -> string -> string -> string -> Types.input
+val input_libvirt_xen_ssh : Libvirt_utils.conn Lazy.t -> Xml.uri -> string -> string -> string -> Types.input
diff --git a/v2v/input_libvirtxml.ml b/v2v/input_libvirtxml.ml
index 570541d7d..5d13faee6 100644
--- a/v2v/input_libvirtxml.ml
+++ b/v2v/input_libvirtxml.ml
@@ -34,7 +34,8 @@ object
method source () =
let xml = read_whole_file file in
- let source, disks = parse_libvirt_xml xml in
+ let conn = Libvirt_utils.connect_ro () in
+ let source, disks = parse_libvirt_xml conn xml in
(* When reading libvirt XML from a file (-i libvirtxml) we allow
* paths to disk images in the libvirt XML to be relative (to the XML
diff --git a/v2v/libvirt_utils-c.c b/v2v/libvirt_utils-c.c
index 93ee5208e..fec14356b 100644
--- a/v2v/libvirt_utils-c.c
+++ b/v2v/libvirt_utils-c.c
@@ -31,6 +31,7 @@
#include <libintl.h>
#include <caml/alloc.h>
+#include <caml/custom.h>
#include <caml/fail.h>
#include <caml/memory.h>
#include <caml/mlvalues.h>
@@ -49,6 +50,39 @@
#define ERROR_MESSAGE_LEN 512
+/* Wrap and unwrap virConnectPtr, with a finalizer. */
+#define Libvirtconn_val(rv) (*(virConnectPtr *)Data_custom_val(rv))
+
+static void
+libvirtconn_finalize (value rev)
+{
+ virConnectPtr conn = Libvirtconn_val (rev);
+ if (conn)
+ virConnectClose (conn);
+}
+
+static struct custom_operations custom_operations = {
+ (char *) "libvirtconn_custom_operations",
+ libvirtconn_finalize,
+ custom_compare_default,
+ custom_hash_default,
+ custom_serialize_default,
+ custom_deserialize_default
+};
+
+static value
+Val_libvirtconn (virConnectPtr conn)
+{
+ CAMLparam0 ();
+ CAMLlocal1 (rv);
+
+ rv = caml_alloc_custom (&custom_operations, sizeof (virConnectPtr), 0, 1);
+ Libvirtconn_val (rv) = conn;
+
+ CAMLreturn (rv);
+}
+
+
static void
ignore_errors (void *ignore, virErrorPtr ignore2)
{
@@ -111,11 +145,10 @@ libvirt_auth_default_wrapper (virConnectCredentialPtr cred,
}
}
-virStoragePoolPtr
+static virStoragePoolPtr
connect_and_load_pool (value connv, value poolnamev)
{
CAMLparam2 (connv, poolnamev);
- const char *conn_uri = NULL;
const char *poolname;
/* We have to assemble the error on the stack because a dynamic
* string couldn't be freed.
@@ -125,31 +158,8 @@ connect_and_load_pool (value connv, value poolnamev)
virConnectPtr conn;
virStoragePoolPtr pool;
- if (connv != Val_int (0))
- conn_uri = String_val (Field (connv, 0)); /* Some conn */
-
- /* We have to call the default authentication handler, not least
- * since it handles all the PolicyKit crap. However it also makes
- * coding this simpler.
- */
- conn = virConnectOpenAuth (conn_uri, virConnectAuthPtrDefault,
- VIR_CONNECT_RO);
- if (conn == NULL) {
- if (conn_uri)
- snprintf (errmsg, sizeof errmsg,
- _("cannot open libvirt connection ‘%s’"), conn_uri);
- else
- snprintf (errmsg, sizeof errmsg, _("cannot open libvirt connection"));
- caml_invalid_argument (errmsg);
- }
-
- /* Suppress default behaviour of printing errors to stderr. Note
- * you can't set this to NULL to ignore errors; setting it to NULL
- * restores the default error handler ...
- */
- virConnSetErrorFunc (conn, NULL, ignore_errors);
-
/* Look up the pool. */
+ conn = Libvirtconn_val (connv);
poolname = String_val (poolnamev);
pool = virStoragePoolLookupByUUIDString (conn, poolname);
@@ -162,48 +172,72 @@ connect_and_load_pool (value connv, value poolnamev)
snprintf (errmsg, sizeof errmsg,
_("cannot find libvirt pool ‘%s’: %s\n\nUse ‘virsh pool-list --all’ to list all available pools, and ‘virsh pool-dumpxml <pool>’ to display details about a particular pool.\n\nTo set the pool which virt-v2v uses, add the ‘-os <pool>’ option."),
poolname, err->message);
- virConnectClose (conn);
caml_invalid_argument (errmsg);
}
CAMLreturnT (virStoragePoolPtr, pool);
}
+
value
-v2v_dumpxml (value passwordv, value connv, value domnamev)
+v2v_libvirt_connect_ro (value connv, value unitv)
{
- CAMLparam3 (passwordv, connv, domnamev);
- CAMLlocal1 (retv);
+ CAMLparam2 (connv, unitv);
+ const char *conn_uri = NULL;
+ char errmsg[ERROR_MESSAGE_LEN];
+ virConnectPtr conn;
+
+ if (connv != Val_int (0))
+ conn_uri = String_val (Field (connv, 0)); /* Some conn */
+
+ /* We have to call the default authentication handler, not least
+ * since it handles all the PolicyKit crap. However it also makes
+ * coding this simpler.
+ */
+ conn = virConnectOpenAuth (conn_uri, virConnectAuthPtrDefault,
+ VIR_CONNECT_RO);
+ if (conn == NULL) {
+ if (conn_uri)
+ snprintf (errmsg, sizeof errmsg,
+ _("cannot open libvirt connection ‘%s’"), conn_uri);
+ else
+ snprintf (errmsg, sizeof errmsg, _("cannot open libvirt connection"));
+ caml_invalid_argument (errmsg);
+ }
+
+ /* Suppress default behaviour of printing errors to stderr. Note
+ * you can't set this to NULL to ignore errors; setting it to NULL
+ * restores the default error handler ...
+ */
+ virConnSetErrorFunc (conn, NULL, ignore_errors);
+
+ CAMLreturn (Val_libvirtconn (conn));
+}
+
+value
+v2v_libvirt_connect_rw (value passwordv, value connv, value unitv)
+{
+ CAMLparam3 (passwordv, connv, unitv);
const char *password = NULL;
const char *conn_uri = NULL;
- const char *domname;
virConnectAuth authdata;
/* We have to assemble the error on the stack because a dynamic
* string couldn't be freed.
*/
char errmsg[ERROR_MESSAGE_LEN];
- virErrorPtr err;
virConnectPtr conn;
- virDomainPtr dom;
- int is_test_uri = 0;
- char *xml;
if (passwordv != Val_int (0))
password = String_val (Field (passwordv, 0)); /* Some password */
- if (connv != Val_int (0)) {
+ if (connv != Val_int (0))
conn_uri = String_val (Field (connv, 0)); /* Some conn */
- is_test_uri = STRPREFIX (conn_uri, "test:");
- }
/* Set up authentication wrapper. */
authdata = *virConnectAuthPtrDefault;
authdata.cb = libvirt_auth_default_wrapper;
authdata.cbdata = (void *) password;
- /* Note this cannot be a read-only connection since we need to use
- * the VIR_DOMAIN_XML_SECURE flag below.
- */
conn = virConnectOpenAuth (conn_uri, &authdata, 0);
if (conn == NULL) {
if (conn_uri)
@@ -220,6 +254,26 @@ v2v_dumpxml (value passwordv, value connv, value domnamev)
*/
virConnSetErrorFunc (conn, NULL, ignore_errors);
+ CAMLreturn (Val_libvirtconn (conn));
+}
+
+value
+v2v_libvirt_dumpxml (value connv, value domnamev)
+{
+ CAMLparam2 (connv, domnamev);
+ CAMLlocal1 (retv);
+ const char *domname;
+ /* We have to assemble the error on the stack because a dynamic
+ * string couldn't be freed.
+ */
+ char errmsg[ERROR_MESSAGE_LEN];
+ virErrorPtr err;
+ virConnectPtr conn;
+ virDomainPtr dom;
+ int is_test_uri = 0;
+ char *xml;
+
+ conn = Libvirtconn_val (connv);
/* Look up the domain. */
domname = String_val (domnamev);
@@ -232,10 +286,11 @@ v2v_dumpxml (value passwordv, value connv, value domnamev)
err = virGetLastError ();
snprintf (errmsg, sizeof errmsg,
_("cannot find libvirt domain ‘%s’: %s"), domname, err->message);
- virConnectClose (conn);
caml_invalid_argument (errmsg);
}
+ is_test_uri = STRPREFIX (virConnectGetURI (conn), "test:");
+
/* As a side-effect we check that the domain is shut down. Of course
* this is only appropriate for virt-v2v. (RHBZ#1138586)
*/
@@ -249,7 +304,6 @@ v2v_dumpxml (value passwordv, value connv, value domnamev)
_("libvirt domain ‘%s’ is running or paused. It must be shut down in order to perform virt-v2v conversion"),
domname);
virDomainFree (dom);
- virConnectClose (conn);
caml_invalid_argument (errmsg);
}
}
@@ -262,11 +316,9 @@ v2v_dumpxml (value passwordv, value connv, value domnamev)
_("cannot fetch XML description of guest ‘%s’: %s"),
domname, err->message);
virDomainFree (dom);
- virConnectClose (conn);
caml_invalid_argument (errmsg);
}
virDomainFree (dom);
- virConnectClose (conn);
retv = caml_copy_string (xml);
free (xml);
@@ -275,7 +327,7 @@ v2v_dumpxml (value passwordv, value connv, value domnamev)
}
value
-v2v_pool_dumpxml (value connv, value poolnamev)
+v2v_libvirt_pool_dumpxml (value connv, value poolnamev)
{
CAMLparam2 (connv, poolnamev);
CAMLlocal1 (retv);
@@ -284,13 +336,11 @@ v2v_pool_dumpxml (value connv, value poolnamev)
*/
char errmsg[ERROR_MESSAGE_LEN];
virErrorPtr err;
- virConnectPtr conn;
virStoragePoolPtr pool;
char *xml;
/* Look up the pool. */
pool = connect_and_load_pool (connv, poolnamev);
- conn = virStoragePoolGetConnect (pool);
xml = virStoragePoolGetXMLDesc (pool, 0);
if (xml == NULL) {
@@ -299,11 +349,9 @@ v2v_pool_dumpxml (value connv, value poolnamev)
_("cannot fetch XML description of pool ‘%s’: %s"),
String_val (poolnamev), err->message);
virStoragePoolFree (pool);
- virConnectClose (conn);
caml_invalid_argument (errmsg);
}
virStoragePoolFree (pool);
- virConnectClose (conn);
retv = caml_copy_string (xml);
free (xml);
@@ -312,7 +360,7 @@ v2v_pool_dumpxml (value connv, value poolnamev)
}
value
-v2v_vol_dumpxml (value connv, value poolnamev, value volnamev)
+v2v_libvirt_vol_dumpxml (value connv, value poolnamev, value volnamev)
{
CAMLparam3 (connv, poolnamev, volnamev);
CAMLlocal1 (retv);
@@ -322,14 +370,12 @@ v2v_vol_dumpxml (value connv, value poolnamev, value volnamev)
*/
char errmsg[ERROR_MESSAGE_LEN];
virErrorPtr err;
- virConnectPtr conn;
virStoragePoolPtr pool;
virStorageVolPtr vol;
char *xml;
/* Look up the pool. */
pool = connect_and_load_pool (connv, poolnamev);
- conn = virStoragePoolGetConnect (pool);
/* Look up the volume. */
volname = String_val (volnamev);
@@ -341,7 +387,6 @@ v2v_vol_dumpxml (value connv, value poolnamev, value volnamev)
snprintf (errmsg, sizeof errmsg,
_("cannot find libvirt volume ‘%s’: %s"), volname, err->message);
virStoragePoolFree (pool);
- virConnectClose (conn);
caml_invalid_argument (errmsg);
}
@@ -353,12 +398,10 @@ v2v_vol_dumpxml (value connv, value poolnamev, value volnamev)
volname, err->message);
virStorageVolFree (vol);
virStoragePoolFree (pool);
- virConnectClose (conn);
caml_invalid_argument (errmsg);
}
virStorageVolFree (vol);
virStoragePoolFree (pool);
- virConnectClose (conn);
retv = caml_copy_string (xml);
free (xml);
@@ -367,11 +410,10 @@ v2v_vol_dumpxml (value connv, value poolnamev, value volnamev)
}
value
-v2v_capabilities (value connv, value unitv)
+v2v_libvirt_capabilities (value connv)
{
- CAMLparam2 (connv, unitv);
+ CAMLparam1 (connv);
CAMLlocal1 (capabilitiesv);
- const char *conn_uri = NULL;
char *capabilities;
/* We have to assemble the error on the stack because a dynamic
* string couldn't be freed.
@@ -380,29 +422,7 @@ v2v_capabilities (value connv, value unitv)
virErrorPtr err;
virConnectPtr conn;
- if (connv != Val_int (0))
- conn_uri = String_val (Field (connv, 0)); /* Some conn */
-
- /* We have to call the default authentication handler, not least
- * since it handles all the PolicyKit crap. However it also makes
- * coding this simpler.
- */
- conn = virConnectOpenAuth (conn_uri, virConnectAuthPtrDefault,
- VIR_CONNECT_RO);
- if (conn == NULL) {
- if (conn_uri)
- snprintf (errmsg, sizeof errmsg,
- _("cannot open libvirt connection ‘%s’"), conn_uri);
- else
- snprintf (errmsg, sizeof errmsg, _("cannot open libvirt connection"));
- caml_invalid_argument (errmsg);
- }
-
- /* Suppress default behaviour of printing errors to stderr. Note
- * you can't set this to NULL to ignore errors; setting it to NULL
- * restores the default error handler ...
- */
- virConnSetErrorFunc (conn, NULL, ignore_errors);
+ conn = Libvirtconn_val (connv);
capabilities = virConnectGetCapabilities (conn);
if (!capabilities) {
@@ -410,23 +430,19 @@ v2v_capabilities (value connv, value unitv)
snprintf (errmsg, sizeof errmsg,
_("cannot get libvirt hypervisor capabilities: %s"),
err->message);
- virConnectClose (conn);
caml_invalid_argument (errmsg);
}
capabilitiesv = caml_copy_string (capabilities);
free (capabilities);
- virConnectClose (conn);
-
CAMLreturn (capabilitiesv);
}
value
-v2v_domain_exists (value connv, value domnamev)
+v2v_libvirt_domain_exists (value connv, value domnamev)
{
CAMLparam2 (connv, domnamev);
- const char *conn_uri = NULL;
const char *domname;
/* We have to assemble the error on the stack because a dynamic
* string couldn't be freed.
@@ -437,31 +453,8 @@ v2v_domain_exists (value connv, value domnamev)
virDomainPtr dom;
int domain_exists;
- if (connv != Val_int (0))
- conn_uri = String_val (Field (connv, 0)); /* Some conn */
-
- /* We have to call the default authentication handler, not least
- * since it handles all the PolicyKit crap. However it also makes
- * coding this simpler.
- */
- conn = virConnectOpenAuth (conn_uri, virConnectAuthPtrDefault,
- VIR_CONNECT_RO);
- if (conn == NULL) {
- if (conn_uri)
- snprintf (errmsg, sizeof errmsg,
- _("cannot open libvirt connection ‘%s’"), conn_uri);
- else
- snprintf (errmsg, sizeof errmsg, _("cannot open libvirt connection"));
- caml_invalid_argument (errmsg);
- }
-
- /* Suppress default behaviour of printing errors to stderr. Note
- * you can't set this to NULL to ignore errors; setting it to NULL
- * restores the default error handler ...
- */
- virConnSetErrorFunc (conn, NULL, ignore_errors);
-
/* Look up the domain. */
+ conn = Libvirtconn_val (connv);
domname = String_val (domnamev);
dom = virDomainLookupByName (conn, domname);
@@ -477,17 +470,44 @@ v2v_domain_exists (value connv, value domnamev)
snprintf (errmsg, sizeof errmsg,
_("cannot find libvirt domain ‘%s’: %s"),
domname, err->message);
- virConnectClose (conn);
caml_invalid_argument (errmsg);
}
}
- virConnectClose (conn);
-
CAMLreturn (Val_bool (domain_exists));
}
value
+v2v_libvirt_get_uri (value connv)
+{
+ CAMLparam1 (connv);
+ CAMLlocal1 (uriv);
+ char *uri;
+ /* We have to assemble the error on the stack because a dynamic
+ * string couldn't be freed.
+ */
+ char errmsg[ERROR_MESSAGE_LEN];
+ virErrorPtr err;
+ virConnectPtr conn;
+
+ conn = Libvirtconn_val (connv);
+
+ uri = virConnectGetURI (conn);
+ if (!uri) {
+ err = virGetLastError ();
+ snprintf (errmsg, sizeof errmsg,
+ _("cannot get libvirt hypervisor URI: %s"),
+ err->message);
+ caml_invalid_argument (errmsg);
+ }
+
+ uriv = caml_copy_string (uri);
+ free (uri);
+
+ CAMLreturn (uriv);
+}
+
+value
v2v_libvirt_get_version (value unitv)
{
CAMLparam1 (unitv);
@@ -529,11 +549,12 @@ v2v_libvirt_get_version (value unitv)
caml_invalid_argument ("virt-v2v was compiled without libvirt support"); \
}
-NO_LIBVIRT (value v2v_dumpxml (value connv, value domv))
-NO_LIBVIRT (value v2v_pool_dumpxml (value connv, value poolv))
-NO_LIBVIRT (value v2v_vol_dumpxml (value connv, value poolnamev, value volnamev))
-NO_LIBVIRT (value v2v_capabilities (value connv, value unitv))
-NO_LIBVIRT (value v2v_domain_exists (value connv, value domnamev))
+NO_LIBVIRT (value v2v_libvirt_dumpxml (value connv, value domv))
+NO_LIBVIRT (value v2v_libvirt_pool_dumpxml (value connv, value poolv))
+NO_LIBVIRT (value v2v_libvirt_vol_dumpxml (value connv, value poolnamev, value volnamev))
+NO_LIBVIRT (value v2v_libvirt_capabilities (value connv, value unitv))
+NO_LIBVIRT (value v2v_libvirt_domain_exists (value connv, value domnamev))
+NO_LIBVIRT (value v2v_libvirt_get_uri (value connv))
NO_LIBVIRT (value v2v_libvirt_get_version (value unitv))
#endif /* !HAVE_LIBVIRT */
diff --git a/v2v/libvirt_utils.ml b/v2v/libvirt_utils.ml
index 248d78c72..d813855cd 100644
--- a/v2v/libvirt_utils.ml
+++ b/v2v/libvirt_utils.ml
@@ -19,13 +19,19 @@
(* This module implements various [virsh]-like commands, but with
non-broken authentication handling. *)
-external dumpxml : ?password:string -> ?conn:string -> string -> string = "v2v_dumpxml"
-external pool_dumpxml : ?conn:string -> string -> string = "v2v_pool_dumpxml"
-external vol_dumpxml : ?conn:string -> string -> string -> string = "v2v_vol_dumpxml"
+type conn
+external connect_ro : ?conn:string -> unit -> conn = "v2v_libvirt_connect_ro"
+external connect_rw : ?password:string -> ?conn:string -> unit -> conn = "v2v_libvirt_connect_rw"
-external capabilities : ?conn:string -> unit -> string = "v2v_capabilities"
+external dumpxml : conn -> string -> string = "v2v_libvirt_dumpxml"
+external pool_dumpxml : conn -> string -> string = "v2v_libvirt_pool_dumpxml"
+external vol_dumpxml : conn -> string -> string -> string = "v2v_libvirt_vol_dumpxml"
-external domain_exists : ?conn:string -> string -> bool = "v2v_domain_exists"
+external capabilities : conn -> string = "v2v_libvirt_capabilities"
+
+external domain_exists : conn -> string -> bool = "v2v_libvirt_domain_exists"
+
+external get_uri : conn -> string = "v2v_libvirt_get_uri"
external libvirt_get_version : unit -> int * int * int
= "v2v_libvirt_get_version"
diff --git a/v2v/libvirt_utils.mli b/v2v/libvirt_utils.mli
index 53dfd48e5..11a83b9a2 100644
--- a/v2v/libvirt_utils.mli
+++ b/v2v/libvirt_utils.mli
@@ -24,32 +24,42 @@
password prompt to stdout, which is the same place we would be
reading the XML from. This file works around this brokenness. *)
-val dumpxml : ?password:string -> ?conn:string -> string -> string
-(** [dumpxml ?password ?conn dom] returns the libvirt XML of domain [dom].
- The optional [?conn] parameter is the libvirt connection URI.
+type conn
+(** The type of a compiled regular expression. *)
+
+val connect_ro : ?conn:string -> unit -> conn
+(** Connect in read-only mode to the specified URI. *)
+
+val connect_rw : ?password:string -> ?conn:string -> unit -> conn
+(** Connect in read-only mode to the specified URI. *)
+
+val dumpxml : conn -> string -> string
+(** [dumpxml conn dom] returns the libvirt XML of domain [dom]
+ in the libvirt connection [conn].
[dom] may be a guest name or UUID. *)
-val pool_dumpxml : ?conn:string -> string -> string
-(** [pool_dumpxml ?conn pool] returns the libvirt XML of pool [pool].
- The optional [?conn] parameter is the libvirt connection URI.
+val pool_dumpxml : conn -> string -> string
+(** [pool_dumpxml ?conn pool] returns the libvirt XML of pool [pool]
+ in the libvirt connection [conn].
[pool] may be a pool name or UUID. *)
-val vol_dumpxml : ?conn:string -> string -> string -> string
-(** [vol_dumpxml ?conn pool vol] returns the libvirt XML of volume [vol],
- which is part of the pool [pool].
- The optional [?conn] parameter is the libvirt connection URI.
+val vol_dumpxml : conn -> string -> string -> string
+(** [vol_dumpxml conn pool vol] returns the libvirt XML of volume [vol],
+ which is part of the pool [pool], in the libvirt connection [conn].
[pool] may be a pool name or UUID. *)
-val capabilities : ?conn:string -> unit -> string
-(** [capabilities ?conn ()] returns the libvirt capabilities XML.
- The optional [?conn] parameter is the libvirt connection URI. *)
+val capabilities : conn -> string
+(** [capabilities conn] returns the libvirt capabilities XML
+ of the libvirt connection [conn]. *)
-val domain_exists : ?conn:string -> string -> bool
-(** [domain_exists ?conn dom] returns a boolean indicating if the
- the libvirt XML domain [dom] exists.
- The optional [?conn] parameter is the libvirt connection URI.
+val domain_exists : conn -> string -> bool
+(** [domain_exists conn dom] returns a boolean indicating if the
+ the libvirt XML domain [dom] exists in the libvirt connection [conn].
[dom] may be a guest name, but not a UUID. *)
+val get_uri : conn -> string
+(** [get_uri conn] returns the URI of the libvirt connection [conn]. *)
+
val libvirt_get_version : unit -> int * int * int
(** [libvirt_get_version] returns the triple [(major, minor, release)]
version number of the libvirt library that we are linked against. *)
diff --git a/v2v/output_libvirt.ml b/v2v/output_libvirt.ml
index b5df8245f..e00cac24b 100644
--- a/v2v/output_libvirt.ml
+++ b/v2v/output_libvirt.ml
@@ -78,8 +78,10 @@ class output_libvirt oc output_pool = object
| Some uri -> sprintf "-o libvirt -oc %s -os %s" uri output_pool
method prepare_targets source targets =
+ let conn = Libvirt_utils.connect_ro ?conn:oc () in
+
(* Get the capabilities from libvirt. *)
- let xml = Libvirt_utils.capabilities ?conn:oc () in
+ let xml = Libvirt_utils.capabilities conn in
debug "libvirt capabilities XML:\n%s" xml;
(* This just checks that the capabilities XML is well-formed,
@@ -94,7 +96,7 @@ class output_libvirt oc output_pool = object
capabilities_doc <- Some doc;
(* Does the domain already exist on the target? (RHBZ#889082) *)
- if Libvirt_utils.domain_exists ?conn:oc source.s_name then (
+ if Libvirt_utils.domain_exists conn source.s_name then (
if source.s_hypervisor = Physical then (* virt-p2v user *)
error (f_"a libvirt domain called ‘%s’ already exists on the target.\n\nIf using virt-p2v, select a different ‘Name’ in the ‘Target properties’. Or delete the existing domain on the target using the ‘virsh undefine’ command.")
source.s_name
@@ -106,7 +108,7 @@ class output_libvirt oc output_pool = object
(* Connect to output libvirt instance and check that the pool exists
* and dump out its XML.
*)
- let xml = Libvirt_utils.pool_dumpxml ?conn:oc output_pool in
+ let xml = Libvirt_utils.pool_dumpxml conn output_pool in
let doc = Xml.parse_memory xml in
let xpathctx = Xml.xpath_new_context doc in
let xpath_string = xpath_string xpathctx in
diff --git a/v2v/parse_libvirt_xml.ml b/v2v/parse_libvirt_xml.ml
index c71707000..e3260c429 100644
--- a/v2v/parse_libvirt_xml.ml
+++ b/v2v/parse_libvirt_xml.ml
@@ -71,7 +71,7 @@ let create_curl_qemu_uri driver host port path =
(* Turn the JSON parameters into a 'json:' protocol string. *)
"json: " ^ JSON.string_of_doc json_params
-let parse_libvirt_xml ?conn xml =
+let parse_libvirt_xml conn xml =
debug "libvirt xml is:\n%s" xml;
let doc = Xml.parse_memory xml in
@@ -328,7 +328,7 @@ let parse_libvirt_xml ?conn xml =
(match xpath_string "source/@pool", xpath_string "source/@volume" with
| None, None | Some _, None | None, Some _ -> ()
| Some pool, Some vol ->
- let xml = Libvirt_utils.vol_dumpxml ?conn pool vol in
+ let xml = Libvirt_utils.vol_dumpxml conn pool vol in
let doc = Xml.parse_memory xml in
let xpathctx = Xml.xpath_new_context doc in
let xpath_string = Xpath_helpers.xpath_string xpathctx in
diff --git a/v2v/parse_libvirt_xml.mli b/v2v/parse_libvirt_xml.mli
index 3d4f7b375..1f2a5056e 100644
--- a/v2v/parse_libvirt_xml.mli
+++ b/v2v/parse_libvirt_xml.mli
@@ -27,7 +27,7 @@ and parsed_source =
| P_source_file of string (** <source file> *)
| P_dont_rewrite (** s_qemu_uri is already set. *)
-val parse_libvirt_xml : ?conn:string -> string -> Types.source * parsed_disk list
+val parse_libvirt_xml : Libvirt_utils.conn -> string -> Types.source * parsed_disk list
(** Take libvirt XML and parse it into a {!Types.source} structure and a
list of source disks.
--
2.13.5
7 years, 3 months
The issue about code coverage for libguestfs
by Yongkui Guo
Hi,
I tried to do code coverage testing for libguestfs with gcov.
The steps are shown as follows:
1. Download and install the source package(libguestfs-1.36.5-1.el7.src.rpm)
2. Modify libguestfs.spec file
#diff -u libguestfs.spec libguestfs.spec.modify
---------------------------------------------------------------------------------------
--- libguestfs.spec 2017-08-29 02:44:35.623751541 -0400
+++ libguestfs.spec.modify 2017-08-29 06:09:49.650654223 -0400
@@ -14,7 +14,7 @@
Name: libguestfs
Epoch: 1
Version: 1.36.5
-Release: 1%{?dist}
+Release: 1.gcov%{?dist}
License: LGPLv2+
# Source and patches.
@@ -69,7 +69,7 @@
Patch0034: 0034-RHEL-7-v2v-disable-unconfig-of-manually-installed-VM.patch
Patch0035: 0035-v2v-i-ova-Prefer-pigz-or-pxz-for-uncompressing-OVA-f.patch
Patch0036: 0036-resize-handle-empty-UUIDs-for-swap-partitions-RHBZ-1.patch
-
+Patch0037: 0037-possible-link-fix.patch
# Use git for patch management.
BuildRequires: git
@@ -815,6 +815,8 @@
%build
+CFLAGS="-fprofile-arcs -ftest-coverage -g -O0"; export CFLAGS
+LDFLAGS="-fprofile-arcs -ftest-coverage -lgcov"; export LDFLAGS
# Test if network is available.
ip addr list ||:
ip route list ||:
@@ -852,6 +854,7 @@
--disable-golang \
$extra
+sed -i 's/^CFLAGS = -fprofile-arcs -ftest-coverage -g -O0/CFLAGS = /g' /home/mockbuild/rpmbuild/BUILD/libguestfs-1.36.5/ocaml/Makefile
# Building index-parse.c by hand works around a race condition in the
# autotools cruft, where two or more copies of yacc race with each
# other, resulting in a corrupted file.
------------------------------------------------------------------------------------------
3.Execute rpmbuild command, but it failed with some errors.
#rpmbuild -ba SPECS/libguestfs.spec
------------------------------------------------------------------------------------------
...
gcc -std=gnu99 -std=gnu99 -DHAVE_CONFIG_H -I. -I.. -DGUESTFS_PRIVATE=1 -I.. -I/usr/lib64/ocaml -I../ocaml -I../common/utils -I../common/utils -I../lib -I../lib -I../gnulib/lib -I../gnulib/lib -fno-common -W -Wabi -Waddress -Waggressive-loop-optimizations -Wall -Wattributes -Wbad-function-cast -Wbuiltin-macro-redefined -Wchar-subscripts -Wclobbered -Wcomment -Wcomments -Wcoverage-mismatch -Wcpp -Wdeprecated -Wdeprecated-declarations -Wdisabled-optimization -Wdiv-by-zero -Wdouble-promotion -Wempty-body -Wendif-labels -Wenum-compare -Wextra -Wformat-contains-nul -Wformat-extra-args -Wformat-nonliteral -Wformat-security -Wformat-y2k -Wformat-zero-length -Wfree-nonheap-object -Wignored-qualifiers -Wimplicit -Wimplicit-function-declaration -Wimplicit-int -Winit-self -Wint-to-pointer-cast -Winvalid-memory-model -Winvalid-pch -Wjump-misses-init -Wlogical-op -Wmain -Wmaybe-uninitialized -Wmissing-braces -Wmissing-declarations -Wmissing-field-initializers -Wmissing-include-dirs -Wmissing-parameter-type -Wmissing-prototypes -Wmultichar -Wnarrowing -Wnested-externs -Wnonnull -Wold-style-declaration -Wold-style-definition -Woverflow -Woverride-init -Wpacked-bitfield-compat -Wparentheses -Wpointer-arith -Wpointer-sign -Wpointer-to-int-cast -Wpragmas -Wreturn-local-addr -Wreturn-type -Wsequence-point -Wsizeof-pointer-memaccess -Wstrict-aliasing -Wstrict-overflow -Wstrict-prototypes -Wsuggest-attribute=format -Wsuggest-attribute=noreturn -Wswitch -Wsync-nand -Wtrampolines -Wtrigraphs -Wtype-limits -Wuninitialized -Wunknown-pragmas -Wunused -Wunused-but-set-parameter -Wunused-but-set-variable -Wunused-function -Wunused-label -Wunused-local-typedefs -Wunused-macros -Wunused-parameter -Wunused-result -Wunused-value -Wunused-variable -Wvarargs -Wvariadic-macros -Wvector-operation-performance -Wvolatile-register-var -Wwrite-strings -Wnormalized=nfc -Wno-unused-parameter -Wno-missing-field-initializers -fdiagnostics-show-option -Wframe-larger-than=5000 -Wstack-usage=10000 -fPIC -fno-strict-overflow -Wno-strict-overflow -c -o ../common/utils/libguestfsocaml_a-utils.o `test -f '../common/utils/utils.c' || echo './'`../common/utils/utils.c
ocamlfind ocamlc -g -annot -warn-error CDEFLMPSUVYZX-3 -package unix -c guestfs.ml -o guestfs.cmo
ocamlfind ocamlopt -g -annot -warn-error CDEFLMPSUVYZX-3 -package unix -c guestfs.ml -o guestfs.cmx
rm -f libguestfsocaml.a
ar cr libguestfsocaml.a libguestfsocaml_a-guestfs-c.o libguestfsocaml_a-guestfs-c-actions.o libguestfsocaml_a-guestfs-c-errnos.o ../common/utils/libguestfsocaml_a-utils.o ../gnulib/lib/libgnu.la
ranlib libguestfsocaml.a
ocamlmklib -o mlguestfs \
libguestfsocaml_a-guestfs-c.o libguestfsocaml_a-guestfs-c-actions.o libguestfsocaml_a-guestfs-c-errnos.o ../common/utils/libguestfsocaml_a-utils.o guestfs.cmo \
-fprofile-arcs -ftest-coverage -lgcov \
\
-L../lib/.libs -lguestfs
Unknown option -fprofile-arcs
Unknown option -ftest-coverage
ocamlmklib -o mlguestfs \
libguestfsocaml_a-guestfs-c.o libguestfsocaml_a-guestfs-c-actions.o libguestfsocaml_a-guestfs-c-errnos.o ../common/utils/libguestfsocaml_a-utils.o guestfs.cmx \
-fprofile-arcs -ftest-coverage -lgcov \
\
-L../lib/.libs -lguestfs
Unknown option -fprofile-arcs
Unknown option -ftest-coverage
touch stamp-mlguestfs
Warning: Element Unix.error not found
make[2]: Leaving directory `/home/mockbuild/rpmbuild/BUILD/libguestfs-1.36.5/ocaml'
Making all in ocaml/examples
make[2]: Entering directory `/home/mockbuild/rpmbuild/BUILD/libguestfs-1.36.5/ocaml/examples'
ocamlfind ocamlopt -cclib -L../../lib/.libs -package unix -linkpkg \
-warn-error A -I .. mlguestfs.cmxa create_disk.ml -o create_disk
ocamlfind ocamlopt -cclib -L../../lib/.libs -package unix -linkpkg \
-warn-error A -I .. mlguestfs.cmxa debug_logging.ml -o debug_logging
../libmlguestfs.a(libguestfsocaml_a-utils.o): In function `guestfs_int_string_is_valid':
utils.c:(.text+0xb99): undefined reference to `c_isalpha'
utils.c:(.text+0xbbf): undefined reference to `c_isdigit'
collect2: error: ld returned 1 exit status
File "caml_startup", line 1:
Error: Error during linking
make[2]: *** [debug_logging] Error 2
make[2]: *** Waiting for unfinished jobs....
../libmlguestfs.a(libguestfsocaml_a-utils.o): In function `guestfs_int_string_is_valid':
utils.c:(.text+0xb99): undefined reference to `c_isalpha'
utils.c:(.text+0xbbf): undefined reference to `c_isdigit'
collect2: error: ld returned 1 exit status
File "caml_startup", line 1:
Error: Error during linking
make[2]: *** [create_disk] Error 2
make[2]: Leaving directory `/home/mockbuild/rpmbuild/BUILD/libguestfs-1.36.5/ocaml/examples'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/home/mockbuild/rpmbuild/BUILD/libguestfs-1.36.5'
make: *** [all] Error 2
error: Bad exit status from /var/tmp/rpm-tmp.JoY6TA (%build)
RPM build errors:
Bad exit status from /var/tmp/rpm-tmp.JoY6TA (%build)
---------------------------------------------------------------------------------------
The patch in attachment added in libguestfs.spec aims to resolve the above issue. But it seems to have no effect. Any idea how to resolve this issue? Thanks.
Best Regards
Yongkui Guo
IRC: yoguo
Tel: 15010777318
7 years, 3 months
virt-resize error on RHEL 7 (was: Re: Regarding libguestfs)
by abinaya.manikandan@wipro.com
Hi Richard,
As per your suggestion we removed pango-devel and build was successful. Thank you!
After the delivery, our customer reported another error related to virt-resize as below:
virt-resize: error: libguestfs error: internal_feature_available:
dispatch_incoming_message: unknown procedure number 458, set
LIBGUESTFS_PATH to point to the matching libguestfs appliance directory
Regards,
Abinaya
-----Original Message-----
From: Richard W.M. Jones [mailto:rjones@redhat.com]
Sent: Tuesday, August 29, 2017 7:56 PM
To: Abinaya Sandhiya Manikandan (GIS) <abinaya.manikandan(a)wipro.com>
Cc: libguestfs(a)redhat.com; Emlyn Jose (GIS) <emlyn.jose(a)wipro.com>
Subject: Re: Pango error when compiling virt-p2v on RHEL 7 (was: Re: [Libguestfs] Regarding libguestfs)
** This mail has been sent from an external source **
On Tue, Aug 29, 2017 at 02:20:47PM +0000, abinaya.manikandan(a)wipro.com<mailto:abinaya.manikandan@wipro.com> wrote:
> Hi,
>
> Yes, We are using pango-devel-1.40.4-1.el7.x86_64.
> Please find details below:
>
> >> [root@euca-10-254-11-189 rpmbuild]# rpm -qf
> >> /usr/include/pango-1.0/pango/pango-version-macros.h
> pango-devel-1.40.4-1.el7.x86_64
>
> Somehow the issue fixed if we remove the pango-devel,
Removing pango-devel most likely disables gtk, thus disabling compilation of virt-p2v. Which is one way to fix it, but I suppose it depends on if you need virt-p2v ...
> but now the issue is different,
>
> >> /opt/autoconf/x86_64/2.69/bin/autoconf: line 505:
> >> /opt/autoconf/x86_64/2.69/bin/autom4te:/opt/autoconf/x86_64/2.69/bi
> >> n/autom4te:: No such file or directory
> automake-1.15: error: autoconf failed with exit status: 127
> WARNING: 'automake-1.15' is missing on your system.
As the error message says, automake is missing. I suppose removing pango also removed automake for whatever reason, or you removed or changed the version of automake while you were removing pango.
I cannot reproduce the original problem right now, but I'm looking at it.
Rich.
--
Richard Jones, Virtualization Group, Red Hat https://clicktime.symantec.com/a/1/RfaWKpJjiitkZvrcQ55iIzI7QAy9m0tPN52hu7...
Read my programming and virtualization blog: https://clicktime.symantec.com/a/1/MS_Vt_w0A9fkbbXBBANKg9ZLqDbmOPA-PncG2X...
virt-df lists disk usage of guests without needing to install any software inside the virtual machine. Supports Linux and Windows.
https://clicktime.symantec.com/a/1/PHy2CxdtLV8q_hJJQHgxNWUP1Pzqdx7qHTUIuc...
______________________________________________________________________
This email has been scanned by the Symantec Email Security.cloud service.
For more information please visit http://www.symanteccloud.com ______________________________________________________________________
The information contained in this electronic message and any attachments to this message are intended for the exclusive use of the addressee(s) and may contain proprietary, confidential or privileged information. If you are not the intended recipient, you should not disseminate, distribute or copy this e-mail. Please notify the sender immediately and destroy all copies of this message and any attachments. WARNING: Computer viruses can be transmitted via email. The recipient should check this email and any attachments for the presence of viruses. The company accepts no liability for any damage caused by any virus transmitted by this email. www.wipro.com
7 years, 3 months
Re: [Libguestfs] guestfs_readdir protocol limit
by Richard W.M. Jones
On Wed, Sep 06, 2017 at 03:55:05PM +0300, Maxim Kozover wrote:
> Hi Richard!
> Tell me, please, is there any chance you have an (unofficial) patch ready
> or almost ready that removes a protocol limit from guestfs_readdir (returns
> a large answer in chunks in a loop etc)?
Yes this is one of the very few remaining APIs which has a
protocol limit.
> I happen to have a need to use libguestfs fuse accessing the directory with
> a million of files in it, the individual files are accessed ok, but the
> directory...
This is a genuine bug. Can you file one?
If you can get away without using fuse (ie. using the API directly)
then a workaround would be to look at how our visitor code works:
https://github.com/libguestfs/libguestfs/blob/master/common/visit/visit.c...
where it only uses APIs which are unlimited, eg:
https://github.com/libguestfs/libguestfs/blob/master/lib/file.c#L507
Rich.
--
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
Read my programming and virtualization blog: http://rwmj.wordpress.com
virt-p2v converts physical machines to virtual machines. Boot with a
live CD or over the network (PXE) and turn machines into KVM guests.
http://libguestfs.org/virt-v2v
7 years, 3 months
[PATCH] run.in: Quote contents of @VAR@ substitutions
by Hilko Bengen
---
run.in | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/run.in b/run.in
index 0d10983..0f23a7c 100755
--- a/run.in
+++ b/run.in
@@ -62,7 +62,7 @@ export PERL_VALGRIND=1
export PERL_DESTRUCT_LEVEL=2
# For Python.
-export PYTHON=@PYTHON@
+export PYTHON="@PYTHON@"
if [ -z "$PYTHONPATH" ]; then
PYTHONPATH="$s/python:$b/python:$b/python/.libs"
else
@@ -71,8 +71,8 @@ fi
export PYTHONPATH
# For Ruby.
-export RUBY=@RUBY@
-export RAKE=@RAKE@
+export RUBY="@RUBY@"
+export RAKE="@RAKE@"
if [ -z "$RUBYLIB" ]; then
RUBYLIB="$s/ruby/lib:$b/ruby/ext/hivex"
else
--
2.14.1
7 years, 3 months
error/crash on mount
by http_error_418
Hi,
I am having issues with libguestfs; I am unable to mount a disk either
from cli or via python bindings. This was working previously, but in
order to have access to python3.5 I am trying to upgrade from Debian
8/Jessie to Debian 9/Stretch. Unfortunately the libguestfs error is
getting in the way. Output of libguestfs-test-tool is attached as per
libguestfs.org help.
My current environment:
aphrodite@cleopatra:~$ uname -a
Linux cleopatra 4.9.0-3-amd64 #1 SMP Debian 4.9.30-2+deb9u3 (2017-08-06)
x86_64 GNU/Linux
aphrodite@cleopatra:~$ /usr/local/sbin/libvirtd --version
/usr/local/sbin/libvirtd (libvirt) 3.1.0
aphrodite@cleopatra:~$ /usr/bin/guestmount --version
guestmount 1.34.6
Please let me know if there is a way I can continue in Stretch - if
necessary I can roll back to Jessie but I really want to get everything
working in Stretch if I can.
Thank you in advance for your time,
http_error_418
7 years, 3 months
[PATCH] launch: direct: limit kvm-pit.lost_tick_policy to x86
by Pino Toscano
This QEMU property is specific to x86/x86_64, so add it only on these
architectures.
---
lib/launch-direct.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/lib/launch-direct.c b/lib/launch-direct.c
index bc43dcea2..3b848165c 100644
--- a/lib/launch-direct.c
+++ b/lib/launch-direct.c
@@ -519,8 +519,10 @@ launch_direct (guestfs_h *g, void *datav, const char *arg)
arg ("-rtc", "driftfix=slew");
if (guestfs_int_qemu_supports (g, data->qemu_data, "-no-hpet"))
flag ("-no-hpet");
+#if defined(__i386__) || defined(__x86_64__)
if (guestfs_int_version_ge (&data->qemu_version, 1, 3, 0))
arg ("-global", "kvm-pit.lost_tick_policy=discard");
+#endif
/* UEFI (firmware) if required. */
if (guestfs_int_get_uefi (g, &uefi_code, &uefi_vars, &uefi_flags) == -1)
--
2.13.5
7 years, 3 months
[supermin][PATCH v2] os-release: use ID_LIKE as a fallback for SUSE detection
by Cédric Bosdonnat
SUSE distros all have in common suse in ID_LIKE field. The ID field
could be varying and is even set to 'Dummy' when building the packages.
If the usual values for openSUSE/SLE can't be found in ID, try with
ID_LIKE.
---
Diff with v1:
* Use Utils.string_split rather than too recent String.split_on_char
src/os_release.ml | 10 +++++++++-
src/os_release.mli | 7 +++++++
src/ph_rpm.ml | 1 +
3 files changed, 17 insertions(+), 1 deletion(-)
diff --git a/src/os_release.ml b/src/os_release.ml
index b2de259..abf2bea 100644
--- a/src/os_release.ml
+++ b/src/os_release.ml
@@ -29,6 +29,7 @@ let split sep str =
type os_release = {
id : string;
+ id_like : string list;
}
let data = ref None
@@ -52,6 +53,7 @@ and parse () =
let lines = List.filter (fun s -> s.[0] <> '#') lines in
let id = ref "" in
+ let id_like = ref [] in
List.iter (
fun line ->
@@ -65,10 +67,11 @@ and parse () =
else value in
match field with
| "ID" -> id := value
+ | "ID_LIKE" -> id_like := string_split " " value
| _ -> ()
) lines;
- Some { id = !id; }
+ Some { id = !id; id_like = !id_like }
) else
None
@@ -76,3 +79,8 @@ let get_id () =
match get_data () with
| None -> ""
| Some d -> d.id
+
+let get_id_like () =
+ match get_data () with
+ | None -> []
+ | Some d -> d.id_like
diff --git a/src/os_release.mli b/src/os_release.mli
index 2ae349b..e9f2993 100644
--- a/src/os_release.mli
+++ b/src/os_release.mli
@@ -24,3 +24,10 @@ val get_id : unit -> string
An empty string is returned if the file does not exist or cannot
be read. *)
+
+val get_id_like : unit -> string list
+(** Get the value of the "ID_LIKE" field from the /etc/os-release file
+ on the current system.
+
+ An empty list is returned if the file does not exist, cannot
+ be read or the ID_LIKE field is not defined. *)
diff --git a/src/ph_rpm.ml b/src/ph_rpm.ml
index b0a5eb2..fd87822 100644
--- a/src/ph_rpm.ml
+++ b/src/ph_rpm.ml
@@ -41,6 +41,7 @@ let opensuse_detect () =
Config.rpm <> "no" && Config.rpm2cpio <> "no" && rpm_is_available () &&
Config.zypper <> "no" &&
(List.mem (Os_release.get_id ()) [ "opensuse"; "sled"; "sles" ] ||
+ List.mem "suse" (Os_release.get_id_like ()) ||
try (stat "/etc/SuSE-release").st_kind = S_REG with Unix_error _ -> false)
let mageia_detect () =
--
2.13.2
7 years, 3 months