diff --git a/manifests/compute/libvirt.pp b/manifests/compute/libvirt.pp index 365c8597c..dd5675114 100644 --- a/manifests/compute/libvirt.pp +++ b/manifests/compute/libvirt.pp @@ -298,6 +298,9 @@ class nova::compute::libvirt ( } } } else { + if $cpu_mode != 'none' and !($virt_type in ['qemu', 'kvm']) { + fail("\$virt_type = \"${virt_type}\" supports only \$cpu_mode = \"none\"") + } $cpu_mode_real = $cpu_mode } diff --git a/spec/classes/nova_compute_libvirt_spec.rb b/spec/classes/nova_compute_libvirt_spec.rb index a2d3e2acf..7f41bb372 100644 --- a/spec/classes/nova_compute_libvirt_spec.rb +++ b/spec/classes/nova_compute_libvirt_spec.rb @@ -164,6 +164,17 @@ describe 'nova::compute::libvirt' do it { is_expected.to contain_nova_config('libvirt/cpu_model_extra_flags').with_value('pcid')} end + context 'with cpu_mode and non qemu/kvm virt_type' do + let :params do + { + :cpu_mode => 'host-passthrough', + :virt_type => 'lxc', + } + end + + it { should raise_error(Puppet::Error, /\$virt_type = "lxc" supports only \$cpu_mode = "none"/) } + end + context 'with non-custom cpu_node and cpu_models' do let :params do { :cpu_models => ['kvm64', 'qemu64'] }