Bug 1850654

Summary: hypervisor-cpu-compare doesn't accept capabilities cpu definition
Product: Red Hat Enterprise Linux 8 Reporter: smitterl
Component: libvirtAssignee: Tim Wiederhake <twiederh>
Status: CLOSED UPSTREAM QA Contact: smitterl
Severity: high Docs Contact:
Priority: medium    
Version: 8.3CC: bugproxy, cohuck, hannsj_uhl, jdenemar, jherrman, jsuchane, mprivozn, thuth, virt-maint
Target Milestone: rcKeywords: Automation, Patch, Triaged, Upstream
Target Release: 8.4   
Hardware: s390x   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2020-10-19 15:53:47 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:
Bug Depends On: 1660904    
Bug Blocks: 1776265    

Description smitterl 2020-06-24 15:59:26 UTC
Description of problem:
CPU xml definition as given by virsh capabilities is not accepted.

Version-Release number of selected component (if applicable):
libvirt-client-6.0.0-24.module+el8.3.0+7105+0cc49779.s390x


How reproducible:
100%

Steps to Reproduce:
1. virsh capabilities > caps.xml
>>
...
    <cpu>
      <arch>s390x</arch>
      <topology sockets='1' dies='1' cores='8' threads='1'/>
      <pages unit='KiB' size='4'/>
      <pages unit='KiB' size='1024'/>
    </cpu>
...
2. Put <cpu>...</cpu> from step 1 into cpu.xml
3. virsh hypervisor-cpu-baseline cpu.xml

Actual results:
error: Failed to compare hypervisor CPU with cpu.xml
error: XML error: Missing CPU model name

Expected results:
Not sure. On x86_64 result is, this depends on the environment IIUC, I got:
CPU described in /root/cpu-caps.xml is incompatible with the CPU provided by hypervisor on the host.

Additional info:
virsh man entry for hypervisor-cpu-compare: "The host CPU definition is the <cpu> element and its contents as printed by the capabilities command."

Comment 1 IBM Bug Proxy 2020-06-25 16:12:07 UTC
------- Comment From Collin.Walling 2020-06-25 12:05 EDT-------
s390 is a bit of a special case here.

Other archs (at least x86) will report a definition for the host CPU via virsh capabilities. S390 does not do this -- it reports a "close enough" host CPU model, which can informally be referred to as the "hypervisor CPU model", via the virsh domcapabilities command.

This "hypervisor CPU model" reports features that are exposed to the hypervisor, which may not necessarily be 1:1 with what the host capabilities are.

The results look correct to me, but perhaps we should document that s390 should use domcapabilities over capabilities?

Comment 2 IBM Bug Proxy 2020-09-02 08:41:05 UTC
------- Comment From tstaudt.com 2020-09-02 04:34 EDT-------
Hello Red Hat,

what do you think about documenting this?
Potential candidates are e.g. the virsh man page, the libvirt domain web page or one the Virtualization Guides / Red Books.

Comment 5 Thomas Huth 2020-09-23 07:21:57 UTC
After reading through the original bug description a second time, I noticed that smitterl referenced the man page of virsh hypervisor-cpu-compare ... so if you read that man page, it indeed sounds like the output of "virsh capabilities" should be a valid input for the other commands... Thus I think the information should rather be added to the man page of virsh, and not to the Virtualization Guides or the webpage.

Comment 7 Jiri Denemark 2020-09-23 16:51:34 UTC
The <cpu> element in host capabilities does not contain any <model> element
because libvirt itself cannot detect the host CPU. It can do so by asking QEMU
and the result is shown in domain capabilities XML. I think the existing
behavior is correct. Libvirt should refuse to make a baseline computation when
the CPU model is not specified.

The documentation of virConnectBaselineHypervisorCPU says:

    For best results the host-model CPUs as advertised by
    virConnectGetDomainCapabilities() should be passed in @xmlCPUs.

which I believe should be enough. Perhaps we should mention something like
that in virsh man page.

Comment 9 Tim Wiederhake 2020-10-09 13:02:54 UTC
Proposed patch: https://www.redhat.com/archives/libvir-list/2020-October/msg00696.html

Comment 10 Michal Privoznik 2020-10-15 09:40:24 UTC
Merged upstream as:

4bd0633211 docs: Expand on recommendation in hypervisor-cpu-baseline description

v6.8.0-327-g4bd0633211

Comment 12 smitterl 2020-10-19 15:53:47 UTC
Given that the observed behavior is correct and the patch has already been merged upstream, I'm closing this as UPSTREAM. Please, shout if you disagree.