Bug 1373849

Summary: CPU feature cmt/mbm_local/mbm_total don't work properly with custom mode and minimum match
Product: Red Hat Enterprise Linux 7 Reporter: chhu
Component: libvirtAssignee: Jiri Denemark <jdenemar>
Status: CLOSED ERRATA QA Contact: Jing Qi <jinqi>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 7.3CC: agurenko, dyuan, jdenemar, lhuang, mtessun, rbalakri, xuzhang, yalzhang
Target Milestone: rcKeywords: Reopened
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: libvirt-2.5.0-1.el7 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2017-08-01 17:14:13 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:    
Bug Blocks: 1199452    

Description chhu 2016-09-07 09:28:10 UTC
Belows issues are moved from bug1365500, comment8,9,10:
CPU feature cmt/mbm_local/mbm_total don't work properly with custom/host-passthrough mode.

Tested with packages:
libvirt-2.0.0-6.el7.x86_64
qemu-kvm-rhev-2.6.0-22.el7.x86_64

Steps:
1. Start VM with xml: cpu mode='custom' match='minimum': Failed with error: "qemu-kvm: CPU feature cmt not found", the VM should be started successfully.

# virsh dumpxml r7.3-raw | grep "<cpu" -A 5
  <cpu mode='custom' match='minimum'>
    <model fallback='allow'>Haswell-noTSX</model>
  </cpu>

# virsh list --all
 Id    Name                           State
----------------------------------------------------
 -     r7.3-raw                       shut off

# virsh start r7.3-raw
error: Failed to start domain r7.3-raw
error: internal error: qemu unexpectedly closed the monitor: 2016-08-18T08:55:33.155930Z qemu-kvm: CPU feature cmt not found

2. Tried to start a VM with cpu mode: host-passthrough with different policy, met the same error: "qemu-kvm: CPU feature cmt not found".

-policy: disable/require/optional/force/forbid

  <cpu mode='host-passthrough'>
    <feature policy='disable' name='cmt'/>
  </cpu>

# virsh start r7t
error: Failed to start domain r7t
error: internal error: qemu unexpectedly closed the monitor: 2016-08-26T07:40:24.934930Z qemu-kvm: CPU feature cmt not found

1) policy=require/ force/optional: met error message: "qemu-kvm: CPU feature cmt not found" =>  as the cmt in not known by qemu-kvm command line, so the error message is reasonable.

2) For policy='disable', the VM should be started successfully, now met error:"qemu-kvm: CPU feature cmt not found" 
  
3) For policy='forbid', should met error message as below:
"error: unsupported configuration: guest and host CPU are not compatible: Host CPU provides forbidden features: cmt"

Now met error:"qemu-kvm: CPU feature cmt not found"

3. Tested with mbm_local/mbm_total on Broadwell met the similar issues as step1 and 2.

Comment 1 Jiri Denemark 2016-09-07 14:06:53 UTC
Oh, you got me wrong, the cmt/mbm_local/mbm_total thing should be fixed as it is a regression. The invtsc issue with minimum match CPUs is not worth a RHEL-only hack since it's been broken ever since we introduced invtsc.

*** This bug has been marked as a duplicate of bug 1365500 ***

Comment 2 Jiri Denemark 2016-09-09 09:30:54 UTC
So the additional patch for bug 1365500 fixed just one of the paths where custom/minimum CPUs are updated according to a host CPU and unfortunately it was not the path which is used when building a command line for QEMU. The patch only fixed "virsh dumpxml --update-cpu".

In other words, domains custom/minimum CPUs will still fail to start on hosts with CMT. I'm reopening this bug.

Comment 3 Jiri Denemark 2016-09-22 13:57:11 UTC
This should be fixed upstream as of

commit 7ce711a30eaf882ccd0217b2528362b563b6d670
Refs: v2.2.0-199-g7ce711a
Author:     Jiri Denemark <jdenemar>
AuthorDate: Wed Jun 22 15:53:48 2016 +0200
Commit:     Jiri Denemark <jdenemar>
CommitDate: Thu Sep 22 15:40:09 2016 +0200

    qemu: Update guest CPU def in live XML

    Storing the updated CPU definition in the live domain definition saves
    us from having to update it over and over when we need it. Not to
    mention that we will soon further update the CPU definition according to
    QEMU once it's started.

    A highly wanted side effect of this patch, libvirt will pass all CPU
    features explicitly specified in domain XML to QEMU, even those that are
    already included in the host model.

    This patch should fix the following bugs:
        https://bugzilla.redhat.com/show_bug.cgi?id=1207095
        https://bugzilla.redhat.com/show_bug.cgi?id=1339680
        https://bugzilla.redhat.com/show_bug.cgi?id=1371039
        https://bugzilla.redhat.com/show_bug.cgi?id=1373849
        https://bugzilla.redhat.com/show_bug.cgi?id=1375524
        https://bugzilla.redhat.com/show_bug.cgi?id=1377913

    Signed-off-by: Jiri Denemark <jdenemar>

Comment 5 Jing Qi 2017-02-27 07:35:52 UTC
Verifed with version libvirt-2.5.0-1.el7.x86_64 & qemu-kvm-rhev-2.8.0-5.el7.x86_64. 
1. Succeeded to start a VM with below CPU mode in domain xml.   
  <cpu mode='custom' match='minimum'>
    <model fallback='allow'>Haswell-noTSX</model>
  </cpu>
2. In the second scenario, set CPU mode in a host with cmt support, there is an error of "Property '.cmt' not found" reported and the error seems like a common error for a wrong value of "feature policy" from qemu-kvm.
 
  <cpu mode='host-passthrough'>
    <feature policy='disable' name='cmt'/>
  </cpu>

error: Failed to start domain rhel7_route
error: internal error: qemu unexpectedly closed the monitor: 2017-02-27T07:21:32.858069Z qemu-kvm: Property '.cmt' not found
 
Can you please help to confirm the error in second scenario is expected? 

3. For "mbmt/mbml", it's the same with item 2, right?

Comment 6 Jiri Denemark 2017-02-27 08:18:49 UTC
Yes, the error is expected if you explicitly mention the unknown feature in the domain XML.

Comment 7 errata-xmlrpc 2017-08-01 17:14:13 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/RHEA-2017:1846

Comment 8 errata-xmlrpc 2017-08-01 23:55:08 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/RHEA-2017:1846

Comment 9 errata-xmlrpc 2017-08-02 01:27:35 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/RHEA-2017:1846