Fixes aarch64 incorrect cpu model

(cherry picked from commit e2cf0dc3027f86cb51f01a5a3be8aea97f83ecf3)
This commit is contained in:
huangtianhua 2021-11-29 03:49:31 +00:00 committed by openeuler-sync-bot
parent 8e02afd34d
commit c0e8883de7
2 changed files with 98 additions and 1 deletions

View File

@ -0,0 +1,93 @@
diff --git a/nova/virt/libvirt/driver.py b/nova/virt/libvirt/driver.py
index f51463f..94d9982 100644
--- a/nova/virt/libvirt/driver.py
+++ b/nova/virt/libvirt/driver.py
@@ -789,12 +789,6 @@ class LibvirtDriver(driver.ComputeDriver):
cpu = vconfig.LibvirtConfigGuestCPU()
for model in models:
cpu.model = self._get_cpu_model_mapping(model)
- if not cpu.model:
- msg = (_("Configured CPU model: %(model)s is not correct, "
- "or your host CPU arch does not suuport this "
- "model. Please correct your config and try "
- "again.") % {'model': model})
- raise exception.InvalidCPUInfo(msg)
try:
self._compare_cpu(cpu, self._get_cpu_info(), None)
except exception.InvalidCPUInfo as e:
@@ -4323,11 +4317,27 @@ class LibvirtDriver(driver.ComputeDriver):
:return: Case-sensitive CPU model name, or None(Only when configured
CPU model name not correct)
"""
+ cpu_info = self._get_cpu_info()
+ if cpu_info['arch'] not in (fields.Architecture.I686,
+ fields.Architecture.X86_64,
+ fields.Architecture.PPC64,
+ fields.Architecture.PPC64LE,
+ fields.Architecture.PPC):
+ return model
+
if not self.cpu_models_mapping:
cpu_models = self._host.get_cpu_model_names()
for cpu_model in cpu_models:
self.cpu_models_mapping[cpu_model.lower()] = cpu_model
- return self.cpu_models_mapping.get(model.lower(), None)
+
+ if model.lower() not in self.cpu_models_mapping:
+ msg = (_("Configured CPU model: %(model)s is not correct, "
+ "or your host CPU arch does not support this "
+ "model. Please correct your config and try "
+ "again.") % {'model': model})
+ raise exception.InvalidCPUInfo(msg)
+
+ return self.cpu_models_mapping.get(model.lower())
def _get_guest_cpu_model_config(self, flavor=None):
mode = CONF.libvirt.cpu_mode
@@ -4338,8 +4348,8 @@ class LibvirtDriver(driver.ComputeDriver):
if (CONF.libvirt.virt_type == "kvm" or
CONF.libvirt.virt_type == "qemu"):
+ caps = self._host.get_capabilities()
if mode is None:
- caps = self._host.get_capabilities()
# AArch64 lacks 'host-model' support because neither libvirt
# nor QEMU are able to tell what the host CPU model exactly is.
# And there is no CPU description code for ARM(64) at this
@@ -4358,6 +4368,12 @@ class LibvirtDriver(driver.ComputeDriver):
mode = "host-model"
if mode == "none":
return vconfig.LibvirtConfigGuestCPU()
+ # On AArch64 platform the return of _get_cpu_model_mapping will not
+ # return the default CPU model.
+ if mode == "custom":
+ if arch == fields.Architecture.AARCH64:
+ if not models:
+ models = ['max']
else:
if mode is None or mode == "none":
return None
@@ -10618,6 +10634,10 @@ class LibvirtDriver(driver.ComputeDriver):
else:
models = [self._get_cpu_model_mapping(model)
for model in CONF.libvirt.cpu_models]
+ # Aarch64 platform doesn't return the default CPU models
+ if caps.host.cpu.arch == fields.Architecture.AARCH64:
+ if not models:
+ models = ['max']
# For custom mode, iterate through cpu models
for model in models:
caps.host.cpu.model = model
diff --git a/nova/virt/libvirt/utils.py b/nova/virt/libvirt/utils.py
index 0c04833..5809b1c 100644
--- a/nova/virt/libvirt/utils.py
+++ b/nova/virt/libvirt/utils.py
@@ -537,6 +537,8 @@ def get_cpu_model_from_arch(arch):
mode = 'qemu32'
elif arch == obj_fields.Architecture.PPC64LE:
mode = 'POWER8'
+ elif arch == obj_fields.Architecture.AARCH64:
+ mode = 'max'
return mode

View File

@ -15,7 +15,7 @@ Name: openstack-nova
# Liberty semver reset
# https://review.openstack.org/#/q/I6a35fa0dda798fad93b804d00a46af80f08d475c,n,z
Version: 20.6.1
Release: 3
Release: 4
Summary: OpenStack Compute (nova)
License: ASL 2.0
@ -48,6 +48,7 @@ Source39: nova_migration_authorized_keys
Source40: nova_migration-rootwrap.conf
Source41: nova_migration-rootwrap_cold_migration
Patch1: Fixes-aarch64-incorrect-cpu-model.patch
BuildArch: noarch
BuildRequires: openstack-macros
@ -730,6 +731,9 @@ exit 0
%endif
%changelog
* Mon Nov 29 2021 huangtianhua <huangtianhua@huawei.com> - 20.6.1-4
- Adds patch to make nova-compute work on aarch64
* Tue Nov 23 2021 zhangy1317 <zhangy1317@foxmail.com> - 20.6.1-3
- Fix install issue