Bug 619259

Summary: qemu "-cpu [check | enforce ]" should work even when a model name is not specified on the command line
Product: Red Hat Enterprise Linux 6 Reporter: john cooper <john.cooper>
Component: qemu-kvmAssignee: john cooper <john.cooper>
Status: CLOSED ERRATA QA Contact: Virtualization Bugs <virt-bugs>
Severity: medium Docs Contact:
Priority: low    
Version: 6.1CC: juzhang, michen, mjenner, mkenneth, nobody, shuang, tburke, virt-maint
Target Milestone: betaKeywords: RHELNAK
Target Release: 6.1   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: qemu-kvm-0.12.1.2-2.144.el6 Doc Type: Bug Fix
Doc Text:
Cause Launching qemu with "-cpu check" doesn't do as expected if a valid cpu model name isn't provided. Consequence "check" and "enforce" actions on the default model don't work and qemu falters with a CLI parsing error. Fix Due to qemu's current CLI argument parsing structure a cpu model name must be provided. So the pseudo name "default" is now recognized which allows "check" and "enforce" to function as expected on both default and "-M" implied cpu models. Result Intuitive and expected behavior for these options is maintained.
Story Points: ---
Clone Of: 601540 Environment:
Last Closed: 2011-05-19 11:33:13 UTC Type: ---
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: 601540    
Bug Blocks: 580953    
Attachments:
Description Flags
Patch to resolve case. none

Comment 2 RHEL Program Management 2010-07-29 05:27:42 UTC
This issue has been proposed when we are only considering blocker
issues in the current Red Hat Enterprise Linux release.

** If you would still like this issue considered for the current
release, ask your support representative to file as a blocker on
your behalf. Otherwise ask that it be considered for the next
Red Hat Enterprise Linux release. **

Comment 4 john cooper 2010-07-30 00:45:14 UTC
I'd envisioned it to be a 6.1 issue when I opened it.
But if sufficient justification exists from other
users to move it into 6.0 that wouldn't be unreasonable.

Comment 5 john cooper 2010-11-19 19:46:02 UTC
Update: due to the internal structure of qemu's arg parsing, adding
this seemingly trivial feature is far more complex/ugly than it
should be.  Let's leave this on the table for now and I'll have
another look to see if some simpler solution exists.

Comment 7 john cooper 2011-01-27 03:55:04 UTC
(In reply to comment #0)
> Description of problem:
> 
> Launching qemu with "-cpu check" doesn't do as expected
> if a valid cpu model name isn't provided.
> 
> Expected results:
> 
> This should work in cases where a model is being chosen
> implicitly, such as when launching via "-M <machine name>"
> in order to launder flags pulled in by the implied model.

Due to qemu's CLI argument parsing structure and the fact cpu models
are initialized depending on build configuration, supporting the
above is far more clunky than it ought to be.

The problem is omitting the cpu model "name" and allowing only feature
flags and modifiers breaks the existing parsing logic, which is
difficult to circumvent given the current implementation.  So as a
minor concession to a far more simple solution we add a pseudo model
name of "default" which expands internally to qemu's build
configuration default and is then interpreted conventionally.  The
result is then the following example usage:


    # x86_64-softmmu/qemu-system-x86_64 ../rhel6.0-beta.img -net nic -net user -m 1024 
    Using CPU model "cpu64-rhel6"
      :

    # 86_64-softmmu/qemu-system-x86_64 ../rhel6.0-beta.img -net nic -net user -m 1024 -cpu default,check
    Using CPU model "cpu64-rhel6,check"
    warning: host cpuid 8000_0001 lacks requested flag 'abm' [0x00000020]
    warning: host cpuid 8000_0001 lacks requested flag 'sse4a' [0x00000040]
      :

    # x86_64-softmmu/qemu-system-x86_64 ../rhel6.0-beta.img -net nic -net user -m 1024 -M rhel6.0.0 -cpu default,enforce,+sse4.1,+sse4.2,-abm
    Using CPU model "cpu64-rhel6,enforce,+sse4.1,+sse4.2,-abm"
    warning: host cpuid 0000_0001 lacks requested flag 'sse4.2|sse4_2' [0x00100000]
    warning: host cpuid 8000_0001 lacks requested flag 'sse4a' [0x00000040]
    Unable to support requested x86 CPU definition

etc..  allowing both the ability here to "check|enforce" the default
model, as well as accepting arbitrary feature flags due to fan into the
existing flag parsing.  The resulting rhel6.1 patch (to follow) is fairly
trivial.   Upstream patch under way.

Comment 8 john cooper 2011-01-27 03:56:38 UTC
Created attachment 475522 [details]
Patch to resolve case.

Comment 15 Suqin Huang 2011-02-18 03:25:06 UTC
fix on qemu-kvm-0.12.1.2-2.145.el6.x86_64

1. qemu-kvm-0.12.1.2-2.132.el6.x86_64
1). /usr/libexec/qemu-kvm /usr/local/staf/test/RHEV/kvm-new/autotest/client/tests/kvm/images/RHEL-Server-6.0-32.raw

