OpenStack Compute (Nova)

support to Nova to allow exposing specific CPU models to the guest, including the host CPU native model.

Reported by William Herry on 2012-05-23
12
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack Compute (nova)
Wishlist
Daniel Berrange

Bug Description

I can't find the libvirt.xml.template file In the latest Nova GIT, which I make a little change to make my vm shows reall cpu info rather than QEMU, It would be very nice to add this feture as a config option to nova

Daniel Berrange (berrange) wrote :

There are a few aspects to this bug, with this page giving the important background information

 http://berrange.com/posts/2010/02/15/guest-cpu-model-configuration-in-libvirt-with-qemukvm/

At a minimum we need the ability to configure a guest CPU model, with a host level config option. This would be sufficient if we make it the admin's responsibility to configure all hosts the same way, or disallow migration. If we want to support migration, we need code so that nova can determine suitable hosts to migrate to. If we want to allow per-guest choice of CPU model, then the initial guest placement code will need to analyse compatibility when scheduling guests on nodes.

Pádraig Brady (p-draigbrady) wrote :

I notice this related change https://review.openstack.org/#/c/8267/

Changed in nova:
importance: Undecided → Wishlist
status: New → Confirmed

Fix proposed to branch: master
Review: https://review.openstack.org/8526

Changed in nova:
assignee: nobody → Daniel Berrange (berrange)
status: Confirmed → In Progress

Fix proposed to branch: master
Review: https://review.openstack.org/8527

Fix proposed to branch: master
Review: https://review.openstack.org/8528

Fix proposed to branch: master
Review: https://review.openstack.org/8694

Fix proposed to branch: master
Review: https://review.openstack.org/8695

Fix proposed to branch: master
Review: https://review.openstack.org/8696

Reviewed: https://review.openstack.org/8526
Committed: http://github.com/openstack/nova/commit/bcc04993fe8fbeb374cacf990105270579a530c2
Submitter: Jenkins
Branch: master

commit bcc04993fe8fbeb374cacf990105270579a530c2
Author: Daniel P. Berrange <email address hidden>
Date: Wed Jun 13 16:34:06 2012 +0100

    Refactor libvirt config classes for representing CPU models/features

    The previously added (but not used) LibvirtConfigCPUTest class
    was too inflexible. It did not distinguish between parts of the
    XML schema which applied to both capabilities & domain XML,
    vs those which only applied to the domain XML. By representing
    features as a plain string it did not allow for setting attributes
    on feature flags like policy. This change replaces the single
    LibvirtConfigCPUTest class with 4 new classes:

     - LibvirtConfigCPUFeature - base class for defining CPU features
     - LibvirtConfigCPU - base class for defining CPU models
     - LibvirtConfigGuestCPUFeature - extension for setting the guest
       specific feature policy
     - LibvirtConfigGuestCPU - extension for setting the guest specific
       match policy, and allowing use of host CPU model passthrough

    Fixes: bug #1003373
    Implements: blueprint libvirt-xml-cpu-model
    Change-Id: I0aa0ddfb86cf8b89b2e4dcc95e21bdca304bd6b3
    Signed-off-by: Daniel P. Berrange <email address hidden>

Changed in nova:
status: In Progress → Fix Committed

Reviewed: https://review.openstack.org/8694
Committed: http://github.com/openstack/nova/commit/272407be59a9de094fa73a557d0823adf03b506b
Submitter: Jenkins
Branch: master

commit 272407be59a9de094fa73a557d0823adf03b506b
Author: Daniel P. Berrange <email address hidden>
Date: Tue Jun 19 14:27:49 2012 +0100

    Add libvirt config classes for handling capabilities XML doc

    Libvirt exposes the host/hypervisor features using an XML
    schema known as "capabilities". Currently the libvirt driver
    code just parses this in an adhoc manner using xpath queries.

    This change provides a handful of classes LibvirtConfigCaps,
    LibvirtConfigCapsHost and LibvirtConfigCapsGuest for maintaining
    an object based representation of the capabilities. The
    LibvirtConfigCapsHost class also uses the existing LibvirtConfigCPU
    class

    Fixes: bug #1003373
    Implements: blueprint libvirt-xml-cpu-model
    Change-Id: Ie962c6378b0da09eddc75983d4824a226ed1c25e
    Signed-off-by: Daniel P. Berrange <email address hidden>

Fix proposed to branch: master
Review: https://review.openstack.org/9117

Changed in nova:
status: Fix Committed → In Progress

Reviewed: https://review.openstack.org/8695
Committed: http://github.com/openstack/nova/commit/b4abb92b815988a4700313274ac7182f374a2286
Submitter: Jenkins
Branch: master

commit b4abb92b815988a4700313274ac7182f374a2286
Author: Daniel P. Berrange <email address hidden>
Date: Tue Jun 19 14:34:03 2012 +0100

    Switch libvirt get_cpu_info method over to use config APIs

    The get_cpu_info method in the libvirt driver currently uses
    XPath queries to extract information from the capabilities
    XML document. Switch this over to use the new config class
    LibvirtConfigCaps. Also provide a test case to validate
    the data being returned

    Fixes: bug #1003373
    Implements: blueprint libvirt-xml-cpu-model
    Change-Id: I4946a16d27f712ae2adf8441ce78e6c0bb0bb657
    Signed-off-by: Daniel P. Berrange <email address hidden>

Changed in nova:
status: In Progress → Fix Committed

