Bug 988718

Summary: libvirtd crash when delete srv only passing one mandatory attributes via virsh net-update
Product: Red Hat Enterprise Linux 7 Reporter: hongming <honzhang>
Component: libvirtAssignee: Ján Tomko <jtomko>
Status: CLOSED CURRENTRELEASE QA Contact: Virtualization Bugs <virt-bugs>
Severity: high Docs Contact:
Priority: high    
Version: 7.0CC: acathrow, dyuan, jtomko, laine, mzhan, yalzhang, ydu
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: libvirt-1.1.1-1.el7 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2014-06-13 10:34:46 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:
Attachments:
Description Flags
libvirt debug log none

Description hongming 2013-07-26 08:44:33 UTC
Description of problem:
libvirtd crash when delete srv only passing one mandatory attributes via virsh net-update


Version-Release number of selected component (if applicable):
libvirt-1.1.0-2.el7.x86_64
kernel-3.10.0-1.el7.x86_64

How reproducible:
100%

Steps to Reproduce:
# virsh net-list
  Name                 State      Autostart     Persistent
----------------------------------------------------------
  default              active     yes           yes
  network              active     no            yes

# virsh net-dumpxml network
<network>
   <name>network</name>
   <uuid>2531df5b-adf0-471f-95f7-68d627053342</uuid>
   <bridge name='virbr2' stp='on' delay='0' />
   <mac address='52:54:00:90:a1:29'/>
   <domain name='example.com'/>
   <dns>
     <txt name='example' value='example value' />
     <srv service='name' protocol='tcp' domain='test-domain-name' 
target='englab.nay.redhat.com' port='1024' priority='10' weight='10'/>
     <host ip='192.168.10.2'>
       <hostname>myhost</hostname>
       <hostname>myhostalias</hostname>
     </host>
   </dns>
   <ip address='192.168.10.1' netmask='255.255.255.0'>
     <dhcp>
       <range start='192.168.10.2' end='192.168.10.254' />
     </dhcp>
   </ip>
</network>

# virsh net-update network delete dns-srv "<srv service='name'/>"
error: Failed to update network network
error: End of file while reading data: Input/output error
error: One or more references were leaked after disconnect from the 
hypervisor
error: Failed to reconnect to the hypervisor

# service libvirtd restart
Redirecting to /bin/systemctl restart  libvirtd.service

# virsh net-list
  Name                 State      Autostart     Persistent
----------------------------------------------------------
  default              active     yes           yes
  network              active     no            yes

# virsh net-update network delete dns-srv "<srv protocol='tcp'/>"
error: Failed to update network network
error: End of file while reading data: Input/output error
error: One or more references were leaked after disconnect from the 
hypervisor
error: Failed to reconnect to the hypervisor.

Actual results:
libvirtd crash when delete srv only passing one mandatory attributes via 
virsh net-update

Expected results:
libvirtd works fine and throw error

Additional info:

Comment 1 hongming 2013-07-26 08:47:25 UTC
Created attachment 778706 [details]
libvirt debug log

Comment 3 Ján Tomko 2013-07-26 10:29:13 UTC
Upstream patch proposed:
https://www.redhat.com/archives/libvir-list/2013-July/msg01711.html

Comment 4 Ján Tomko 2013-07-26 11:08:44 UTC
Now fixed upstream:
commit 461fd86a661f32a9aa8044190b2a63b05290332f
Author:     Ján Tomko <jtomko>
AuthorDate: 2013-07-26 12:11:21 +0200
Commit:     Ján Tomko <jtomko>
CommitDate: 2013-07-26 12:53:45 +0200

    Don't check validity of missing attributes in DNS SRV XML
    
    This fixes a crash if one of them is missing.
    
    https://bugzilla.redhat.com/show_bug.cgi?id=988718

git describe: v1.1.1-rc1-35-g461fd86


virsh net-update default delete dns-host "<host protocol='name'/>"
was also crashing if there were no dns host records in the network, fixed by:
commit c4e23388e6c7f769e45d1c162f880cd81e4d4d3b
Author:     Ján Tomko <jtomko>
AuthorDate: 2013-07-26 12:04:32 +0200
Commit:     Ján Tomko <jtomko>
CommitDate: 2013-07-26 12:50:34 +0200

    Set the number of elements 0 in virNetwork*Clear
    
    Decrementing it when it was already 0 causes an invalid free
    in virNetworkDefUpdateDNSHost if virNetworkDNSHostDefParseXML
    fails and virNetworkDNSHostDefClear gets called twice.
    
    virNetworkForwardDefClear left the number untouched even if it
    freed all the elements.

git describe: v1.1.1-rc1-34-gc4e2338

Comment 5 yanbing du 2013-07-31 06:57:18 UTC
Verify this bug with libvirt-1.1.1-1.el7.x86_64.
Following the reproduce steps in comment0:
Create/Define,start a libvirt network
# virsh net-list
 Name                 State      Autostart     Persistent
----------------------------------------------------------
 default              active     yes           yes
 network              active     no            no

# virsh net-update network delete dns-srv "<srv service='name'/>"
Updated network network live state