can boot without worning

2). check
/usr/libexec/qemu-kvm /usr/local/staf/test/RHEV/kvm-new/autotest/client/tests/kvm/images/RHEL-Server-6.0-32.raw -cpu default,check
Unknown cpu model: default
Unable to support requested x86 CPU definition

/usr/libexec/qemu-kvm /usr/local/staf/test/RHEV/kvm-new/autotest/client/tests/kvm/images/RHEL-Server-6.0-32.raw -cpu check
Unknown cpu model: check
Unable to support requested x86 CPU definition
3). enforce
[root@amd-4450b-4-2 ~]# /usr/libexec/qemu-kvm /usr/local/staf/test/RHEV/kvm-new/autotest/client/tests/kvm/images/RHEL-Server-6.0-32.raw -cpu enforce
Unknown cpu model: enforce
Unable to support requested x86 CPU definition
[root@amd-4450b-4-2 ~]# /usr/libexec/qemu-kvm /usr/local/staf/test/RHEV/kvm-new/autotest/client/tests/kvm/images/RHEL-Server-6.0-32.raw -cpu default,enforce
Unknown cpu model: default
Unable to support requested x86 CPU definition

2. qemu-kvm-0.12.1.2-2.145.el6.x86_64

1). /usr/libexec/qemu-kvm /home/shuang/images/rhel5.test
Using CPU model "cpu64-rhel6"

2). /usr/libexec/qemu-kvm /home/shuang/images/rhel5.test -cpu default,check
Using CPU model "cpu64-rhel6,check"
warning: host cpuid 8000_0001:ecx flag restricted to guest 'svm' [0x00000004]
warning: host cpuid 8000_0001:ecx lacks requested flag 'abm' [0x00000020]
warning: host cpuid 8000_0001:ecx lacks requested flag 'sse4a' [0x00000040]

3). /usr/libexec/qemu-kvm /home/shuang/images/rhel5.test -cpu default,enforce
Using CPU model "cpu64-rhel6,enforce"
warning: host cpuid 8000_0001:ecx flag restricted to guest 'svm' [0x00000004]
warning: host cpuid 8000_0001:ecx lacks requested flag 'abm' [0x00000020]
warning: host cpuid 8000_0001:ecx lacks requested flag 'sse4a' [0x00000040]
Unable to support requested x86 CPU definition

/usr/libexec/qemu-kvm /home/shuang/images/rhel5.test -cpu default,enforce,+svm,+abm,+sse4a
Using CPU model "cpu64-rhel6,enforce,+svm,+abm,+sse4a"
warning: host cpuid 8000_0001:ecx flag restricted to guest 'svm' [0x00000004]
warning: host cpuid 8000_0001:ecx lacks requested flag 'abm' [0x00000020]
warning: host cpuid 8000_0001:ecx lacks requested flag 'sse4a' [0x00000040]
Unable to support requested x86 CPU definition

Comment 16 john cooper 2011-02-18 20:37:23 UTC
Looks good.  Incidentally you might consider adding unit test to
validate we're picking up other built-in defaults when the "-M"
flag is specified, as a regression check of sorts.  For example:

    # x86_64-softmmu/qemu-system-x86_64 -M rhel5.4.4
    Using CPU model "cpu64-rhel5"
      :

    # x86_64-softmmu/qemu-system-x86_64 -M rhel5.4.4 -cpu default,check
    Using CPU model "cpu64-rhel5,check"
    warning: host cpuid 8000_0001:edx lacks requested flag '3dnowext' [0x40000000]
    warning: host cpuid 8000_0001:edx lacks requested flag '3dnow' [0x80000000]
    warning: host cpuid 8000_0001:ecx lacks requested flag 'svm' [0x00000004]

Note the warnings above in the case of "check" are of no general concern.
The cpu64-rhel* models intentionally request a wider set of features than
they typically will receive and are not guaranteed to be migration portable
models.

Comment 17 Suqin Huang 2011-04-13 07:49:02 UTC
test the default cpu model when the "-M" flag is specified ==> PASS

qemu-kvm-0.12.1.2-2.156.el6.x86_64

