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 700272 - RFE add support for "host cpu" in Libvirt
Summary: RFE add support for "host cpu" in Libvirt
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 6
Classification: Red Hat
Component: libvirt
Version: 6.2
Hardware: Unspecified
OS: Unspecified
high
medium
Target Milestone: rc
: ---
Assignee: Jiri Denemark
QA Contact: Virtualization Bugs
URL:
Whiteboard:
Depends On:
Blocks: 747667 756082 796527
TreeView+ depends on / blocked
 
Reported: 2011-04-28 00:27 UTC by Andrew Cathrow
Modified: 2014-09-07 22:54 UTC (History)
14 users (show)

Fixed In Version: libvirt-0.9.10-1.el6
Doc Type: Enhancement
Doc Text:
Clone Of:
: 796527 (view as bug list)
Environment:
Last Closed: 2012-06-20 06:27:20 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHSA-2012:0748 0 normal SHIPPED_LIVE Low: libvirt security, bug fix, and enhancement update 2012-06-19 19:31:38 UTC

Description Andrew Cathrow 2011-04-28 00:27:28 UTC
Add support to libvirt to allow user to specify equivalent of -cpu host in domain XML.

Use case : To allow users to squeeze the maximum performance out of their virtual machines if they are willing to forgo the more flexible migration options offered by the existing libvirt support.

Comment 1 Andrew Cathrow 2011-04-28 16:28:23 UTC
The important part is that we allow the VM to be generically configured to use all the resources of the host CPU.
eg <cpu>host</cpu>  

That doesn't mean we have to translate that to qemu-kvm -cpu host
that could mean that libvirt dynamically builds the CPU configuration - so if the VM is started on machine that would translate to  <vendor>Intel</vendor> <model>core2duo</model> but on machine B that would be translated to <model>opteron2</model> etc.

The goal would be a generic guest configuration that would use the maximum available CPU resources on the host.

Using that approach rather that -cpu host would allow migration without sacrificing performance.

Comment 6 Cole Robinson 2011-07-21 14:09:59 UTC
Libvirt already allows doing this in a round about way, the steps are:

virsh capabilities | less
<copy out the <cpu> block>
virsh edit $vmname
<paste under <domain> block>

virt-manager provides a button for this, "copy from host cpu"
virt-install provides a --cpu host option for this

but it would probably be an easy addition to libvirt to have

<cpu>
  <model>host</model>
<cpu>

just be a shortcut for autopopulating the XML with the host CPU info. we wouldn't carry <model>host</model> around in the XML or anything, so it would be exactly the same as the above steps. this would also make tools lives easier since we wouldn't have to do the capabilities->domainxml dance

Comment 7 Cole Robinson 2011-07-21 14:11:27 UTC
Ah I just read comment #2 and realize that the RFE is slightly different. my comment still stands though :)

Comment 8 Dave Allan 2011-07-21 18:25:27 UTC
(In reply to comment #7)
> Ah I just read comment #2 and realize that the RFE is slightly different. my
> comment still stands though :)

Actually, I think your comment 6 about

<cpu>
  <model>host</model>
<cpu>

is exactly what's being requested.

Comment 9 Dave Allan 2011-07-21 18:26:34 UTC
It's just syntactic sugar so applications and users don't have to do the capabilities dance, as you point out.

Comment 10 Andrew Cathrow 2011-07-21 19:51:48 UTC
And also so that they only do it once and the domain XML can be used on many different hosts without change and will always be optimal for that machine.

Comment 11 John Walicki 2011-09-06 23:41:38 UTC
This would be an important feature for IBM.

Comment 13 Jiri Denemark 2012-01-06 15:06:27 UTC
An initial version of patches providing this functionality was sent upstream for review: https://www.redhat.com/archives/libvir-list/2012-January/msg00229.html

Comment 14 Jiri Denemark 2012-01-17 11:45:30 UTC
This feature is now implemented upstream as of v0.9.9-59-ge7201af:

commit e7201afdf7648a3c2c654218a651ae8c967aa789
Author: Jiri Denemark <jdenemar>
Date:   Wed Dec 21 13:47:17 2011 +0100

    qemu: Add support for host CPU modes
    
    This adds support for host-model and host-passthrough CPU modes to qemu
    driver. The host-passthrough mode is mapped to -cpu host.

Detailed documentation should be available (in about 1 hour since now) at http://www.libvirt.org/formatdomain.html#elementsCPU

Comment 18 Min Zhan 2012-02-14 09:39:20 UTC
Reproduce this bug with libvirt-0.9.9-2.el6;

Verified this bug with libvirt-0.9.10-1.el6
Steps:
1. Check host-model mode

For a shutdown guest, add the following
# virsh edit guest
...
<cpu mode='host-model'/>
...

