Fix exception when vcpu_pin_set is set to ""
We should treat vcpu_pin_set="", same as vcpu_pin_set=None and
avoid the problem mentioned in the bug report.
Closes-Bug: #1579664
Change-Id: Ifa2b960aa74072ba668c9d028df108af6156fe40
(cherry picked from commit 8b199c6dff
)
This commit is contained in:
parent
92ca31b27d
commit
104f8cc4c4
|
@ -5875,6 +5875,16 @@ class LibvirtConnTestCase(test.NoDBTestCase):
|
|||
self.assertEqual(uuids[3], vm4.UUIDString())
|
||||
mock_list.assert_called_with(only_guests=True, only_running=False)
|
||||
|
||||
@mock.patch('nova.virt.libvirt.host.Host.get_online_cpus',
|
||||
return_value=None)
|
||||
@mock.patch('nova.virt.libvirt.host.Host.get_cpu_count',
|
||||
return_value=4)
|
||||
def test_get_host_vcpus_is_empty(self, get_cpu_count, get_online_cpus):
|
||||
drvr = libvirt_driver.LibvirtDriver(fake.FakeVirtAPI(), False)
|
||||
self.flags(vcpu_pin_set="")
|
||||
vcpus = drvr._get_vcpu_total()
|
||||
self.assertEqual(4, vcpus)
|
||||
|
||||
@mock.patch('nova.virt.libvirt.host.Host.get_online_cpus')
|
||||
def test_get_host_vcpus(self, get_online_cpus):
|
||||
drvr = libvirt_driver.LibvirtDriver(fake.FakeVirtAPI(), False)
|
||||
|
|
|
@ -4862,7 +4862,7 @@ class LibvirtDriver(driver.ComputeDriver):
|
|||
"function is not implemented for this platform. "))
|
||||
return 0
|
||||
|
||||
if CONF.vcpu_pin_set is None:
|
||||
if not CONF.vcpu_pin_set:
|
||||
return total_pcpus
|
||||
|
||||
available_ids = hardware.get_vcpu_pin_set()
|
||||
|
|
Loading…
Reference in New Issue