add check before adding cpus to cpuset_reserved

There are some cases where None value is set to cpuset_reserved in
InstanceNUMATopology at _numa_fit_instance_cell() function in
hardware.py. However, libvirt driver treat cpuset_reserved value
as an iterate object when it constructs xml configuration.

To avoid a risk to get an error in libvirt driver, this patch adds
a check to see if the value is not None before adding the cpus
for emulator threads.

Change-Id: Iab3d950c4f4138118ac6a9fd98407eaadcb24d9e
Closes-Bug: #1746674
(cherry picked from commit 24d9e06ec6)
(cherry picked from commit 2dc4d7a366)
This commit is contained in:
Tetsuro Nakamura 2018-02-01 04:32:41 +09:00 committed by Matt Riedemann
parent 6557395982
commit 461e42dcc4
2 changed files with 4 additions and 4 deletions

View File

@ -3013,8 +3013,7 @@ class LibvirtConnTestCase(test.NoDBTestCase,
id=1, cpuset=set([2, 3]),
memory=1024, pagesize=2048,
cpu_policy=fields.CPUAllocationPolicy.DEDICATED,
cpu_pinning={2: 7, 3: 8},
cpuset_reserved=set([]))])
cpu_pinning={2: 7, 3: 8})])
instance_ref = objects.Instance(**self.test_instance)
instance_ref.numa_topology = instance_topology

View File

@ -4246,8 +4246,9 @@ class LibvirtDriver(driver.ComputeDriver):
else:
pin_cpuset.cpuset = host_cell.cpuset
if emulator_threads_isolated:
emupcpus.extend(
object_numa_cell.cpuset_reserved)
if object_numa_cell.cpuset_reserved:
emupcpus.extend(
object_numa_cell.cpuset_reserved)
elif not wants_realtime or cpu not in vcpus_rt:
# - If realtime IS NOT enabled, the
# emulator threads are allowed to float