Bugzilla will be upgraded to version 5.0. The upgrade date is tentatively scheduled for 2 December 2018, pending final testing and feedback.
Bug 1229119 - Unrelated info in fstab makes virt-v2v fail with unclear error info
Unrelated info in fstab makes virt-v2v fail with unclear error info
Status: CLOSED ERRATA
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: libguestfs (Show other bugs)
7.2
x86_64 Unspecified
medium Severity medium
: rc
: ---
Assigned To: Richard W.M. Jones
Virtualization Bugs
V2V
:
Depends On: 1218766
Blocks: 1288337
  Show dependency treegraph
 
Reported: 2015-06-08 02:21 EDT by tingting zheng
Modified: 2016-11-03 13:53 EDT (History)
5 users (show)

See Also:
Fixed In Version: libguestfs-1.32.0-2.el7
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2016-11-03 13:53:42 EDT
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)
Debug log (106.52 KB, text/plain)
2015-06-08 02:21 EDT, tingting zheng
no flags Details


External Trackers
Tracker ID Priority Status Summary Last Updated
Red Hat Product Errata RHSA-2016:2576 normal SHIPPED_LIVE Moderate: libguestfs and virt-p2v security, bug fix, and enhancement update 2016-11-03 08:06:51 EDT

  None (edit)
Description tingting zheng 2015-06-08 02:21:12 EDT
Created attachment 1036136 [details]
Debug log

Description:
Unrelated info in fstab makes virt-v2v fail with unclear error info

Version:
libguestfs-1.28.1-1.37.el7.x86_64
virt-v2v-1.28.1-1.37.el7.x86_64

How reproducible:
100%

Steps to Reproduce:
1.Prepare a guest,add some wrong info in /etc/fstab.
eg: Add a new line with "test"

2.Use virt-v2v to convert the guest,fail with the below error:
# virt-v2v -o rhev -os 10.66.90.115:/vol/v2v_auto/auto_export -n rhevm rhel6.7-x64
[   0.0] Opening the source -i libvirt rhel6.7-x64
[   0.0] Creating an overlay to protect the source from being modified
[   0.0] Opening the overlay
[ 105.0] Initializing the target -o rhev -os 10.66.90.115:/vol/v2v_auto/auto_export
virt-v2v: warning: cannot write files to the NFS server as 36:36, even 
though we appear to be running as root. This probably means the NFS client 
or idmapd is not configured properly.

You will have to chown the files that virt-v2v creates after the run, 
otherwise RHEV-M will not be able to import the VM.
[ 106.0] Inspecting the overlay
[ 118.0] Checking for sufficient free disk space in the guest
[ 118.0] Estimating space required on target for each disk
[ 118.0] Converting Red Hat Enterprise Linux Server release 6.7 Beta (Santiago) to run on KVM
virt-v2v: error: no grub1/grub-legacy or grub2 configuration file was found

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

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

Actual results:
As description.

Expected results:
The results should be one of the below:
1.Virt-v2v ignore these unrelated info in /etc/fstab and Guest can be converted successfully.
2.Much more clear error info shows and virt-v2v fails.

Additional info:
Attached detailed log.
Comment 2 Richard W.M. Jones 2015-09-03 13:08:16 EDT
The reproducer for this is:

