libvirt: avoid cpu check at s390x arch

nova compute will call check_can_live_migrate_destination when doing
live migration and it will compare cpu model, however, following info
indicated that cpu compare is not supported at s390x arch.

URI qemu:///system does not support full set of host capabilities: this
function is not supported by the connection driver:
cannot compute baseline CPU of s390x architecture

https://www.libvirt.org/news.html has the info
v5.9.0 has Improvements part indicated the compare was added at 5.9

so the workaround is to avoid the check and let the migration proceed.

Change-Id: I253f4f305ecf8b5331212be87caef41f2ebb747e
Closes-Bug: 1854126
(cherry picked from commit 011cce6adb)
(cherry picked from commit 7d7a3ba70a)
This commit is contained in:
jichenjc 2019-12-04 03:34:23 +00:00 committed by Stephen Finucane
parent d8853597e8
commit 21642202ff
2 changed files with 32 additions and 0 deletions

View File

@ -9348,6 +9348,26 @@ class LibvirtConnTestCase(test.NoDBTestCase,
ret = conn._compare_cpu(None, None, instance)
self.assertIsNone(ret)
def test_compare_cpu_virt_platform_s390x(self):
_fake_s390xcpu_info = {
"arch": "s390x",
"model": "test_model",
"vendor": "test_vendor",
"topology": {
"sockets": 1,
"cores": 8,
"threads": 16
},
"features": ["feature1", "feature2"]
}
instance = objects.Instance(**self.test_instance)
conn = libvirt_driver.LibvirtDriver(fake.FakeVirtAPI(), False)
ret = conn._compare_cpu(None,
jsonutils.dumps(_fake_s390xcpu_info),
instance)
self.assertIsNone(ret)
@mock.patch.object(host.Host, 'compare_cpu')
@mock.patch.object(nova.virt.libvirt, 'config')
def test_compare_cpu_invalid_cpuinfo_raises(self, mock_vconfig,

View File

@ -97,6 +97,7 @@ import nova.privsep.path
import nova.privsep.utils
from nova import utils
from nova import version
from nova.virt import arch
from nova.virt import block_device as driver_block_device
from nova.virt import configdrive
from nova.virt.disk import api as disk_api
@ -7434,6 +7435,17 @@ class LibvirtDriver(driver.ComputeDriver):
else:
cpu = self._vcpu_model_to_cpu_config(guest_cpu)
# s390x doesn't support cpu model in host info, so compare
# cpu info will raise an error anyway, thus have to avoid check
# see bug 1854126 for more info
min_libvirt_version = (5, 9, 0)
if (cpu.arch in (arch.S390X, arch.S390) and
not self._host.has_min_version(min_libvirt_version)):
LOG.debug("on s390x platform, the min libvirt version "
"support cpu model compare is %s",
min_libvirt_version)
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")