RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 1346723 - some bugs in function which used to parse perf event xml element
Summary: some bugs in function which used to parse perf event xml element
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: libvirt
Version: 7.3
Hardware: x86_64
OS: Linux
medium
medium
Target Milestone: rc
: ---
Assignee: Peter Krempa
QA Contact: Virtualization Bugs
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2016-06-15 08:51 UTC by Luyao Huang
Modified: 2016-11-03 18:47 UTC (History)
4 users (show)

Fixed In Version: libvirt-2.0.0-1.el7
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2016-11-03 18:47:04 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHSA-2016:2577 0 normal SHIPPED_LIVE Moderate: libvirt security, bug fix, and enhancement update 2016-11-03 12:07:06 UTC

Description Luyao Huang 2016-06-15 08:51:25 UTC
Description of problem:
some bugs in function which used to parse perf event xml element

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

How reproducible:
100%

Steps to Reproduce:
1. use perf cmd to set 2 event and restart libvirtd, guest will disappear:

# virsh perf rhel7.0-rhel
cmt            : enabled
mbmt           : disabled
mbml           : enabled

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

# virsh dumpxml rhel7.0-rhel
error: failed to get domain 'rhel7.0-rhel'
error: Domain not found: no domain with matching name 'rhel7.0-rhel'

log:

internal error: A domain definition can have no more than one event node with name no

2. add mbml event in guest xml, the xml will fail xml validate check:

# virsh edit rhel7.0-rhel

add this
  <perf>
    <event name='mbml' enabled='yes'/>
  </perf>


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

Failed. Try again? [y,n,i,f,?]: 


3. add mbml event in guest xml and libvirt will parse it as cmt:

# virsh edit rhel7.0-rhel --skip-validate

add this
  <perf>
    <event name='mbml' enabled='yes'/>
  </perf>


Domain rhel7.0-rhel XML configuration edited.

# virsh dumpxml rhel7.0-rhel --inactive |grep -1 perf
  </pm>
  <perf>
    <event name='cmt' enabled='yes'/>
  </perf>
  <devices>

4. the output error not correct when enable 2 event in guest:

# virsh perf rhel7.0-rhel
cmt            : enabled
mbmt           : disabled
mbml           : enabled

# virsh start rhel7.0-rhel
error: Failed to start domain rhel7.0-rhel
error: internal error: A domain definition can have no more than one event node with name no
           ^
           ~~~~~~~ i think should be the event name


Actual results:

check the steps

Expected results:

1. guest still exist
2. fix schema
3. fix it
4. report error like this:

A domain definition can have no more than one event node with name cmt

Additional info:

In virDomainPerfEventDefParseXML():

    if (perf->events[VIR_PERF_EVENT_CMT] != VIR_TRISTATE_BOOL_ABSENT) {
        virReportError(VIR_ERR_INTERNAL_ERROR,
                       _("A domain definition can have no more than "
                         "one event node with name %s"),
                       virTristateBoolTypeToString(name_type));

        goto cleanup;
    }
    perf->events[VIR_PERF_EVENT_CMT] = enabled_type;

libvirt will always update enable info to cmt event this cause the problem 1 and 3. Also libvirt should use virPerfEventTypeToString to format event name this cause problem 4

there is no schema update code in commit 90b9995d1 and this cause problem 2

  <element name="event">
          <attribute name="name">
            <choice>
              <value>cmt</value>
            </choice>
          </attribute>
          <attribute name="enabled">
            <ref name="virYesNo"/>
          </attribute>
        </element>

Comment 1 Peter Krempa 2016-06-17 07:51:00 UTC
Fixed upstream:

commit 23690e1d74b3551eecb69e2187ed4089238a9838
Author: Peter Krempa <pkrempa>
Date:   Wed Jun 15 16:33:20 2016 +0200

    conf: Fix perf event parser
    
    The parser was totaly broken. Fix it by rewriting it. Add tests so that
    it doesn't happen.
    
    Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1346723

commit c22dad33c2b5e8a93d540715604784032783734f
Author: Peter Krempa <pkrempa>
Date:   Wed Jun 15 16:31:19 2016 +0200

    docs: Add at least some docs and fix schema entry for perf events
    
    There was no documentation at all for the XML part. I added at least
    some. The 2.0.0 introduction date is deliberate as the parser for the
    XML is broken.
    
    The schema file was missing entries for 'mbml' and 'mbmt'.

Comment 3 yalzhang@redhat.com 2016-07-04 12:59:42 UTC
Hi Peter,

Test on libvirt-2.0.0-1.el7.x86_64, the 'mbmt' and 'mbml' pass the xml validate. But the guest can not start with a mbmt or mbml set to enable, If there is any restriction?

# virsh dumpxml rhel7.2 | grep /perf -B4
  <perf>
    <event name='cmt' enabled='no'/>
    <event name='mbmt' enabled='yes'/>
    <event name='mbml' enabled='no'/>
  </perf>
# virsh start rhel7.2
error: Failed to start domain rhel7.2
error: Unable to open perf type=26 for pid=24570: Invalid argument

