From 461e42dcc4831083c46f4ff9763807862aab9b4a Mon Sep 17 00:00:00 2001 From: Tetsuro Nakamura Date: Thu, 1 Feb 2018 04:32:41 +0900 Subject: [PATCH] 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 24d9e06ec68dfd0ead9bc56ad186e7b4e0acd8fb) (cherry picked from commit 2dc4d7a366efe11acb1099eca13bd3f3c2af9012) --- nova/tests/unit/virt/libvirt/test_driver.py | 3 +-- nova/virt/libvirt/driver.py | 5 +++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/nova/tests/unit/virt/libvirt/test_driver.py b/nova/tests/unit/virt/libvirt/test_driver.py index f940ace3e9cf..a6663941ebdd 100755 --- a/nova/tests/unit/virt/libvirt/test_driver.py +++ b/nova/tests/unit/virt/libvirt/test_driver.py @@ -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 diff --git a/nova/virt/libvirt/driver.py b/nova/virt/libvirt/driver.py index fd9ff8c35b84..30ec4fbb2043 100644 --- a/nova/virt/libvirt/driver.py +++ b/nova/virt/libvirt/driver.py @@ -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