libvirt: not setting membacking when mempages are empty host topology

The current version of Libvirt in the gate doesn't return mempages in numa
cells. When requesting guest topology the instance is crashing.
Not setting the guest.membacking when libvirt version is less than the
required minimum

Closes-Bug: #1408070

Change-Id: Ib83062f413bf17e1fbfe2399348c3f5e1e703559
This commit is contained in:
Vladik Romanovsky 2015-01-06 14:23:38 -05:00
parent f795f048c9
commit 3466e72754
2 changed files with 14 additions and 1 deletions

View File

@ -1242,7 +1242,9 @@ class LibvirtConnTestCase(test.NoDBTestCase):
return conn._get_guest_memory_backing_config(
inst_topology, numatune)
def test_get_guest_memory_backing_config_large_success(self):
@mock.patch.object(host.Host,
'has_min_version', return_value=True)
def test_get_guest_memory_backing_config_large_success(self, mock_version):
host_topology = objects.NUMATopology(
cells=[
objects.NUMACell(
@ -1269,6 +1271,12 @@ class LibvirtConnTestCase(test.NoDBTestCase):
self.assertEqual(2048, result.hugepages[0].size_kb)
self.assertEqual([0], result.hugepages[0].nodeset)
def test_get_guest_memory_backing_config_mempages_none(self):
with mock.patch.object(host.Host, 'has_min_version',
return_value=False):
self.assertIsNone(self._test_get_guest_memory_backing_config(
'not_empty', 'not_empty', 'not_empty'))
@mock.patch.object(objects.Flavor, 'get_by_id')
def test_get_guest_config_numa_host_instance_fit_w_cpu_pinset(self,
mock_flavor):

View File

@ -363,6 +363,8 @@ REQ_HYPERVISOR_DISCARD = "QEMU"
MIN_LIBVIRT_NUMA_TOPOLOGY_VERSION = (1, 0, 4)
# fsFreeze/fsThaw requirement
MIN_LIBVIRT_FSFREEZE_VERSION = (1, 2, 5)
# libvirt mempage size report
MIN_LIBVIRT_MEMPAGES_VERSION = (1, 2, 8)
# Hyper-V paravirtualized time source
MIN_LIBVIRT_HYPERV_TIMER_VERSION = (1, 2, 2)
@ -3790,6 +3792,9 @@ class LibvirtDriver(driver.ComputeDriver):
self._add_rng_device(guest, flavor)
def _get_guest_memory_backing_config(self, inst_topology, numatune):
if not self._host.has_min_version(MIN_LIBVIRT_MEMPAGES_VERSION):
return
host_topology = self._get_host_numa_topology()
membacking = None