[virt-tools-list] [PATCH virt-manager 2/3] virtinst: drop parsingof cpu features

Chen Hanxiao chen_han_xiao at 126.com
Thu Mar 13 15:00:36 UTC 2014


On 03/13/2014 08:51 PM, Giuseppe Scrivano wrote:
> 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 at redhat.com>
> ---
>   tests/capabilities.py    | 20 +++-----------------
>   virtinst/capabilities.py | 36 ++++--------------------------------
>   2 files changed, 7 insertions(+), 49 deletions(-)
>
> diff --git a/tests/capabilities.py b/tests/capabilities.py
> index b718dc1..c062e4c 100644
> --- a/tests/capabilities.py
> +++ b/tests/capabilities.py
> @@ -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()
> diff --git a/virtinst/capabilities.py b/virtinst/capabilities.py
> index 2fe2c0a..2ab39cd 100644
> --- a/virtinst/capabilities.py
> +++ b/virtinst/capabilities.py
> @@ -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
ACK

-Chen




More information about the virt-tools-list mailing list