Reviewed: https://review.openstack.org/8527
Committed: http://github.com/openstack/nova/commit/4f4ffc91a8fc28b273660837593d925aa6892efb
Submitter: Jenkins
Branch: master

commit 4f4ffc91a8fc28b273660837593d925aa6892efb
Author: Daniel P. Berrange <email address hidden>
Date: Wed Jun 13 17:57:03 2012 +0100

    Allow specification of the libvirt guest CPU model per host

    Currently Nova does not configure any CPU model for libvirt
    guests. This is sub-optimal because the default KVM CPU
    model has changed a number of times, and more importantly
    VMs are not able to take advantage of many performance
    features in newer CPUs. To get a consistent CPU model exposed
    to the guest and maximize performance of VMs in the cloud,
    explicit specification of CPU models per host is desirable.

    This change adds a new Nova config flag:

      libvirt_cpu_mode = host-model|host-passthrough|custom

    Where

      * host-model == configure a model that matches the features
                      available in the host CPU

      * host-passthrough == passthrough the host CPU precisely
                            with no change at all

      * custom == configure a specific named CPU model

    If the 'custom' mode is used, then the additional flag
    is available to choose the model:

      libvirt_cpu_model = <one of the names from /usr/share/libvirt/cpu_model.xml>

    eg

      libvirt_cpu_model = core2duo

    If specifying a custom CPU model, it is wise to choose one that is
    capable of running on all the various different Nova hosts in the
    cloud. That said, libvirt will enforce compatibility at time of
    starting or migrating guests & refuse the operation if required.

    If using either the host-model or host-passthrough modes, and use
    of live migration is desired, admins should ensure that all hosts
    have a homogeneous CPU model. If hosts have a hetergeneous CPU
    models, then a custom named CPU model is a better choice

    This configuration only works for libvirt >= 0.9.10, due to the
    use of the 'mode' attribute on the <cpu> element for configuring
    host models.

    Fixes: bug #1003373
    Implements: blueprint libvirt-xml-cpu-model
    Change-Id: I90ce78d7e29bd0d563e3bc547b7cc5d64dd9496e
    Signed-off-by: Daniel P. Berrange <email address hidden>

Changed in nova:
status: Fix Committed → In Progress

Reviewed: https://review.openstack.org/8696
Committed: http://github.com/openstack/nova/commit/2a236d24a84875ee17df427ed90457414aaa9149
Submitter: Jenkins
Branch: master

commit 2a236d24a84875ee17df427ed90457414aaa9149
Author: Daniel P. Berrange <email address hidden>
Date: Tue Jun 19 14:42:59 2012 +0100

    Add compatibility for CPU model config with libvirt < 0.9.10

    Libvirt versions prior to 0.9.10 do not support the simpler
    'mode' attribute for choosing CPU model. So with such libvirt
    releases we must explicitly construct the guest CPU model
    from the host capabilities info when mode=host-model. We
    can not support mode=host-passthrough at all with these
    earlier libvirt versions

    This change can be reverted in the future, if the value of
    the MIN_LIBVIRT_VERSION constant is increased to 0.9.10
    or later

    Fixes: bug #1003373
    Implements: blueprint libvirt-xml-cpu-model
    Change-Id: I3e55ffccf38be18454f810efeb5c201aab94ddb0
    Signed-off-by: Daniel P. Berrange <email address hidden>

Changed in nova:
status: In Progress → Fix Committed
Changed in nova:
status: Fix Committed → In Progress

Reviewed: https://review.openstack.org/9117
Committed: http://github.com/openstack/nova/commit/9698a45a308f54865811e67498e8f0500c8187f2
Submitter: Jenkins
Branch: master

commit 9698a45a308f54865811e67498e8f0500c8187f2
Author: Daniel P. Berrange <email address hidden>
Date: Thu Jun 28 12:35:04 2012 +0100

    Set the default CPU mode to 'host-model' for Libvirt KVM/QEMU guests

    Historically Nova has not set any CPU model for guests started with
    the libvirt driver. This means they are all using the per-hyervisor
    default settings for CPU model. With KVM/QEMU guests the model was
    traditionally a very conserative choice which exposed minimal features.
    This is significantly limits the performance of applications. Further
    the model has changed over time, so the exact default model is
    unpredictable. Switching Nova to use the host CPU model by default
    should improve the out of the box performance & give a known
    setup.

    This does not impact migration compatibility, since the migration
    code is already doing comparison checks against the source and
    destination host CPU model, regardless of the actual model used
    in the guest. In the future the migration code should be tweaked
    so that it actually compares the current guest CPU model, against
    the target host CPU model, which would potentially broaden the
    migration compatibility pool.

    With this patch there is a new libvirt_cpu_mode="none" which
    can be used to explicitly prevent any CPU model setting in the
    instance XML. The default value None, will now default to
    "none" for LXC/UML/etc, and "host-model" for QEMU/KVM

    Fixes: bug #1003373
    Implements: blueprint libvirt-xml-cpu-model
    Change-Id: I5b96e4532b6a960e1608dd6e19ae9d194379fb6a
    Signed-off-by: Daniel P. Berrange <email address hidden>

Changed in nova:
status: In Progress → Fix Committed
Thierry Carrez (ttx) on 2012-08-16
Changed in nova:
milestone: none → folsom-3
status: Fix Committed → Fix Released
Thierry Carrez (ttx) on 2012-09-27
Changed in nova:
milestone: folsom-3 → 2012.2
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers