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:
parent
4bbb9cfde2
commit
9698a45a30
@ -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)
|
||||
|
||||
|
@ -168,9 +168,11 @@ libvirt_opts = [
|
||||
cfg.StrOpt('libvirt_cpu_mode',
|
||||
default=None,
|
||||
help='Set to "host-model" to clone the host CPU feature flags; '
|
||||
'to "host-passthrough" to use the host CPU model '
|
||||
'exactly; or to "custom" to use a named CPU model. Only '
|
||||
'has effect if libvirt_type="kvm|qemu"'),
|
||||
'to "host-passthrough" to use the host CPU model exactly; '
|
||||
'to "custom" to use a named CPU model; '
|
||||
'to "none" to not set any CPU model. '
|
||||
'If libvirt_type="kvm|qemu", it will default to '
|
||||
'"host-model", otherwise it will default to "none"'),
|
||||
cfg.StrOpt('libvirt_cpu_model',
|
||||
default=None,
|
||||
help='Set to a named libvirt CPU model (see names listed '
|
||||
@ -1504,6 +1506,12 @@ class LibvirtDriver(driver.ComputeDriver):
|
||||
model = FLAGS.libvirt_cpu_model
|
||||
|
||||
if mode is None:
|
||||
if FLAGS.libvirt_type == "kvm" or FLAGS.libvirt_type == "qemu":
|
||||
mode = "host-model"
|
||||
else:
|
||||
mode = "none"
|
||||
|
||||
if mode == "none":
|
||||
return None
|
||||
|
||||
if FLAGS.libvirt_type != "kvm" and FLAGS.libvirt_type != "qemu":
|
||||
|
Loading…
Reference in New Issue
Block a user