# virsh perf rhel7.2 --enable mbml --disable cmt,mbmt
# virsh perf rhel7.2 
cmt            : disabled
mbmt           : disabled
mbml           : enabled
# virsh start rhel7.2
error: Failed to start domain rhel7.2
error: Unable to open perf type=26 for pid=24633: Invalid argument

# virsh perf rhel7.2 --enable cmt --disable mbml,mbmt
# virsh start rhel7.2
Domain rhel7.2 started
# virsh perf rhel7.2 --enable cmt,mbml --disable mbmt
error: Unable to enable/disable perf events
error: Unable to open perf type=26 for pid=24713: Invalid argument

Comment 4 yalzhang@redhat.com 2016-07-05 09:18:26 UTC
Sorry, Commet 3 is test on a machine with CPU E5-2620 v3, which do not support mbm and just support cmt. I will reserve a machine with E5-2600 v4 CPU and retest this bug.

Comment 5 yalzhang@redhat.com 2016-07-06 06:16:02 UTC
Hi Peter,
Could you please help to confirm if below results is expected?

1. After restart libvirtd, the perf.cmt, perf.mbmt and perf.mbml may be '0'
# virsh domstats rhel7.2 --perf
Domain: 'rhel7.2'
  perf.cmt=19087360
  perf.mbmt=77168640
  perf.mbml=67788800
# service libvirtd restart
Redirecting to /bin/systemctl restart  libvirtd.service
# service libvirtd restart
Redirecting to /bin/systemctl restart  libvirtd.service
# virsh domstats rhel7.2 --perf
Domain: 'rhel7.2'
  perf.cmt=122880
  perf.mbmt=122880
  perf.mbml=0
 
2. Besides, if the host do not support the cmt, mbm, the error message when start the guest is just like comment 3. If we can update the error message to something more clearly, such as "mbml/cmt/mbmt is not supported by the host CPU"?

Test on a machine with cpu "Intel(R) Xeon(R) CPU E5-2640 v4".
Both cmt, mbmt and mbml can be parsed correctly and pass xml validate.
Add below lines in the guest's xml
  <perf>
    <event name='cmt' enabled='yes'/>
    <event name='mbmt' enabled='yes'/>
    <event name='mbml' enabled='yes'/>
  </perf>
# virsh edit rhel7.2
Domain rhel7.2 XML configuration not changed.

# virsh dumpxml rhel7.2 | grep /perf -B4
  <perf>
    <event name='cmt' enabled='yes'/>
    <event name='mbmt' enabled='yes'/>
    <event name='mbml' enabled='yes'/>
  </perf>
# virsh start rhel7.2
Domain rhel7.2 started
# virsh perf rhel7.2
cmt            : enabled
mbmt           : enabled
mbml           : enabled
# service libvirtd restart
Redirecting to /bin/systemctl restart  libvirtd.service
# virsh list
 Id    Name                           State
----------------------------------------------------
 20    rhel7.2                        running

# virsh domstats rhel7.2 --perf
Domain: 'rhel7.2'
  perf.cmt=81920
  perf.mbmt=819200
  perf.mbml=450560

Comment 6 Peter Krempa 2016-07-26 15:15:50 UTC
(In reply to yalzhang from comment #5)
> Hi Peter,
> Could you please help to confirm if below results is expected?
> 
> 1. After restart libvirtd, the perf.cmt, perf.mbmt and perf.mbml may be '0'
> # virsh domstats rhel7.2 --perf
> Domain: 'rhel7.2'
>   perf.cmt=19087360
>   perf.mbmt=77168640
>   perf.mbml=67788800
> # service libvirtd restart
> Redirecting to /bin/systemctl restart  libvirtd.service
> # service libvirtd restart
> Redirecting to /bin/systemctl restart  libvirtd.service
> # virsh domstats rhel7.2 --perf
> Domain: 'rhel7.2'
>   perf.cmt=122880
>   perf.mbmt=122880
>   perf.mbml=0

I unfortunately don't really know how that is supposed to work.

> 2. Besides, if the host do not support the cmt, mbm, the error message when
> start the guest is just like comment 3. If we can update the error message
> to something more clearly, such as "mbml/cmt/mbmt is not supported by the
> host CPU"?

It might be worth to do so. As that isn't a critical issue I'd suggest you file a new bug for this since otherwise I'll probably forget about it.

Comment 7 yalzhang@redhat.com 2016-07-27 02:43:41 UTC
(In reply to Peter Krempa from comment #6)
> (In reply to yalzhang from comment #5)
> > Hi Peter,
> > Could you please help to confirm if below results is expected?
> > 
> > 1. After restart libvirtd, the perf.cmt, perf.mbmt and perf.mbml may be '0'

> > 2. Besides, if the host do not support the cmt, mbm, the error message when
> > start the guest is just like comment 3. If we can update the error message
> > to something more clearly, such as "mbml/cmt/mbmt is not supported by the
> > host CPU"?
> 
> It might be worth to do so. As that isn't a critical issue I'd suggest you
> file a new bug for this since otherwise I'll probably forget about it.

File a bug
Bug 1360533 - The error message need to improve when enable a perf event on a host which do not support it

Comment 9 errata-xmlrpc 2016-11-03 18:47:04 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/RHSA-2016-2577.html


Note You need to log in before you can comment on or make changes to this bug.