Bug 1208897

Summary: Bad parsing of network-scripts/ifcfg-xxxx files.
Product: Red Hat Enterprise Linux 6 Reporter: Laine Stump <laine>
Component: netcfAssignee: Laine Stump <laine>
Status: CLOSED ERRATA QA Contact: Virtualization Bugs <virt-bugs>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 6.6CC: allan-redhat, cwei, dyuan, hbrock, honzhang, jiri.lunacek, laine, mshao, mzhan, pmoore, thoger, virt-bugs, ydu
Target Milestone: rc   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: netcf-0.2.4-3.el6 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: 761246 Environment:
Last Closed: 2015-07-22 06:26:13 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Laine Stump 2015-04-03 18:22:47 UTC
+++ This bug was initially created as a clone of Bug #761246 +++

Description of problem:

Log files fill with errors when virt-manager is running.
Command "virsh iface-list --all" fails to list active interfaces.

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

virt-manager-0.9.0-7.el6.x86_64
libvirt-client-0.9.4-23.el6_2.1.x86_64
netcf-0.1.9-2.el6.x86_64
netcf-libs-0.1.9-2.el6.x86_64


How reproducible:

Always.

Steps to Reproduce:
1. Start virt-manager.
2. Manually edit /etc/sysconfig/network-scripts/ifcfg-eth0 and add a semicolon at the end of any line.
3. Tail the relevant log file to see two errors every second.
4. Run the command "virsh iface-list --all" to see a failure to list all interfaces.
  
Actual results:

Log file fills with errors as listed below when virt-manager is running.

    07:38:00.045: 3684: error : interfaceNumOfInterfaces:195 : internal error
                                failed to get number of interfaces on host:
                                unspecified error - errors in loading some
                                config files
    07:38:00.094: 3683: error : interfaceNumOfDefinedInterfaces:237 : internal
                                error failed to get number of defined
                                interfaces on host: unspecified error - errors
                                in loading some config files

Running the command "virsh iface-list --all" reports
    error: Failed to list active interfaces
    error: internal error failed to get number of interfaces on host:
           unspecified error - errors in loading some config files

Expected results:

The virt-manager tool should list all interfaces, or at least those that it believes to have a valid configuration file.
The virsh tool should list all interfaces, or at least those that it believes to have a valid configuration file.

Additional info:

For virt-manager to log the same information every second repeatedly can quickly fill up the log files. I would expect virt-manager to report an error and stop trying to list interfaces to limit this scenario.

This bug is related to the netcf parsing bug https://bugzilla.redhat.com/show_bug.cgi?id=613886 and particularly comments subsequent to comment 29.

As per the comments in the above (resolved) bug, the /etc/sysconfig/network-scripts/ifcfg-xxxx files are parsed sourced by network-functions from the bash file /sbin/ifup (initscripts) and so according to initscripts, they may contain any valid shell syntax including double-quotes surrounding variable assignments and comments starting with the '#' symbol.


--- Additional comment from Laine Stump on 2015-03-03 12:13:32 EST ---

I just pushed a patch upstream to remove the netcf-specific sysconfig.aug file, causing netcf to rely on the lens that is now a part of augeas itself. This resolves the problems with partial-line comments and trailing semicolons.

commit f5dd51e65cccd24c7dfd8448b6c2f2aa2804ef92
Author: Laine Stump <laine>
Date:   Fri Feb 27 22:03:28 2015 -0500

    eliminate netcf-specific sysconfig.aug lens
    
    Back in 2010 when netcf needed a separate augeas lens for files in
    sysconfig/network-scripts (e.g. the ifcfg-* files), augeas itself had
    no special purpose sysconfig.aug lens, so netcf has its own
    sysconfig.aug lens based on the shellvars.aug lens from augeas at the
    time. Sometime soon after that augeas got its own sysconfig.aug lens,
    but netcf never rid itself of its own copy.
    
    The sysconfig.aug in netcf is now severely out of date compared to the
    one in augeas, and is missing many bugfixes. This patch just removes
    the netcf version from /usr/share/netcf/lenses, so that augeas will
    use its own lens when it's called by netcf. Among other things, this
    updated lens properly ignores semicolons and "#"-initiated partial
    line comments at the ends of lines that contain valid variable
    settings at the beginning.

Along with any other newly encountered problem in parsing ifcfg files, the problem with leading whitespace on a line as mentioned in Comment 14 will need to be addressed in augeas rather than netcf. And in fact the leading whitespace problem *is* fixed by the augeas upstream commit 3bc029d 

  https://github.com/hercules-team/augeas/pull/212/files

Comment 4 Hu Jianwei 2015-04-20 05:55:40 UTC
I can reproduce it on old version.

[root@ibm-x3650m3-04 ~]# cat /etc/sysconfig/network-scripts/ifcfg-eth1
DEVICE=eth1;
ONBOOT=yes;
IPV6INIT="yes";
IPV6_AUTOCONF="no";
DHCPV6C="no";
IPV6ADDR="2002::200/64";
IPV6ADDR_SECONDARIES="2002::201/64 2002::202/64";
[root@ibm-x3650m3-04 ~]# virsh iface-list --all
error: Failed to list interfaces
error: internal error failed to get number of host interfaces: unspecified error - errors in loading some config files

[root@ibm-x3650m3-04 ~]# ll /usr/share/netcf/lenses/sysconfig.aug 
-rw-r--r--. 1 root root 2041 Jul 20  2010 /usr/share/netcf/lenses/sysconfig.aug
 

And, I can not reproduce it on below fixed version.

[root@ibm-x3650m3-04 ~]# rpm -q libvirt netcf-libs
libvirt-0.10.2-53.el6.x86_64
netcf-libs-0.2.4-3.el6.x86_64

[root@ibm-x3650m3-04 ~]# ll /usr/share/netcf/lenses/sysconfig.aug 
ls: cannot access /usr/share/netcf/lenses/sysconfig.aug: No such file or directory

[root@ibm-x3650m3-04 ~]# cat /etc/sysconfig/network-scripts/ifcfg-eth1
DEVICE=eth1;
ONBOOT=yes;
IPV6INIT="yes";
IPV6_AUTOCONF="no";
DHCPV6C="no";
IPV6ADDR="2002::200/64";
IPV6ADDR_SECONDARIES="2002::201/64 2002::202/64";
[root@ibm-x3650m3-04 ~]# virsh iface-list --all
Name                 State      MAC Address
--------------------------------------------
eth0                 active     e4:1f:13:b9:60:a0
eth1                 inactive   e4:1f:13:b9:60:a2
lo                   active     00:00:00:00:00:00
usb0                 active     e6:1f:13:ac:60:a3

[root@ibm-x3650m3-04 ~]# virsh iface-dumpxml eth1
<interface type='ethernet' name='eth1'>
  <start mode='onboot'/>
  <protocol family='ipv6'>
    <ip address='2002::200' prefix='64'/>
    <ip address='2002::201' prefix='64'/>
    <ip address='2002::202' prefix='64'/>
  </protocol>
</interface>

We can get expected results.

Comment 5 Hu Jianwei 2015-06-02 08:41:31 UTC
According to comment 4, changed to Verified.

Comment 7 errata-xmlrpc 2015-07-22 06:26:13 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/RHBA-2015-1307.html