Bug 1926820

Summary: RFE: support for QEMU "-cpu max" model
Product: Red Hat Enterprise Linux Advanced Virtualization Reporter: Daniel Berrangé <berrange>
Component: libvirtAssignee: Daniel Berrangé <berrange>
Status: CLOSED ERRATA QA Contact: Luyao Huang <lhuang>
Severity: medium Docs Contact:
Priority: medium    
Version: 8.5CC: jdenemar, jsuchane, virt-maint, yalzhang
Target Milestone: rcKeywords: FutureFeature, Triaged
Target Release: 8.4   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: libvirt-7.3.0-1.el8 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2021-11-16 07:51:42 UTC Type: Feature Request
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version: 7.1.0
Embargoed:

Description Daniel Berrangé 2021-02-09 14:13:29 UTC
Description of problem:
QEMU has supported a "max" CPU model for many releases now, but somehow
we never got it wired up into libvirt.

"max" is useful for applications which don't care about live migration
and just want the best CPU model possible. Normally "host" would be used
but this only works for KVM. "max" is identical to "host" for KVM, while
for TCG it exposes every feature TCG implements.

This "max" model will be a natural choice for something like libguestfs
and probably other apps too.

Although RHEL does not consider TCG supported, once the "max" model is supported in libvirt upstream, it will get inherited by RHEL and likely used by applications like libguestfs.

This BZ is primarily a placeholder to record need for QE testing. There is no urgent LP requirement in this area.

In terms of testing, it is will likely be a case of taking an existing guest config

   <cpu mode="host-passthrough"/>

and changing it to:

   <cpu mode="maximum"/>


For KVM, these two should behaviour in an identical way.

For TCG, "host-passthrough" is not supported, but "maximum" will expose all possible TCG features. If we do see any bugs in this case, they are likely to in fact be pre-existing TCG bugs rather than libvirt bugs.

Comment 1 Daniel Berrangé 2021-02-15 14:12:42 UTC
This is merged upstream 

3f1f7845756e1b65946ad189979a598069a0a0ce schemas: Add support for maximum CPU mode
c32f172d123c3cbe44214571c1d9118807608ec5 qemu: wire up support for maximum CPU model
9c89cc5d6ff60122e15c086c92e93aeb5180cb6e qemu: probe for "-cpu max" support
7c1653f63a44020f8888dcde7ac3f4be615975cd cpu: wire up support for maximum CPU mode
09cbd460fbdf2e9d8dbf23020bcb4048518aa290 conf: add reporting of "maximum" CPU mode in domain caps
d153c101d2e92725a4e60b7a15e3bcb812ff297f conf: define a new "maximum" CPU mode

Comment 15 Luyao Huang 2021-06-04 09:40:33 UTC
Verify this bug with libvirt-daemon-7.4.0-1.module+el8.5.0+11218+83343022.x86_64:

S1: Start KVM guest with maximum cpu mode 

1. define a kvm guest with maximum cpu mode

# virsh dumpxml vm1

<domain type='kvm'>
...
  <cpu mode='maximum' check='none'>
...

2. start guest

# virsh start vm1
Domain 'vm1' started

3. check qemu command line:

# ps aux|grep qemu
...-cpu max...

4. Login guest and check guest cpu info

IN GUEST:

# lscpu
...
Model name:          Intel(R) Xeon(R) CPU E3-1230 v6 @ 3.50GHz
...
Flags:               fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ss syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon rep_good nopl xtopology cpuid tsc_known_freq pni pclmulqdq vmx ssse3 fma cx16 pdcm pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand hypervisor lahf_lm abm 3dnowprefetch cpuid_fault invpcid_single pti ssbd ibrs ibpb stibp tpr_shadow vnmi flexpriority ept vpid ept_ad fsgsbase tsc_adjust bmi1 hle avx2 smep bmi2 erms invpcid rtm mpx rdseed adx smap clflushopt xsaveopt xsavec xgetbv1 xsaves arat umip md_clear arch_capabilities

S2: Start TCG guest with maximum cpu mode

1. define a tcg guest with maximum cpu mode

# virsh dumpxml vm1

<domain type='qemu'>
...
  <cpu mode='maximum' check='none'>
...

2. start guest

# virsh start vm1
Domain 'vm1' started

3. check qemu command line:

# ps aux|grep qemu
...-cpu max...

4. Login guest and check guest cpu info

IN GUEST:

# lscpu
...
Model name:          QEMU TCG CPU version 2.5+
...
Flags:               fpu de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush acpi mmx fxsr sse sse2 ss syscall nx mmxext pdpe1gb rdtscp lm 3dnowext 3dnow nopl cpuid pni pclmulqdq monitor ssse3 cx16 sse4_1 sse4_2 movbe popcnt aes xsave rdrand hypervisor lahf_lm svm cr8_legacy abm sse4a vmmcall fsgsbase bmi1 smep bmi2 erms mpx adx smap clflushopt clwb xsaveopt xgetbv1 arat npt pku ospke la57

Comment 17 errata-xmlrpc 2021-11-16 07:51:42 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 (virt:av bug fix and enhancement update), 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/RHBA-2021:4684