Blame SOURCES/0152-v2v-Move-augeas_debug_errors-renamed-debug_augeas_er.patch

e76f14
From 3efce06fd92ef66098f84bd9955ff9b4c16cb6f4 Mon Sep 17 00:00:00 2001
e76f14
From: "Richard W.M. Jones" <rjones@redhat.com>
e76f14
Date: Wed, 13 Jul 2016 19:16:07 +0100
e76f14
Subject: [PATCH] v2v: Move augeas_debug_errors (renamed debug_augeas_errors)
e76f14
 to common code.
e76f14
e76f14
Since the function uses the StringMap module, I also had to
e76f14
move this to mllib.
e76f14
e76f14
The function is renamed and the 'if verbose ()' part is moved into the
e76f14
function, but apart from that, it's all just code motion.
e76f14
e76f14
(cherry picked from commit eb22e2d36e3a28805f36e43b2be549ccbd3457b1)
e76f14
---
e76f14
 builder/Makefile.am          |  1 +
e76f14
 customize/Makefile.am        |  1 +
e76f14
 dib/Makefile.am              |  1 +
e76f14
 get-kernel/Makefile.am       |  1 +
e76f14
 mllib/Makefile.am            |  3 +++
e76f14
 mllib/common_utils.ml        | 63 +++++++++++++++++++++++++++++++++++++++++++
e76f14
 mllib/common_utils.mli       | 14 ++++++++++
e76f14
 mllib/stringMap.ml           | 21 +++++++++++++++
e76f14
 mllib/stringMap.mli          | 54 +++++++++++++++++++++++++++++++++++++
e76f14
 po/POTFILES-ml               |  2 +-
e76f14
 resize/Makefile.am           |  1 +
e76f14
 sparsify/Makefile.am         |  1 +
e76f14
 sysprep/Makefile.am          |  1 +
e76f14
 v2v/Makefile.am              |  6 ++---
e76f14
 v2v/linux.ml                 | 64 ++------------------------------------------
e76f14
 v2v/stringMap.ml             | 21 ---------------
e76f14
 v2v/stringMap.mli            | 54 -------------------------------------
e76f14
 v2v/test-harness/Makefile.am |  1 +
e76f14
 18 files changed, 169 insertions(+), 141 deletions(-)
e76f14
 create mode 100644 mllib/stringMap.ml
e76f14
 create mode 100644 mllib/stringMap.mli
e76f14
 delete mode 100644 v2v/stringMap.ml
e76f14
 delete mode 100644 v2v/stringMap.mli
e76f14
e76f14
diff --git a/builder/Makefile.am b/builder/Makefile.am
e76f14
index 54aa10b..d69e7ec 100644
e76f14
--- a/builder/Makefile.am
e76f14
+++ b/builder/Makefile.am
e76f14
@@ -136,6 +136,7 @@ BOBJECTS = \
e76f14
 	$(top_builddir)/mllib/guestfs_config.cmo \
e76f14
 	$(top_builddir)/mllib/common_gettext.cmo \
e76f14
 	$(top_builddir)/mllib/dev_t.cmo \
e76f14
+	$(top_builddir)/mllib/stringMap.cmo \
e76f14
 	$(top_builddir)/mllib/common_utils.cmo \
e76f14
 	$(top_builddir)/mllib/fsync.cmo \
e76f14
 	$(top_builddir)/mllib/planner.cmo \
e76f14
diff --git a/customize/Makefile.am b/customize/Makefile.am
e76f14
index 661917a..05f144f 100644
e76f14
--- a/customize/Makefile.am
e76f14
+++ b/customize/Makefile.am
e76f14
@@ -95,6 +95,7 @@ BOBJECTS = \
e76f14
 	$(top_builddir)/mllib/guestfs_config.cmo \
e76f14
 	$(top_builddir)/mllib/common_gettext.cmo \
e76f14
 	$(top_builddir)/mllib/dev_t.cmo \
e76f14
+	$(top_builddir)/mllib/stringMap.cmo \
e76f14
 	$(top_builddir)/mllib/common_utils.cmo \
