Bug 1220265

Summary: libvirt format a (null) in ./devices/shmem/msi[@ioeventfd] when pass a invalid ioeventfd
Product: Red Hat Enterprise Linux 7 Reporter: Luyao Huang <lhuang>
Component: libvirtAssignee: Martin Kletzander <mkletzan>
Status: CLOSED ERRATA QA Contact: Virtualization Bugs <virt-bugs>
Severity: low Docs Contact:
Priority: low    
Version: 7.2CC: dyuan, honzhang, mzhan, rbalakri
Target Milestone: rc   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: libvirt-1.2.16-1.el7 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2015-11-19 06:30:36 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 Luyao Huang 2015-05-11 07:07:55 UTC
Description of problem:
libvirt format a (null) in ./devices/shmem/msi[@ioeventfd] when pass a invalid ioeventfd

Version-Release number of selected component (if applicable):
libvirt-1.2.15-1.el7.x86_64

How reproducible:
100%

Steps to Reproduce:
1. add this shmem in a guest xml:

# virsh edit test3

    <shmem name='my_shmem0'>
      <size unit='M'>2</size>
      <server path='/tmp/socket-shmem'/>
      <msi vectors='32' ioeventfd='aaa'/>
    </shmem>


2. check the xml
# virsh dumpxml test3 
     <shmem name='my_shmem0'>
      <size unit='M'>2</size>
      <server path='/tmp/socket-shmem'/>
      <msi vectors='32' ioeventfd='(null)'/>
    </shmem>

3.

Actual results:
libvirt format a (null) at ./devices/shmem/msi[@ioeventfd] when pass a invalid ioeventfd

Expected results:
output error when we set a invalid ioeventfd or just drop the wrong settings.

Additional info:

Comment 1 Luyao Huang 2015-05-11 13:00:44 UTC
Another try (version 2):

https://www.redhat.com/archives/libvir-list/2015-May/msg00305.html

Comment 2 Ján Tomko 2015-05-14 12:19:54 UTC
commit c49b9032a212538ff28786d1b9922ebf549ea5ca
Author:     Luyao Huang <lhuang>
AuthorDate: 2015-05-11 20:59:37 +0800
Commit:     Martin Kletzander <mkletzan>
CommitDate: 2015-05-11 16:05:07 +0200

    conf: Report error for unknown shmem ioeventfd value
    
    https://bugzilla.redhat.com/show_bug.cgi?id=1220265
    
    Passing the return value to an enum directly is not safe.  Fix this by
    comparing the true integer result of virTristateSwitchTypeFromString().
    
    Signed-off-by: Luyao Huang <lhuang>

git describe: v1.2.15-56-gc49b903

Comment 4 hongming 2015-08-07 07:58:15 UTC
Verify it as follows. The result is expected. Move its status to VERIFIED.

# rpm -q libvirt
libvirt-1.2.17-3.el7.x86_64

# virsh edit test4

    <shmem name='my_shmem0'>
      <size unit='M'>2</size>
      <server path='/tmp/socket-shmem'/>
      <msi vectors='32' ioeventfd='aaa'/>
    </shmem>

error: XML document failed to validate against schema: Unable to validate doc against /usr/share/libvirt/schemas/domain.rng
Extra element devices in interleave
Element domain failed to validate content


# virsh edit test4

    <shmem name='my_shmem0'>
      <size unit='M'>2</size>
      <server path='/tmp/socket-shmem'/>
      <msi vectors='32' ioeventfd=' '/>
    </shmem>

Failed. Try again? [y,n,i,f,?]: 
error: XML document failed to validate against schema: Unable to validate doc against /usr/share/libvirt/schemas/domain.rng
Extra element devices in interleave
Element domain failed to validate content

# virsh edit test4

    <shmem name='my_shmem0'>
      <size unit='M'>2</size>
      <server path='/tmp/socket-shmem'/>
      <msi vectors='32' ioeventfd='111'/>
    </shmem>


Failed. Try again? [y,n,i,f,?]: 
error: XML document failed to validate against schema: Unable to validate doc against /usr/share/libvirt/schemas/domain.rng
Extra element devices in interleave
Element domain failed to validate content


# virsh edit test4

    <shmem name='my_shmem0'>
      <size unit='M'>2</size>
      <server path='/tmp/socket-shmem'/>
      <msi vectors='32' ioeventfd='on'/>
    </shmem>

Domain test4 XML configuration edited.


# virsh edit test4

    <shmem name='my_shmem0'>
      <size unit='M'>2</size>
      <server path='/tmp/socket-shmem'/>
      <msi vectors='32' ioeventfd='off'/>
    </shmem>

Domain test4 XML configuration edited.

Comment 5 Martin Kletzander 2015-08-07 08:03:28 UTC
(In reply to hongming from comment #4)
Did you also try it without the RNG validation?  For example with 'virsh define' or by pressing 'i' when the XML error pops out?

Comment 6 hongming 2015-08-18 05:44:15 UTC
# cat r7.xml |grep /shmem -B4
    <shmem name='my_shmem0'>
      <size unit='M'>2</size>
      <server path='/tmp/socket-shmem'/>
      <msi vectors='32' ioeventfd='aaa'/>
    </shmem>
# virsh define r7.xml
error: Failed to define domain from r7.xml
error: XML error: invalid msi ioeventfd setting for shmem: 'aaa'

# vim r7.xml
# cat r7.xml |grep /shmem -B4
    <shmem name='my_shmem0'>
      <size unit='M'>2</size>
      <server path='/tmp/socket-shmem'/>
      <msi vectors='32' ioeventfd=' '/>
    </shmem>
# virsh define r7.xml
error: Failed to define domain from r7.xml
error: XML error: invalid msi ioeventfd setting for shmem: ' '

# vim r7.xml
# cat r7.xml |grep /shmem -B4
    <shmem name='my_shmem0'>
      <size unit='M'>2</size>
      <server path='/tmp/socket-shmem'/>
      <msi vectors='32' ioeventfd='111'/>
    </shmem>
# virsh define r7.xml
error: Failed to define domain from r7.xml
error: XML error: invalid msi ioeventfd setting for shmem: '111'


# virsh edit r7.1
error: XML document failed to validate against schema: Unable to validate doc against /usr/share/libvirt/schemas/domain.rng
Extra element devices in interleave
Element domain failed to validate content

Failed. Try again? [y,n,i,f,?]: 
error: XML error: invalid msi ioeventfd setting for shmem: 'aaa'
Failed. Try again? [y,n,f,?]:

Comment 8 errata-xmlrpc 2015-11-19 06:30:36 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-2202.html