Bug 1229119 - Unrelated info in fstab makes virt-v2v fail with unclear error info
Summary: Unrelated info in fstab makes virt-v2v fail with unclear error info
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: libguestfs
Version: 7.2
Hardware: x86_64
OS: Unspecified
medium
medium
Target Milestone: rc
: ---
Assignee: Richard W.M. Jones
QA Contact: Virtualization Bugs
URL:
Whiteboard: V2V
Depends On: 1218766
Blocks: 1288337
TreeView+ depends on / blocked
 
Reported: 2015-06-08 06:21 UTC by tingting zheng
Modified: 2016-11-03 17:53 UTC (History)
5 users (show)

Fixed In Version: libguestfs-1.32.0-2.el7
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2016-11-03 17:53:42 UTC


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


Links
System 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 12:06:51 UTC

Description tingting zheng 2015-06-08 06:21:12 UTC
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 17:08:16 UTC
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 15:58:39 UTC
(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 08:44:39 UTC
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 09:07:21 UTC
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 Xiaodai Wang 2016-02-25 10:52:10 UTC
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-26 02:38:04 UTC
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 Xiaodai Wang 2016-02-26 07:02:31 UTC
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 17:53:42 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://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.