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 <berrange@redhat.com>
This commit is contained in:
Daniel P. Berrange
2012-06-28 12:35:04 +01:00
parent 818c23d32c
commit dd3f899fbe

View File

@@ -608,6 +608,52 @@ class LibvirtConnTestCase(test.TestCase):
self.assertEquals(cfg.devices[3].target_dev, 'vdd')
def test_get_guest_cpu_config_none(self):
self.flags(libvirt_cpu_mode="none")
conn = libvirt_driver.LibvirtDriver(True)
instance_ref = db.instance_create(self.context, self.test_instance)
conf = conn.get_guest_config(instance_ref,
_fake_network_info(self.stubs, 1),
None, None)
self.assertEquals(conf.cpu, None)
def test_get_guest_cpu_config_default_kvm(self):
self.flags(libvirt_type="kvm",
libvirt_cpu_mode=None)
def get_lib_version_stub(self):
return (0 * 1000 * 1000) + (9 * 1000) + 11
self.stubs.Set(libvirt.virConnect,
"getLibVersion",
get_lib_version_stub)
conn = libvirt_driver.LibvirtDriver(True)
instance_ref = db.instance_create(self.context, self.test_instance)
conf = conn.get_guest_config(instance_ref,
_fake_network_info(self.stubs, 1),
None, None)
self.assertEquals(type(conf.cpu),
config.LibvirtConfigGuestCPU)
self.assertEquals(conf.cpu.mode, "host-model")
self.assertEquals(conf.cpu.model, None)
def test_get_guest_cpu_config_default_uml(self):
self.flags(libvirt_type="uml",
libvirt_cpu_mode=None)
conn = libvirt_driver.LibvirtDriver(True)
instance_ref = db.instance_create(self.context, self.test_instance)
conf = conn.get_guest_config(instance_ref,
_fake_network_info(self.stubs, 1),
None, None)
self.assertEquals(conf.cpu, None)
def test_get_guest_cpu_config_default_lxc(self):
self.flags(libvirt_type="lxc",
libvirt_cpu_mode=None)
conn = libvirt_driver.LibvirtDriver(True)
instance_ref = db.instance_create(self.context, self.test_instance)