virtinst: drop parsing of cpu features

As for the previous patch, this information is not used anywhere and
this information should be retrieved using the libvirt baselineCPU
API.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
This commit is contained in:
Giuseppe Scrivano 2014-03-12 20:59:33 +01:00
parent 143a689592
commit 6c2645f0d2
2 changed files with 7 additions and 49 deletions

View File

@ -225,37 +225,23 @@ class TestCapabilities(unittest.TestCase):
cpu_32 = caps.get_cpu_values("i486")
cpu_random = caps.get_cpu_values("mips")
def test_cpu_map(cpumap, vendors, cpus):
def test_cpu_map(cpumap, cpus):
cpunames = sorted([c.model for c in cpumap.cpus],
key=str.lower)
for v in vendors:
self.assertTrue(v in cpumap.vendors)
for c in cpus:
self.assertTrue(c in cpunames)
def test_single_cpu(cpumap, model, vendor, features):
cpu = cpumap.get_cpu(model)
self.assertEquals(cpu.vendor, vendor)
self.assertEquals(cpu.features, features)
self.assertEquals(cpu_64, cpu_32)
x86_vendors = ["AMD", "Intel"]
x86_cpunames = [
'486', 'athlon', 'Conroe', 'core2duo', 'coreduo', 'n270',
'Nehalem', 'Opteron_G1', 'Opteron_G2', 'Opteron_G3', 'Penryn',
'pentium', 'pentium2', 'pentium3', 'pentiumpro', 'phenom',
'qemu32', 'qemu64']
test_cpu_map(cpu_64, x86_vendors, x86_cpunames)
test_cpu_map(cpu_random, [], [])
athlon_features = [
'3dnow', '3dnowext', 'apic', 'cmov', 'cx8', 'de', 'fpu', 'fxsr',
'mce', 'mmx', 'mmxext', 'msr', 'mtrr', 'pae', 'pat', 'pge', 'pse',
'pse36', 'sep', 'sse', 'sse2', 'tsc', 'vme']
test_single_cpu(cpu_64, "athlon", "AMD", athlon_features)
test_cpu_map(cpu_64, x86_cpunames)
test_cpu_map(cpu_random, [])
if __name__ == "__main__":
unittest.main()

View File

@ -37,34 +37,10 @@ def xpathString(node, path, default=None):
class CPUValuesModel(object):
"""
Single <model> definition from cpu_map
Single CPU model
"""
def __init__(self, node):
self.model = node.prop("name")
self.features = []
self.parent = None
self.vendor = None
self._parseXML(node)
def _parseXML(self, node):
child = node.children
while child:
if child.name == "model":
self.parent = child.prop("name")
if child.name == "vendor":
self.vendor = child.prop("name")
if child.name == "feature":
self.features.append(child.prop("name"))
child = child.next
self.features.sort()
def inheritParent(self, parentcpu):
self.vendor = parentcpu.vendor or self.vendor
self.features += parentcpu.features
self.features.sort()
def __init__(self, model):
self.model = model
class CPUValuesArch(object):
@ -85,11 +61,7 @@ class CPUValuesArch(object):
if child.name == "vendor":
self.vendors.append(child.prop("name"))
if child.name == "model":
newcpu = CPUValuesModel(child)
if newcpu.parent:
for chkcpu in self.cpus:
if chkcpu.model == newcpu.parent:
newcpu.inheritParent(chkcpu)
newcpu = CPUValuesModel(child.prop("name"))
self.cpus.append(newcpu)
child = child.next