# virsh net-dumpxml network
<network>
  <name>network</name>
  <uuid>2531df5b-adf0-471f-95f7-68d627053342</uuid>
  <bridge name='virbr2' stp='on' delay='0' />
  <mac address='52:54:00:90:a1:29'/>
  <domain name='example.com'/>
  <dns>
    <txt name='example' value='example value' />
    <host ip='192.168.10.2'>
      <hostname>myhost</hostname>
      <hostname>myhostalias</hostname>
    </host>
  </dns>
  <ip address='192.168.10.1' netmask='255.255.255.0'>
    <dhcp>
      <range start='192.168.10.2' end='192.168.10.254' />
    </dhcp>
  </ip>
</network>
# virsh net-update network add dns-srv "<srv service='name' protocol='tcp'/>"
Updated network network live state

# virsh net-update network delete dns-txt "<txt name='example' value='example value'/>"
Updated network network live state

Comment 6 Ludek Smid 2014-06-13 10:34:46 UTC
This request was resolved in Red Hat Enterprise Linux 7.0.

Contact your manager or support representative in case you have further questions about the request.

Comment 8 yalzhang@redhat.com 2016-05-20 06:11:29 UTC
Hi jtomko,

As comment 5 above, it indicates that the dns-srv, dns-txt, dns-host(I have tried) can be updated by the command net-update. But in fact, it can not take effect immediately. Perhaps it needs to re-run dnsmasq to pick up the changes just like update ip-dhcp-range. what do you think about it?

# virsh net-dumpxml network
<network>
  <name>network</name>
  <uuid>2531df5b-adf0-471f-95f7-68d627053342</uuid>
  <bridge name='virbr2' stp='on' delay='0'/>
  <mac address='52:54:00:90:a1:29'/>
  <domain name='example.com'/>
  <dns>
    <txt name='example' value='example value'/>
    <srv service='name' protocol='tcp' domain='test-domain-name' target='englab.nay.redhat.com' port='1024' priority='10' weight='10'/>
    <host ip='192.168.10.2'>
      <hostname>myhost</hostname>
      <hostname>myhostalias</hostname>
    </host>
  </dns>
  <ip address='192.168.10.1' netmask='255.255.255.0'>
    <dhcp>
      <range start='192.168.10.2' end='192.168.10.254'/>
    </dhcp>
  </ip>
</network>
# virsh net-update network delete dns-srv "<srv service='name' protocol='tcp'/>"
Updated network network live state
# virsh net-update network delete dns-txt "<txt name='example'/>"
Updated network network live state
# virsh net-dumpxml network
<network>
  <name>network</name>
  <uuid>2531df5b-adf0-471f-95f7-68d627053342</uuid>
  <bridge name='virbr2' stp='on' delay='0'/>
  <mac address='52:54:00:90:a1:29'/>
  <domain name='example.com'/>
  <dns>
    <host ip='192.168.10.2'>
      <hostname>myhost</hostname>
      <hostname>myhostalias</hostname>
    </host>
  </dns>
  <ip address='192.168.10.1' netmask='255.255.255.0'>
    <dhcp>
      <range start='192.168.10.2' end='192.168.10.254'/>
    </dhcp>
  </ip>
</network>
# cat /var/lib/libvirt/dnsmasq/network.conf
##WARNING:  THIS IS AN AUTO-GENERATED FILE. CHANGES TO IT ARE LIKELY TO BE
##OVERWRITTEN AND LOST.  Changes to this configuration should be made using:
##    virsh net-edit network
## or other application using the libvirt API.
##
## dnsmasq conf file created by libvirt
strict-order
domain=example.com
expand-hosts
pid-file=/var/run/libvirt/network/network.pid
except-interface=lo
bind-dynamic
interface=virbr2
dhcp-option=3
no-resolv
txt-record=example,example value
srv-host=_name._tcp.test-domain-name,englab.nay.redhat.com,1024,10,10
dhcp-range=192.168.10.2,192.168.10.254
dhcp-no-override
dhcp-lease-max=253
dhcp-hostsfile=/var/lib/libvirt/dnsmasq/network.hostsfile
addn-hosts=/var/lib/libvirt/dnsmasq/network.addnhosts

The txt and srv still exists in the network.conf file after delete. And still can parse correctly in the guest.

Comment 9 yalzhang@redhat.com 2016-05-25 00:28:31 UTC
comment 8 test on libvirt-1.3.4-1.el7.x86_64

Comment 10 Ján Tomko 2016-05-31 15:20:24 UTC
Yes, it is possible libvirtd forgot to write the config file. That is unrelated to this bug about libvirtd crashing, please file a separate one.

Comment 11 Laine Stump 2016-05-31 15:56:56 UTC
I haven't seen a separate bug filed yet, but I do see the source of the problem and have posted a patch upstream:

https://www.redhat.com/archives/libvir-list/2016-May/msg02122.html

If you do file a bug, please note this patch email and assign it to me.

Comment 12 yalzhang@redhat.com 2016-06-14 02:07:03 UTC
file Bug 1341460 to track the issue in comment 8.