From 554d7b1ce01adac9f8dc0e08ad4b05e000bf9e79 Mon Sep 17 00:00:00 2001 From: Takashi Kajinami Date: Thu, 11 Jul 2024 13:21:09 +0900 Subject: [PATCH] Reject customized cpu_mode for unsupported virt_type Using cpu_mode other than 'none' is supported only when virt_type is qemu or kvm and nova-compute fails to start in case an unsupported combination is used. Enforce this requirement during deployment to make the invalid configuration more visible. Change-Id: If9fc59797c4a24a3b7536cd3fe8770316fdf4f4d --- manifests/compute/libvirt.pp | 3 +++ spec/classes/nova_compute_libvirt_spec.rb | 11 +++++++++++ 2 files changed, 14 insertions(+) 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'] }