Expose libvirt/hw_machine_type for consistent machine types.

The libvirt driver currently does not set the machine type for a KVM
guest by default.  When not specified, libvirt will use the newest
one it knows about.  Unfortunately, that can result in live
migrations failing if your environment is using different versions of
the host OS on compute nodes as the destination node may not be able
to support the machine type used when the VM was originally started.

Change-Id: I269ade8997389fc56ce3009fbd0660d1a47a0c4a
(cherry picked from commit 13fd6e4045)
This commit is contained in:
Sven Anderson 2016-11-10 18:16:02 +01:00 committed by Oliver Walsh
parent e3fe6dc353
commit efd92e909d
3 changed files with 13 additions and 0 deletions

View File

@ -50,6 +50,10 @@
# Qemu1.5 (raw format) Qemu1.6(qcow2 format).
# Defaults to $::os_service_default
#
# [*libvirt_hw_machine_type*]
# (optional) Option to specify a default machine type per host architecture.
# Defaults to $::os_service_default
#
# [*libvirt_inject_password*]
# (optional) Inject the admin password at boot time, without an agent.
# Defaults to false
@ -119,6 +123,7 @@ class nova::compute::libvirt (
$libvirt_snapshot_image_format = $::os_service_default,
$libvirt_disk_cachemodes = [],
$libvirt_hw_disk_discard = $::os_service_default,
$libvirt_hw_machine_type = $::os_service_default,
$libvirt_inject_password = false,
$libvirt_inject_key = false,
$libvirt_inject_partition = -2,
@ -192,6 +197,7 @@ class nova::compute::libvirt (
'libvirt/inject_key': value => $libvirt_inject_key;
'libvirt/inject_partition': value => $libvirt_inject_partition;
'libvirt/hw_disk_discard': value => $libvirt_hw_disk_discard;
'libvirt/hw_machine_type': value => $libvirt_hw_machine_type;
}
# cpu_model param is only valid if cpu_mode=custom

View File

@ -0,0 +1,5 @@
---
features:
- Add libvirt_hw_machine_type parameter to
nova::compute::libvirt to allow setting the
libvirt/hw_machine_type option in nova.conf

View File

@ -70,6 +70,7 @@ describe 'nova::compute::libvirt' do
:libvirt_snapshot_image_format => 'raw',
:libvirt_disk_cachemodes => ['file=directsync','block=none'],
:libvirt_hw_disk_discard => 'unmap',
:libvirt_hw_machine_type => 'x86_64=machinetype1,armv7l=machinetype2',
:remove_unused_base_images => true,
:remove_unused_resized_minimum_age_seconds => 3600,
:remove_unused_original_minimum_age_seconds => 3600,
@ -91,6 +92,7 @@ describe 'nova::compute::libvirt' do
it { is_expected.to contain_nova_config('libvirt/snapshot_image_format').with_ensure('absent')}
it { is_expected.to contain_nova_config('libvirt/disk_cachemodes').with_value('file=directsync,block=none')}
it { is_expected.to contain_nova_config('libvirt/hw_disk_discard').with_value('unmap')}
it { is_expected.to contain_nova_config('libvirt/hw_machine_type').with_value('x86_64=machinetype1,armv7l=machinetype2')}
it { is_expected.to contain_nova_config('vnc/vncserver_listen').with_value('0.0.0.0')}
it { is_expected.to contain_nova_config('DEFAULT/remove_unused_base_images').with_value(true)}
it { is_expected.to contain_nova_config('DEFAULT/remove_unused_original_minimum_age_seconds').with_value(3600)}