Bug 1219216

Summary: virt-v2v fails to match kernel line in grub.conf
Product: Red Hat Enterprise Linux 6 Reporter: Dylan Gross <dgross>
Component: augeasAssignee: Dominic Cleal <dcleal>
Status: CLOSED WONTFIX QA Contact: Virtualization Bugs <virt-bugs>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 6.6CC: dgross, rjones
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
: 1239053 (view as bug list) Environment:
Last Closed: 2015-07-03 11:40:18 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 Dylan Gross 2015-05-06 20:29:54 UTC
Description of problem:

   augeas tool fails to find the kernel line in /boot/grub/grub.conf if unexpected console lines are present when trying to virt-v2v a guest

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

   virt-v2v-0.9.1-5.el6_5.x86_64

How reproducible:  Always

   
Steps to Reproduce:
1.  *note:  This was encountered by customer extracting a VM from an ESX environment, and adding it to a RHEV 3.5 environment, but from what I see that shouldn't matter and I was able to reproduce it by extracting a local kvm guest.

2.  Add the "serial" and "terminal" lines to the grub.conf of a VM guest to be converted.  (Examples at the bottom of this post)

3.  Attempt a virt-v2v of that VM guest:
Example:
# virt-v2v -ic qemu:///session -o rhev -os myrhev.redhat.com:/exportdomain --network rhevm kvmr6n1 


Actual results:

virt-v2v fails with the following two lines in the virt-v2v.log:

virtio configured, but no virtio kernel found at /usr/share/perl5/vendor_perl/Sys/VirtConvert/Converter/RedHat.pm line 1007.
virt-v2v: Transferring storage volume New Virtual Machine_New Virtual Machine: 161061273600 bytes


Expected results:

  Successfully create the VM for import (in this case in the RHEV 3.5 export domain.

Additional info:


Notes from support case is that one of the aug_match() calls in /usr/share/perl5/vendor_perl/Sys/VirtConvert/Converter/RedHat.pm is having problems with those two lines"


"The problem seems the be the augeas tool:

/usr/share/perl5/vendor_perl/Sys/VirtConvert/Converter/RedHat.pm:
...
 141 sub list_kernels
...
 150     # Look for a kernel, starting with the default
 151     my @paths = eval {
 152         # Get a list of all kernels
 153         my @ret = $g->aug_match("/files$grub_conf/title/kernel");

We use aug_match which does not return the value. The problem is the two lines
related to the serial console

    serial -unit=0  -speed=115200 
    terminal -timeout=10 serial console   
"


Example grub.conf with the "serial" and "terminal" lines....

# grub.conf generated by anaconda
#
# Note that you do not have to rerun grub after making changes to this file
# NOTICE:  You have a /boot partition.  This means that
#          all kernel and initrd paths are relative to /boot/, eg.
#          root (hd0,0)
#          kernel /vmlinuz-version ro root=/dev/mapper/vg00-lv_root
#          initrd /initrd-[generic-]version.img
#boot=/dev/sda
serial -unit=0 -speed=115200
terminal -timeout=10 serial console
default=0
timeout=10
#splashimage=(hd0,0)/grub/splash.xpm.gz
hiddenmenu
title Red Hat Enterprise Linux Server (2.6.32-220.23.1.el6.x86_64)
root (hd0,0)
kernel /vmlinuz-2.6.32-220.23.1.el6.x86_64 ro root=/dev/mapper/vg00-lv_root 
	initrd /initramfs-2.6.32-220.23.1.el6.x86_64.img

Comment 2 Dominic Cleal 2015-05-07 09:40:45 UTC
(In reply to Dylan Gross from comment #0)
> We use aug_match which does not return the value. The problem is the two
> lines
> related to the serial console
> 
>     serial -unit=0  -speed=115200 
>     terminal -timeout=10 serial console   
> "

Are these actually valid and working configuration directives?

The documentation suggests it must be two hyphens, not one:

https://www.gnu.org/software/grub/manual/legacy/Serial-terminal.html
https://www.gnu.org/software/grub/manual/legacy/serial.html
https://www.gnu.org/software/grub/manual/legacy/terminal.html

I see nothing there to suggest that "-unit=0" is valid.

Comment 3 Dominic Cleal 2015-05-07 11:05:03 UTC
Checked the GRUB 0.97 source code too, and it doesn't parse options with only one hyphen, which makes me believe this is a configuration error.  Augeas generally only tries to parse valid configs, not be tolerant of errors.

Comment 4 Dylan Gross 2015-05-28 13:56:58 UTC
Customer confirmed that we he did remedy those incorrect arguments with double-hyphens, the virt-v2v no longer failed.  If that is the intended behaviour of augeas when parsing, then this is probably "NOTABUG".   

Perhaps the error about not being able to match a kernel line could be more specific about failing on a different line.  Or maybe not.  I don't know enough about how the parsing is being done to know if it can get that granular.

Comment 5 Dominic Cleal 2015-05-28 14:05:04 UTC
(In reply to Dylan Gross from comment #4)
> Customer confirmed that we he did remedy those incorrect arguments with
> double-hyphens, the virt-v2v no longer failed.  If that is the intended
> behaviour of augeas when parsing, then this is probably "NOTABUG".   

Indeed.

> Perhaps the error about not being able to match a kernel line could be more
> specific about failing on a different line.  Or maybe not.  I don't know
> enough about how the parsing is being done to know if it can get that
> granular.

Yeah, it looks like virt-v2v isn't showing that Augeas hasn't managed to parse the file.  It should be possible to report Augeas' own error output (from /augeas//error), like we did here for netcf: https://lists.fedorahosted.org/pipermail/netcf-devel/2014-September/000907.html

or Puppet: https://github.com/puppetlabs/puppet/blob/4.1.0/lib/puppet/provider/augeas/augeas.rb#L327-L354

I don't know whether you'd prefer to move this bug or recreate one against v2v.