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 1592737 - Cannot use a xml file with XML declaration as a input of cpu-compare
Summary: Cannot use a xml file with XML declaration as a input of cpu-compare
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: libvirt
Version: 7.6
Hardware: x86_64
OS: Linux
medium
medium
Target Milestone: rc
: 7.7
Assignee: Jiri Denemark
QA Contact: jiyan
URL:
Whiteboard:
: 1659045 (view as bug list)
Depends On:
Blocks: 1598750 1619379 1651787 1659045 1659048
TreeView+ depends on / blocked
 
Reported: 2018-06-19 08:03 UTC by Luyao Huang
Modified: 2019-08-06 13:14 UTC (History)
13 users (show)

Fixed In Version: libvirt-4.5.0-12.el7
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2019-08-06 13:13:52 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHSA-2019:2294 0 None None None 2019-08-06 13:14:21 UTC

Description Luyao Huang 2018-06-19 08:03:57 UTC
Description of problem:
Cannot use a xml file with XML declaration as a input of cpu-compare

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

How reproducible:
100%

Steps to Reproduce:
1. prepare a xml with XML declaration for cpu-compare cmd:

# cat /tmp/cpu.xml
<?xml version='1.0' encoding='UTF-8'?><cpu><vendor>Intel</vendor><model>Haswell-noTSX-IBRS</model><feature name="vme" policy="require" /><feature name="ds" policy="require" /><feature name="acpi" policy="require" /><feature name="ss" policy="require" /><feature name="ht" policy="require" /><feature name="tm" policy="require" /><feature name="pbe" policy="require" /><feature name="dtes64" policy="require" /><feature name="monitor" policy="require" /><feature name="ds_cpl" policy="require" /><feature name="vmx" policy="require" /><feature name="smx" policy="require" /><feature name="est" policy="require" /><feature name="tm2" policy="require" /><feature name="xtpr" policy="require" /><feature name="pdcm" policy="require" /><feature name="dca" policy="require" /><feature name="osxsave" policy="require" /><feature name="f16c" policy="require" /><feature name="rdrand" policy="require" /><feature name="arat" policy="require" /><feature name="tsc_adjust" policy="require" /><feature name="cmt" policy="require" /><feature name="stibp" policy="require" /><feature name="xsaveopt" policy="require" /><feature name="pdpe1gb" policy="require" /><feature name="abm" policy="require" /><feature name="invtsc" policy="require" /></cpu>

2. use cpu-compare

# virsh cpu-compare /tmp/cpu.xml
error: /tmp/cpu.xml:1: XML declaration allowed only at the start of the document
<container><?xml version='1.0' encoding='UTF-8'?>
 ----------------^

3.

Actual results:
libvirt direct put the string in input xml file in <container>%s</container>, and this will cause the xml with XML declaration cannot work with this command anymore

Expected results:
return cpu compare result in step 2

Additional info:

Caught by avocado, and cannot be reproduced in 4.3.0

Comment 3 Jiri Denemark 2018-09-06 15:13:40 UTC
The cpu-compare and cpu-baseline virsh commands were made user friendly so
that the user can pass various XMLs generated by other libvirt commands to
them. The cpu-compare command takes a single XML document, while cpu-baseline
accepts several concatenated XMLs. Thus there were two separate pieces of code
dealing with the same. When I was adding the hypervisor variants of these
commands I had to add support for parsing one more type of XML document
generated by libvirt. While doing that, I merged the code for all the commands
to reduce duplication. And because libvirt never produces the <?xml ?>
declaration, the code does not work correctly when it sees <?xml ?>.

I will try to look at this and come up with a fix which would not be too
hacky. However, I don't see this as a big priority. Only virsh is affected,
calling libvirt API (even using some of the bindings) directly would just
work. And all avocado tests should really be rewritten to use libvirt's python
bindings.

Comment 4 Jiri Denemark 2018-11-23 11:54:34 UTC
Patch sent upstream for review:
https://www.redhat.com/archives/libvir-list/2018-November/msg00838.html

Comment 5 Jiri Denemark 2018-11-29 12:58:24 UTC
Fixed upstream by

