Even though this option is not to be used according to the manual, it:
a) still might be useful even for machine-readable logs
b) should not break the machine-readable output
Signed-off-by: Martin Kletzander <mkletzan(a)redhat.com>
---
v2v/v2v.ml | 29 ++++++++++++++++++++++-------
1 file changed, 22 insertions(+), 7 deletions(-)
diff --git a/v2v/v2v.ml b/v2v/v2v.ml
index 4ee15663f261..508a2b4f39a5 100644
--- a/v2v/v2v.ml
+++ b/v2v/v2v.ml
@@ -815,13 +815,28 @@ and actual_target_size target_file disk_stats =
(* Save overlays if --debug-overlays option was used. *)
and preserve_overlays overlays src_name =
- List.iter (
- fun ov ->
- let saved_filename =
- sprintf "%s/%s-%s.qcow2" overlay_dir src_name ov.ov_sd in
- rename ov.ov_overlay_file saved_filename;
- info (f_"Overlay saved as %s [--debug-overlays]") saved_filename
- ) overlays
+ let filenames = List.map (
+ fun ov ->
+ let saved_filename =
+ sprintf "%s/%s-%s.qcow2" overlay_dir src_name ov.ov_sd in
+ rename ov.ov_overlay_file saved_filename;
+ saved_filename
+ ) overlays in
+ match machine_readable () with
+ | None ->
+ List.iter (
+ fun filename ->
+ info (f_"Overlay saved as %s [--debug-overlays]") filename
+ ) filenames
+ | Some {pr} ->
+ let json = [
+ "type", JSON.String "data";
+ "data", JSON.Dict [
+ "saved_overlays",
+ JSON.List (List.map (fun s -> JSON.String s) filenames);
+ ]
+ ] in
+ pr "%s\n" (JSON.string_of_doc json)
(* Request guest caps based on source configuration. *)
and rcaps_from_source source =
--
2.23.0