Use consistent default cpu_mode when virt_type is qemu

Nova uses host-model cpu mode when virt_type is qemu, unless users
gives a specific value. This updates the logic to define the default
value so that the default value selected when virt_type is qemu becomes
consistent with nova.

Change-Id: Iedaefc3c3c1150205ced29fd30adf7cdcb365001
This commit is contained in:
Takashi Kajinami
2023-11-01 12:29:27 +09:00
parent 29378852ad
commit 4bb2704179
2 changed files with 16 additions and 9 deletions

View File

@@ -24,7 +24,7 @@
# [*cpu_mode*] # [*cpu_mode*]
# (optional) The libvirt CPU mode to configure. Possible values # (optional) The libvirt CPU mode to configure. Possible values
# include custom, host-model, none, host-passthrough. # include custom, host-model, none, host-passthrough.
# Defaults to 'host-model' if virt_type is set to kvm, # Defaults to 'host-model' if virt_type is set to qemu or kvm,
# otherwise defaults to 'none'. # otherwise defaults to 'none'.
# #
# [*cpu_models*] # [*cpu_models*]
@@ -238,7 +238,7 @@ class nova::compute::libvirt (
$virt_type = 'kvm', $virt_type = 'kvm',
$vncserver_listen = '127.0.0.1', $vncserver_listen = '127.0.0.1',
Boolean $migration_support = false, Boolean $migration_support = false,
$cpu_mode = false, $cpu_mode = undef,
Array[String[1]] $cpu_models = [], Array[String[1]] $cpu_models = [],
$cpu_model_extra_flags = undef, $cpu_model_extra_flags = undef,
$cpu_power_management = $facts['os_service_default'], $cpu_power_management = $facts['os_service_default'],
@@ -287,15 +287,15 @@ class nova::compute::libvirt (
# cpu_mode has different defaults depending on hypervisor. # cpu_mode has different defaults depending on hypervisor.
if !$cpu_mode { if !$cpu_mode {
case $virt_type { case $virt_type {
'kvm': { 'qemu', 'kvm': {
$cpu_mode_default = 'host-model' $cpu_mode_real = 'host-model'
} }
default: { default: {
$cpu_mode_default = 'none' $cpu_mode_real = 'none'
} }
} }
} else { } else {
$cpu_mode_default = $cpu_mode $cpu_mode_real = $cpu_mode
} }
if($facts['os']['family'] == 'Debian') { if($facts['os']['family'] == 'Debian') {
@@ -355,7 +355,7 @@ class nova::compute::libvirt (
'DEFAULT/preallocate_images': value => $preallocate_images; 'DEFAULT/preallocate_images': value => $preallocate_images;
'vnc/server_listen': value => $vncserver_listen; 'vnc/server_listen': value => $vncserver_listen;
'libvirt/virt_type': value => $virt_type; 'libvirt/virt_type': value => $virt_type;
'libvirt/cpu_mode': value => $cpu_mode_default; 'libvirt/cpu_mode': value => $cpu_mode_real;
'libvirt/cpu_power_management': value => $cpu_power_management; 'libvirt/cpu_power_management': value => $cpu_power_management;
'libvirt/cpu_power_management_strategy': value => $cpu_power_management_strategy; 'libvirt/cpu_power_management_strategy': value => $cpu_power_management_strategy;
'libvirt/cpu_power_governor_low': value => $cpu_power_governor_low; 'libvirt/cpu_power_governor_low': value => $cpu_power_governor_low;
@@ -391,7 +391,7 @@ class nova::compute::libvirt (
# cpu_model param is only valid if cpu_mode=custom # cpu_model param is only valid if cpu_mode=custom
# otherwise it should be commented out # otherwise it should be commented out
if $cpu_mode_default == 'custom' and !empty($cpu_models){ if $cpu_mode_real == 'custom' and !empty($cpu_models){
$cpu_models_real = join($cpu_models, ',') $cpu_models_real = join($cpu_models, ',')
} else { } else {
if !empty($cpu_models) { if !empty($cpu_models) {
@@ -405,7 +405,7 @@ class nova::compute::libvirt (
# cpu_model_extra_flags is only valid if cpu_mode!=none # cpu_model_extra_flags is only valid if cpu_mode!=none
# otherwise it should be commented out # otherwise it should be commented out
if $cpu_mode_default != 'none' and $cpu_model_extra_flags { if $cpu_mode_real != 'none' and $cpu_model_extra_flags {
$cpu_model_extra_flags_real = join(any2array($cpu_model_extra_flags), ',') $cpu_model_extra_flags_real = join(any2array($cpu_model_extra_flags), ',')
} else { } else {
if $cpu_model_extra_flags { if $cpu_model_extra_flags {

View File

@@ -0,0 +1,7 @@
---
upgrade:
- |
The ``[libvirt] cpu_mode`` option is set to ``host-model`` by default when
qemu virt type is used, which is consistent with the default selected by
nova. Set the ``nova::compute::libvirt::cpu_mode`` parameter to use
a different mode such as the previous default (``none``).