libvirt: avoid setting the memnodes where when it's not a supported option
The current version of Libvirt in the gate doesn't support a memnode element in the numa tune configuration. When requesting guest topology the instance is crashing. Not setting the numa tune memnodes option when libvirt version is less than the required minimum. Change-Id: I99d0bb64bd6d698f2d5ce978cb3778bbad8eec91 Closes-Bug: #1415333
This commit is contained in:
parent
2ff55736ee
commit
cf3a1262ec
|
@ -1144,6 +1144,27 @@ class LibvirtConnTestCase(test.NoDBTestCase):
|
|||
self.assertIsNone(self._test_get_guest_memory_backing_config(
|
||||
'not_empty', 'not_empty', 'not_empty'))
|
||||
|
||||
def test_get_guest_numa_tune_memnodes(self):
|
||||
drvr = libvirt_driver.LibvirtDriver(fake.FakeVirtAPI(), True)
|
||||
guest_cpu_numa_config = objects.InstanceNUMATopology(cells=[
|
||||
objects.InstanceNUMACell(
|
||||
id=1, cpuset=set([0, 1]),
|
||||
memory=1024, pagesize=2048)])
|
||||
memnodes = [vconfig.LibvirtConfigGuestNUMATuneMemNode()]
|
||||
with mock.patch.object(host.Host, 'has_min_version',
|
||||
return_value=True):
|
||||
self.assertIsNotNone(drvr._get_guest_numa_tune_memnodes(
|
||||
guest_cpu_numa_config, memnodes))
|
||||
self.assertEqual(guest_cpu_numa_config.cells[0].id,
|
||||
memnodes[0].cellid)
|
||||
|
||||
def test_get_guest_numa_tune_memnodes_none(self):
|
||||
drvr = libvirt_driver.LibvirtDriver(fake.FakeVirtAPI(), True)
|
||||
with mock.patch.object(host.Host, 'has_min_version',
|
||||
return_value=False):
|
||||
self.assertIsNone(drvr._get_guest_numa_tune_memnodes(
|
||||
'something', 'something'))
|
||||
|
||||
@mock.patch.object(objects.Flavor, 'get_by_id')
|
||||
def test_get_guest_config_numa_host_instance_fit_w_cpu_pinset(self,
|
||||
mock_flavor):
|
||||
|
|
|
@ -366,6 +366,8 @@ MIN_LIBVIRT_NUMA_TOPOLOGY_VERSION = (1, 0, 4)
|
|||
MIN_LIBVIRT_FSFREEZE_VERSION = (1, 2, 5)
|
||||
# libvirt mempage size report
|
||||
MIN_LIBVIRT_MEMPAGES_VERSION = (1, 2, 8)
|
||||
# libvirt memory allocation policy for each guest NUMA node
|
||||
MIN_LIBVIRT_MEMNODE_VERSION = (1, 2, 7)
|
||||
|
||||
# Hyper-V paravirtualized time source
|
||||
MIN_LIBVIRT_HYPERV_TIMER_VERSION = (1, 2, 2)
|
||||
|
@ -3481,14 +3483,14 @@ class LibvirtDriver(driver.ComputeDriver):
|
|||
guest_cpu_tune.vcpupin.sort(key=operator.attrgetter("id"))
|
||||
|
||||
guest_numa_tune.memory = numa_mem
|
||||
guest_numa_tune.memnodes = numa_memnodes
|
||||
|
||||
# normalize cell.id
|
||||
for i, (cell, memnode) in enumerate(
|
||||
zip(guest_cpu_numa_config.cells,
|
||||
guest_numa_tune.memnodes)):
|
||||
for i, cell in enumerate(guest_cpu_numa_config.cells):
|
||||
cell.id = i
|
||||
memnode.cellid = i
|
||||
|
||||
guest_numa_tune.memnodes = self._get_guest_numa_tune_memnodes(
|
||||
guest_cpu_numa_config,
|
||||
numa_memnodes)
|
||||
|
||||
return GuestNumaConfig(None, guest_cpu_tune,
|
||||
guest_cpu_numa_config,
|
||||
|
@ -3497,6 +3499,18 @@ class LibvirtDriver(driver.ComputeDriver):
|
|||
return GuestNumaConfig(allowed_cpus, None,
|
||||
guest_cpu_numa_config, None)
|
||||
|
||||
def _get_guest_numa_tune_memnodes(self, guest_cpu_numa_config,
|
||||
numa_memnodes):
|
||||
if not self._host.has_min_version(MIN_LIBVIRT_MEMNODE_VERSION):
|
||||
return
|
||||
|
||||
# normalize cell.id
|
||||
for (cell, memnode) in zip(guest_cpu_numa_config.cells,
|
||||
numa_memnodes):
|
||||
memnode.cellid = cell.id
|
||||
|
||||
return numa_memnodes
|
||||
|
||||
def _get_guest_os_type(self, virt_type):
|
||||
"""Returns the guest OS type based on virt type."""
|
||||
if virt_type == "lxc":
|
||||
|
|
Loading…
Reference in New Issue