# virsh start guest
# ps -ef|grep kvm 
qemu      8338     1 28 04:14 ?        00:00:20 /usr/libexec/qemu-kvm -S -M rhel6.2.0 -cpu Penryn,+osxsave,+xsave,+pdcm,+xtpr,+tm2,+est,+smx,+vmx,+ds_cpl,+monitor,+dtes64,+pbe,+tm,+ht,+ss,+acpi,+ds,+vme -enable-kvm -m 1024 -smp 1,sockets=1,cores=1,threads=1 -name rhel62......

# virsh capabilities
...
  <host>
...
      <model>Penryn</model>
...

Found the guest is using the same model as host. Here is Penryn.

But there is a issue that virt-manager can not get and display this model info. For virt-manager it could be correct only if you click 'copy host model' button. Is it a bug for virt-manager, at least rfe, right? 

Cole, could you help to confirm? Thanks


2. Check host-passthrough model

For a shutdown guest, add the following
# virsh edit guest
...
<cpu mode='host-passthrough'/>
...

# virsh start guest

# ps -ef |grep kvm
qemu     10137     1 10 04:28 ?        00:00:00 /usr/libexec/qemu-kvm -S -M rhel6.2.0 -cpu host -enable-kvm -m 1024 -smp 1,sockets=1,cores=1,threads=1 -name rhel62 ....

We can find '-cpu host' from qemu cmd.

----------------
For the 2 newly added cpu models, the verification passed. So move to VERIFIED status. But also waiting for dev's confirmation about the issue above. Maybe open a new bug to track in virt-manager.

Comment 20 Cole Robinson 2012-03-04 19:05:36 UTC
Clearing NEEDINFO since a virt-manager bug was opened.

Comment 22 errata-xmlrpc 2012-06-20 06:27:20 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.

http://rhn.redhat.com/errata/RHSA-2012-0748.html

Comment 23 Yaniv Kaul 2012-12-04 14:54:04 UTC
Why isn't it adding +x2apic?

Comment 24 Jiri Denemark 2012-12-04 17:33:45 UTC
Well, with <cpu mode='host-passthrough'/> libvirt is supposed to call qemu-kvm with -cpu host and it's up to qemu-kvm to decide what the guest CPU should look like.

Comment 25 Doron Fediuck 2012-12-04 17:51:23 UTC
(In reply to comment #23)
> Why isn't it adding +x2apic?

Yaniv, IIUC x2apic is a specific flag of the cpu, which may / may not be exposed by the host processor. So this will work even with host-passthrough if all hosts have the same processor capabilities.

See also: http://www.linux-kvm.org/page/Tuning_KVM

Comment 26 Yaniv Kaul 2012-12-04 17:52:54 UTC
(In reply to comment #25)
> (In reply to comment #23)
> > Why isn't it adding +x2apic?
> 
> Yaniv, IIUC x2apic is a specific flag of the cpu, which may / may not be
> exposed by the host processor. So this will work even with host-passthrough
> if all hosts have the same processor capabilities.
> 
> See also: http://www.linux-kvm.org/page/Tuning_KVM

That's not true, x2apic is emulated by KVM. Even if the host doesn't have it, it's worth (for linux guests) to have it.

Comment 27 Doron Fediuck 2012-12-04 17:56:08 UTC
(In reply to comment #26)
> (In reply to comment #25)
> > (In reply to comment #23)
> > > Why isn't it adding +x2apic?

> > See also: http://www.linux-kvm.org/page/Tuning_KVM
> 
> That's not true, x2apic is emulated by KVM. Even if the host doesn't have
> it, it's worth (for linux guests) to have it.

In this case it cannot work together, as host-passthrough exposes flags which kvm does not support / aware of. So it cannot maintain compatibility when using flags kvm does not support.

Comment 28 Yaniv Kaul 2012-12-04 21:56:07 UTC
(In reply to comment #27)
> (In reply to comment #26)
> > (In reply to comment #25)
> > > (In reply to comment #23)
> > > > Why isn't it adding +x2apic?
> 
> > > See also: http://www.linux-kvm.org/page/Tuning_KVM
> > 
> > That's not true, x2apic is emulated by KVM. Even if the host doesn't have
> > it, it's worth (for linux guests) to have it.
> 
> In this case it cannot work together, as host-passthrough exposes flags
> which kvm does not support / aware of. So it cannot maintain compatibility
> when using flags kvm does not support.

Of course KVM supports it. I would not have recommended it otherwise.
It has nothing to do with the host, it's emulated by KVM (see http://patchwork.ozlabs.org/patch/98478/).

It's probably a libvirt bug (RFE?) to add it to the host delivered flags, unconditionally (pending the kvm version?).


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