From 13fd6e4045e436964d466312b3de673c41202c96 Mon Sep 17 00:00:00 2001 From: Sven Anderson Date: Thu, 10 Nov 2016 18:16:02 +0100 Subject: [PATCH] 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 --- manifests/compute/libvirt.pp | 6 ++++++ ..._libvirt_hw_machine_type_parameter-a385e959c6aea16d.yaml | 5 +++++ spec/classes/nova_compute_libvirt_spec.rb | 2 ++ 3 files changed, 13 insertions(+) create mode 100644 releasenotes/notes/add_libvirt_hw_machine_type_parameter-a385e959c6aea16d.yaml diff --git a/manifests/compute/libvirt.pp b/manifests/compute/libvirt.pp index ba28c0a96..abcd75d93 100644 --- a/manifests/compute/libvirt.pp +++ b/manifests/compute/libvirt.pp @@ -45,6 +45,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 @@ -113,6 +117,7 @@ class nova::compute::libvirt ( $libvirt_cpu_model = undef, $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, @@ -189,6 +194,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 diff --git a/releasenotes/notes/add_libvirt_hw_machine_type_parameter-a385e959c6aea16d.yaml b/releasenotes/notes/add_libvirt_hw_machine_type_parameter-a385e959c6aea16d.yaml new file mode 100644 index 000000000..d762c60da --- /dev/null +++ b/releasenotes/notes/add_libvirt_hw_machine_type_parameter-a385e959c6aea16d.yaml @@ -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 diff --git a/spec/classes/nova_compute_libvirt_spec.rb b/spec/classes/nova_compute_libvirt_spec.rb index 1e6b2d77f..78826f0e6 100644 --- a/spec/classes/nova_compute_libvirt_spec.rb +++ b/spec/classes/nova_compute_libvirt_spec.rb @@ -68,6 +68,7 @@ describe 'nova::compute::libvirt' do :libvirt_cpu_model => 'kvm64', :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, @@ -88,6 +89,7 @@ describe 'nova::compute::libvirt' do it { is_expected.to contain_nova_config('libvirt/cpu_model').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)}