$ virt-builder centos-6 --run-command 'echo >>/etc/fstab; echo test >>/etc/fstab'
$ virt-v2v -i disk centos-6.img -o null
[...]
[  16.1] Converting CentOS release 6.6 (Final) to run on KVM
virt-v2v: error: no grub1/grub-legacy or grub2 configuration file was found
Comment 3 Pino Toscano 2015-10-15 11:58:39 EDT
(In reply to Richard W.M. Jones from comment #2)
> The reproducer for this is:
> 
> $ virt-builder centos-6 --run-command 'echo >>/etc/fstab; echo test
> >>/etc/fstab'
> $ virt-v2v -i disk centos-6.img -o null
> [...]
> [  16.1] Converting CentOS release 6.6 (Final) to run on KVM
> virt-v2v: error: no grub1/grub-legacy or grub2 configuration file was found

The invalid content in /etc/fstab causes the inspection code to not read any of the mountpoints listed there: as a consequence, /boot is not mounted from its partition, and grub is not detected.
Comment 4 Pino Toscano 2015-10-16 04:44:39 EDT
This has been fixed upstream with
https://github.com/libguestfs/libguestfs/commit/279addeb7dd4f5f2446a3995eb7704980c08b5ff
which is in libguestfs >= 1.31.18.

The behaviour now is that guests with an invalid /etc/fstab will fail at the inspection stage, so when using the inspect-os API or the virt-inspector tool you will get an error.  When trying to convert the guest using virt-v2v, the same error will cause the conversion to fail much earlier, and with a clearer information.
Comment 5 Richard W.M. Jones 2015-10-16 05:07:21 EDT
With the patch, my test (comment 2) now fails like this:

virt-v2v -i disk centos-6.img -o null
[   0.0] Opening the source -i disk centos-6.img
[   0.1] Creating an overlay to protect the source from being modified
[   0.3] Opening the overlay
[  12.8] Initializing the target -o null
[  12.8] Inspecting the overlay
virt-v2v: error: libguestfs error: augeas could not parse /etc/fstab
Comment 8 xiaodwan 2016-02-25 05:52:10 EST
I can reproduce it with packages as below.
# rpm -q libguestfs virt-v2v
libguestfs-1.28.1-1.55.el7.x86_64
virt-v2v-1.28.1-1.55.el7.x86_64

And then verified it with latest version.
# rpm -q libguestfs virt-v2v
libguestfs-1.32.2-6.el7.x86_64
virt-v2v-1.32.2-6.el7.x86_64

Steps:
1. Prepare a guest, add some wrong info in /etc/fstab.
eg: Add a new line with "test"
2. Run virt-v2v command.
# virt-v2v -i disk rhel7.2-1030-clone.qcow2 -o null
[   0.0] Opening the source -i disk rhel7.2-1030-clone.qcow2
[   0.0] Creating an overlay to protect the source from being modified
[   0.0] Opening the overlay
[  70.0] Initializing the target -o null
[  70.0] Inspecting the overlay
[  80.0] Checking for sufficient free disk space in the guest
[  80.0] Estimating space required on target for each disk
[  80.0] Converting Red Hat Enterprise Linux Server release 7.2 (Maipo) to run on KVM
virt-v2v: error: no grub1/grub-legacy or grub2 configuration file was found

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

  virt-v2v -v -x [...]
[root@localhost images]# virt-v2v -i disk rhel7.2-1030-clone.qcow2 -o null
[   0.0] Opening the source -i disk rhel7.2-1030-clone.qcow2
[   0.1] Creating an overlay to protect the source from being modified
[   0.5] Initializing the target -o null
[   0.5] Opening the overlay
[  55.9] Inspecting the overlay
virt-v2v: error: libguestfs error: /etc/fstab:12:4: augeas parse failure: 
Iterated lens matched less than it should

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

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

So move the bug from ON_QA to VERIFIED.
Comment 9 tingting zheng 2016-02-25 21:38:04 EST
How about these scenarios in the patch as below,it seems we didn't test cover such test scenarioes,Would you pls test it and add comments in the bug.

Now guests with invalid files such as /etc/fstab, /etc/mdadm.conf, and
/etc/sysconfig/network will cause the inspection to fail, instead of
being reported with a single mount point ('/').
Comment 10 xiaodwan 2016-02-26 02:02:31 EST
I tested /etc/mdadm.conf, the result is as below.

virt-v2v: error: libguestfs error: /etc/mdadm.conf:1:0: augeas parse 
failure: Iterated lens matched less than it should

And i also tested /etc/sysconfig/network, it's a blank file. I tried to add some invalid string into it, but it seems like this can't make the file invalid. 

And I think it's enough only cover one configure file because they use same logic.
Comment 12 errata-xmlrpc 2016-11-03 13:53:42 EDT
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://rhn.redhat.com/errata/RHSA-2016-2576.html

Note You need to log in before you can comment on or make changes to this bug.