Store correct VirtCPUTopology
When booting a NUMA-enabled instance, the scheduler generates and stores a meaningless VirtCPUTopology as part of the InstanceNumaCell objects. A correct value is later generated and used in libvirt XML generation but this is not stored. Fix this by skipping the initial generation and storing of the VirtCPUTopology in favour of storing the correctly generated version. Change-Id: Ief4fcdec0e107a233225ebd68207ac6172b3751e Closes-bug: #1466780
This commit is contained in:
parent
a3c610f1f2
commit
8358936a24
|
@ -4050,6 +4050,32 @@ class LibvirtConnTestCase(test.NoDBTestCase):
|
|||
self.assertEqual(conf.cpu.cores, 1)
|
||||
self.assertEqual(conf.cpu.threads, 1)
|
||||
|
||||
@mock.patch.object(host.Host, "has_min_version", return_value=True)
|
||||
def test_get_guest_cpu_config_numa_topology(self, mock_has_min_version):
|
||||
drvr = libvirt_driver.LibvirtDriver(fake.FakeVirtAPI(), True)
|
||||
instance_ref = objects.Instance(**self.test_instance)
|
||||
instance_ref.flavor.vcpus = 2
|
||||
instance_ref.numa_topology = objects.InstanceNUMATopology(cells=[
|
||||
objects.InstanceNUMACell(
|
||||
id=0,
|
||||
cpuset=set([0, 1]),
|
||||
memory=1024,
|
||||
cpu_pinning={})])
|
||||
image_meta = {}
|
||||
disk_info = blockinfo.get_disk_info(CONF.libvirt.virt_type,
|
||||
instance_ref,
|
||||
image_meta)
|
||||
|
||||
self.assertIsNone(instance_ref.numa_topology.cells[0].cpu_topology)
|
||||
|
||||
drvr._get_guest_config(
|
||||
instance_ref, _fake_network_info(self.stubs, 1), {}, disk_info)
|
||||
|
||||
topo = instance_ref.numa_topology.cells[0].cpu_topology
|
||||
self.assertIsNotNone(topo)
|
||||
self.assertEqual(topo.cores * topo.sockets * topo.threads,
|
||||
instance_ref.flavor.vcpus)
|
||||
|
||||
def test_get_guest_cpu_topology(self):
|
||||
instance_ref = objects.Instance(**self.test_instance)
|
||||
instance_ref.flavor.vcpus = 8
|
||||
|
|
|
@ -698,6 +698,7 @@ def _pack_instance_onto_cores(available_siblings, instance_cell, host_cell_id):
|
|||
pinning = zip(sorted(instance_cell.cpuset),
|
||||
itertools.chain(*sliced_sibs))
|
||||
|
||||
# NOTE(sfinucan) - this may be overriden later on by the drivers
|
||||
topology = (instance_cell.cpu_topology or
|
||||
objects.VirtCPUTopology(sockets=1,
|
||||
cores=len(sliced_sibs),
|
||||
|
|
|
@ -3083,6 +3083,10 @@ class LibvirtDriver(driver.ComputeDriver):
|
|||
topology = hardware.get_best_cpu_topology(
|
||||
flavor, image_meta, numa_topology=instance_numa_topology)
|
||||
|
||||
if instance_numa_topology:
|
||||
for cell in instance_numa_topology.cells:
|
||||
cell.cpu_topology = topology
|
||||
|
||||
cpu.sockets = topology.sockets
|
||||
cpu.cores = topology.cores
|
||||
cpu.threads = topology.threads
|
||||
|
|
Loading…
Reference in New Issue