Bug 879473

Summary: net-update may cause libvirtd crash when modify portgroup
Product: Red Hat Enterprise Linux 6 Reporter: weizhang <weizhan>
Component: libvirtAssignee: Laine Stump <laine>
Status: CLOSED ERRATA QA Contact: Virtualization Bugs <virt-bugs>
Severity: high Docs Contact:
Priority: high    
Version: 6.4CC: acathrow, dallan, dyasny, dyuan, mzhan, rwu, whuang
Target Milestone: rc   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: libvirt-0.10.2-11.el6 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2013-02-21 07:27:38 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: 886216    
Attachments:
Description Flags
libvirtd crash log none

Description weizhang 2012-11-23 05:54:02 UTC
Created attachment 650212 [details]
libvirtd crash log

Description of problem:
net-update may cause libvirtd crash when modify portgroup with xml "<portgroup default='xxx'/>"


Version-Release number of selected component (if applicable):
libvirt-0.10.2-9.el6.x86_64
qemu-kvm-0.12.1.2-2.323.el6.x86_64
kernel-2.6.32-329.el6.x86_64

How reproducible:
100%

Steps to Reproduce:
1. Define a network with "<portgroup name='engineering'>", for example
<network>
  <name>testnet</name>
  <uuid>50dc2e11-2cd7-06e4-8b04-80d9c6649623</uuid>
  <forward mode='route'/>
  <bridge name='testbridge' stp='on' delay='0' />
  <mac address='52:54:00:83:20:D7'/>
  <ip address='192.168.111.1' netmask='255.255.255.0'>
    <dhcp>
      <range start='192.168.111.2' end='192.168.111.254' />
    </dhcp>
  </ip>
  <ip family='ipv6' address='2001:db8:ca2:2::1' prefix='64'>
  </ip>
  <portgroup name='engineering'>
  </portgroup>
</network>


# virsh net-update testnet modify portgroup "<portgroup default='no'/>"
  
Actual results:
error: Failed to update network testnet
error: End of file while reading data: Input/output error
error: Failed to reconnect to the hypervisor

libvirtd status is "libvirtd dead but pid file exists"


Expected results:
no crash occured

Additional info:
The crash log is in the attachment

Comment 1 Laine Stump 2012-11-26 20:45:02 UTC
A quick look indicates we may not be checking for the mandatory "name" attribute in the parse function for portgroup. That's likely the culprit.

Comment 2 Laine Stump 2012-11-28 17:56:32 UTC
Fix pushed upstream. Will be in upstream libvirt-1.0.1

commit 012d69dff1e031f8079a9952e886a31795e589b2
Author: Laine Stump <laine>
Date:   Tue Nov 27 23:59:17 2012 -0500

    network: fix crash when portgroup has no name
    
    The name attribute is required for portgroup elements (yes, the RNG
    specifies that), and there is code in libvirt that assumes it is
    non-null.  Unfortunately, the portgroup parsing function wasn't
    checking for lack of portgroup. One adverse result of this was that
    attempts to update a network by adding a portgroup with no name would
    cause libvirtd to segfault. For example:

       virsh net-update default add portgroup "<portgroup default='yes'/>"

    This patch causes virNetworkPortGroupParseXML to fail if no name is
    specified, thus avoiding any later problems.

Comment 5 Huang Wenlong 2012-12-06 05:52:53 UTC
Verify this bug :
libvirt-0.10.2-11.el6.x86_64


#cat net.xml
<network>
  <name>testnet</name>
  <uuid>50dc2e11-2cd7-06e4-8b04-80d9c6649623</uuid>
  <forward mode='route'/>
  <bridge name='testbridge' stp='on' delay='0' />
  <mac address='52:54:00:83:20:D7'/>
  <ip address='192.168.111.1' netmask='255.255.255.0'>
    <dhcp>
      <range start='192.168.111.2' end='192.168.111.254' />
    </dhcp>
  </ip>
  <ip family='ipv6' address='2001:db8:ca2:2::1' prefix='64'>
  </ip>
  <portgroup name='engineering'>
  </portgroup>
</network>


# virsh net-define net.xml 
Network testnet defined from net.xml

[root@intel-q9400-4-2 ~]# virsh net-update testnet modify portgroup "<portgroup default='no'/>"
error: Failed to update network testnet
error: XML error: Missing required name attribute in portgroup

Comment 6 errata-xmlrpc 2013-02-21 07:27:38 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.

http://rhn.redhat.com/errata/RHSA-2013-0276.html