e76f14
 	$(top_builddir)/mllib/regedit.cmo \
e76f14
 	$(top_builddir)/mllib/URI.cmo \
e76f14
diff --git a/dib/Makefile.am b/dib/Makefile.am
e76f14
index d1674a9..ff6a933 100644
e76f14
--- a/dib/Makefile.am
e76f14
+++ b/dib/Makefile.am
e76f14
@@ -59,6 +59,7 @@ BOBJECTS = \
e76f14
 	$(top_builddir)/mllib/guestfs_config.cmo \
e76f14
 	$(top_builddir)/mllib/common_gettext.cmo \
e76f14
 	$(top_builddir)/mllib/dev_t.cmo \
e76f14
+	$(top_builddir)/mllib/stringMap.cmo \
e76f14
 	$(top_builddir)/mllib/common_utils.cmo \
e76f14
 	$(top_builddir)/mllib/mkdtemp.cmo \
e76f14
 	$(SOURCES_ML:.ml=.cmo)
e76f14
diff --git a/get-kernel/Makefile.am b/get-kernel/Makefile.am
e76f14
index 9d8fc61..e2d78b0 100644
e76f14
--- a/get-kernel/Makefile.am
e76f14
+++ b/get-kernel/Makefile.am
e76f14
@@ -58,6 +58,7 @@ BOBJECTS = \
e76f14
 	$(top_builddir)/mllib/guestfs_config.cmo \
e76f14
 	$(top_builddir)/mllib/common_gettext.cmo \
e76f14
 	$(top_builddir)/mllib/dev_t.cmo \
e76f14
+	$(top_builddir)/mllib/stringMap.cmo \
e76f14
 	$(top_builddir)/mllib/common_utils.cmo \
e76f14
 	$(top_builddir)/mllib/URI.cmo \
e76f14
 	$(SOURCES_ML:.ml=.cmo)
e76f14
diff --git a/mllib/Makefile.am b/mllib/Makefile.am
e76f14
index 0a6dd93..8807d86 100644
e76f14
--- a/mllib/Makefile.am
e76f14
+++ b/mllib/Makefile.am
e76f14
@@ -37,11 +37,13 @@ SOURCES_MLI = \
e76f14
 	progress.mli \
e76f14
 	regedit.mli \
e76f14
 	StatVFS.mli \
e76f14
+	stringMap.mli \
e76f14
 	URI.mli
e76f14
 
e76f14
 SOURCES_ML = \
e76f14
 	guestfs_config.ml \
e76f14
 	libdir.ml \
e76f14
+	stringMap.ml \
e76f14
 	common_gettext.ml \
e76f14
 	dev_t.ml \
e76f14
 	common_utils.ml \
e76f14
@@ -150,6 +152,7 @@ common_utils_tests_BOBJECTS = \
e76f14
 	guestfs_config.cmo \
e76f14
 	common_gettext.cmo \
e76f14
 	dev_t.cmo \
e76f14
+	stringMap.cmo \
e76f14
 	common_utils.cmo \
e76f14
 	common_utils_tests.cmo
e76f14
 common_utils_tests_XOBJECTS = $(common_utils_tests_BOBJECTS:.cmo=.cmx)
e76f14
diff --git a/mllib/common_utils.ml b/mllib/common_utils.ml
e76f14
index 7bd02f8..2dfe475 100644
e76f14
--- a/mllib/common_utils.ml
e76f14
+++ b/mllib/common_utils.ml
e76f14
@@ -796,6 +796,69 @@ let truncate_recursive (g : Guestfs.guestfs) dir =
e76f14
   let files = List.filter g#is_file files in
e76f14
   List.iter g#truncate files
e76f14
 
