summaryrefslogtreecommitdiff
path: root/nova/virt/libvirt/driver.py
diff options
context:
space:
mode:
authorKevin Zhao <kevin.zhao@linaro.org>2020-11-23 22:10:42 -0500
committerKevin Zhao <kevin.zhao@linaro.org>2021-09-03 11:14:51 +0800
commita6ef502aa06599102ae9a5a86067f3bc4b6440b2 (patch)
treed72e9f67074180e82e3edf219bb5a23d3ff61b5d /nova/virt/libvirt/driver.py
parent370830e9445c9825d1e34e60cca01fdfe88d5d82 (diff)
downloadnova-a6ef502aa06599102ae9a5a86067f3bc4b6440b2.tar.gz
Support Cpu Compararion on Aarch64 Platform
The general use case of libvirt's compareCPU() API is to allow comparing a guest CPU to a host CPU. However, for AArch64, the _only_ use case libvirt supports is to allow comparing host CPU with a destination CPU which is accomplished with the help of this patch[1]. So what we're talking about here, in context of AArch64, is comparing source _host_ CPU to destination _host_ CPU, so as to prevent a guest from migrating to a completely different host. For AArch64, in the past we skipped[2] _guest_ CPU to host CPU comparison (the "traditional" use case) check for AArch64 for two main reasons, and these reasons are still valid: 1. There are lots of vendors making different AArch64 CPUs, and they are all not easily comparable because they all differ in various ways. 2. QEMU AArch64 developers themselves recommend that using 'host- passthrough' is the way to run KVM guests on AArch64. In sum, for AArch64, (a) guests should use 'host-passthrough'; and (b) src host to dest host CPU comparison only makes sense to know about _host_ CPU compatibility, but you will not get any CPU config that you can give to a guest. For more detail discussion, please check link [3] and discussion [4]. [1] https://listman.redhat.com/archives/libvir-list/2020-September/msg01391.html — Modify virCPUarmCompare to perform compare actions [2] https://review.opendev.org/c/openstack/nova/+/589769/1/nova/virt/libvirt/driver.py#6892 [3] https://www.redhat.com/archives/libvir-list/2020-September/msg00262.html [4] https://www.redhat.com/archives/libvir-list/2020-September/msg00328.html, Change-Id: I9026f2ec39660408e4ac66fc0a85223e4b25e4d1 Signed-off-by: Kevin Zhao <kevin.zhao@linaro.org>
Diffstat (limited to 'nova/virt/libvirt/driver.py')
-rw-r--r--nova/virt/libvirt/driver.py20
1 files changed, 16 insertions, 4 deletions
diff --git a/nova/virt/libvirt/driver.py b/nova/virt/libvirt/driver.py
index 729254e8bd..66d1929aeb 100644
--- a/nova/virt/libvirt/driver.py
+++ b/nova/virt/libvirt/driver.py
@@ -219,6 +219,8 @@ MIN_QEMU_VERSION = (4, 2, 0)
NEXT_MIN_LIBVIRT_VERSION = (7, 0, 0)
NEXT_MIN_QEMU_VERSION = (5, 2, 0)
+MIN_LIBVIRT_AARCH64_CPU_COMPARE = (6, 9, 0)
+
# Virtuozzo driver support
MIN_VIRTUOZZO_VERSION = (7, 0, 0)
@@ -9350,6 +9352,20 @@ class LibvirtDriver(driver.ComputeDriver):
else:
cpu = self._vcpu_model_to_cpu_config(guest_cpu)
+ host_cpu = self._host.get_capabilities().host.cpu
+ if host_cpu.arch == fields.Architecture.AARCH64:
+ if self._host.has_min_version(MIN_LIBVIRT_AARCH64_CPU_COMPARE):
+ LOG.debug("On AArch64 hosts, source and destination host "
+ "CPUs are compared to check if they're compatible"
+ "(the only use-case supported by libvirt for "
+ "Arm64/AArch64)")
+ cpu = host_cpu
+ else:
+ LOG.debug("You need %s libvirt version to be able to compare "
+ "source host CPU with destination host CPU; skip "
+ "CPU comparison", MIN_LIBVIRT_AARCH64_CPU_COMPARE)
+ return
+
u = ("http://libvirt.org/html/libvirt-libvirt-host.html#"
"virCPUCompareResult")
m = _("CPU doesn't have compatibility.\n\n%(ret)s\n\nRefer to %(u)s")
@@ -9359,10 +9375,6 @@ class LibvirtDriver(driver.ComputeDriver):
LOG.debug("cpu compare xml: %s", cpu_xml, instance=instance)
ret = self._host.compare_cpu(cpu_xml)
except libvirt.libvirtError as e:
- if cpu.arch == fields.Architecture.AARCH64:
- LOG.debug("Host CPU compatibility check does not make "
- "sense on AArch64; skip CPU comparison")
- return
error_code = e.get_error_code()
if error_code == libvirt.VIR_ERR_NO_SUPPORT:
LOG.debug("URI %(uri)s does not support cpu comparison. "