Bug 1455825

Summary: Host attribute for bind mode of udp-backend rng device is missing in dumpxml if service attribute is not specified.
Product: Red Hat Enterprise Linux 7 Reporter: Fangge Jin <fjin>
Component: libvirtAssignee: Ján Tomko <jtomko>
Status: CLOSED ERRATA QA Contact: Yanqiu Zhang <yanqzhan>
Severity: medium Docs Contact:
Priority: medium    
Version: 7.4CC: dyuan, jtomko, rbalakri, xuzhang, yafu, yanqzhan, zpeng
Target Milestone: rc   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: libvirt-3.8.0-1.el7 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2018-04-10 10:46:43 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 Fangge Jin 2017-05-26 08:39:07 UTC
Description of problem:
Host attribute for bind mode of udp-backend rng device is missing in dumpxml if service attribute is not specified.

Version-Release number of selected component:
libvirt-3.2.0-6.el7.x86_64

How reproducible:
100%

Steps to Reproduce:
1.Prepare a guest with rng device like below, without service attribute for bind mode:
# virsh edit vm1
    <rng model='virtio'>
      <backend model='egd' type='udp'>
        <source mode='connect' host='127.0.0.1' service='1234'/>
        <source mode='bind' host='10.66.144.57'/> 
      </backend>
    </rng>

Domain vm1 XML configuration edited.

2.Dump guest xml, host attribute is missing:
# virsh dumpxml vm1
...
    <rng model='virtio'>
      <backend model='egd' type='udp'>
        <source mode='bind'/>
        <source mode='connect' host='127.0.0.1' service='1234'/>
      </backend>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x09' function='0x0'/>
    </rng>

3.Start guest
# virsh start vm1
 
4.Check qemu command line:
#ps aux|grep rng
...-chardev udp,id=charrng0,host=127.0.0.1,port=1234,localaddr=10.66.144.57,localport=0

4.Check UDP connection, UDP binds to 10.66.144.57:57209
# netstat -tunap |grep 1234
udp        0      0 10.66.144.57:57209      127.0.0.1:1234          ESTABLISHED 21345/qemu-kvm

5.Do managedsave and start
# virsh managedsave vm1
# virsh start vm1

6.Check UDP connection again, UDP binds to 127.0.0.1:1234
# netstat -tunap |grep 1234
udp        0      0 127.0.0.1:54807         127.0.0.1:1234          ESTABLISHED 22370/qemu-kvm   


Actual results:
Host attribute for bind mode is missing in dumpxml, which results to wrong UDP binding after managedsave&&resotre

Expected results:
Host attribute for bind mode should not be missing in dumpxml

Comment 1 Ján Tomko 2017-09-26 11:41:11 UTC
Upstream patch:
https://www.redhat.com/archives/libvir-list/2017-September/msg00921.html

Comment 2 Ján Tomko 2017-09-26 13:56:00 UTC
commit fcd5c61cd4ea3d1a0a14260e2b3443b0292b19cb
Author:     Ján Tomko <jtomko>
CommitDate: 2017-09-26 13:36:51 +0200

    conf: fix formatting of udp chardev attributes
    
    It is possible (although possibly not very useful) to leave out
    the service attribute when using <source mode='bind'/>
    
    Fix the formatter bug introduced by commit 4a0da34 and format
    the host when its present (checked for non-NULL inside
    virBufferEscapeString) instead of basing it on the presence
    of the service attribute.
    
    https://bugzilla.redhat.com/show_bug.cgi?id=1455825

git describe: v3.7.0-171-gfcd5c61cd

Comment 4 Yanqiu Zhang 2017-10-25 10:31:28 UTC
Can reproduce the bug with same steps as comment0.

Verify this bug with libvirt-3.8.0-1.el7.x86_64.

Steps to verify:
1. Add following rng device to domain xml:(bind mode with 'host' no 'service')
# virsh edit V
    <rng model='virtio'>
      <backend model='egd' type='udp'>
        <source mode='bind' host='10.66.*.*'/>
        <source mode='connect' host='127.0.0.1' service='1024'/>
      </backend>
    </rng>

2.Dumpxml to check:
# virsh dumpxml V|grep 'rng m' -A7
    <rng model='virtio'>
      <backend model='egd' type='udp'>
        <source mode='bind' host='10.66.*.*'/>   <=='host' didn't disappear
        <source mode='connect' host='127.0.0.1' service='1024'/>
      </backend>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x09' function='0x0'/>
    </rng>

3.Start domain and check domain xml again:
# virsh start V
Domain V started

# virsh dumpxml V|grep 'rng m' -A7
    <rng model='virtio'>
      <backend model='egd' type='udp'>
        <source mode='bind' host='10.66.*.*'/>   <=='host' didn't disappear
        <source mode='connect' host='127.0.0.1' service='1024'/>
      </backend>
      <alias name='rng0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x09' function='0x0'/>
    </rng>

4. Check UDP connection:
# netstat -tunap|grep 1024
udp        0      0 10.66.*.*:34854       127.0.0.1:1024          ESTABLISHED 7671/qemu-kvm

5.Do managedsave/restore, check the UDP connection again:
# virsh managedsave V

Domain V state saved by libvirt

# virsh start V
Domain V started

# netstat -tunap|grep 1024
udp        0      0 10.66.*.*:35696       127.0.0.1:1024          ESTABLISHED 7718/qemu-kvm      <== Still binds to the specified ip: 10.66.*.*

Since the result is as expected, mark this bug as verified.

Comment 8 errata-xmlrpc 2018-04-10 10:46:43 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://access.redhat.com/errata/RHEA-2018:0704