e76f14
+let debug_augeas_errors g =
e76f14
+  if verbose () then (
e76f14
+    try
e76f14
+      let errors = g#aug_match "/augeas/files//error" in
e76f14
+      let errors = Array.to_list errors in
e76f14
+      let map =
e76f14
+        List.fold_left (
e76f14
+          fun map error ->
e76f14
+            let detail_paths = g#aug_match (error ^ "//*") in
e76f14
+            let detail_paths = Array.to_list detail_paths in
e76f14
+            List.fold_left (
e76f14
+              fun map path ->
e76f14
+                (* path is "/augeas/files/<filename>/error/<field>".  Put
e76f14
+                 * <filename>, <field> and the value of this Augeas field
e76f14
+                 * into a map.
e76f14
+                 *)
e76f14
+                let i = String.find path "/error/" in
e76f14
+                assert (i >= 0);
e76f14
+                let filename = String.sub path 13 (i-13) in
e76f14
+                let field =
e76f14
+                  String.sub path (i+7) (String.length path - (i+7)) in
e76f14
+
e76f14
+                let detail = g#aug_get path in
e76f14
+
e76f14
+                let fmap : string StringMap.t =
e76f14
+                  try StringMap.find filename map
e76f14
+                  with Not_found -> StringMap.empty in
e76f14
+                let fmap = StringMap.add field detail fmap in
e76f14
+                StringMap.add filename fmap map
e76f14
+            ) map detail_paths
e76f14
+        ) StringMap.empty errors in
e76f14
+
e76f14
+      let filenames = StringMap.keys map in
e76f14
+      let filenames = List.sort compare filenames in
e76f14
+
e76f14
+      List.iter (
e76f14
+        fun filename ->
e76f14
+          eprintf "augeas failed to parse %s:\n" filename;
e76f14
+          let fmap = StringMap.find filename map in
e76f14
+          (try
e76f14
+            let msg = StringMap.find "message" fmap in
e76f14
+            eprintf " error \"%s\"" msg
e76f14
+          with Not_found -> ()
e76f14
+          );
e76f14
+          (try
e76f14
+            let line = StringMap.find "line" fmap
e76f14
+            and char = StringMap.find "char" fmap in
e76f14
+            eprintf " at line %s char %s" line char
e76f14
+          with Not_found -> ()
e76f14
+          );
e76f14
+          (try
e76f14
+            let lens = StringMap.find "lens" fmap in
e76f14
+            eprintf " in lens %s" lens
e76f14
+          with Not_found -> ()
e76f14
+          );
e76f14
+          eprintf "\n"
e76f14
+      ) filenames;
e76f14
+
e76f14
+      flush stderr
e76f14
+    with
e76f14
+      Guestfs.Error msg -> eprintf "%s: augeas: %s (ignored)\n" prog msg
e76f14
+  )
e76f14
+
e76f14
 (* Detect type of a file. *)
e76f14
 let detect_file_type filename =
e76f14
   let chan = open_in filename in
e76f14
diff --git a/mllib/common_utils.mli b/mllib/common_utils.mli
e76f14
index 4cfe7d0..c66efa7 100644
e76f14
--- a/mllib/common_utils.mli
e76f14
+++ b/mllib/common_utils.mli
e76f14
@@ -319,6 +319,20 @@ val truncate_recursive : Guestfs.guestfs -> string -> unit
e76f14
 (** Using the libguestfs API, recurse into the given directory and
e76f14
     truncate all files found to zero size. *)
e76f14
 
