Bug 1580292

Summary: Virt-v2v rhel7.6 build can't convert guest with qemu-kvm rhel7.5.z build
Product: Red Hat Enterprise Linux 7 Reporter: mxie <mxie>
Component: libguestfsAssignee: Richard W.M. Jones <rjones>
Status: CLOSED ERRATA QA Contact: Virtualization Bugs <virt-bugs>
Severity: urgent Docs Contact:
Priority: urgent    
Version: 7.6CC: juzhou, mxie, mzhan, ptoscano, tzheng, xiaodwan
Target Milestone: rcKeywords: Regression
Target Release: ---   
Hardware: x86_64   
OS: Unspecified   
Whiteboard: V2V
Fixed In Version: libguestfs-1.38.2-2.el7 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2018-10-30 07:45:35 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:
Attachments:
Description Flags
v2v_1.38.2-1-rhel7.5.z_qemu-kvm.log
none
v2v_1.38.1-1-rhel7.5.z_qemu-kvm.log none

Description mxie@redhat.com 2018-05-21 07:59:13 UTC
Created attachment 1439442 [details]
v2v_1.38.2-1-rhel7.5.z_qemu-kvm.log

Description of problem:
Virt-v2v rhel7.6 build can't convert guest with qemu-kvm rhel7.5.z build

Version-Release number of selected component (if applicable):
virt-v2v-1.38.2-1.el7.x86_64
libguestfs-1.38.2-1.el7.x86_64
libvirt-3.9.0-14.el7_5.5.x86_64
qemu-kvm-1.5.3-156.el7_5.2.x86_64


How reproducible:
100%

Steps to Reproduce:
1.Convert a guest from vmware by virt-v2v but failed,details pls refer to "v2v_1.38.2-1-rhel7.5.z_qemu-kvm.log"

# virt-v2v -ic vpx://root.75.182/data/10.73.72.61/?no_verify=1 esx6.0-rhel7.5-x86_64 -o rhv -os 10.66.144.40:/home/nfs_export -of qcow2 --password-file /tmp/passwd
[   0.0] Opening the source -i libvirt -ic vpx://root.75.182/data/10.73.72.61/?no_verify=1 esx6.0-rhel7.5-x86_64
[   1.9] Creating an overlay to protect the source from being modified
[   2.7] Initializing the target -o rhv -os 10.66.144.40:/home/nfs_export
[   3.0] Opening the overlay
[  93.9] Inspecting the overlay
[ 214.5] Checking for sufficient free disk space in the guest
[ 214.5] Estimating space required on target for each disk
[ 214.5] Converting Red Hat Enterprise Linux Server 7.5 (Maipo) to run on KVM
virt-v2v: This guest has virtio drivers installed.
[1085.6] Mapping filesystem data to avoid copying unused and blank areas
[1088.3] Closing the overlay
[1089.2] Checking if the guest needs BIOS or UEFI to boot
[1089.2] Assigning disks to buses
[1089.2] Copying disk 1/1 to /tmp/v2v.5lXaeg/ea9cb06f-8bf9-4fc8-a247-478e754d898a/images/8dd065f1-1a54-4cf9-89fa-b0a918380497/a4e98681-8ea6-419d-8c8d-5db45e1f472f (qcow2)
qemu-img: Could not open 'file:/tmp/v2v.5lXaeg/ea9cb06f-8bf9-4fc8-a247-478e754d898a/images/8dd065f1-1a54-4cf9-89fa-b0a918380497/a4e98681-8ea6-419d-8c8d-5db45e1f472f': Could not open 'file:/tmp/v2v.5lXaeg/ea9cb06f-8bf9-4fc8-a247-478e754d898a/images/8dd065f1-1a54-4cf9-89fa-b0a918380497/a4e98681-8ea6-419d-8c8d-5db45e1f472f': No such file or directory

virt-v2v: error: qemu-img command failed, see earlier errors

If reporting bugs, run virt-v2v with debugging enabled and include the 
complete output:

  virt-v2v -v -x [...]


Actual results:
As above description

Expected results:
Virt-v2v rhel7.6 build can convert guest with qemu-kvm rhel7.5.z build

Additional info:
Summary the others related test result as below:
(1)virt-v2v-1.38.1-1.el7.x86_64/virt-v2v-1.38.0-1.el7.x86_64(rhel7.6) + qemu-kvm-1.5.3-156.el7_5.2.x86_64(rhel7.5.z)-----> Failed with different error "qemu-img: Unknown protocol 'json:{ "file.driver": "null-co", "file.size": "1E" }'", details pls refer to "v2v_1.38.1-1-rhel7.5.z_qemu-kvm.log"

