Blame SOURCES/0010-output-Remove-o-json-mode.patch

c1a9fa
From a1f1129dc148639ed0b05b737157268d9b824a63 Mon Sep 17 00:00:00 2001
c1a9fa
From: "Richard W.M. Jones" <rjones@redhat.com>
c1a9fa
Date: Mon, 11 Apr 2022 11:01:46 +0100
c1a9fa
Subject: [PATCH] output: Remove -o json mode
c1a9fa
c1a9fa
This removes the -o json mode completely.
c1a9fa
c1a9fa
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
c1a9fa
(cherry picked from commit 4e6b389b4e27c8d13e57fcaf777d96ad7e08650b)
c1a9fa
---
c1a9fa
 docs/virt-v2v.pod            |   4 -
c1a9fa
 output/Makefile.am           |  51 +-----
c1a9fa
 output/create_json.ml        | 338 -----------------------------------
c1a9fa
 output/create_json.mli       |  27 ---
c1a9fa
 output/output_json.ml        | 153 ----------------
c1a9fa
 output/output_json.mli       |  21 ---
c1a9fa
 output/var_expander.ml       |  72 --------
c1a9fa
 output/var_expander.mli      |  82 ---------
c1a9fa
 output/var_expander_tests.ml | 113 ------------
c1a9fa
 tests/Makefile.am            |   2 -
c1a9fa
 tests/test-v2v-o-json.sh     |  68 -------
c1a9fa
 v2v/v2v.ml                   |   7 +-
c1a9fa
 12 files changed, 5 insertions(+), 933 deletions(-)
c1a9fa
 delete mode 100644 output/create_json.ml
c1a9fa
 delete mode 100644 output/create_json.mli
c1a9fa
 delete mode 100644 output/output_json.ml
c1a9fa
 delete mode 100644 output/output_json.mli
c1a9fa
 delete mode 100644 output/var_expander.ml
c1a9fa
 delete mode 100644 output/var_expander.mli
c1a9fa
 delete mode 100644 output/var_expander_tests.ml
c1a9fa
 delete mode 100755 tests/test-v2v-o-json.sh
c1a9fa
c1a9fa
diff --git a/docs/virt-v2v.pod b/docs/virt-v2v.pod
c1a9fa
index 7ad22f00..912f1bc3 100644
c1a9fa
--- a/docs/virt-v2v.pod
c1a9fa
+++ b/docs/virt-v2v.pod
c1a9fa
@@ -409,10 +409,6 @@ See L</Networks and bridges> below.
c1a9fa
 
c1a9fa
 This is the same as I<-o local>.
c1a9fa
 
c1a9fa
-=item B<-o> B<json>
c1a9fa
-
c1a9fa
-This option is deprecated and will be removed in S<virt-v2v 2.2>.
c1a9fa
-
c1a9fa
 =item B<-o> B<libvirt>
c1a9fa
 
c1a9fa
 Set the output method to I<libvirt>.  This is the default.
c1a9fa
diff --git a/output/Makefile.am b/output/Makefile.am
c1a9fa
index 61caf68b..dd488549 100644
c1a9fa
--- a/output/Makefile.am
c1a9fa
+++ b/output/Makefile.am
c1a9fa
@@ -39,18 +39,15 @@ EXTRA_DIST = \
c1a9fa
 	rhv-upload-precheck.py \
c1a9fa
 	rhv-upload-transfer.py \
c1a9fa
 	rhv-upload-vmcheck.py \
c1a9fa
-	test-v2v-python-syntax.sh \
c1a9fa
-	var_expander_tests.ml
c1a9fa
+	test-v2v-python-syntax.sh
c1a9fa
 
c1a9fa
 SOURCES_MLI = \
c1a9fa
 	changeuid.mli \
c1a9fa
-	create_json.mli \
c1a9fa
 	create_libvirt_xml.mli \
c1a9fa
 	openstack_image_properties.mli \
c1a9fa
 	output.mli \
c1a9fa
 	output_disk.mli \
c1a9fa
 	output_glance.mli \
c1a9fa
-	output_json.mli \
c1a9fa
 	output_libvirt.mli \
c1a9fa
 	output_null.mli \
c1a9fa
 	output_openstack.mli \
c1a9fa
@@ -66,14 +63,11 @@ SOURCES_MLI = \
c1a9fa
 	output_rhv_upload_transfer_source.mli \
c1a9fa
 	output_rhv_upload_vmcheck_source.mli \
c1a9fa
 	python_script.mli \
c1a9fa
-	qemuopts.mli \
c1a9fa
-	var_expander.mli
c1a9fa
+	qemuopts.mli
c1a9fa
 
c1a9fa
 SOURCES_ML = \
c1a9fa
 	changeuid.ml \
c1a9fa
 	python_script.ml \
c1a9fa
-	var_expander.ml \
c1a9fa
-	create_json.ml \
c1a9fa
 	create_libvirt_xml.ml \
c1a9fa
 	qemuopts.ml \
c1a9fa
 	openstack_image_properties.ml \
c1a9fa
@@ -87,7 +81,6 @@ SOURCES_ML = \
c1a9fa
 	output.ml \
c1a9fa
 	output_disk.ml \
c1a9fa
 	output_glance.ml \
c1a9fa
-	output_json.ml \
c1a9fa
 	output_libvirt.ml \
c1a9fa
 	output_null.ml \
c1a9fa
 	output_openstack.ml \
c1a9fa
@@ -203,47 +196,9 @@ $(MLOUTPUT_CMA): $(OBJECTS) libmloutput.a
c1a9fa
 	$(OCAMLFIND) mklib $(OCAMLPACKAGES) \
c1a9fa
 	    $(OBJECTS) $(libmloutput_a_OBJECTS) -o mloutput
c1a9fa
 
c1a9fa
-# Unit tests.
c1a9fa
-TESTS =
c1a9fa
-if HAVE_OCAML_PKG_OUNIT
c1a9fa
-TESTS += \
c1a9fa
-	var_expander_tests
c1a9fa
-check_PROGRAMS = \
c1a9fa
-	var_expander_tests
c1a9fa
-endif
c1a9fa
-
c1a9fa
-var_expander_tests_BOBJECTS = \
c1a9fa
-	var_expander.cmo \
c1a9fa
-	var_expander_tests.cmo
c1a9fa
-var_expander_tests_XOBJECTS = $(var_expander_tests_BOBJECTS:.cmo=.cmx)
c1a9fa
-
c1a9fa
-var_expander_tests_SOURCES = dummy.c
c1a9fa
-var_expander_tests_CPPFLAGS = $(virt_v2v_CPPFLAGS)
c1a9fa
-var_expander_tests_CFLAGS = $(virt_v2v_CFLAGS)
c1a9fa
-
c1a9fa
-if !HAVE_OCAMLOPT
c1a9fa
-# Can't call this var_expander_tests_OBJECTS because automake gets confused.
c1a9fa
-var_expander_tests_THEOBJECTS = $(var_expander_tests_BOBJECTS)
c1a9fa
-var_expander_tests.cmo: OCAMLPACKAGES += -package ounit2
c1a9fa
-else
c1a9fa
-var_expander_tests_THEOBJECTS = $(var_expander_tests_XOBJECTS)
c1a9fa
-var_expander_tests.cmx: OCAMLPACKAGES += -package ounit2
c1a9fa
-endif
c1a9fa
-
c1a9fa
-var_expander_tests_DEPENDENCIES = \
c1a9fa
-	$(var_expander_tests_THEOBJECTS) \
c1a9fa
-	$(top_builddir)/common/mlpcre/mlpcre.$(MLARCHIVE) \
c1a9fa
-	$(top_srcdir)/ocaml-link.sh
c1a9fa
-var_expander_tests_LINK = \
c1a9fa
-	$(top_srcdir)/ocaml-link.sh -cclib '$(OCAMLCLIBS)' -- \
c1a9fa
-	  $(OCAMLFIND) $(BEST) $(OCAMLFLAGS) \
c1a9fa
-	  $(OCAMLPACKAGES) -package ounit2 \
c1a9fa
-	  $(OCAMLLINKFLAGS) \
c1a9fa
-	  $(var_expander_tests_THEOBJECTS) -o $@
c1a9fa
-
c1a9fa
 # Unit tests.
