From 924aa8b70a64e9b076f8f56328a2b49650ab713c Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Wed, 19 Jan 2022 13:10:45 +0000 Subject: [PATCH] Restore message about setting up the input and output MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Old virt-v2v would print a summary of the input and output options before connecting to the input/output, looking something like this: [ 0.2] Opening the source -i libvirt -ic [etc] This gave reassurance that virt-v2v was doing something in the case where the source was slow or unreachable. In particular if you use -i libvirt with a vCenter URL, and the URL is wrong, libvirt hangs for a few minutes without printing anything. Modular virt-v2v rearranged things so the connecting phase was silent, which meant that in the case above virt-v2v appeared to hang for a few minutes printing nothing at all. This change adds to_string functions to all the input and output methods and uses them to print a message like: [ 0.0] Setting up the source: -i libvirt -ic [etc] The hang still happens, but at least it's now clear where it's hanging. Note the old "Opening the source" message now refers to libguestfs connecting to the NBD source disk pipeline. Typical full output looks like this: $ virt-v2v -i disk /var/tmp/fedora-35.img -o disk -os /var/tmp/out [ 0.0] Setting up the source: -i disk /var/tmp/fedora-35.img [ 1.1] Opening the source [ 5.9] Inspecting the source [ 11.5] Checking for sufficient free disk space in the guest [ 11.5] Converting Fedora Linux 35 (Thirty Five) to run on KVM virt-v2v: warning: /files/boot/grub2/device.map/hd0 references unknown device "vda". You may have to fix this entry manually after conversion. virt-v2v: This guest has virtio drivers installed. [ 57.4] Mapping filesystem data to avoid copying unused and blank areas [ 61.0] Closing the overlay [ 61.7] Assigning disks to buses [ 61.7] Checking if the guest needs BIOS or UEFI to boot [ 61.7] Setting up the destination: -o disk -os /var/tmp/out [ 62.8] Copying disk 1/1 ā–ˆ 100% [****************************************] [ 81.7] Creating output metadata [ 81.7] Finishing off Reported-by: Xiaodai Wang Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=2041886 Fixes: commit 255722cbf39afc0b012e2ac00d16fa6ba2f8c21f Reviewed-by: Laszlo Ersek --- input/input.ml | 1 + input/input.mli | 4 ++++ input/input_disk.ml | 2 ++ input/input_libvirt.ml | 10 ++++++++++ input/input_ova.ml | 2 ++ input/input_vcenter_https.ml | 9 +++++++++ input/input_vddk.ml | 9 +++++++++ input/input_vmx.ml | 2 ++ input/input_xen_ssh.ml | 9 +++++++++ output/output.ml | 1 + output/output.mli | 4 ++++ output/output_disk.ml | 6 ++++++ output/output_glance.ml | 2 ++ output/output_json.ml | 6 ++++++ output/output_libvirt.ml | 6 ++++++ output/output_null.ml | 2 ++ output/output_openstack.ml | 16 ++++++++++++++++ output/output_qemu.ml | 6 ++++++ output/output_rhv.ml | 2 ++ output/output_rhv_upload.ml | 9 +++++++++ output/output_vdsm.ml | 2 ++ tests/test-v2v-i-vmx-1.expected | 1 + tests/test-v2v-i-vmx-2.expected | 1 + tests/test-v2v-i-vmx-3.expected | 1 + tests/test-v2v-i-vmx-4.expected | 1 + tests/test-v2v-i-vmx-5.expected | 1 + tests/test-v2v-i-vmx.sh | 3 +++ tests/test-v2v-print-source.sh | 3 +++ v2v/v2v.ml | 4 ++++ 29 files changed, 125 insertions(+) diff --git a/input/input.ml b/input/input.ml index 00474bec..b1175fa3 100644 --- a/input/input.ml +++ b/input/input.ml @@ -26,6 +26,7 @@ type options = { } module type INPUT = sig + val to_string : options -> string list -> string val setup : string -> options -> string list -> Types.source val query_input_options : unit -> unit end diff --git a/input/input.mli b/input/input.mli index 4f899b1d..b61df3e9 100644 --- a/input/input.mli +++ b/input/input.mli @@ -26,6 +26,10 @@ type options = { } module type INPUT = sig + val to_string : options -> string list -> string + (** [to_string options args] converts the source to a printable + string (for messages). *) + val setup : string -> options -> string list -> Types.source (** [setup dir options args] diff --git a/input/input_disk.ml b/input/input_disk.ml index bcdaf78c..2b21950a 100644 --- a/input/input_disk.ml +++ b/input/input_disk.ml @@ -142,6 +142,8 @@ and detect_local_input_format { input_format } filenames = get_format formats module Disk = struct + let to_string options args = String.concat " " ("-i disk" :: args) + let setup dir options args = disk_source dir options args diff --git a/input/input_libvirt.ml b/input/input_libvirt.ml index f20082c2..33f61086 100644 --- a/input/input_libvirt.ml +++ b/input/input_libvirt.ml @@ -129,6 +129,14 @@ and libvirt_xml_source _ args = source, disks module Libvirt_ = struct + let to_string options args = + let xs = "-i libvirt" :: args in + let xs = + match options.input_conn with + | Some ic -> ("-ic " ^ ic) :: xs + | None -> xs in + String.concat " " xs + let setup dir options args = let source, data = libvirt_source options args in libvirt_servers dir data; @@ -139,6 +147,8 @@ module Libvirt_ = struct end module LibvirtXML = struct + let to_string options args = String.concat " " ("-i libvirtxml" :: args) + let setup dir options args = let source, data = libvirt_xml_source options args in libvirt_servers dir data; diff --git a/input/input_ova.ml b/input/input_ova.ml index 0115f771..19c22d55 100644 --- a/input/input_ova.ml +++ b/input/input_ova.ml @@ -229,6 +229,8 @@ and error_missing_href href = error (f_"-i ova: OVF references file ā€˜%sā€™ which was not found in the OVA archive") href module OVA = struct + let to_string options args = String.concat " " ("-i ova" :: args) + let setup dir options args = ova_source dir options args diff --git a/input/input_vcenter_https.ml b/input/input_vcenter_https.ml index 24ac927d..bcefed16 100644 --- a/input/input_vcenter_https.ml +++ b/input/input_vcenter_https.ml @@ -117,6 +117,15 @@ let rec vcenter_https_source dir options args = source module VCenterHTTPS = struct + let to_string options args = + let xs = args in + let xs = + match options.input_conn with + | Some ic -> ("-ic " ^ ic) :: xs + | None -> xs in + let xs = "-i libvirt" :: xs in + String.concat " " xs + let setup dir options args = vcenter_https_source dir options args diff --git a/input/input_vddk.ml b/input/input_vddk.ml index 1cfb7f5e..b9a0b8bf 100644 --- a/input/input_vddk.ml +++ b/input/input_vddk.ml @@ -193,6 +193,15 @@ and vddk_source dir options args = source module VDDK = struct + let to_string options args = + let xs = "-it vddk" :: args in + let xs = + match options.input_conn with + | Some ic -> ("-ic " ^ ic) :: xs + | None -> xs in + let xs = "-i libvirt" :: xs in + String.concat " " xs + let setup dir options args = vddk_source dir options args diff --git a/input/input_vmx.ml b/input/input_vmx.ml index 9065e857..6e8948f9 100644 --- a/input/input_vmx.ml +++ b/input/input_vmx.ml @@ -118,6 +118,8 @@ and absolute_path_from_other_file other_filename filename = else (Filename.dirname (absolute_path other_filename)) // filename module VMX = struct + let to_string options args = String.concat " " ("-i vmx" :: args) + let setup dir options args = vmx_source dir options args diff --git a/input/input_xen_ssh.ml b/input/input_xen_ssh.ml index cb8b1f91..f18ac5cf 100644 --- a/input/input_xen_ssh.ml +++ b/input/input_xen_ssh.ml @@ -112,6 +112,15 @@ let rec xen_ssh_source dir options args = source module XenSSH = struct + let to_string options args = + let xs = args in + let xs = + match options.input_conn with + | Some ic -> ("-ic " ^ ic) :: xs + | None -> xs in + let xs = "-i libvirt" :: xs in + String.concat " " xs + let setup dir options args = xen_ssh_source dir options args diff --git a/output/output.ml b/output/output.ml index 101da82a..659d20ac 100644 --- a/output/output.ml +++ b/output/output.ml @@ -38,6 +38,7 @@ type options = { module type OUTPUT = sig type t + val to_string : options -> string val setup : string -> options -> Types.source -> t val finalize : string -> options -> Types.source -> Types.inspect -> Types.target_meta -> diff --git a/output/output.mli b/output/output.mli index 03d71daf..ced22161 100644 --- a/output/output.mli +++ b/output/output.mli @@ -30,6 +30,10 @@ module type OUTPUT = sig type t (** Opaque data used by the output mode. *) + val to_string : options -> string + (** [to_string options] converts the destination to a printable + string (for messages). *) + val setup : string -> options -> Types.source -> t (** [setup dir options source] diff --git a/output/output_disk.ml b/output/output_disk.ml index eca3c727..386d031b 100644 --- a/output/output_disk.ml +++ b/output/output_disk.ml @@ -96,6 +96,12 @@ and disk_finalize dir source inspect target_meta module Disk = struct type t = unit + let to_string options = + "-o disk" ^ + match options.output_storage with + | Some os -> " -os " ^ os + | None -> "" + let setup dir options source = if options.output_options <> [] then error (f_"no -oo (output options) are allowed here"); diff --git a/output/output_glance.ml b/output/output_glance.ml index 0d7838dd..85cbe58e 100644 --- a/output/output_glance.ml +++ b/output/output_glance.ml @@ -122,6 +122,8 @@ and glance_finalize dir source inspect target_meta output_format tmpdir = module Glance = struct type t = string + let to_string options = "-o glance" + let setup dir options source = if options.output_options <> [] then error (f_"no -oo (output options) are allowed here"); diff --git a/output/output_json.ml b/output/output_json.ml index bb0cdfeb..88fb4778 100644 --- a/output/output_json.ml +++ b/output/output_json.ml @@ -134,6 +134,12 @@ and json_path os output_name json_disks_pattern i = module Json = struct type t = unit + let to_string options = + "-o json" ^ + match options.output_storage with + | Some os -> " -os " ^ os + | None -> "" + let setup dir options source = let data = json_parse_options options in let output_name = get_output_name options source in diff --git a/output/output_libvirt.ml b/output/output_libvirt.ml index 52c45401..20333363 100644 --- a/output/output_libvirt.ml +++ b/output/output_libvirt.ml @@ -198,6 +198,12 @@ and target_features_of_capabilities_doc doc arch = module Libvirt_ = struct type t = string * string + let to_string options = + "-o libvirt" ^ + match options.output_storage with + | Some os -> " -os " ^ os + | None -> "" + let setup dir options source = if options.output_options <> [] then error (f_"no -oo (output options) are allowed here"); diff --git a/output/output_null.ml b/output/output_null.ml index 34fbd6e1..56fb7ec6 100644 --- a/output/output_null.ml +++ b/output/output_null.ml @@ -76,6 +76,8 @@ and null_servers dir disks output_name = module Null = struct type t = unit + let to_string options = "-o null" + let setup dir options source = if options.output_options <> [] then error (f_"no -oo (output options) are allowed here"); diff --git a/output/output_openstack.ml b/output/output_openstack.ml index 334a1fc2..6e52ddb3 100644 --- a/output/output_openstack.ml +++ b/output/output_openstack.ml @@ -462,6 +462,22 @@ and iso_time = module Openstack = struct type t = string list + let to_string options = + (* Try to get the server-id since it seems useful to display + * that for diagnostics. + *) + let server_id = ref None in + List.iter ( + function + | "server-id", v -> server_id := Some v + | _ -> () + ) options.output_options; + + "-o openstack" ^ + (match !server_id with + | None -> "" + | Some id -> sprintf " -oo server-id=%s" id) + let setup dir options source = let data = openstack_parse_options options in let output_name = get_output_name options source in diff --git a/output/output_qemu.ml b/output/output_qemu.ml index 0aac1eba..3d5d6782 100644 --- a/output/output_qemu.ml +++ b/output/output_qemu.ml @@ -315,6 +315,12 @@ and qemu_finalize dir source inspect target_meta module QEMU = struct type t = unit + let to_string options = + "-o qemu" ^ + match options.output_storage with + | Some os -> " -os " ^ os + | None -> "" + let setup dir options source = let data = qemu_parse_options options in let output_name = get_output_name options source in diff --git a/output/output_rhv.ml b/output/output_rhv.ml index 6a67b7aa..a386b9a5 100644 --- a/output/output_rhv.ml +++ b/output/output_rhv.ml @@ -266,6 +266,8 @@ and check_storage_domain domain_class os mp = module RHV = struct type t = string * string * string * string list * string list * int64 list + let to_string options = "-o rhv" + let setup dir options source = if options.output_options <> [] then error (f_"no -oo (output options) are allowed here"); diff --git a/output/output_rhv_upload.ml b/output/output_rhv_upload.ml index 91e7be45..4d8dc1c1 100644 --- a/output/output_rhv_upload.ml +++ b/output/output_rhv_upload.ml @@ -444,6 +444,15 @@ module RHVUpload = struct JSON.field list * string option * string option * string option * string + let to_string options = + "-o rhv-upload" ^ + (match options.output_conn with + | Some oc -> " -oc " ^ oc + | None -> "") ^ + (match options.output_storage with + | Some os -> " -os " ^ os + | None -> "") + let setup dir options source = let data = rhv_upload_parse_options options in let output_name = get_output_name options source in diff --git a/output/output_vdsm.ml b/output/output_vdsm.ml index ce0d5b5e..676ecf00 100644 --- a/output/output_vdsm.ml +++ b/output/output_vdsm.ml @@ -212,6 +212,8 @@ and vdsm_finalize dir source inspect target_meta module VDSM = struct type t = string * string * int64 list + let to_string options = "-o vdsm" + let setup dir options source = let data = vdsm_parse_options options in let output_name = get_output_name options source in diff --git a/tests/test-v2v-i-vmx-1.expected b/tests/test-v2v-i-vmx-1.expected index bca99c48..59e2c5d3 100644 --- a/tests/test-v2v-i-vmx-1.expected +++ b/tests/test-v2v-i-vmx-1.expected @@ -1,3 +1,4 @@ + Source guest information (--print-source option): source name: BZ1308535_21disks diff --git a/tests/test-v2v-i-vmx-2.expected b/tests/test-v2v-i-vmx-2.expected index e56777c8..576d347b 100644 --- a/tests/test-v2v-i-vmx-2.expected +++ b/tests/test-v2v-i-vmx-2.expected @@ -1,3 +1,4 @@ + Source guest information (--print-source option): source name: Fedora 20 diff --git a/tests/test-v2v-i-vmx-3.expected b/tests/test-v2v-i-vmx-3.expected index 47e4d25e..102e82eb 100644 --- a/tests/test-v2v-i-vmx-3.expected +++ b/tests/test-v2v-i-vmx-3.expected @@ -1,3 +1,4 @@ + Source guest information (--print-source option): source name: RHEL 7.1 UEFI diff --git a/tests/test-v2v-i-vmx-4.expected b/tests/test-v2v-i-vmx-4.expected index dd731294..0d772855 100644 --- a/tests/test-v2v-i-vmx-4.expected +++ b/tests/test-v2v-i-vmx-4.expected @@ -1,3 +1,4 @@ + Source guest information (--print-source option): source name: Windows 7 x64 diff --git a/tests/test-v2v-i-vmx-5.expected b/tests/test-v2v-i-vmx-5.expected index cfddcda7..1b8e15bf 100644 --- a/tests/test-v2v-i-vmx-5.expected +++ b/tests/test-v2v-i-vmx-5.expected @@ -1,3 +1,4 @@ + Source guest information (--print-source option): source name: MSEdge - Win10_preview diff --git a/tests/test-v2v-i-vmx.sh b/tests/test-v2v-i-vmx.sh index f2fda66d..db870bea 100755 --- a/tests/test-v2v-i-vmx.sh +++ b/tests/test-v2v-i-vmx.sh @@ -29,6 +29,8 @@ set -x skip_if_skipped +export LANG=C + export VIRT_TOOLS_DATA_DIR="$srcdir/../test-data/fake-virt-tools" export VIRTIO_WIN="$srcdir/../test-data/fake-virtio-win" @@ -52,6 +54,7 @@ for i in 1 2 3 4 5; do # Normalize the print-source output. mv test-v2v-i-vmx-$i.actual test-v2v-i-vmx-$i.actual.old sed \ + -e "s,.*Setting up the source.*,," \ -e "s,.*Opening the source.*,," \ -e "s,$(pwd),," \ < test-v2v-i-vmx-$i.actual.old > test-v2v-i-vmx-$i.actual diff --git a/tests/test-v2v-print-source.sh b/tests/test-v2v-print-source.sh index c4717361..e46fd126 100755 --- a/tests/test-v2v-print-source.sh +++ b/tests/test-v2v-print-source.sh @@ -27,6 +27,8 @@ set -x skip_if_skipped requires test -f ../test-data/phony-guests/windows.img +export LANG=C + d=test-v2v-print-source.d rm -rf $d cleanup_fn rm -r $d @@ -39,6 +41,7 @@ $VG virt-v2v --debug-gc \ mv $d/output $d/output.orig < $d/output.orig \ +grep -v 'Setting up the source' | grep -v 'Opening the source' | grep -v 'Source guest information' | sed -e 's,/.*/windows.img,windows.img,' | diff --git a/v2v/v2v.ml b/v2v/v2v.ml index 47e6e937..d74cc21f 100644 --- a/v2v/v2v.ml +++ b/v2v/v2v.ml @@ -532,6 +532,8 @@ read the man page virt-v2v(1). } in (* Start the input module (runs an NBD server in the background). *) + message (f_"Setting up the source: %s") + (Input_module.to_string input_options args); let source = Input_module.setup tmpdir input_options args in (* If --print-source then print the source metadata and exit. *) @@ -548,6 +550,8 @@ read the man page virt-v2v(1). unlink (tmpdir // "convert"); (* Start the output module (runs an NBD server in the background). *) + message (f_"Setting up the destination: %s") + (Output_module.to_string output_options); let output_t = Output_module.setup tmpdir output_options source in (* Debug the v2vdir. *) -- 2.31.1