[root@intel-e5620-12-1 ~]# /usr/libexec/qemu-kvm test.qcow2 -M pc -cpu default,check -vnc :1
Using CPU model "cpu64-rhel6,check"
warning: host cpuid 8000_0001:ecx lacks requested flag 'svm' [0x00000004]
warning: host cpuid 8000_0001:ecx lacks requested flag 'abm' [0x00000020]
warning: host cpuid 8000_0001:ecx lacks requested flag 'sse4a' [0x00000040]


[root@intel-e5620-12-1 ~]# /usr/libexec/qemu-kvm test.qcow2 -M rhel6.1.0 -cpu default,check -vnc :1
Using CPU model "cpu64-rhel6,check"
warning: host cpuid 8000_0001:ecx lacks requested flag 'svm' [0x00000004]
warning: host cpuid 8000_0001:ecx lacks requested flag 'abm' [0x00000020]
warning: host cpuid 8000_0001:ecx lacks requested flag 'sse4a' [0x00000040]


[root@intel-e5620-12-1 ~]# /usr/libexec/qemu-kvm test.qcow2 -M rhel6.0.0 -cpu default,check -vnc :1
Using CPU model "cpu64-rhel6,check"
warning: host cpuid 8000_0001:ecx lacks requested flag 'svm' [0x00000004]
warning: host cpuid 8000_0001:ecx lacks requested flag 'abm' [0x00000020]
warning: host cpuid 8000_0001:ecx lacks requested flag 'sse4a' [0x00000040]


[root@intel-e5620-12-1 ~]# /usr/libexec/qemu-kvm test.qcow2 -M rhel5.5.0 -cpu default,check -vnc :1
Using CPU model "cpu64-rhel5,check"
warning: host cpuid 8000_0001:edx lacks requested flag '3dnowext' [0x40000000]
warning: host cpuid 8000_0001:edx lacks requested flag '3dnow' [0x80000000]
warning: host cpuid 8000_0001:ecx lacks requested flag 'svm' [0x00000004]


[root@intel-e5620-12-1 ~]# /usr/libexec/qemu-kvm test.qcow2 -M rhel5.4.0 -cpu default,check -vnc :1
Using CPU model "cpu64-rhel5,check"
warning: host cpuid 8000_0001:edx lacks requested flag '3dnowext' [0x40000000]
warning: host cpuid 8000_0001:edx lacks requested flag '3dnow' [0x80000000]
warning: host cpuid 8000_0001:ecx lacks requested flag 'svm' [0x00000004]


[root@intel-e5620-12-1 ~]# /usr/libexec/qemu-kvm test.qcow2 -M rhel5.4.4 -cpu default,check -vnc :1
Using CPU model "cpu64-rhel5,check"
warning: host cpuid 8000_0001:edx lacks requested flag '3dnowext' [0x40000000]
warning: host cpuid 8000_0001:edx lacks requested flag '3dnow' [0x80000000]
warning: host cpuid 8000_0001:ecx lacks requested flag 'svm' [0x00000004]

Comment 18 Miya Chen 2011-04-14 11:16:06 UTC
move it to verified based on comment#15 and comment#17

Comment 19 john cooper 2011-05-05 14:57:59 UTC
Add CCFR.

Comment 20 john cooper 2011-05-05 14:57:59 UTC
    Technical note added. If any revisions are required, please edit the "Technical Notes" field
    accordingly. All revisions will be proofread by the Engineering Content Services team.
    
    New Contents:
Cause
    Launching qemu with "-cpu check" doesn't do as expected
if a valid cpu model name isn't provided.

Consequence
    "check" and "enforce"  actions on the default model don't work
and qemu falters with a CLI parsing error.

Fix
    Due to qemu's current CLI argument parsing structure a cpu model
name must be provided.  So the pseudo name "default" is now recognized
which allows  "check" and "enforce" to function as expected
on both default and "-M" implied cpu models.

Result
    Intuitive and expected behavior for these options is maintained.

Comment 21 errata-xmlrpc 2011-05-19 11:33:13 UTC
An advisory has been issued which should help the problem
described in this bug report. This report is therefore being
closed with a resolution of ERRATA. For more information
on therefore solution and/or where to find the updated files,
please follow the link below. You may reopen this bug report
if the solution does not work for you.

http://rhn.redhat.com/errata/RHSA-2011-0534.html

Comment 22 errata-xmlrpc 2011-05-19 12:46:48 UTC
An advisory has been issued which should help the problem
described in this bug report. This report is therefore being
closed with a resolution of ERRATA. For more information
on therefore solution and/or where to find the updated files,
please follow the link below. You may reopen this bug report
if the solution does not work for you.

http://rhn.redhat.com/errata/RHSA-2011-0534.html