Bug 1690574

Summary: virt-v2v fails to import a guest while cannot find `file_architecture` for a file
Product: Red Hat Enterprise Linux 7 Reporter: Javier Coscia <jcoscia>
Component: libguestfsAssignee: Richard W.M. Jones <rjones>
Status: CLOSED ERRATA QA Contact: Virtualization Bugs <virt-bugs>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 7.6CC: juzhou, mxie, mzhan, ptoscano, tzheng, xiaodwan, zili
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard: V2V
Fixed In Version: libguestfs-1.40.2-2.el7 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of:
: 1703408 (view as bug list) Environment:
Last Closed: 2019-08-06 12:44:47 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:
Bug Depends On:    
Bug Blocks: 1703408    

Description Javier Coscia 2019-03-19 18:06:20 UTC
Description of problem:

virt-v2v fails to convert a guest if this has a file without architecture.

An example would be a 3rd party kernel module like fileaccess_mod.ko

~~~
chroot: /sysroot: running 'file: /lib/modules/3.10.0-957.1.3.el7.x86_64/fileaccess/fileaccess_mod.ko'
ocaml_exn: 'file_architecture' raised 'Failure' exception
guestfsd: error: unknown architecture: /lib/modules/3.10.0-957.1.3.el7.x86_64/fileaccess/fileaccess_mod.ko
guestfsd: => file_architecture (0x1db) took 0.01 secs
libguestfs: trace: v2v: file_architecture = NULL (error)
virt-v2v: error: libguestfs error: file_architecture: unknown architecture: 
/lib/modules/3.10.0-957.1.3.el7.x86_64/fileaccess/fileaccess_mod.ko
~~~

Version-Release number of selected component (if applicable):

libguestfs-1.38.2-12.28.lp.el7ev.x86_64

How reproducible:

100%


Steps to Reproduce:
1. Have a valid guest with a 3rd party module loaded
2. In this case, the Import was invoked through RHV UI which runs the virt-v2v

Actual results:
Import failed

Expected results:
Import should succeed

Additional info:

Comment 3 Pino Toscano 2019-03-20 11:36:48 UTC
fileaccess_mod.ko seems like a McAfee kernel module:
https://kc.mcafee.com/corporate/index?page=content&id=KB91044
https://kc.mcafee.com/corporate/index?page=content&id=KB89912

I'm puzzled why `file` can fail to run on this file, or maybe the output is not what we expect.

Anyway, just posted a patch to workaround such situations:
https://www.redhat.com/archives/libguestfs/2019-March/msg00069.html

Comment 5 Pino Toscano 2019-03-20 16:02:53 UTC
It seems like the issue is due to the module file being a symlink: `file` (invoked by the "file" API, invoked by the "file-architecture" API) does not dereference symlinks, and thus the architecture detection (based on the output of `file`) fails.

I posted another fix/workaround for this, simpler than the previous one:
https://www.redhat.com/archives/libguestfs/2019-March/msg00078.html

Comment 8 liuzi 2019-04-29 06:26:07 UTC
Reproduce the bug with builds:
virt-v2v-1.38.2-12.el7.x86_64
libguestfs-1.38.2-12.el7.x86_64
libvirt-4.5.0-10.el7_6.4.x86_64
qemu-kvm-rhev-2.12.0-18.el7_6.3.x86_64