(2)virt-v2v-1.36.10-6.el7_5.2.x86_64(rhel7.5.z) + qemu-kvm-1.5.3-156.el7_5.2.x86_64(rhel7.5.z)-------->PASS

(3)virt-v2v-1.36.10-6.el7_5.2.x86_64(rhel7.5.z) + qemu-kvm-1.5.3-156.el7.x86_64 (rhel7.5)------->PASS

(4)virt-v2v-1.38.2-1.el7.x86_64(rhel7.6) + qemu-kvm-1.5.3-156.el7.x86_64 (rhel7.5)-------> Failed with error"qemu-img: Unknown protocol 'json:{ "file.driver": "null-co", "file.size": "1E" }'"

Comment 3 mxie@redhat.com 2018-05-21 08:00:54 UTC
Created attachment 1439443 [details]
v2v_1.38.1-1-rhel7.5.z_qemu-kvm.log

Comment 4 Richard W.M. Jones 2018-05-21 08:14:16 UTC
Any errors about the ‘null-co’ driver (presumably related
to using ‘-o null’) should be filed under a new BZ.

Comment 5 mxie@redhat.com 2018-05-21 08:34:01 UTC
(In reply to Richard W.M. Jones from comment #4)
> Any errors about the ‘null-co’ driver (presumably related
> to using ‘-o null’) should be filed under a new BZ.

I just want to add a comment to explain the error ""qemu-img: Unknown protocol" got from null target, thanks for your reminding, I will file a new bug to track this problem

Comment 6 Pino Toscano 2018-05-21 08:36:21 UTC
(In reply to mxie from comment #5)
> (In reply to Richard W.M. Jones from comment #4)
> > Any errors about the ‘null-co’ driver (presumably related
> > to using ‘-o null’) should be filed under a new BZ.
> 
> I just want to add a comment to explain the error ""qemu-img: Unknown
> protocol" got from null target, thanks for your reminding, I will file a new
> bug to track this problem

Most probably this happens because qemu-kvm 1.5 does not have the null-co driver, whereas a newer qemu-kvm-rhev has it.  Also, I see the test uses qemu-kvm 1.5.

Do you still hit the same issues if you use qemu-kvm-rhev instead of qemu-kvm?

Comment 7 mxie@redhat.com 2018-05-21 08:47:38 UTC
> Most probably this happens because qemu-kvm 1.5 does not have the null-co
> driver, whereas a newer qemu-kvm-rhev has it.  Also, I see the test uses
> qemu-kvm 1.5.
> 
> Do you still hit the same issues if you use qemu-kvm-rhev instead of
> qemu-kvm?

V2V can convert guest to null with builds:
virt-v2v-1.38.2-1.el7.x86_64
libguestfs-1.38.2-1.el7.x86_64
qemu-kvm-rhev-2.10.0-21.el7_5.3.x86_64

Comment 8 Richard W.M. Jones 2018-05-21 09:58:43 UTC
qemu-img convert (not qemu-img-rhev) does not support file:... URLs for
the output, eg:

$ truncate -s 1G test.raw
$ qemu-img convert -f raw test.raw -O qcow2 file:/tmp/test.qcow2
qemu-img: file:/tmp/test.qcow2: error while converting qcow2: Could not create file: No such file or directory
$ rpm -qf /usr/bin/qemu-img
qemu-img-1.5.3-141.el7.x86_64

This is a problem with virt-v2v 1.38 because of:

https://github.com/libguestfs/libguestfs/commit/e29296cfa20dd691995832940a30fe2e6b98149a

which adds the ‘file:’ prefix to the output name when converting to
a file.  This is right for recent QEMU but not for ancient QEMU 1.5.

A simple downstream patch for RHEL 7 should fix this:

v2v/v2v.ml:
      let cmd =
        let filename =
          match t.target_file with
-         | TargetFile filename -> "file:" ^ filename
+         | TargetFile filename -> filename
          | TargetURI uri -> uri in
        [ Guestfs_config.qemu_img; "convert" ] @

Comment 9 Pino Toscano 2018-05-21 13:18:52 UTC
(In reply to Richard W.M. Jones from comment #8)
> A simple downstream patch for RHEL 7 should fix this:
> 
> v2v/v2v.ml:
>       let cmd =
>         let filename =
>           match t.target_file with
> -         | TargetFile filename -> "file:" ^ filename
> +         | TargetFile filename -> filename
>           | TargetURI uri -> uri in
>         [ Guestfs_config.qemu_img; "convert" ] @

This seems to work fine also on Fedora 28 with qemu 2.11 (both `make check`, and `make check-slow` in v2v/ work fine), so maybe this could be done upstream?

Comment 10 Richard W.M. Jones 2018-05-21 13:30:07 UTC
‘filename’ is badly named, it's really a URI.  So if we did change this
upstream then we'd minimally also want to protect the output filename
from being misinterpreted as a URI.  But with my upstream hat on I don't
want to support this ancient version of qemu at all.

Comment 11 Pino Toscano 2018-05-21 13:48:00 UTC
(In reply to Richard W.M. Jones from comment #10)
> ‘filename’ is badly named, it's really a URI.  So if we did change this
> upstream then we'd minimally also want to protect the output filename
> from being misinterpreted as a URI.

I think we have qemu_input_filename in Std_utils to deal with this of situation -- would that be enough in this case?

Comment 12 Richard W.M. Jones 2018-05-22 07:11:55 UTC
Yes that's a better idea.  Here's the patch:

https://www.redhat.com/archives/libguestfs/2018-May/msg00099.html

Comment 13 Richard W.M. Jones 2018-05-22 08:09:07 UTC
Upstream in >= 1.39.6:

https://github.com/libguestfs/libguestfs/commit/0c934144eb8ea0ee1e1f68d4975415c001a62556

Comment 15 mxie@redhat.com 2018-05-24 16:44:39 UTC
Verify the bug with below builds:
virt-v2v-1.38.2-2.el7.x86_64
libguestfs-1.38.2-2.el7.x86_64
libvirt-client-4.3.0-1.el7.x86_64
qemu-kvm-1.5.3-156.el7_5.2.x86_64
qemu-img-1.5.3-156.el7_5.2.x86_64


Steps:
1.Convert a guest from vmware to rhv by virt-v2v,conversion is finished without error and checkpoints of guest are passed
#  virt-v2v -ic vpx://root.75.182/data/10.73.72.61/?no_verify=1 esx6.0-rhel7.5-x86_64 -o rhv -os 10.66.144.40:/home/nfs_export -of qcow2 --password-file /tmp/passwd
[   0.0] Opening the source -i libvirt -ic vpx://root.75.182/data/10.73.72.61/?no_verify=1 esx6.0-rhel7.5-x86_64
[   2.1] Creating an overlay to protect the source from being modified
[   2.8] Initializing the target -o rhv -os 10.66.144.40:/home/nfs_export
[   3.1] Opening the overlay
[  82.8] Inspecting the overlay
[ 403.4] Checking for sufficient free disk space in the guest
[ 403.4] Estimating space required on target for each disk
[ 403.4] Converting Red Hat Enterprise Linux Server 7.5 (Maipo) to run on KVM
virt-v2v: This guest has virtio drivers installed.
[1448.9] Mapping filesystem data to avoid copying unused and blank areas
[1451.3] Closing the overlay
[1452.3] Checking if the guest needs BIOS or UEFI to boot
[1452.3] Assigning disks to buses
[1452.3] Copying disk 1/1 to /tmp/v2v.aFHYm8/ea9cb06f-8bf9-4fc8-a247-478e754d898a/images/dc08f5a5-daf6-497f-8034-b1bd969ce86d/f93971be-4790-41fe-84e3-90a3414db665 (qcow2)
    (100.00/100%)
[2046.3] Creating output metadata
[2046.5] Finishing off


2.Convert a guest from xen to libvirt by virt-v2v,conversion is finished without error and checkpoints of guest are passed
# virt-v2v -ic xen+ssh://root.3.21 xen-hvm-rhel7.5-x86_64 -of raw
 

3.Convert a guest from vmware to rhv by virt-v2v via vmx,conversion is finished without error and checkpoints of guest are passed
# virt-v2v -i vmx esx6.7-win7-i386.vmx -o rhv -os 10.66.144.40:/home/nfs_export -of raw

Result:
   According above test result, latest virt-v2v can convert guest with qemu-kvm rhel7.5.z build, so move this bug from ON_QA to VERIFIED

Comment 17 errata-xmlrpc 2018-10-30 07:45:35 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/RHEA-2018:3021