commit fcd1c865e168bdb9763b19e790c15e80aa29be66
Refs: v4.10.0-rc1-5-gfcd1c865e1
Author:     Jiri Denemark <jdenemar>
AuthorDate: Thu Nov 22 16:28:56 2018 +0100
Commit:     Jiri Denemark <jdenemar>
CommitDate: Thu Nov 29 11:46:42 2018 +0100

    virsh: Strip XML declaration when extracting CPU XMLs

    Since commit v4.3.0-336-gc84726fbdd all
    {hypervisor-,}cpu-{baseline,compare} commands use a generic
    vshExtractCPUDefXMLs helper for extracting individual CPU definitions
    from the provided input file. The helper wraps the input file in a
    <container> element so that several independent elements can be easily
    parsed from the file. This works fine except when the file starts with
    XML declaration (<?xml version="1.0" ... ?>) because the XML declaration
    cannot be put inside any element. In fact it has to be at the very
    beginning of the XML document without any preceding white space
    characters. We can just simply skip the XML declaration.

    https://bugzilla.redhat.com/show_bug.cgi?id=1592737

    Signed-off-by: Jiri Denemark <jdenemar>
    Reviewed-by: Ján Tomko <jtomko>

Comment 7 Jiri Denemark 2018-12-13 13:18:54 UTC
*** Bug 1659045 has been marked as a duplicate of this bug. ***

Comment 8 IBM Bug Proxy 2018-12-13 13:24:27 UTC
------- Comment From satheera.com 2018-12-13 08:08 EDT-------
Fixed by upstream commit

Comment 13 jiyan 2019-04-10 05:53:01 UTC
Verified on libvirt-4.5.0-12.el7.x86_64.

Version:
kernel-3.10.0-1036.el7.x86_64
libvirt-4.5.0-12.el7.x86_64
qemu-kvm-rhev-2.12.0-25.el7.x86_64

Steps:
1. Prepare 2 intel/AMD hosts, and get the output of 'virsh capabilities' on each host
# virsh capabilities >> cap_1.xml

# virsh capabilities >> cap_2.xml

# cat cap_1.xml >> cap.xml 

# cat cap_2.xml >> cap.xml

2. Test {hypervisor-,}cpu-{baseline,compare} commands with the 'cpu.xml' above
# virsh hypervisor-cpu-baseline cap.xml 
<cpu mode='custom' match='exact'>
  <model fallback='forbid'>Penryn</model>
  <vendor>Intel</vendor>
  <feature policy='require' name='vme'/>
  <feature policy='require' name='ds'/>
  <feature policy='require' name='acpi'/>
  <feature policy='require' name='ss'/>
  <feature policy='require' name='ht'/>
  <feature policy='require' name='tm'/>
  <feature policy='require' name='pbe'/>
  <feature policy='require' name='dtes64'/>
  <feature policy='require' name='monitor'/>
  <feature policy='require' name='ds_cpl'/>
  <feature policy='require' name='vmx'/>
  <feature policy='require' name='tm2'/>
  <feature policy='require' name='xtpr'/>
  <feature policy='require' name='pdcm'/>
  <feature policy='require' name='xsave'/>
  <feature policy='require' name='osxsave'/>
</cpu>

# virsh hypervisor-cpu-compare cap.xml 
CPU described in cap.xml is incompatible with the CPU provided by hypervisor on the host

# virsh cpu-baseline cap.xml 
<cpu mode='custom' match='exact'>
  <model fallback='allow'>Penryn</model>
  <vendor>Intel</vendor>
  <feature policy='require' name='vme'/>
  <feature policy='require' name='ds'/>
  <feature policy='require' name='acpi'/>
  <feature policy='require' name='ss'/>
  <feature policy='require' name='ht'/>
  <feature policy='require' name='tm'/>
  <feature policy='require' name='pbe'/>
  <feature policy='require' name='dtes64'/>
  <feature policy='require' name='monitor'/>
  <feature policy='require' name='ds_cpl'/>
  <feature policy='require' name='vmx'/>
  <feature policy='require' name='tm2'/>
  <feature policy='require' name='xtpr'/>
  <feature policy='require' name='pdcm'/>
  <feature policy='require' name='xsave'/>
  <feature policy='require' name='osxsave'/>
</cpu>

# virsh cpu-compare cap.xml 
CPU described in cap.xml is incompatible with host CPU

All the test results are as expected, move this bug to be verified.

Comment 14 jiyan 2019-06-18 06:00:30 UTC
In step-1, Add the <?xml version='1.0' encoding='UTF-8'?> XMl declaration at the first of each file.

Comment 16 errata-xmlrpc 2019-08-06 13:13:52 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/RHSA-2019:2294


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