c1a9fa
 TESTS_ENVIRONMENT = $(top_builddir)/run --test
c1a9fa
-TESTS += test-v2v-python-syntax.sh
c1a9fa
+TESTS = test-v2v-python-syntax.sh
c1a9fa
 
c1a9fa
 # Dependencies.
c1a9fa
 .depend: \
c1a9fa
diff --git a/output/create_json.ml b/output/create_json.ml
c1a9fa
deleted file mode 100644
c1a9fa
index cbc27fdc..00000000
c1a9fa
--- a/output/create_json.ml
c1a9fa
+++ /dev/null
c1a9fa
@@ -1,338 +0,0 @@
c1a9fa
-(* virt-v2v
c1a9fa
- * Copyright (C) 2019 Red Hat Inc.
c1a9fa
- *
c1a9fa
- * This program is free software; you can redistribute it and/or modify
c1a9fa
- * it under the terms of the GNU General Public License as published by
c1a9fa
- * the Free Software Foundation; either version 2 of the License, or
c1a9fa
- * (at your option) any later version.
c1a9fa
- *
c1a9fa
- * This program is distributed in the hope that it will be useful,
c1a9fa
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
c1a9fa
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
c1a9fa
- * GNU General Public License for more details.
c1a9fa
- *
c1a9fa
- * You should have received a copy of the GNU General Public License along
c1a9fa
- * with this program; if not, write to the Free Software Foundation, Inc.,
c1a9fa
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
c1a9fa
- *)
c1a9fa
-
c1a9fa
-open Std_utils
c1a9fa
-open C_utils
c1a9fa
-open Tools_utils
c1a9fa
-
c1a9fa
-open Types
c1a9fa
-open Utils
c1a9fa
-
c1a9fa
-module G = Guestfs
c1a9fa
-
c1a9fa
-let json_list_of_string_list =
c1a9fa
-  List.map (fun x -> JSON.String x)
c1a9fa
-
c1a9fa
-let json_list_of_string_string_list =
c1a9fa
-  List.map (fun (x, y) -> x, JSON.String y)
c1a9fa
-
c1a9fa
-let push_optional_string lst name = function
c1a9fa
-  | None -> ()
c1a9fa
-  | Some v -> List.push_back lst (name, JSON.String v)
c1a9fa
-
c1a9fa
-let push_optional_int lst name = function
c1a9fa
-  | None -> ()
c1a9fa
-  | Some v -> List.push_back lst (name, JSON.Int (Int64.of_int v))
c1a9fa
-
c1a9fa
-let json_unknown_string = function
c1a9fa
-  | "unknown" -> JSON.Null
c1a9fa
-  | v -> JSON.String v
c1a9fa
-
c1a9fa
-let create_json_metadata source inspect
c1a9fa
-      { guestcaps; target_buses; target_firmware; target_nics }
c1a9fa
-      outdisk_name output_format output_name =
c1a9fa
-  let doc = ref [
c1a9fa
-    "version", JSON.Int 1L;
c1a9fa
-    "name", JSON.String output_name;
c1a9fa
-    "memory", JSON.Int source.s_memory;
c1a9fa
-    "vcpu", JSON.Int (Int64.of_int source.s_vcpu);
c1a9fa
-  ] in
c1a9fa
-
c1a9fa
-  (match source.s_genid with
c1a9fa
-   | None -> ()
c1a9fa
-   | Some genid -> List.push_back doc ("genid", JSON.String genid)
c1a9fa
-  );
c1a9fa
-
c1a9fa
-  if source.s_cpu_vendor <> None || source.s_cpu_model <> None ||
c1a9fa
-     source.s_cpu_topology <> None then (
c1a9fa
-    let cpu = ref [] in
c1a9fa
-
c1a9fa
-    push_optional_string cpu "vendor" source.s_cpu_vendor;
c1a9fa
-    push_optional_string cpu "model" source.s_cpu_model;
c1a9fa
-    (match source.s_cpu_topology with
c1a9fa
-     | None -> ()
c1a9fa
-     | Some { s_cpu_sockets; s_cpu_cores; s_cpu_threads } ->
c1a9fa
-        let attrs = [
c1a9fa
-          "sockets", JSON.Int (Int64.of_int s_cpu_sockets);
c1a9fa
-          "cores", JSON.Int (Int64.of_int s_cpu_cores);
c1a9fa
-          "threads", JSON.Int (Int64.of_int s_cpu_threads);
c1a9fa
-        ] in
c1a9fa
-        List.push_back cpu ("topology", JSON.Dict attrs)
c1a9fa
-    );
c1a9fa
-
c1a9fa
-    List.push_back doc ("cpu", JSON.Dict !cpu);
c1a9fa
-  );
c1a9fa
-
c1a9fa
-  let firmware =
c1a9fa
-    let firmware_type =
c1a9fa
-      match target_firmware with
c1a9fa
-      | TargetBIOS -> "bios"
c1a9fa
-      | TargetUEFI -> "uefi" in
c1a9fa
-
c1a9fa
-    let fw = ref [
c1a9fa
-      "type", JSON.String firmware_type;
c1a9fa
-    ] in
c1a9fa
-
c1a9fa
-    (match target_firmware with
c1a9fa
-     | TargetBIOS -> ()
c1a9fa
-     | TargetUEFI ->
c1a9fa
-       let uefi_firmware = find_uefi_firmware guestcaps.gcaps_arch in
c1a9fa
-       let flags =
c1a9fa
-         List.map (
c1a9fa
-           function
c1a9fa
-           | Uefi.UEFI_FLAG_SECURE_BOOT_REQUIRED -> "secure_boot_required"
c1a9fa
-         ) uefi_firmware.Uefi.flags in
c1a9fa
-
c1a9fa
-       let uefi = ref [
c1a9fa
-         "code", JSON.String uefi_firmware.Uefi.code;
c1a9fa
-         "vars", JSON.String uefi_firmware.Uefi.vars;
c1a9fa
-         "flags", JSON.List (json_list_of_string_list flags);
c1a9fa
-       ] in
c1a9fa
-
c1a9fa
-       push_optional_string uefi "code-debug" uefi_firmware.Uefi.code_debug;
c1a9fa
-
c1a9fa
-       List.push_back fw ("uefi", JSON.Dict !uefi)
c1a9fa
-    );
c1a9fa
-
c1a9fa
-    !fw in
c1a9fa
-  List.push_back doc ("firmware", JSON.Dict firmware);
c1a9fa
-
c1a9fa
-  List.push_back doc ("features",
c1a9fa
-                      JSON.List (json_list_of_string_list source.s_features));
c1a9fa
-
c1a9fa
-  let machine =
c1a9fa
-    match guestcaps.gcaps_machine with
c1a9fa
-    | I440FX -> "pc"
c1a9fa
-    | Q35 -> "q35"
c1a9fa
-    | Virt -> "virt" in
c1a9fa
-  List.push_back doc ("machine", JSON.String machine);
c1a9fa
-
c1a9fa
-  let disks, removables =
c1a9fa
-    let disks = ref []
c1a9fa
-    and removables = ref [] in
c1a9fa
-
c1a9fa
-    let iter_bus bus_name drive_prefix i = function
c1a9fa
-    | BusSlotEmpty -> ()
c1a9fa
-    | BusSlotDisk d ->
c1a9fa
-       (* Find the corresponding target disk. *)
c1a9fa
-       let outdisk = outdisk_name d.s_disk_id in
c1a9fa
-
c1a9fa
-       let disk = [
c1a9fa
-         "dev", JSON.String (drive_prefix ^ drive_name i);
c1a9fa
-         "bus", JSON.String bus_name;
c1a9fa
-         "format", JSON.String output_format;
c1a9fa
-         "file", JSON.String outdisk;
c1a9fa
-       ] in
c1a9fa
-
c1a9fa
-       List.push_back disks (JSON.Dict disk)
c1a9fa
-
c1a9fa
-    | BusSlotRemovable { s_removable_type = CDROM } ->
c1a9fa
-       let cdrom = [
c1a9fa
-         "type", JSON.String "cdrom";
c1a9fa
-         "dev", JSON.String (drive_prefix ^ drive_name i);
c1a9fa
-         "bus", JSON.String bus_name;
c1a9fa
-       ] in
c1a9fa
-
c1a9fa
-       List.push_back removables (JSON.Dict cdrom)
c1a9fa
-
c1a9fa
-    | BusSlotRemovable { s_removable_type = Floppy } ->
c1a9fa
-       let floppy = [
c1a9fa
-         "type", JSON.String "floppy";
c1a9fa
-         "dev", JSON.String (drive_prefix ^ drive_name i);
c1a9fa
-       ] in
c1a9fa
-
c1a9fa
-       List.push_back removables (JSON.Dict floppy)
c1a9fa
-    in
c1a9fa
-
c1a9fa
-    Array.iteri (iter_bus "virtio" "vd") target_buses.target_virtio_blk_bus;
c1a9fa
-    Array.iteri (iter_bus "ide" "hd") target_buses.target_ide_bus;
c1a9fa
-    Array.iteri (iter_bus "scsi" "sd") target_buses.target_scsi_bus;
c1a9fa
-    Array.iteri (iter_bus "floppy" "fd") target_buses.target_floppy_bus;
c1a9fa
-
c1a9fa
-    !disks, !removables in
c1a9fa
-  List.push_back doc ("disks", JSON.List disks);
c1a9fa
-  List.push_back doc ("removables", JSON.List removables);
c1a9fa
-
c1a9fa
-  let nics =
c1a9fa
-    List.map (
c1a9fa
-      fun { s_mac = mac; s_vnet_type = vnet_type; s_nic_model = nic_model;
c1a9fa
-            s_vnet = vnet; } ->
c1a9fa
-        let vnet_type_str =
c1a9fa
-          match vnet_type with
c1a9fa
-          | Bridge -> "bridge"
c1a9fa
-          | Network -> "network" in
c1a9fa
-
c1a9fa
-        let nic = ref [
c1a9fa
-          "vnet", JSON.String vnet;
c1a9fa
-          "vnet-type", JSON.String vnet_type_str;
c1a9fa
-        ] in
c1a9fa
-
c1a9fa
-        let nic_model_str = Option.map string_of_nic_model nic_model in
c1a9fa
-        push_optional_string nic "model" nic_model_str;
c1a9fa
-
c1a9fa
-        push_optional_string nic "mac" mac;
c1a9fa
-
c1a9fa
-        JSON.Dict !nic
c1a9fa
-    ) target_nics in
c1a9fa
-  List.push_back doc ("nics", JSON.List nics);
c1a9fa
-
c1a9fa
-  let guestcaps_dict =
c1a9fa
-    let block_bus =
c1a9fa
-      match guestcaps.gcaps_block_bus with
c1a9fa
-      | Virtio_blk -> "virtio-blk"
c1a9fa
-      | IDE -> "ide" in
c1a9fa
-    let net_bus =
c1a9fa
-      match guestcaps.gcaps_net_bus with
c1a9fa
-      | Virtio_net -> "virtio-net"
c1a9fa
-      | E1000 -> "e1000"
c1a9fa
-      | RTL8139 -> "rtl8139" in
c1a9fa
-    let video = "vga" in
c1a9fa
-    let machine =
c1a9fa
-      match guestcaps.gcaps_machine with
c1a9fa
-      | I440FX -> "i440fx"
c1a9fa
-      | Q35 -> "q35"
c1a9fa
-      | Virt -> "virt" in
c1a9fa
-
c1a9fa
-    [
c1a9fa
-      "block-bus", JSON.String block_bus;
c1a9fa
-      "net-bus", JSON.String net_bus;
c1a9fa
-      "video", JSON.String video;
c1a9fa
-      "machine", JSON.String machine;
c1a9fa
-      "arch", JSON.String guestcaps.gcaps_arch;
c1a9fa
-      "virtio-rng", JSON.Bool guestcaps.gcaps_virtio_rng;
c1a9fa
-      "virtio-balloon", JSON.Bool guestcaps.gcaps_virtio_balloon;
c1a9fa
-      "isa-pvpanic", JSON.Bool guestcaps.gcaps_isa_pvpanic;
c1a9fa
-      "virtio-socket", JSON.Bool guestcaps.gcaps_virtio_socket;
c1a9fa
-      "acpi", JSON.Bool guestcaps.gcaps_acpi;
c1a9fa
-      "virtio-1-0", JSON.Bool guestcaps.gcaps_virtio_1_0;
c1a9fa
-    ] in
c1a9fa
-  List.push_back doc ("guestcaps", JSON.Dict guestcaps_dict);
c1a9fa
-
c1a9fa
-  (match source.s_sound with
c1a9fa
-   | None -> ()
c1a9fa
-   | Some { s_sound_model = model } ->
c1a9fa
-     let sound = [
c1a9fa
-       "model", JSON.String (string_of_source_sound_model model);
c1a9fa
-     ] in
c1a9fa
-     List.push_back doc ("sound", JSON.Dict sound)
c1a9fa
-   );
c1a9fa
-
c1a9fa
-  (match source.s_display with
c1a9fa
-   | None -> ()
c1a9fa
-   | Some d ->
c1a9fa
-     let display_type =
c1a9fa
-       match d.s_display_type with
c1a9fa
-       | Window -> "window"
c1a9fa
-       | VNC -> "vnc"
c1a9fa
-       | Spice -> "spice" in
c1a9fa
-
c1a9fa
-     let display = ref [
c1a9fa
-       "type", JSON.String display_type;
c1a9fa
-     ] in
c1a9fa
-
c1a9fa
-     push_optional_string display "keymap" d.s_keymap;
c1a9fa
-     push_optional_string display "password" d.s_password;
c1a9fa
-
c1a9fa
-     let listen =
c1a9fa
-       match d.s_listen with
c1a9fa
-       | LNoListen -> None
c1a9fa
-       | LAddress address ->
c1a9fa
-         Some [
c1a9fa
-           "type", JSON.String "address";
c1a9fa
-           "address", JSON.String address;
c1a9fa
-         ]
c1a9fa
-       | LNetwork network ->
c1a9fa
-         Some [
c1a9fa
-           "type", JSON.String "network";
c1a9fa
-           "network", JSON.String network;
c1a9fa
-         ]
c1a9fa
-       | LSocket None ->
c1a9fa
-         Some [
c1a9fa
-           "type", JSON.String "socket";
c1a9fa
-           "socket", JSON.Null;
c1a9fa
-         ]
c1a9fa
-       | LSocket (Some socket) ->
c1a9fa
-         Some [
c1a9fa
-           "type", JSON.String "socket";
c1a9fa
-           "socket", JSON.String socket;
c1a9fa
-         ]
c1a9fa
-       | LNone ->
c1a9fa
-         Some [
c1a9fa
-           "type", JSON.String "none";
c1a9fa
-         ] in
c1a9fa
-     (match listen with
c1a9fa
-      | None -> ()
c1a9fa
-      | Some l -> List.push_back display ("listen", JSON.Dict l)
c1a9fa
-     );
c1a9fa
-
c1a9fa
-     push_optional_int display "port" d.s_port;
c1a9fa
-
c1a9fa
-     List.push_back doc ("display", JSON.Dict !display)
c1a9fa
-  );
c1a9fa
-
c1a9fa
-  let inspect_dict =
c1a9fa
-    let apps =
c1a9fa
-      List.map (
c1a9fa
-        fun { G.app2_name = name; app2_display_name = display_name;
c1a9fa
-              app2_epoch = epoch; app2_version = version;
c1a9fa
-              app2_release = release; app2_arch = arch; } ->
c1a9fa
-          JSON.Dict [
c1a9fa
-            "name", JSON.String name;
c1a9fa
-            "display-name", JSON.String display_name;
c1a9fa
-            "epoch", JSON.Int (Int64.of_int32 epoch);
c1a9fa
-            "version", JSON.String version;
c1a9fa
-            "release", JSON.String release;
c1a9fa
-            "arch", JSON.String arch;
c1a9fa
-          ]
c1a9fa
-      ) inspect.i_apps in
c1a9fa
-
c1a9fa
-    let firmware_dict =
c1a9fa
-      match inspect.i_firmware with
c1a9fa
-      | I_BIOS ->
c1a9fa
-        [
c1a9fa
-          "type", JSON.String "bios";
c1a9fa
-        ]
c1a9fa
-      | I_UEFI devices ->
c1a9fa
-        [
c1a9fa
-          "type", JSON.String "uefi";
c1a9fa
-          "devices", JSON.List (json_list_of_string_list devices);
c1a9fa
-        ] in
c1a9fa
-
c1a9fa
-    [
c1a9fa
-      "root", JSON.String inspect.i_root;
c1a9fa
-      "type", JSON.String inspect.i_type;
c1a9fa
-      "distro", json_unknown_string inspect.i_distro;
c1a9fa
-      "osinfo", json_unknown_string inspect.i_osinfo;
c1a9fa
-      "arch", JSON.String inspect.i_arch;
c1a9fa
-      "major-version", JSON.Int (Int64.of_int inspect.i_major_version);
c1a9fa
-      "minor-version", JSON.Int (Int64.of_int inspect.i_minor_version);
c1a9fa
-      "package-format", json_unknown_string inspect.i_package_format;
c1a9fa
-      "package-management", json_unknown_string inspect.i_package_management;
c1a9fa
-      "product-name", json_unknown_string inspect.i_product_name;
c1a9fa
-      "product-variant", json_unknown_string inspect.i_product_variant;
c1a9fa
-      "mountpoints", JSON.Dict (json_list_of_string_string_list inspect.i_mountpoints);
c1a9fa
-      "applications", JSON.List apps;
c1a9fa
-      "windows-systemroot", JSON.String inspect.i_windows_systemroot;
c1a9fa
-      "windows-software-hive", JSON.String inspect.i_windows_software_hive;
c1a9fa
-      "windows-system-hive", JSON.String inspect.i_windows_system_hive;
c1a9fa
-      "windows-current-control-set", JSON.String inspect.i_windows_current_control_set;
c1a9fa
-      "firmware", JSON.Dict firmware_dict;
c1a9fa
-    ] in
c1a9fa
-  List.push_back doc ("inspect", JSON.Dict inspect_dict);
c1a9fa
-
c1a9fa
-  !doc
c1a9fa
diff --git a/output/create_json.mli b/output/create_json.mli
c1a9fa
deleted file mode 100644
c1a9fa
index 97086ff5..00000000
c1a9fa
--- a/output/create_json.mli
c1a9fa
+++ /dev/null
c1a9fa
@@ -1,27 +0,0 @@
c1a9fa
-(* virt-v2v
c1a9fa
- * Copyright (C) 2019 Red Hat Inc.
c1a9fa
- *
c1a9fa
- * This program is free software; you can redistribute it and/or modify
c1a9fa
- * it under the terms of the GNU General Public License as published by
c1a9fa
- * the Free Software Foundation; either version 2 of the License, or
c1a9fa
- * (at your option) any later version.
c1a9fa
- *
c1a9fa
- * This program is distributed in the hope that it will be useful,
c1a9fa
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
c1a9fa
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
c1a9fa
- * GNU General Public License for more details.
c1a9fa
- *
c1a9fa
- * You should have received a copy of the GNU General Public License along
c1a9fa
- * with this program; if not, write to the Free Software Foundation, Inc.,
c1a9fa
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
c1a9fa
- *)
c1a9fa
-
c1a9fa
-(** Create JSON metadata for [-o json]. *)
c1a9fa
-
c1a9fa
-val create_json_metadata : Types.source -> Types.inspect ->
c1a9fa
-                           Types.target_meta ->
c1a9fa
-                           (int -> string) -> string -> string ->
c1a9fa
-                           JSON.doc
c1a9fa
-(** [create_json_metadata source targets outdisk_map output_format output_name]
c1a9fa
-    creates the JSON with the majority of the data that virt-v2v used for the
c1a9fa
-    conversion. *)
c1a9fa
diff --git a/output/output_json.ml b/output/output_json.ml
c1a9fa
deleted file mode 100644
c1a9fa
index 6e81b639..00000000
c1a9fa
--- a/output/output_json.ml
c1a9fa
+++ /dev/null
c1a9fa
@@ -1,153 +0,0 @@
c1a9fa
-(* virt-v2v
c1a9fa
- * Copyright (C) 2009-2021 Red Hat Inc.
c1a9fa
- *
c1a9fa
- * This program is free software; you can redistribute it and/or modify
c1a9fa
- * it under the terms of the GNU General Public License as published by
c1a9fa
- * the Free Software Foundation; either version 2 of the License, or
c1a9fa
- * (at your option) any later version.
c1a9fa
- *
c1a9fa
- * This program is distributed in the hope that it will be useful,
c1a9fa
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
c1a9fa
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
c1a9fa
- * GNU General Public License for more details.
c1a9fa
- *
c1a9fa
- * You should have received a copy of the GNU General Public License along
c1a9fa
- * with this program; if not, write to the Free Software Foundation, Inc.,
c1a9fa
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
c1a9fa
- *)
c1a9fa
-
c1a9fa
-open Printf
c1a9fa
-open Unix
c1a9fa
-
c1a9fa
-open C_utils
c1a9fa
-open Std_utils
c1a9fa
-open Tools_utils
c1a9fa
-open Common_gettext.Gettext
c1a9fa
-
c1a9fa
-open Types
c1a9fa
-open Utils
c1a9fa
-
c1a9fa
-open Output
c1a9fa
-
c1a9fa
-module Json = struct
c1a9fa
-  type poptions = string * Types.output_allocation * string * string * string
c1a9fa
-
c1a9fa
-  type t = unit
c1a9fa
-
c1a9fa
-  let to_string options =
c1a9fa
-    "-o json" ^
c1a9fa
-      match options.output_storage with
c1a9fa
-      | Some os -> " -os " ^ os
c1a9fa
-      | None -> ""
c1a9fa
-
c1a9fa
-  let query_output_options () =
c1a9fa
-    printf (f_"Output options (-oo) which can be used with -o json:
c1a9fa
-
c1a9fa
-  -oo json-disks-pattern=PATTERN   Pattern for the disks.
c1a9fa
-")
c1a9fa
-
c1a9fa
-  let parse_options options source =
c1a9fa
-    if options.output_conn <> None then
c1a9fa
-      error_option_cannot_be_used_in_output_mode "json" "-oc";
c1a9fa
-    if options.output_password <> None then
c1a9fa
-      error_option_cannot_be_used_in_output_mode "json" "-op";
c1a9fa
-
c1a9fa
-    let known_pattern_variables = ["DiskNo"; "DiskDeviceName"; "GuestName"] in
c1a9fa
-    let json_disks_pattern = ref None in
c1a9fa
-    List.iter (
c1a9fa
-      fun (k, v) ->
c1a9fa
-        match k with
c1a9fa
-        | "json-disks-pattern" ->
c1a9fa
-           if !json_disks_pattern <> None then
c1a9fa
-             error (f_"-o json: -oo json-disks-pattern set more than once");
c1a9fa
-           let vars =
c1a9fa
-             try Var_expander.scan_variables v
c1a9fa
-             with Var_expander.Invalid_variable var ->
c1a9fa
-               error (f_"-o json: -oo json-disks-pattern: invalid variable %%{%s}")
c1a9fa
-                 var in
c1a9fa
-           List.iter (
c1a9fa
-             fun var ->
c1a9fa
-               if not (List.mem var known_pattern_variables) then
c1a9fa
-                 error (f_"-o json: -oo json-disks-pattern: unhandled variable %%{%s}")
c1a9fa
-                   var
c1a9fa
-           ) vars;
c1a9fa
-           json_disks_pattern := Some v
c1a9fa
-        | k ->
c1a9fa
-           error (f_"-o json: unknown output option ‘-oo %s’") k
c1a9fa
-      ) options.output_options;
c1a9fa
-
c1a9fa
-    let json_disks_pattern =
c1a9fa
-      Option.default "%{GuestName}-%{DiskDeviceName}" !json_disks_pattern in
c1a9fa
-
c1a9fa
-    (* -os must be set to a directory. *)
c1a9fa
-    let output_storage =
c1a9fa
-      match options.output_storage with
c1a9fa
-      | None ->
c1a9fa
-         error (f_"-o json: output directory was not specified, use '-os /dir'")
c1a9fa
-      | Some d when not (is_directory d) ->
c1a9fa
-         error (f_"-os %s: output directory does not exist or is not a directory") d
c1a9fa
-      | Some d -> d in
c1a9fa
-
c1a9fa
-    let output_name = Option.default source.s_name options.output_name in
c1a9fa
-
c1a9fa
-    (json_disks_pattern,
c1a9fa
-     options.output_alloc, options.output_format, output_name, output_storage)
c1a9fa
-
c1a9fa
-  let rec setup dir options source =
c1a9fa
-    let disks = get_disks dir in
c1a9fa
-    let json_disks_pattern,
c1a9fa
-        output_alloc, output_format, output_name,
c1a9fa
-        output_storage = options in
c1a9fa
-
c1a9fa
-    List.iter (
c1a9fa
-      fun (i, size) ->
c1a9fa
-        let socket = sprintf "%s/out%d" dir i in
c1a9fa
-        On_exit.unlink socket;
c1a9fa
-
c1a9fa
-        (* Create the actual output disk. *)
c1a9fa
-        let outdisk = json_path output_storage output_name
c1a9fa
-                        json_disks_pattern i in
c1a9fa
-        mkdir_p (Filename.dirname outdisk) 0o755;
c1a9fa
-
c1a9fa
-        output_to_local_file output_alloc output_format outdisk size socket
c1a9fa
-    ) disks
c1a9fa
-
c1a9fa
-  (* For -o json, return the output disk name of the i'th disk. *)
c1a9fa
-  and json_path os output_name json_disks_pattern i =
c1a9fa
-    let outname =
c1a9fa
-      let vars_fn = function
c1a9fa
-        | "DiskNo" -> Some (string_of_int (i+1))
c1a9fa
-        | "DiskDeviceName" -> Some (sprintf "sd%s" (drive_name i))
c1a9fa
-        | "GuestName" -> Some output_name
c1a9fa
-        | _ -> assert false
c1a9fa
-      in
c1a9fa
-      Var_expander.replace_fn json_disks_pattern vars_fn in
c1a9fa
-    let outdisk = os // outname in
c1a9fa
-    let outdisk = absolute_path outdisk in
c1a9fa
-    outdisk
c1a9fa
-
c1a9fa
-  let finalize dir options () source inspect target_meta =
c1a9fa
-    let json_disks_pattern,
c1a9fa
-        output_alloc, output_format, output_name, output_storage = options in
c1a9fa
-
c1a9fa
-    let doc =
c1a9fa
-      Create_json.create_json_metadata source inspect target_meta
c1a9fa
-        (json_path output_storage output_name json_disks_pattern)
c1a9fa
-        output_format output_name in
c1a9fa
-    let doc_string = JSON.string_of_doc ~fmt:JSON.Indented doc in
c1a9fa
-
c1a9fa
-    if verbose () then (
c1a9fa
-      eprintf "resulting JSON:\n";
c1a9fa
-      output_string Stdlib.stderr doc_string;
c1a9fa
-      eprintf "\n\n%!";
c1a9fa
-    );
c1a9fa
-
c1a9fa
-    let file = output_storage // output_name ^ ".json" in
c1a9fa
-    with_open_out file (
c1a9fa
-      fun chan ->
c1a9fa
-        output_string chan doc_string;
c1a9fa
-        output_char chan '\n'
c1a9fa
-    )
c1a9fa
-
c1a9fa
-  let request_size = None
c1a9fa
-end
c1a9fa
diff --git a/output/output_json.mli b/output/output_json.mli
c1a9fa
deleted file mode 100644
c1a9fa
index 00786ef7..00000000
c1a9fa
--- a/output/output_json.mli
c1a9fa
+++ /dev/null
c1a9fa
@@ -1,21 +0,0 @@
c1a9fa
-(* virt-v2v
c1a9fa
- * Copyright (C) 2009-2021 Red Hat Inc.
c1a9fa
- *
c1a9fa
- * This program is free software; you can redistribute it and/or modify
c1a9fa
- * it under the terms of the GNU General Public License as published by
c1a9fa
- * the Free Software Foundation; either version 2 of the License, or
c1a9fa
- * (at your option) any later version.
c1a9fa
- *
c1a9fa
- * This program is distributed in the hope that it will be useful,
c1a9fa
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
c1a9fa
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
c1a9fa
- * GNU General Public License for more details.
c1a9fa
- *
c1a9fa
- * You should have received a copy of the GNU General Public License along
c1a9fa
- * with this program; if not, write to the Free Software Foundation, Inc.,
c1a9fa
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
c1a9fa
- *)
c1a9fa
-
c1a9fa
-(** [-o json] output mode. *)
c1a9fa
-
c1a9fa
-module Json : Output.OUTPUT
c1a9fa
diff --git a/output/var_expander.ml b/output/var_expander.ml
c1a9fa
deleted file mode 100644
c1a9fa
index 24b9bafe..00000000
c1a9fa
--- a/output/var_expander.ml
c1a9fa
+++ /dev/null
c1a9fa
@@ -1,72 +0,0 @@
c1a9fa
-(* virt-v2v
c1a9fa
- * Copyright (C) 2019 Red Hat Inc.
c1a9fa
- *
c1a9fa
- * This program is free software; you can redistribute it and/or modify
c1a9fa
- * it under the terms of the GNU General Public License as published by
c1a9fa
- * the Free Software Foundation; either version 2 of the License, or
c1a9fa
- * (at your option) any later version.
c1a9fa
- *
c1a9fa
- * This program is distributed in the hope that it will be useful,
c1a9fa
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
c1a9fa
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
c1a9fa
- * GNU General Public License for more details.
c1a9fa
- *
c1a9fa
- * You should have received a copy of the GNU General Public License along
c1a9fa
- * with this program; if not, write to the Free Software Foundation, Inc.,
c1a9fa
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
c1a9fa
- *)
c1a9fa
-
c1a9fa
-open Std_utils
c1a9fa
-
c1a9fa
-exception Invalid_variable of string
c1a9fa
-
c1a9fa
-let var_re = PCRE.compile "(^|[^%])%{([^}]+)}"
c1a9fa
-
c1a9fa
-let check_variable var =
c1a9fa
-  String.iter (
c1a9fa
-    function
c1a9fa
-    | '0'..'9'
c1a9fa
-    | 'a'..'z'
c1a9fa
-    | 'A'..'Z'
c1a9fa
-    | '_'
c1a9fa
-    | '-' -> ()
c1a9fa
-    | _ -> raise (Invalid_variable var)
c1a9fa
-  ) var
c1a9fa
-
c1a9fa
-let scan_variables str =
c1a9fa
-  let res = ref [] in
c1a9fa
-  let offset = ref 0 in
c1a9fa
-  while PCRE.matches ~offset:!offset var_re str; do
c1a9fa
-    let var = PCRE.sub 2 in
c1a9fa
-    check_variable var;
c1a9fa
-    let _, end_ = PCRE.subi 0 in
c1a9fa
-    List.push_back res var;
c1a9fa
-    offset := end_
c1a9fa
-  done;
c1a9fa
-  List.remove_duplicates !res
c1a9fa
-
c1a9fa
-let replace_fn str fn =
c1a9fa
-  let res = ref str in
c1a9fa
-  let offset = ref 0 in
c1a9fa
-  while PCRE.matches ~offset:!offset var_re !res; do
c1a9fa
-    let var = PCRE.sub 2 in
c1a9fa
-    check_variable var;
c1a9fa
-    let start_, end_ = PCRE.subi 0 in
c1a9fa
-    match fn var with
c1a9fa
-    | None ->
c1a9fa
-      offset := end_
c1a9fa
-    | Some text ->
c1a9fa
-      let prefix_len =
c1a9fa
-        let prefix_start, prefix_end = PCRE.subi 1 in
c1a9fa
-        prefix_end - prefix_start in
c1a9fa
-      res := (String.sub !res 0 (start_ + prefix_len)) ^ text ^ (String.sub !res end_ (String.length !res - end_));
c1a9fa
-      offset := start_ + prefix_len + String.length text
c1a9fa
-  done;
c1a9fa
-  !res
c1a9fa
-
c1a9fa
-let replace_list str lst =
c1a9fa
-  let fn var =
c1a9fa
-    try Some (List.assoc var lst)
c1a9fa
-    with Not_found -> None
c1a9fa
-  in
c1a9fa
-  replace_fn str fn
c1a9fa
diff --git a/output/var_expander.mli b/output/var_expander.mli
c1a9fa
deleted file mode 100644
c1a9fa
index 80aa33c2..00000000
c1a9fa
--- a/output/var_expander.mli
c1a9fa
+++ /dev/null
c1a9fa
@@ -1,82 +0,0 @@
c1a9fa
-(* virt-v2v
c1a9fa
- * Copyright (C) 2019 Red Hat Inc.
c1a9fa
- *
c1a9fa
- * This program is free software; you can redistribute it and/or modify
c1a9fa
- * it under the terms of the GNU General Public License as published by
c1a9fa
- * the Free Software Foundation; either version 2 of the License, or
c1a9fa
- * (at your option) any later version.
c1a9fa
- *
c1a9fa
- * This program is distributed in the hope that it will be useful,
c1a9fa
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
c1a9fa
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
c1a9fa
- * GNU General Public License for more details.
c1a9fa
- *
c1a9fa
- * You should have received a copy of the GNU General Public License along
c1a9fa
- * with this program; if not, write to the Free Software Foundation, Inc.,
c1a9fa
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
c1a9fa
- *)
c1a9fa
-
c1a9fa
-(** Simple variable expander.
c1a9fa
-
c1a9fa
-    This module provides the support to expand variables in strings,
c1a9fa
-    specified in the form of [%{name}].
c1a9fa
-
c1a9fa
-    For example:
c1a9fa
-
c1a9fa
-{v
c1a9fa
-let str = "variable-%{INDEX} in %{INDEX} replaced %{INDEX} times"
c1a9fa
-let index = ref 0
c1a9fa
-let fn = function
c1a9fa
-  | "INDEX" ->
c1a9fa
-    incr index;
c1a9fa
-    Some (string_of_int !index)
c1a9fa
-  | _ -> None
c1a9fa
-in
c1a9fa
-let str = Var_expander.replace_fn str fn
c1a9fa
-(* now str is "variable-1 in 2 replaced 3 times" *)
c1a9fa
-v}
c1a9fa
-
c1a9fa
-    The names of variables can contain only ASCII letters (uppercase,
c1a9fa
-    and lowercase), digits, underscores, and dashes.
c1a9fa
-
c1a9fa
-    The replacement is done in a single pass: this means that if a
c1a9fa
-    variable is replaced with the text of a variable, that new text
c1a9fa
-    is kept as is in the final output.  In practice:
c1a9fa
-
c1a9fa
-{v
c1a9fa
-let str = "%{VAR}"
c1a9fa
-let str = Var_expander.replace_list str [("VAR", "%{VAR}")]
c1a9fa
-(* now str is "%{VAR}" *)
c1a9fa
-v}
c1a9fa
-*)
c1a9fa
-
c1a9fa
-exception Invalid_variable of string
c1a9fa
-(** Invalid variable name error.
c1a9fa
-
c1a9fa
-    In case a variable contains characters not allowed, then this
c1a9fa
-    exception with the actual unacceptable variable. *)
c1a9fa
-
c1a9fa
-val scan_variables : string -> string list
c1a9fa
-(** Scan the pattern string for all the variables available.
c1a9fa
-
c1a9fa
-    This can raise {!Invalid_variable} in case there are invalid
c1a9fa
-    variable names. *)
c1a9fa
-
c1a9fa
-val replace_fn : string -> (string -> string option) -> string
c1a9fa
-(** Replaces a string expanding all the variables.
c1a9fa
-
c1a9fa
-    The replacement function specify how a variable is replaced;
c1a9fa
-    if [None] is returned, then that variable is not replaced.
c1a9fa
-
c1a9fa
-    This can raise {!Invalid_variable} in case there are invalid
c1a9fa
-    variable names. *)
c1a9fa
-
c1a9fa
-val replace_list : string -> (string * string) list -> string
c1a9fa
-(** Replaces a string expanding all the variables.
c1a9fa
-
c1a9fa
-    The replacement list specify how a variable is replaced;
c1a9fa
-    if it is not specified in the list, then that variable is not
c1a9fa
-    replaced.
c1a9fa
-
c1a9fa
-    This can raise {!Invalid_variable} in case there are invalid
c1a9fa
-    variable names. *)
c1a9fa
diff --git a/output/var_expander_tests.ml b/output/var_expander_tests.ml
c1a9fa
deleted file mode 100644
c1a9fa
index 35b62836..00000000
c1a9fa
--- a/output/var_expander_tests.ml
c1a9fa
+++ /dev/null
c1a9fa
@@ -1,113 +0,0 @@
c1a9fa
-(* virt-v2v
c1a9fa
- * Copyright (C) 2019 Red Hat Inc.
c1a9fa
- *
c1a9fa
- * This program is free software; you can redistribute it and/or modify
c1a9fa
- * it under the terms of the GNU General Public License as published by
c1a9fa
- * the Free Software Foundation; either version 2 of the License, or
c1a9fa
- * (at your option) any later version.
c1a9fa
- *
c1a9fa
- * This program is distributed in the hope that it will be useful,
c1a9fa
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
c1a9fa
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
c1a9fa
- * GNU General Public License for more details.
c1a9fa
- *
c1a9fa
- * You should have received a copy of the GNU General Public License along
c1a9fa
- * with this program; if not, write to the Free Software Foundation, Inc.,
c1a9fa
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
c1a9fa
- *)
c1a9fa
-
c1a9fa
-open Printf
c1a9fa
-open OUnit
c1a9fa
-
c1a9fa
-open Std_utils
c1a9fa
-
c1a9fa
-let assert_equal_string = assert_equal ~printer:identity
c1a9fa
-let assert_equal_stringlist = assert_equal ~printer:(fun x -> "(" ^ (String.escaped (String.concat "," x)) ^ ")")
c1a9fa
-
c1a9fa
-let replace_none_fn _ = None
c1a9fa
-let replace_empty_fn _ = Some ""
c1a9fa
-
c1a9fa
-let test_no_replacement () =
c1a9fa
-  assert_equal_string "" (Var_expander.replace_fn "" replace_none_fn);
c1a9fa
-  assert_equal_string "x" (Var_expander.replace_fn "x" replace_none_fn);
c1a9fa
-  assert_equal_string "%{}" (Var_expander.replace_fn "%{}" replace_none_fn);
c1a9fa
-  assert_equal_string "%{EMPTY}" (Var_expander.replace_fn "%{EMPTY}" replace_none_fn);
c1a9fa
-  assert_equal_string "%{EMPTY} %{no}" (Var_expander.replace_fn "%{EMPTY} %{no}" replace_none_fn);
c1a9fa
-  assert_equal_string "a %{EMPTY} b" (Var_expander.replace_fn "a %{EMPTY} b" replace_none_fn);
c1a9fa
-  ()
c1a9fa
-
c1a9fa
-let test_replacements () =
c1a9fa
-  assert_equal_string "" (Var_expander.replace_fn "%{EMPTY}" replace_empty_fn);
c1a9fa
-  assert_equal_string "x " (Var_expander.replace_fn "x %{EMPTY}" replace_empty_fn);
c1a9fa
-  assert_equal_string "xy" (Var_expander.replace_fn "x%{EMPTY}y" replace_empty_fn);
c1a9fa
-  assert_equal_string "x<->y" (Var_expander.replace_fn "x%{FOO}y" (function | "FOO" -> Some "<->" | _ -> None));
c1a9fa
-  assert_equal_string "a x b" (Var_expander.replace_fn "a %{FOO} b" (function | "FOO" -> Some "x" | _ -> None));
c1a9fa
-  assert_equal_string "%{FOO} x" (Var_expander.replace_fn "%{FOO} %{BAR}" (function | "BAR" -> Some "x" | _ -> None));
c1a9fa
-  assert_equal_string "%{FOO}" (Var_expander.replace_fn "%{BAR}" (function | "BAR" -> Some "%{FOO}" | _ -> None));
c1a9fa
-  assert_equal_string "%{FOO} x" (Var_expander.replace_fn "%{BAR} %{FOO}" (function | "BAR" -> Some "%{FOO}" | "FOO" -> Some "x" | _ -> None));
c1a9fa
-  begin
c1a9fa
-    let str = "%{INDEX}, %{INDEX}, %{INDEX}" in
c1a9fa
-    let index = ref 0 in
c1a9fa
-    let fn = function
c1a9fa
-      | "INDEX" ->
c1a9fa
-        incr index;
c1a9fa
-        Some (string_of_int !index)
c1a9fa
-      | _ -> None
c1a9fa
-    in
c1a9fa
-    assert_equal_string "1, 2, 3" (Var_expander.replace_fn str fn)
c1a9fa
-  end;
c1a9fa
-  ()
c1a9fa
-
c1a9fa
-let test_escape () =
c1a9fa
-  assert_equal_string "%%{FOO}" (Var_expander.replace_fn "%%{FOO}" replace_empty_fn);
c1a9fa
-  assert_equal_string "x %%{FOO} x" (Var_expander.replace_fn "%{FOO} %%{FOO} %{FOO}" (function | "FOO" -> Some "x" | _ -> None));
c1a9fa
-  ()
c1a9fa
-
c1a9fa
-let test_list () =
c1a9fa
-  assert_equal_string "x %{NONE}" (Var_expander.replace_list "%{FOO} %{NONE}" [("FOO", "x")]);
c1a9fa
-  ()
c1a9fa
-
c1a9fa
-let test_scan_variables () =
c1a9fa
-  let assert_invalid_variable var =
c1a9fa
-    let str = "%{" ^ var ^ "}" in
c1a9fa
-    assert_raises (Var_expander.Invalid_variable var)
c1a9fa
-                  (fun () -> Var_expander.scan_variables str)
c1a9fa
-  in
c1a9fa
-  assert_equal_stringlist [] (Var_expander.scan_variables "");
c1a9fa
-  assert_equal_stringlist [] (Var_expander.scan_variables "foo");
c1a9fa
-  assert_equal_stringlist ["FOO"] (Var_expander.scan_variables "%{FOO}");
c1a9fa
-  assert_equal_stringlist ["FOO"; "BAR"] (Var_expander.scan_variables "%{FOO} %{BAR}");
c1a9fa
-  assert_equal_stringlist ["FOO"; "BAR"] (Var_expander.scan_variables "%{FOO} %{BAR} %{FOO}");
c1a9fa
-  assert_equal_stringlist ["FOO"; "BAR"] (Var_expander.scan_variables "%{FOO} %%{ESCAPED} %{BAR}");
c1a9fa
-  assert_invalid_variable "FOO/BAR";
c1a9fa
-  ()
c1a9fa
-
c1a9fa
-let test_errors () =
c1a9fa
-  let assert_invalid_variable var =
c1a9fa
-    let str = "%{" ^ var ^ "}" in
c1a9fa
-    assert_raises (Var_expander.Invalid_variable var)
c1a9fa
-                  (fun () -> Var_expander.replace_fn str replace_none_fn)
c1a9fa
-  in
c1a9fa
-  assert_invalid_variable "FOO/BAR";
c1a9fa
-  assert_invalid_variable "FOO:BAR";
c1a9fa
-  assert_invalid_variable "FOO(BAR";
c1a9fa
-  assert_invalid_variable "FOO)BAR";
c1a9fa
-  assert_invalid_variable "FOO@BAR";
c1a9fa
-  ()
c1a9fa
-
c1a9fa
-(* Suites declaration. *)
c1a9fa
-let suite =
c1a9fa
-  TestList ([
c1a9fa
-    "basic" >::: [
c1a9fa
-      "no_replacement" >:: test_no_replacement;
c1a9fa
-      "replacements" >:: test_replacements;
c1a9fa
-      "escape" >:: test_escape;
c1a9fa
-      "list" >:: test_list;
c1a9fa
-      "scan_variables" >:: test_scan_variables;
c1a9fa
-      "errors" >:: test_errors;
c1a9fa
-    ];
c1a9fa
-  ])
c1a9fa
-
c1a9fa
-let () =
c1a9fa
-  ignore (run_test_tt_main suite);
c1a9fa
-  Printf.fprintf stderr "\n"
c1a9fa
diff --git a/tests/Makefile.am b/tests/Makefile.am
c1a9fa
index db32e42b..e787a86c 100644
c1a9fa
--- a/tests/Makefile.am
c1a9fa
+++ b/tests/Makefile.am
c1a9fa
@@ -81,7 +81,6 @@ TESTS = \
c1a9fa
 	test-v2v-machine-readable.sh \
c1a9fa
 	test-v2v-networks-and-bridges.sh \
c1a9fa
 	test-v2v-o-glance.sh \
c1a9fa
-	test-v2v-o-json.sh \
c1a9fa
 	test-v2v-o-libvirt.sh \
c1a9fa
 	test-v2v-o-null.sh \
c1a9fa
 	test-v2v-o-openstack.sh \
c1a9fa
@@ -241,7 +240,6 @@ EXTRA_DIST += \
c1a9fa
 	test-v2v-networks-and-bridges.sh \
c1a9fa
 	test-v2v-networks-and-bridges-expected.xml \
c1a9fa
 	test-v2v-o-glance.sh \
c1a9fa
-	test-v2v-o-json.sh \
c1a9fa
 	test-v2v-o-libvirt.sh \
c1a9fa
 	test-v2v-o-null.sh \
c1a9fa
 	test-v2v-o-openstack.sh \
c1a9fa
diff --git a/tests/test-v2v-o-json.sh b/tests/test-v2v-o-json.sh
c1a9fa
deleted file mode 100755
c1a9fa
index 15e7ad5a..00000000
c1a9fa
--- a/tests/test-v2v-o-json.sh
c1a9fa
+++ /dev/null
c1a9fa
@@ -1,68 +0,0 @@
c1a9fa
-#!/bin/bash -
c1a9fa
-# libguestfs virt-v2v test script
c1a9fa
-# Copyright (C) 2019 Red Hat Inc.
c1a9fa
-#
c1a9fa
-# This program is free software; you can redistribute it and/or modify
c1a9fa
-# it under the terms of the GNU General Public License as published by
c1a9fa
-# the Free Software Foundation; either version 2 of the License, or
c1a9fa
-# (at your option) any later version.
c1a9fa
-#
c1a9fa
-# This program is distributed in the hope that it will be useful,
c1a9fa
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
c1a9fa
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
c1a9fa
-# GNU General Public License for more details.
c1a9fa
-#
c1a9fa
-# You should have received a copy of the GNU General Public License
c1a9fa
-# along with this program; if not, write to the Free Software
c1a9fa
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
c1a9fa
-
c1a9fa
-# Test -o json.
c1a9fa
-
c1a9fa
-set -e
c1a9fa
-set -x
c1a9fa
-
c1a9fa
-source ./functions.sh
c1a9fa
-set -e
c1a9fa
-set -x
c1a9fa
-
c1a9fa
-skip_if_skipped
c1a9fa
-requires test -f ../test-data/phony-guests/windows.img
c1a9fa
-requires jq --version
c1a9fa
-
c1a9fa
-libvirt_uri="test://$abs_top_builddir/test-data/phony-guests/guests.xml"
c1a9fa
-
c1a9fa
-export VIRT_TOOLS_DATA_DIR="$srcdir/../test-data/fake-virt-tools"
c1a9fa
-
c1a9fa
-guestname=windows
c1a9fa
-
c1a9fa
-d=test-v2v-o-json.d
c1a9fa
-rm -rf $d
c1a9fa
-cleanup_fn rm -r $d
c1a9fa
-mkdir $d
c1a9fa
-
c1a9fa
-json=$d/$guestname.json
c1a9fa
-disk=$d/$guestname-sda
c1a9fa
-
c1a9fa
-$VG virt-v2v --debug-gc \
c1a9fa
-    -i libvirt -ic "$libvirt_uri" windows \
c1a9fa
-    -o json -os $d -on $guestname
c1a9fa
-
c1a9fa
-# Test the disk was created.
c1a9fa
-test -f $disk
c1a9fa
-
c1a9fa
-# Test the JSON.
c1a9fa
-test x$(jq -r '.name' $json) = xwindows
c1a9fa
-test x$(jq -r '.inspect.type' $json) = xwindows
c1a9fa
-test x$(jq -r '.inspect.distro' $json) = xwindows
c1a9fa
-test $(jq -r '.disks | length' $json) -eq 1
c1a9fa
-test $(jq -r '.disks[0].file' $json) = $(realpath $disk)
c1a9fa
-test $(jq -r '.nics | length' $json) -eq 1
c1a9fa
-test $(jq -r '.removables | length' $json) -eq 0
c1a9fa
-
c1a9fa
-# libguestfs 1.40 didn't have osinfo inspection data, but we want this
c1a9fa
-# test to work with 1.40, so ignore if jq returns this field as
c1a9fa
-# "null".
c1a9fa
-osinfo=$(jq -r '.inspect.osinfo' $json)
c1a9fa
-if [ "x$osinfo" != "xnull" ]; then
c1a9fa
-    test x$osinfo = xwin7
c1a9fa
-fi
c1a9fa
diff --git a/v2v/v2v.ml b/v2v/v2v.ml
c1a9fa
index e00f9814..994982ac 100644
c1a9fa
--- a/v2v/v2v.ml
c1a9fa
+++ b/v2v/v2v.ml
c1a9fa
@@ -194,7 +194,6 @@ let rec main () =
c1a9fa
     match mode with
c1a9fa
     | "libvirt" -> output_mode := `Libvirt
c1a9fa
     | "disk" | "local" -> output_mode := `Disk
c1a9fa
-    | "json" -> output_mode := `JSON
c1a9fa
     | "null" -> output_mode := `Null
c1a9fa
     | "openstack" | "osp" | "rhosp" -> output_mode := `Openstack
c1a9fa
     | "ovirt" | "rhv" | "rhev" -> output_mode := `RHV
c1a9fa
@@ -241,7 +240,7 @@ let rec main () =
c1a9fa
       s_"Map network ‘in’ to ‘out’";
c1a9fa
     [ L"no-trim" ],  Getopt.String ("-", no_trim_warning),
c1a9fa
       s_"Ignored for backwards compatibility";
c1a9fa
-    [ S 'o' ],       Getopt.String ("json|libvirt|local|null|openstack|qemu|rhv|rhv-upload|vdsm", set_output_mode),
c1a9fa
+    [ S 'o' ],       Getopt.String ("libvirt|local|null|openstack|qemu|rhv|rhv-upload|vdsm", set_output_mode),
c1a9fa
       s_"Set output mode (default: libvirt)";
c1a9fa
     [ M"oa" ],       Getopt.String ("sparse|preallocated", set_output_alloc),
c1a9fa
                                     s_"Set output allocation mode";
c1a9fa
@@ -376,7 +375,6 @@ read the man page virt-v2v(1).
c1a9fa
       pr "input:libvirtxml\n";
c1a9fa
       pr "input:ova\n";
c1a9fa
       pr "input:vmx\n";
c1a9fa
-      pr "output:json\n";
c1a9fa
       pr "output:libvirt\n";
c1a9fa
       pr "output:local\n";
c1a9fa
       pr "output:null\n";
c1a9fa
@@ -472,8 +470,7 @@ read the man page virt-v2v(1).
c1a9fa
     | `Openstack -> (module Output_openstack.Openstack)
c1a9fa
     | `RHV_Upload -> (module Output_rhv_upload.RHVUpload)
c1a9fa
     | `RHV -> (module Output_rhv.RHV)
c1a9fa
-    | `VDSM -> (module Output_vdsm.VDSM)
c1a9fa
-    | `JSON -> (module Output_json.Json) in
c1a9fa
+    | `VDSM -> (module Output_vdsm.VDSM) in
c1a9fa
 
c1a9fa
   let output_options = {
c1a9fa
     Output.output_alloc = output_alloc;