Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add the ability to configure the CPU model exposed to KVM virtual machines. #756

Closed
OpenNebulaProject opened this issue Nov 20, 2017 · 3 comments

Comments

@OpenNebulaProject
Copy link


Author Name: Vladislav Gorbunov (Vladislav Gorbunov)
Original Redmine Issue: 2869, https://dev.opennebula.org/issues/2869
Original Date: 2014-05-06


One of the most important missing features was the ability to configure the CPU model exposed to KVM virtual machines. There are a couple of reasons for wanting to specify the CPU model

  • To maximise performance of virtual machines by exposing new host CPU features to the guest
  • To ensure a consistent default CPU across all machines, removing reliance of variable QEMU defaults.
    In libvirt, the CPU is specified by providing a base CPU model name (which is a shorthand for a set of feature flags), a set of additional feature flags, and the topology (sockets/cores/threads). The libvirt KVM driver provides a number of standard CPU model names (defined in /usr/share/libvirt/cpu_map.xml):
    "486", "pentium", "pentium2", "pentiumpro", "coreduo", "n270", "pentiumpro", "qemu32", "kvm32", "cpu64-rhel5", "cpu64-rhel5", "kvm64", "pentiumpro", "Conroe" "Penryn", "Nehalem", "Westmere", "pentiumpro", "cpu64-rhel5", "cpu64-rhel5", "Opteron_G1", "Opteron_G2", "Opteron_G3, "Opteron_G4"
    It is also possible to request the host CPU model in two ways
  • "host-model" - this causes libvirt to identify the named CPU model which most closely matches the host from the above list, and then request additional CPU flags to complete the match. This should give close to maximum functionality/performance, which maintaining good reliability/compatibility if the guest is migrated to another host with slightly different host CPUs.
  • "host-passthrough" - this causes libvirt to tell KVM to passthrough the host CPU with no modifications. The difference to host-model, instead of just matching feature flags, every last detail of the host CPU is matched. This gives absolutely best performance, and can be important to some apps which check low level CPU details. The guest can only be migrated to an exactly matching host CPU.

This path is add CPUMODEL support:
OS = [ CPUMODEL="host" ] for host-passthrough
or for example
OS = [ CPUMODEL="core2duo" ] for custom CPU model. Full list of supported cpu shown by the command:
kvm -cpu ?

@OpenNebulaProject
Copy link
Author


Original Redmine Comment
Author Name: Ruben S. Montero (@rsmontero)
Original Date: 2014-05-06T09:18:36Z


Thanks for the patch! :) Scheduling this 4.8

@OpenNebulaProject
Copy link
Author


Original Redmine Comment
Author Name: Eugene W (Eugene W)
Original Date: 2015-07-19T16:26:54Z


Is it working now in OpenNebula 4.12?

I tried to add

OS       = [ boot = "hd", arch = "x86_64", CPUMODEL="host", machine = "q35" ]

``` into 

/etc/one/vmm_exec_kvm.conf


But it is can not help (I tried make a new template).

@OpenNebulaProject
Copy link
Author


Original Redmine Comment
Author Name: Eugene W (Eugene W)
Original Date: 2015-07-19T16:59:54Z


Have found solution for CPU host-passthrough.

If need to to expose the underlying physical CPU to the virtual machine.

To do this, you need to modify your VM’s template to include the following raw attributes:

RAW=[ DATA="<cpu mode='host-passthrough'/>", TYPE="kvm" ]

You can add these attributes by following these steps:

  1. Choose your VM template
  2. Click on ‘UPDATE’
  3. Click on ‘Other’
  4. From the ‘RAW data’ dropdown menu, choose ‘KVM’
  5. In the DATA text box, insert:
"<cpu mode='host-passthrough'/>"

@rsmontero rsmontero added this to the Release 5.6 milestone Jan 10, 2018
rsmontero added a commit that referenced this issue Jan 12, 2018
  - new kvm monitor probe to gather model and machine types from hosts
  - generate cpu element in deployment file
abelCoronado93 pushed a commit to abelCoronado93/one that referenced this issue Jan 16, 2018
abelCoronado93 pushed a commit to abelCoronado93/one that referenced this issue Jan 16, 2018
abelCoronado93 pushed a commit to abelCoronado93/one that referenced this issue Jan 16, 2018
abelCoronado93 pushed a commit to abelCoronado93/one that referenced this issue Jan 16, 2018
abelCoronado93 pushed a commit to abelCoronado93/one that referenced this issue Jan 16, 2018
abelCoronado93 pushed a commit that referenced this issue Jan 16, 2018
rsmontero added a commit that referenced this issue Jan 18, 2018
* F #756: Add support for CPU_MODEL.
  - new kvm monitor probe to gather model and machine types from hosts
  - generate cpu element in deployment file

* F #756: Added machine-models to install.sh

* F #756: Rename 'OS Booting' to 'OS & CPU'

* F #756: Rename 'libvirt machine' to 'machine type'

* F #756: Change 'machine type' to a drop-down

* F #756: KVM IM machines probe prioritize kvm/kqemu/qemu domain types

* F #756: Added CPU Model section
rsmontero added a commit that referenced this issue Jan 18, 2018
* F #756: Add support for CPU_MODEL.
  - new kvm monitor probe to gather model and machine types from hosts
  - generate cpu element in deployment file

* F #756: Added machine-models to install.sh

* F #756: Rename 'OS Booting' to 'OS & CPU'

* F #756: Rename 'libvirt machine' to 'machine type'

* F #756: Change 'machine type' to a drop-down

* F #756: KVM IM machines probe prioritize kvm/kqemu/qemu domain types

* F #756: Added CPU Model section
@rsmontero rsmontero removed this from the Release 5.6 milestone Jan 18, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants