libvirt: make default value of numa cell memory to 0 when not defined

Some arch can have cells without memory or cpus defined and libvirt
will return an XML without these elements. Our object defintion of the
fields cpus and memory cannot let us to make them to None when not
defined but currently the config representation of a NUMA make it to
None.

This patch fix the default value of config memory to 0 when libvirt
does not return memory element for a cell.

Also this cannot be considered come a fix for bug 1418187 since we
have to handle these cases (cpus or memory not defined) during
scheduling. thse case can be addressed when using distances which will
be addressed in a next serie of patches.

Conflicts:
        nova/tests/unit/virt/libvirt/test_config.py
        nova/virt/libvirt/config.py

NOTE(mriedem): The conflict in config.py is due to the mempages
code added on master with commit 3283e2a42 that's not in juno.
The test conflict was due to moving the tests in kilo.

Related-Bug: #1418187
Change-Id: Iac08d1221341a86c081d5e905c704fb1c9dca276
(cherry picked from commit 291c1a1db1)
This commit is contained in:
Sahid Orentino Ferdjaoui 2015-03-03 05:00:40 -05:00 committed by Matt Riedemann
parent a19a1e52f1
commit 34f029e68d
2 changed files with 23 additions and 1 deletions

View File

@ -121,6 +121,28 @@ class LibvirtConfigCapsTest(LibvirtConfigBaseTest):
self.assertXmlEqual(xmlin, xmlout)
def test_config_host_numa_cell_no_memory_caps(self):
xmlin = """
<cell id='0'>
<cpus num='1'>
<cpu id='0' socket_id='0' core_id='0' siblings='0'/>
</cpus>
</cell>"""
obj = config.LibvirtConfigCapsNUMACell()
obj.parse_str(xmlin)
self.assertEqual(0, obj.memory)
self.assertEqual(1, len(obj.cpus))
def test_config_host_numa_cell_no_cpus_caps(self):
xmlin = """
<cell id='0'>
<memory unit='KiB'>128</memory>
</cell>"""
obj = config.LibvirtConfigCapsNUMACell()
obj.parse_str(xmlin)
self.assertEqual(128, obj.memory)
self.assertEqual(0, len(obj.cpus))
class LibvirtConfigGuestTimerTest(LibvirtConfigBaseTest):
def test_config_platform(self):

View File

@ -153,7 +153,7 @@ class LibvirtConfigCapsNUMACell(LibvirtConfigObject):
**kwargs)
self.id = None
self.memory = None
self.memory = 0
self.cpus = []
def parse_dom(self, xmldoc):