Merge "libvirt: Get the CPU model, not 'arch' from get_capabilities()"
This commit is contained in:
commit
2c22a39bb9
|
@ -1492,6 +1492,14 @@ class Connection(object):
|
|||
|
||||
model_node = tree.find('./model')
|
||||
if model_node is not None:
|
||||
# arch_node may not present, therefore query all cpu models.
|
||||
if model_node.text not in self.getCPUModelNames('x86_64') and \
|
||||
model_node.text not in self.getCPUModelNames('ppc64'):
|
||||
raise make_libvirtError(
|
||||
libvirtError,
|
||||
"internal error: Unknown CPU model %s" % model_node.text,
|
||||
error_code = VIR_ERR_INTERNAL_ERROR,
|
||||
error_domain=VIR_FROM_QEMU)
|
||||
if model_node.text != self.host_info.cpu_model:
|
||||
return VIR_CPU_COMPARE_INCOMPATIBLE
|
||||
|
||||
|
|
|
@ -1326,6 +1326,14 @@ class LibvirtConnTestCase(test.NoDBTestCase,
|
|||
self.assertRaises(exception.InvalidCPUInfo,
|
||||
drvr.init_host, "dummyhost")
|
||||
|
||||
def test__check_cpu_compatibility_with_flag(self):
|
||||
self.flags(cpu_mode="custom",
|
||||
cpu_models=["Penryn"],
|
||||
cpu_model_extra_flags = ["aes"],
|
||||
group="libvirt")
|
||||
drvr = libvirt_driver.LibvirtDriver(fake.FakeVirtAPI(), True)
|
||||
drvr.init_host("dummyhost")
|
||||
|
||||
@mock.patch('nova.virt.libvirt.host.libvirt.Connection.compareCPU')
|
||||
def test__check_cpu_compatibility_advance_flag(self, mocked_compare):
|
||||
mocked_compare.side_effect = (2, 0)
|
||||
|
|
|
@ -366,8 +366,7 @@ class FakeLibvirtTests(test.NoDBTestCase):
|
|||
conn.host_info.cpu_sockets,
|
||||
conn.host_info.cpu_cores,
|
||||
conn.host_info.cpu_threads)
|
||||
self.assertEqual(conn.compareCPU(xml, 0),
|
||||
libvirt.VIR_CPU_COMPARE_INCOMPATIBLE)
|
||||
self.assertRaises(libvirt.libvirtError, conn.compareCPU, xml, 0)
|
||||
|
||||
def test_compareCPU_compatible_unspecified_model(self):
|
||||
conn = self.get_openAuth_curry_func()('qemu:///system')
|
||||
|
|
|
@ -788,7 +788,7 @@ class LibvirtDriver(driver.ComputeDriver):
|
|||
# Use guest CPU model to check the compatibility between guest CPU and
|
||||
# configured extra_flags
|
||||
cpu = vconfig.LibvirtConfigGuestCPU()
|
||||
cpu.model = self._host.get_capabilities().host.cpu.arch
|
||||
cpu.model = self._host.get_capabilities().host.cpu.model
|
||||
for flag in set(x.lower() for x in CONF.libvirt.cpu_model_extra_flags):
|
||||
cpu.add_feature(vconfig.LibvirtConfigCPUFeature(flag))
|
||||
try:
|
||||
|
|
Loading…
Reference in New Issue