e76f14
+val debug_augeas_errors : Guestfs.guestfs -> unit
e76f14
+(** In verbose mode, any Augeas errors which happened most recently
e76f14
+    on the handle and printed on standard error.  You should usually
e76f14
+    call this just after either [g#aug_init] or [g#aug_load].
e76f14
+
e76f14
+    Note this doesn't call {!error} if there were any errors on the
e76f14
+    handle.  It is just for debugging.  It is expected that a
e76f14
+    subsequent Augeas command will fail, eg. when trying to match
e76f14
+    an Augeas path which is expected to exist but does not exist
e76f14
+    because of a parsing error.  In that case turning on debugging
e76f14
+    will reveal the parse error.
e76f14
+
e76f14
+    If not in verbose mode, this does nothing. *)
e76f14
+
e76f14
 val detect_file_type : string -> [`GZip | `Tar | `XZ | `Zip | `Unknown]
e76f14
 (** Detect type of a file (for a very limited range of file types). *)
e76f14
 
e76f14
diff --git a/mllib/stringMap.ml b/mllib/stringMap.ml
e76f14
new file mode 100644
e76f14
index 0000000..ea47a6e
e76f14
--- /dev/null
e76f14
+++ b/mllib/stringMap.ml
e76f14
@@ -0,0 +1,21 @@
e76f14
+(* virt-v2v
e76f14
+ * Copyright (C) 2009-2016 Red Hat Inc.
e76f14
+ *
e76f14
+ * This program is free software; you can redistribute it and/or modify
e76f14
+ * it under the terms of the GNU General Public License as published by
e76f14
+ * the Free Software Foundation; either version 2 of the License, or
e76f14
+ * (at your option) any later version.
e76f14
+ *
e76f14
+ * This program is distributed in the hope that it will be useful,
e76f14
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
e76f14
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
e76f14
+ * GNU General Public License for more details.
e76f14
+ *
e76f14
+ * You should have received a copy of the GNU General Public License along
e76f14
+ * with this program; if not, write to the Free Software Foundation, Inc.,
e76f14
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
e76f14
+ *)
e76f14
+
e76f14
+include Map.Make (String)
e76f14
+
e76f14
+let keys map = fold (fun k _ ks -> k :: ks) map []
e76f14
diff --git a/mllib/stringMap.mli b/mllib/stringMap.mli
e76f14
new file mode 100644
e76f14
index 0000000..b668538
e76f14
--- /dev/null
e76f14
+++ b/mllib/stringMap.mli
e76f14
@@ -0,0 +1,54 @@
e76f14
+(* virt-v2v
e76f14
+ * Copyright (C) 2009-2016 Red Hat Inc.
e76f14
+ *
e76f14
+ * This program is free software; you can redistribute it and/or modify
e76f14
+ * it under the terms of the GNU General Public License as published by
e76f14
+ * the Free Software Foundation; either version 2 of the License, or
e76f14
+ * (at your option) any later version.
e76f14
+ *
e76f14
+ * This program is distributed in the hope that it will be useful,
e76f14
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
e76f14
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
e76f14
+ * GNU General Public License for more details.
e76f14
+ *
e76f14
+ * You should have received a copy of the GNU General Public License along
e76f14
+ * with this program; if not, write to the Free Software Foundation, Inc.,
e76f14
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
e76f14
+ *)
e76f14
+
e76f14
+type key = String.t
e76f14
+type 'a t = 'a Map.Make(String).t
e76f14
+
e76f14
+val empty : 'a t
e76f14
+val is_empty : 'a t -> bool
e76f14
+val mem : key -> 'a t -> bool
e76f14
+val add : key -> 'a -> 'a t -> 'a t
e76f14
+(*
e76f14
+val singleton : key -> 'a -> 'a t
e76f14
+*)
e76f14
+val remove : key -> 'a t -> 'a t
e76f14
+(*
e76f14
+val merge : (key -> 'a option -> 'b option -> 'c option) -> 'a t -> 'b t -> 'c t
e76f14
+*)
e76f14
+val compare : ('a -> 'a -> int) -> 'a t -> 'a t -> int
e76f14
+val equal : ('a -> 'a -> bool) -> 'a t -> 'a t -> bool
e76f14
+val iter : (key -> 'a -> unit) -> 'a t -> unit
e76f14
+val fold : (key -> 'a -> 'b -> 'b) -> 'a t -> 'b -> 'b
e76f14
+(*
e76f14
+val for_all : (key -> 'a -> bool) -> 'a t -> bool
e76f14
+val exists : (key -> 'a -> bool) -> 'a t -> bool
e76f14
+val filter : (key -> 'a -> bool) -> 'a t -> 'a t
e76f14
+val partition : (key -> 'a -> bool) -> 'a t -> 'a t * 'a t
e76f14
+val cardinal : 'a t -> int
e76f14
+val bindings : 'a t -> (key * 'a) list
e76f14
+val min_binding : 'a t -> key * 'a
e76f14
+val max_binding : 'a t -> key * 'a
e76f14
+val choose : 'a t -> key * 'a
e76f14
+val split : key -> 'a t -> 'a t * 'a option * 'a t
e76f14
+*)
e76f14
+val find : key -> 'a t -> 'a
e76f14
+val map : ('a -> 'b) -> 'a t -> 'b t
e76f14
+(*
e76f14
+val mapi : (key -> 'a -> 'b) -> 'a t -> 'b t
e76f14
+*)
e76f14
+val keys : 'a t -> key list
e76f14
diff --git a/po/POTFILES-ml b/po/POTFILES-ml
e76f14
index 5937ff5..4ea49a5 100644
e76f14
--- a/po/POTFILES-ml
e76f14
+++ b/po/POTFILES-ml
e76f14
@@ -52,6 +52,7 @@ mllib/mkdtemp.ml
e76f14
 mllib/planner.ml
e76f14
 mllib/progress.ml
e76f14
 mllib/regedit.ml
e76f14
+mllib/stringMap.ml
e76f14
 resize/resize.ml
e76f14
 sparsify/cmdline.ml
e76f14
 sparsify/copying.ml
e76f14
@@ -123,7 +124,6 @@ v2v/output_null.ml
e76f14
 v2v/output_qemu.ml
e76f14
 v2v/output_rhev.ml
e76f14
 v2v/output_vdsm.ml
e76f14
-v2v/stringMap.ml
e76f14
 v2v/target_bus_assignment.ml
e76f14
 v2v/test-harness/v2v_test_harness.ml
e76f14
 v2v/types.ml
e76f14
diff --git a/resize/Makefile.am b/resize/Makefile.am
e76f14
index e9f48da..c3c025d 100644
e76f14
--- a/resize/Makefile.am
e76f14
+++ b/resize/Makefile.am
e76f14
@@ -60,6 +60,7 @@ BOBJECTS = \
e76f14
 	$(top_builddir)/mllib/guestfs_config.cmo \
e76f14
 	$(top_builddir)/mllib/common_gettext.cmo \
e76f14
 	$(top_builddir)/mllib/dev_t.cmo \
e76f14
+	$(top_builddir)/mllib/stringMap.cmo \
e76f14
 	$(top_builddir)/mllib/common_utils.cmo \
e76f14
 	$(SOURCES_ML:.ml=.cmo)
e76f14
 XOBJECTS = $(BOBJECTS:.cmo=.cmx)
e76f14
diff --git a/sparsify/Makefile.am b/sparsify/Makefile.am
e76f14
index 9dd9179..22a684b 100644
e76f14
--- a/sparsify/Makefile.am
e76f14
+++ b/sparsify/Makefile.am
e76f14
@@ -59,6 +59,7 @@ BOBJECTS = \
e76f14
 	$(top_builddir)/mllib/guestfs_config.cmo \
e76f14
 	$(top_builddir)/mllib/common_gettext.cmo \
e76f14
 	$(top_builddir)/mllib/dev_t.cmo \
e76f14
+	$(top_builddir)/mllib/stringMap.cmo \
e76f14
 	$(top_builddir)/mllib/common_utils.cmo \
e76f14
 	$(top_builddir)/mllib/progress.cmo \
e76f14
 	$(top_builddir)/mllib/StatVFS.cmo \
e76f14
diff --git a/sysprep/Makefile.am b/sysprep/Makefile.am
e76f14
index e439a88..46cc324 100644
e76f14
--- a/sysprep/Makefile.am
e76f14
+++ b/sysprep/Makefile.am
e76f14
@@ -108,6 +108,7 @@ BOBJECTS = \
e76f14
 	$(top_builddir)/mllib/guestfs_config.cmo \
e76f14
 	$(top_builddir)/mllib/common_gettext.cmo \
e76f14
 	$(top_builddir)/mllib/dev_t.cmo \
e76f14
+	$(top_builddir)/mllib/stringMap.cmo \
e76f14
 	$(top_builddir)/mllib/common_utils.cmo \
e76f14
 	$(top_builddir)/mllib/URI.cmo \
e76f14
 	$(top_builddir)/mllib/mkdtemp.cmo \
e76f14
diff --git a/v2v/Makefile.am b/v2v/Makefile.am
e76f14
index e0d013a..09a63a0 100644
e76f14
--- a/v2v/Makefile.am
e76f14
+++ b/v2v/Makefile.am
e76f14
@@ -70,7 +70,6 @@ SOURCES_MLI = \
e76f14
 	output_rhev.mli \
e76f14
 	output_vdsm.mli \
e76f14
 	OVF.mli \
e76f14
-	stringMap.mli \
e76f14
 	target_bus_assignment.mli \
e76f14
 	types.mli \
e76f14
 	utils.mli \
e76f14
@@ -80,7 +79,6 @@ SOURCES_MLI = \
e76f14
 	xml.mli
e76f14
 
e76f14
 SOURCES_ML = \
e76f14
-	stringMap.ml \
e76f14
 	types.ml \
e76f14
 	xml.ml \
e76f14
 	utils.ml \
e76f14
@@ -142,6 +140,7 @@ BOBJECTS = \
e76f14
 	$(top_builddir)/mllib/guestfs_config.cmo \
e76f14
 	$(top_builddir)/mllib/common_gettext.cmo \
e76f14
 	$(top_builddir)/mllib/dev_t.cmo \
e76f14
+	$(top_builddir)/mllib/stringMap.cmo \
e76f14
 	$(top_builddir)/mllib/common_utils.cmo \
e76f14
 	$(top_builddir)/mllib/regedit.cmo \
e76f14
 	$(top_builddir)/mllib/mkdtemp.cmo \
e76f14
@@ -212,6 +211,7 @@ COPY_TO_LOCAL_BOBJECTS = \
e76f14
 	$(top_builddir)/mllib/guestfs_config.cmo \
e76f14
 	$(top_builddir)/mllib/common_gettext.cmo \
e76f14
 	$(top_builddir)/mllib/dev_t.cmo \
e76f14
+	$(top_builddir)/mllib/stringMap.cmo \
e76f14
 	$(top_builddir)/mllib/common_utils.cmo \
e76f14
 	$(top_builddir)/mllib/JSON.cmo \
e76f14
 	$(top_builddir)/mllib/StatVFS.cmo \
e76f14
@@ -373,9 +373,9 @@ v2v_unit_tests_BOBJECTS = \
e76f14
 	$(top_builddir)/mllib/guestfs_config.cmo \
e76f14
 	$(top_builddir)/mllib/common_gettext.cmo \
e76f14
 	$(top_builddir)/mllib/dev_t.cmo \
e76f14
+	$(top_builddir)/mllib/stringMap.cmo \
e76f14
 	$(top_builddir)/mllib/common_utils.cmo \
e76f14
 	$(top_builddir)/mllib/regedit.cmo \
e76f14
-	stringMap.cmo \
e76f14
 	types.cmo \
e76f14
 	xml.cmo \
e76f14
 	utils.cmo \
e76f14
diff --git a/v2v/linux.ml b/v2v/linux.ml
e76f14
index 8c1fde2..46cb3ba 100644
e76f14
--- a/v2v/linux.ml
e76f14
+++ b/v2v/linux.ml
e76f14
@@ -31,71 +31,11 @@ module G = Guestfs
e76f14
  *)
e76f14
 let rec augeas_init g =
e76f14
   g#aug_init "/" 1;
e76f14
-  if verbose () then augeas_debug_errors g
e76f14
+  debug_augeas_errors g
e76f14
 
e76f14
 and augeas_reload g =
e76f14
   g#aug_load ();
e76f14
-  if verbose () then augeas_debug_errors g
e76f14
-
e76f14
-and augeas_debug_errors g =
e76f14
-  try
e76f14
-    let errors = g#aug_match "/augeas/files//error" in
e76f14
-    let errors = Array.to_list errors in
e76f14
-    let map =
e76f14
-      List.fold_left (
e76f14
-        fun map error ->
e76f14
-          let detail_paths = g#aug_match (error ^ "//*") in
e76f14
-          let detail_paths = Array.to_list detail_paths in
e76f14
-          List.fold_left (
e76f14
-            fun map path ->
e76f14
-              (* path is "/augeas/files/<filename>/error/<field>".  Put
e76f14
-               * <filename>, <field> and the value of this Augeas field
e76f14
-               * into a map.
e76f14
-               *)
e76f14
-              let i = String.find path "/error/" in
e76f14
-              assert (i >= 0);
e76f14
-              let filename = String.sub path 13 (i-13) in
e76f14
-              let field = String.sub path (i+7) (String.length path - (i+7)) in
e76f14
-
e76f14
-              let detail = g#aug_get path in
e76f14
-
e76f14
-              let fmap : string StringMap.t =
e76f14
-                try StringMap.find filename map
e76f14
-                with Not_found -> StringMap.empty in
e76f14
-              let fmap = StringMap.add field detail fmap in
e76f14
-              StringMap.add filename fmap map
e76f14
-          ) map detail_paths
e76f14
-      ) StringMap.empty errors in
e76f14
-
e76f14
-    let filenames = StringMap.keys map in
e76f14
-    let filenames = List.sort compare filenames in
e76f14
-
e76f14
-    List.iter (
e76f14
-      fun filename ->
e76f14
-        eprintf "augeas failed to parse %s:\n" filename;
e76f14
-        let fmap = StringMap.find filename map in
e76f14
-        (try
e76f14
-           let msg = StringMap.find "message" fmap in
e76f14
-           eprintf " error \"%s\"" msg
e76f14
-         with Not_found -> ()
e76f14
-        );
e76f14
-        (try
e76f14
-           let line = StringMap.find "line" fmap
e76f14
-           and char = StringMap.find "char" fmap in
e76f14
-           eprintf " at line %s char %s" line char
e76f14
-         with Not_found -> ()
e76f14
-        );
e76f14
-        (try
e76f14
-           let lens = StringMap.find "lens" fmap in
e76f14
-           eprintf " in lens %s" lens
e76f14
-         with Not_found -> ()
e76f14
-        );
e76f14
-        eprintf "\n"
e76f14
-    ) filenames;
e76f14
-
e76f14
-    flush stderr
e76f14
-  with
e76f14
-    Guestfs.Error msg -> eprintf "%s: augeas: %s (ignored)\n" prog msg
e76f14
+  debug_augeas_errors g
e76f14
 
e76f14
 let remove g inspect packages =
e76f14
   if packages <> [] then (
e76f14
diff --git a/v2v/stringMap.ml b/v2v/stringMap.ml
e76f14
deleted file mode 100644
e76f14
index ea47a6e..0000000
e76f14
--- a/v2v/stringMap.ml
e76f14
+++ /dev/null
e76f14
@@ -1,21 +0,0 @@
e76f14
-(* virt-v2v
e76f14
- * Copyright (C) 2009-2016 Red Hat Inc.
e76f14
- *
e76f14
- * This program is free software; you can redistribute it and/or modify
e76f14
- * it under the terms of the GNU General Public License as published by
e76f14
- * the Free Software Foundation; either version 2 of the License, or
e76f14
- * (at your option) any later version.
e76f14
- *
e76f14
- * This program is distributed in the hope that it will be useful,
e76f14
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
e76f14
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
e76f14
- * GNU General Public License for more details.
e76f14
- *
e76f14
- * You should have received a copy of the GNU General Public License along
e76f14
- * with this program; if not, write to the Free Software Foundation, Inc.,
e76f14
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
e76f14
- *)
e76f14
-
e76f14
-include Map.Make (String)
e76f14
-
e76f14
-let keys map = fold (fun k _ ks -> k :: ks) map []
e76f14
diff --git a/v2v/stringMap.mli b/v2v/stringMap.mli
e76f14
deleted file mode 100644
e76f14
index b668538..0000000
e76f14
--- a/v2v/stringMap.mli
e76f14
+++ /dev/null
e76f14
@@ -1,54 +0,0 @@
e76f14
-(* virt-v2v
e76f14
- * Copyright (C) 2009-2016 Red Hat Inc.
e76f14
- *
e76f14
- * This program is free software; you can redistribute it and/or modify
e76f14
- * it under the terms of the GNU General Public License as published by
e76f14
- * the Free Software Foundation; either version 2 of the License, or
e76f14
- * (at your option) any later version.
e76f14
- *
e76f14
- * This program is distributed in the hope that it will be useful,
e76f14
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
e76f14
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
e76f14
- * GNU General Public License for more details.
e76f14
- *
e76f14
- * You should have received a copy of the GNU General Public License along
e76f14
- * with this program; if not, write to the Free Software Foundation, Inc.,
e76f14
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
e76f14
- *)
e76f14
-
e76f14
-type key = String.t
e76f14
-type 'a t = 'a Map.Make(String).t
e76f14
-
e76f14
-val empty : 'a t
e76f14
-val is_empty : 'a t -> bool
e76f14
-val mem : key -> 'a t -> bool
e76f14
-val add : key -> 'a -> 'a t -> 'a t
e76f14
-(*
e76f14
-val singleton : key -> 'a -> 'a t
e76f14
-*)
e76f14
-val remove : key -> 'a t -> 'a t
e76f14
-(*
e76f14
-val merge : (key -> 'a option -> 'b option -> 'c option) -> 'a t -> 'b t -> 'c t
e76f14
-*)
e76f14
-val compare : ('a -> 'a -> int) -> 'a t -> 'a t -> int
e76f14
-val equal : ('a -> 'a -> bool) -> 'a t -> 'a t -> bool
e76f14
-val iter : (key -> 'a -> unit) -> 'a t -> unit
e76f14
-val fold : (key -> 'a -> 'b -> 'b) -> 'a t -> 'b -> 'b
e76f14
-(*
e76f14
-val for_all : (key -> 'a -> bool) -> 'a t -> bool
e76f14
-val exists : (key -> 'a -> bool) -> 'a t -> bool
e76f14
-val filter : (key -> 'a -> bool) -> 'a t -> 'a t
e76f14
-val partition : (key -> 'a -> bool) -> 'a t -> 'a t * 'a t
e76f14
-val cardinal : 'a t -> int
e76f14
-val bindings : 'a t -> (key * 'a) list
e76f14
-val min_binding : 'a t -> key * 'a
e76f14
-val max_binding : 'a t -> key * 'a
e76f14
-val choose : 'a t -> key * 'a
e76f14
-val split : key -> 'a t -> 'a t * 'a option * 'a t
e76f14
-*)
e76f14
-val find : key -> 'a t -> 'a
e76f14
-val map : ('a -> 'b) -> 'a t -> 'b t
e76f14
-(*
e76f14
-val mapi : (key -> 'a -> 'b) -> 'a t -> 'b t
e76f14
-*)
e76f14
-val keys : 'a t -> key list
e76f14
diff --git a/v2v/test-harness/Makefile.am b/v2v/test-harness/Makefile.am
e76f14
index cba5b41..5b376f0 100644
e76f14
--- a/v2v/test-harness/Makefile.am
e76f14
+++ b/v2v/test-harness/Makefile.am
e76f14
@@ -61,6 +61,7 @@ BOBJECTS = \
e76f14
 	$(top_builddir)/mllib/guestfs_config.cmo \
e76f14
 	$(top_builddir)/mllib/common_gettext.cmo \
e76f14
 	$(top_builddir)/mllib/dev_t.cmo \
e76f14
+	$(top_builddir)/mllib/stringMap.cmo \
e76f14
 	$(top_builddir)/mllib/common_utils.cmo \
e76f14
 	$(top_builddir)/v2v/xml.cmo \
e76f14
 	$(SOURCES_ML:.ml=.cmo) \
e76f14
-- 
e76f14
1.8.3.1
e76f14