Steps:
1.Prepare a rhel7 guest with third party module loaded
1.1 Download the package ENSL1022_Eval.zip from https://www.mcafee.com/enterprise/en-us/downloads/trials.html
1.2 Unzip the package and install MFEma.x86_64.rpm and MFErt.i686.rpm
1.3 Check the 3rd party module info:
# file -zb /lib/modules/3.10.0-957.el7.x86_64/fileaccess/fileaccess_mod.ko 
symbolic link to `/opt/isec/ens/esp/modules/fileaccess/3.10.0-957.el7.x86_64-fileaccess_mod.ko'

# rpm -qf /lib/modules/3.10.0-957.el7.x86_64/fileaccess/fileaccess_mod.ko 
file /lib/modules/3.10.0-957.el7.x86_64/fileaccess/fileaccess_mod.ko is not owned by any package

2.Use virt-v2v to convert the guest to rhv;
#  virt-v2v -ic vpx://root.73.141/data/10.73.75.219/?no_verify=1 esx6.7-rhel7.6-kdump --password-file /tmp/passwd -o rhv-upload -oc https://ibm-x3250m5-03.rhts.eng.pek2.redhat.com/ovirt-engine/api -os nfs_data -op /tmp/rhvpasswd -oo rhv-cafile=/home/ca.pem -oo rhv-direct=true -oo rhv-cluster=nfs
[   0.3] Opening the source -i libvirt -ic vpx://root.73.141/data/10.73.75.219/?no_verify=1 esx6.7-rhel7.6-kdump
[   2.5] Creating an overlay to protect the source from being modified
[   3.7] Initializing the target -o rhv-upload -oc https://ibm-x3250m5-03.rhts.eng.pek2.redhat.com/ovirt-engine/api -op /tmp/rhvpasswd -os nfs_data
[   5.6] Opening the overlay
[  28.0] Inspecting the overlay
[ 262.0] Checking for sufficient free disk space in the guest
[ 262.0] Estimating space required on target for each disk
[ 262.0] Converting Red Hat Enterprise Linux Server 7.6 (Maipo) to run on KVM
virt-v2v: error: libguestfs error: file_architecture: unknown architecture: 
/lib/modules/3.10.0-957.el7.x86_64/fileaccess/fileaccess_mod.ko

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

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


Verify bug with builds:
virt-v2v-1.40.2-3.el7.x86_64
libvirt-4.5.0-12.el7.x86_64
libguestfs-1.40.2-3.el7.x86_64
qemu-kvm-rhev-2.12.0-26.el7.x86_64

Steps:
1.Prepare a rhel7 guest with third party module loaded
2.Use virt-v2v to convert the guest to thv
#  virt-v2v -ic vpx://root.73.141/data/10.73.75.219/?no_verify=1 esx6.7-rhel7.6-kdump --password-file /tmp/passwd -o rhv-upload -oc https://ibm-x3250m5-03.rhts.eng.pek2.redhat.com/ovirt-engine/api -os nfs_data -op /tmp/rhvpasswd -oo rhv-cafile=/home/ca.pem -oo rhv-direct=true -oo rhv-cluster=nfs
Exception AttributeError: "'module' object has no attribute 'dump_plugin'" in <module 'threading' from '/usr/lib64/python2.7/threading.pyc'> ignored
[   0.5] Opening the source -i libvirt -ic vpx://root.73.141/data/10.73.75.219/?no_verify=1 esx6.7-rhel7.6-kdump
[   2.6] Creating an overlay to protect the source from being modified
[   3.4] Opening the overlay
[  55.2] Inspecting the overlay
[ 279.3] Checking for sufficient free disk space in the guest
[ 279.3] Estimating space required on target for each disk
[ 279.3] Converting Red Hat Enterprise Linux Server 7.6 (Maipo) to run on KVM
virt-v2v: This guest has virtio drivers installed.
[2048.1] Mapping filesystem data to avoid copying unused and blank areas
[2049.5] Closing the overlay
[2050.3] Assigning disks to buses
[2050.3] Checking if the guest needs BIOS or UEFI to boot
[2050.3] Initializing the target -o rhv-upload -oc https://ibm-x3250m5-03.rhts.eng.pek2.redhat.com/ovirt-engine/api -op /tmp/rhvpasswd -os nfs_data
[2051.8] Copying disk 1/1 to qemu URI json:{ "file.driver": "nbd", "file.path": "/var/tmp/rhvupload.LCzPnr/nbdkit0.sock", "file.export": "/" } (raw)
    (100.00/100%)
[3688.2] Creating output metadata
[3708.8] Finishing off
You have new mail in /var/spool/mail/root

3.The conversion can be finished successfully and boot the guest in rhv.
3.1 The guest can pass all regular checkpoints.
3.2 Check the 3rd party kernel module info:
# rpm -qf /lib/modules/3.10.0-957.el7.x86_64/fileaccess/fileaccess_mod.ko 
file /lib/modules/3.10.0-957.el7.x86_64/fileaccess/fileaccess_mod.ko is not owned by any package
# file -zb /lib/modules/3.10.0-957.el7.x86_64/fileaccess/fileaccess_mod.ko 
symbolic link to `/opt/isec/ens/esp/modules/fileaccess/3.10.0-957.el7.x86_64-fileaccess_mod.ko'

Result:Virt-v2v can convert guest which has a file without architecture,so change the bug from ON_QA to VERIFIED.

Comment 10 errata-xmlrpc 2019-08-06 12:44:47 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-2019:2096