Bug 1731171

Summary: RFE: JSON messages for error/warning/info/status messages of tools
Product: Red Hat Enterprise Linux Advanced Virtualization Reporter: Pino Toscano <ptoscano>
Component: libguestfsAssignee: Libvirt Maintainers <libvirt-maint>
Status: CLOSED ERRATA QA Contact: Virtualization Bugs <virt-bugs>
Severity: medium Docs Contact:
Priority: medium    
Version: 8.1CC: mtessun, mxie, mzhan, ptoscano, rjones, tzheng, xiaodwan, zili
Target Milestone: rc   
Target Release: 8.0   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard: V2V
Fixed In Version: libguestfs-1.40.2-11.module+el8.1.0+3730+7d905127 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2019-11-06 07:17:49 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Pino Toscano 2019-07-18 14:12:50 UTC
Description of problem:
To ease the handling of the output of OCaml tools, there is already a --machine-readable output option. This option is supposed to turn the output of these tools in a bit more machine-parseable friendly way.
In addition to that, this mode was recently enhanced to output all the various error/warning/info/status messages to JSON in the same machine-parseable stream: this helps users of the tools even more, as they can easily see what's going on (especially on error) with no need to parse stdout/stderr.

Additional info:
This was implemented upstream with two commits:
f79129b8dc92470e3a5597daf53c84038bd6859e
1086599ad8eeb8be299d5ffbcb2efb1024ff9ab8

Comment 1 Pino Toscano 2019-07-18 14:14:27 UTC
This will be hopefully used by the virt-v2v-wrapper when converting guests -- also related to IMS.

Comment 3 liuzi 2019-08-22 06:27:48 UTC
Verify bug with builds:
virt-v2v-1.40.2-13.module+el8.1.0+3975+96069438.x86_64
libguestfs-1.40.2-13.module+el8.1.0+3975+96069438.x86_64
qemu-kvm-4.1.0-4.module+el8.1.0+4020+16089f93.x86_64


Steps:
1.Prepare a rhel8.1 AV conversion server and install latest virt-v2v.
2.Check info about machine-readable in virt-v2v man page
   Machine readable output
       The --machine-readable option can be used to make the output more machine friendly, which is useful when calling virt-v2v from other programs, GUIs etc.

       There are two ways to use this option.

       Firstly use the option on its own to query the capabilities of the virt-v2v binary.  Typical output looks like this:

        $ virt-v2v --machine-readable
        virt-v2v
        libguestfs-rewrite
        colours-option
        vdsm-compat-option
        input:disk
        [...]
        output:local
        [...]
        convert:linux
        convert:windows

       A list of features is printed, one per line, and the program exits with status 0

3.Use virt-v2v to convert a guest with --machine-readable option.
#  virt-v2v  -ic vpx://root.75.182/data/10.73.3.19/?no_verify=1  esx5.5-win2012-x86_64 -o null --password-file /home/passwd  --machine-readable=file:v2v_log.json
[   0.0] Opening the source -i libvirt -ic vpx://root.75.182/data/10.73.3.19/?no_verify=1 esx5.5-win2012-x86_64
[  33.4] Creating an overlay to protect the source from being modified
[  34.4] Opening the overlay
[  73.9] Inspecting the overlay
[ 248.4] Checking for sufficient free disk space in the guest
[ 248.4] Estimating space required on target for each disk
[ 248.4] Converting Windows Server 2012 Datacenter to run on KVM
virt-v2v: warning: /usr/share/virt-tools/pnp_wait.exe is missing.  
Firstboot scripts may conflict with PnP.
virt-v2v: warning: there are no virtio drivers available for this version 
of Windows (6.2 x86_64 Server).  virt-v2v looks for drivers in /dev/loop0

The guest will be configured to use slower emulated devices.
virt-v2v: This guest does not have virtio drivers installed.
[ 302.3] Mapping filesystem data to avoid copying unused and blank areas
[ 309.6] Closing the overlay
[ 310.1] Assigning disks to buses
[ 310.1] Checking if the guest needs BIOS or UEFI to boot
[ 310.1] Initializing the target -o null
[ 310.1] Copying disk 1/1 to qemu URI json:{ "file.driver": "null-co", "file.size": "1E" } (raw)
    (100.00/100%)
[3527.9] Creating output metadata
[3527.9] Finishing off

4.After conversion,check the v2v_log.json file
# cat v2v_log.json 
{ "message": "Opening the source -i libvirt -ic vpx://root.75.182/data/10.73.3.19/?no_verify=1 esx5.5-win2012-x86_64", "timestamp": "2019-08-21T23:28:48.089081841-04:00", "type": "message" }
{ "message": "Creating an overlay to protect the source from being modified", "timestamp": "2019-08-21T23:29:21.471913217-04:00", "type": "message" }
{ "message": "Opening the overlay", "timestamp": "2019-08-21T23:29:22.443435720-04:00", "type": "message" }
{ "message": "Inspecting the overlay", "timestamp": "2019-08-21T23:30:02.011333615-04:00", "type": "message" }
{ "message": "Checking for sufficient free disk space in the guest", "timestamp": "2019-08-21T23:32:56.500540379-04:00", "type": "message" }
{ "message": "Estimating space required on target for each disk", "timestamp": "2019-08-21T23:32:56.500622515-04:00", "type": "message" }
{ "message": "Converting Windows Server 2012 Datacenter to run on KVM", "timestamp": "2019-08-21T23:32:56.500677027-04:00", "type": "message" }
{ "message": "/usr/share/virt-tools/pnp_wait.exe is missing.  Firstboot scripts may conflict with PnP.", "timestamp": "2019-08-21T23:32:56.702273169-04:00", "type": "warning" }
{ "message": "there are no virtio drivers available for this version of Windows (6.2 x86_64 Server).  virt-v2v looks for drivers in /dev/loop0\n\nThe guest will be configured to use slower emulated devices.", "timestamp": "2019-08-21T23:32:56.852149580-04:00", "type": "warning" }
{ "message": "This guest does not have virtio drivers installed.", "timestamp": "2019-08-21T23:33:03.057814381-04:00", "type": "info" }
{ "message": "Mapping filesystem data to avoid copying unused and blank areas", "timestamp": "2019-08-21T23:33:50.414454326-04:00", "type": "message" }
{ "message": "Closing the overlay", "timestamp": "2019-08-21T23:33:57.657157281-04:00", "type": "message" }
{ "message": "Assigning disks to buses", "timestamp": "2019-08-21T23:33:58.166150945-04:00", "type": "message" }
{ "message": "Checking if the guest needs BIOS or UEFI to boot", "timestamp": "2019-08-21T23:33:58.166210005-04:00", "type": "message" }
{ "message": "Initializing the target -o null", "timestamp": "2019-08-21T23:33:58.166228739-04:00", "type": "message" }
{ "message": "Copying disk 1/1 to qemu URI json:{ \"file.driver\": \"null-co\", \"file.size\": \"1E\" } (raw)", "timestamp": "2019-08-21T23:33:58.171875268-04:00", "type": "message" }
{ "message": "Creating output metadata", "timestamp": "2019-08-22T00:27:36.007962417-04:00", "type": "message" }
{ "message": "Finishing off", "timestamp": "2019-08-22T00:27:36.008012209-04:00", "type": "message" }

Result:virt-v2v can output all the various error/warning/info/status messages to JSON in the same machine-parseable stream,so change the bug form ON_QA to verified.

Comment 5 errata-xmlrpc 2019-11-06 07:17:49 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2019:3723